diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-06-11 07:05:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-11 07:05:46 -0700 |
| commit | df0a201d85eac4c55c1abf15ed0bf9baea0ae971 (patch) | |
| tree | 2ee9aa509fd9da80c9be0d5647c181bde41fa0b3 /source | |
| parent | 51d358546424646f60f1b214378a366ebb077d03 (diff) | |
Support integer typed textures for GLSL (#4329)
* Support integer typed textures for GLSL
This commit re-enables the ability to sample from an integer typed
texture for GLSL functions while keeping it unavailable for HLSL target.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/glsl.meta.slang | 129 | ||||
| -rw-r--r-- | source/slang/hlsl.meta.slang | 190 |
2 files changed, 214 insertions, 105 deletions
diff --git a/source/slang/glsl.meta.slang b/source/slang/glsl.meta.slang index 1daf0ec07..db5f9c2fa 100644 --- a/source/slang/glsl.meta.slang +++ b/source/slang/glsl.meta.slang @@ -1878,7 +1878,7 @@ public ivec3 textureSize(Sampler2DMSArray<vector<T,N>,sampleCount> sampler) // textureQueryLod // ------------------- -__generic<T:IFloat, let isArray:int, let sampleCount:int, let isShadow:int, let format:int> +__generic<T, let isArray:int, let sampleCount:int, let isShadow:int, let format:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_querylod)] public vec2 textureQueryLod(__TextureImpl< @@ -1910,10 +1910,11 @@ public vec2 textureQueryLod(__TextureImpl< } } -__generic<T:IFloat, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let isShadow:int, let format:int> +__generic<T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let isShadow:int, let format:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_querylod)] -public vec2 textureQueryLod(__TextureImpl<T, +public vec2 textureQueryLod(__TextureImpl< + T, Shape, isArray, 0, // isMS @@ -2086,10 +2087,10 @@ public int textureQueryLevels(samplerCubeArrayShadow sampler) // textureSamples // ------------------- -__generic<T:__BuiltinArithmeticType, let N:int, let sampleCount:int> +__generic<T, let sampleCount:int> [ForceInline] [require(glsl_hlsl_spirv, image_samples)] -public int textureSamples(Sampler2DMS<vector<T,N>,sampleCount> sampler) +public int textureSamples(Sampler2DMS<T,sampleCount> sampler) { vector<int,2> dim; int sampleCount; @@ -2098,10 +2099,10 @@ public int textureSamples(Sampler2DMS<vector<T,N>,sampleCount> sampler) return sampleCount; } -__generic<T:__BuiltinArithmeticType, let N:int, let sampleCount:int> +__generic<T, let sampleCount:int> [ForceInline] [require(glsl_hlsl_spirv, image_samples)] -public int textureSamples(Sampler2DMSArray<vector<T,N>,sampleCount> sampler) +public int textureSamples(Sampler2DMSArray<T,sampleCount> sampler) { vector<int,3> dim; int sampleCount; @@ -2118,7 +2119,7 @@ public int textureSamples(Sampler2DMSArray<vector<T,N>,sampleCount> sampler) // texture // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> texture(Sampler1D<vector<T,N>> sampler, float p) @@ -2126,7 +2127,7 @@ public vector<T,4> texture(Sampler1D<vector<T,N>> sampler, float p) return __vectorReshape<4>(sampler.Sample(p)); } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> texture(Sampler1D<vector<T,N>> sampler, float p, constexpr float bias) @@ -2134,7 +2135,7 @@ public vector<T,4> texture(Sampler1D<vector<T,N>> sampler, float p, constexpr fl return __vectorReshape<4>(sampler.SampleBias(p, bias)); } -__generic<T:__BuiltinFloatingPointType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let format:int> +__generic<T:__BuiltinArithmeticType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let format:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> texture(__TextureImpl< @@ -2152,7 +2153,7 @@ public vector<T,4> texture(__TextureImpl< return __vectorReshape<4>(sampler.Sample(p)); } -__generic<T:__BuiltinFloatingPointType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let format:int> +__generic<T:__BuiltinArithmeticType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let format:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> texture(__TextureImpl< @@ -2304,7 +2305,7 @@ public float texture(samplerCubeArrayShadow sampler, vec4 p, float compare) // textureProj // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec2 p) @@ -2321,7 +2322,7 @@ public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec2 p) } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec2 p, float bias) @@ -2338,7 +2339,7 @@ public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec2 p, float bia } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec4 p) @@ -2355,7 +2356,7 @@ public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec4 p) } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec4 p, float bias) @@ -2372,7 +2373,7 @@ public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec4 p, float bia } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec3 p) @@ -2389,7 +2390,7 @@ public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec3 p) } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec3 p, float bias) @@ -2406,7 +2407,7 @@ public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec3 p, float bia } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec4 p) @@ -2423,7 +2424,7 @@ public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec4 p) } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec4 p, float bias) @@ -2440,7 +2441,7 @@ public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec4 p, float bia } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler3D<vector<T,N>> sampler, vec4 p) @@ -2457,7 +2458,7 @@ public vector<T,4> textureProj(Sampler3D<vector<T,N>> sampler, vec4 p) } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProj(Sampler3D<vector<T,N>> sampler, vec4 p, float bias) @@ -2562,7 +2563,7 @@ public float textureProj(sampler2DShadow sampler, vec4 p, float bias) // textureLod // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureLod(Sampler1D<vector<T,N>> sampler, float p, float lod) @@ -2570,7 +2571,7 @@ public vector<T,4> textureLod(Sampler1D<vector<T,N>> sampler, float p, float lod return __vectorReshape<4>(sampler.SampleLevel(p, lod)); } -__generic<T:__BuiltinFloatingPointType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let format:int> +__generic<T:__BuiltinArithmeticType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let format:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureLod(__TextureImpl< @@ -2649,7 +2650,7 @@ public float textureLod(sampler1DArrayShadow sampler, vec3 p, float lod) // textureOffset // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureOffset(Sampler1D<vector<T,N>> sampler, float p, constexpr int offset, float bias = 0.0) @@ -2657,7 +2658,7 @@ public vector<T,4> textureOffset(Sampler1D<vector<T,N>> sampler, float p, conste return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureOffset(Sampler2D<vector<T,N>> sampler, vec2 p, constexpr ivec2 offset, float bias = 0.0) @@ -2665,7 +2666,7 @@ public vector<T,4> textureOffset(Sampler2D<vector<T,N>> sampler, vec2 p, constex return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureOffset(Sampler3D<vector<T,N>> sampler, vec3 p, constexpr ivec3 offset, float bias = 0.0) @@ -2739,7 +2740,7 @@ public float textureOffset(sampler1DShadow sampler, vec3 p, constexpr int offset } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureOffset(Sampler1DArray<vector<T,N>> sampler, vec2 p, constexpr int offset, float bias = 0.0) @@ -2747,7 +2748,7 @@ public vector<T,4> textureOffset(Sampler1DArray<vector<T,N>> sampler, vec2 p, co return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureOffset(Sampler2DArray<vector<T,N>> sampler, vec3 p, constexpr ivec2 offset, float bias = 0.0) @@ -2918,7 +2919,7 @@ public vector<T,4> texelFetchOffset(Sampler2DRect<vector<T,N>> sampler, ivec2 p, // textureProjOffset // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec2 p, constexpr int offset) @@ -2935,7 +2936,7 @@ public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec2 p, con } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec2 p, constexpr int offset, float bias) @@ -2952,7 +2953,7 @@ public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec2 p, con } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec4 p, constexpr int offset) @@ -2973,7 +2974,7 @@ public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec4 p, con } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec4 p, constexpr int offset, float bias) @@ -2994,7 +2995,7 @@ public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec4 p, con } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec3 p, constexpr ivec2 offset) @@ -3011,7 +3012,7 @@ public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec3 p, con } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec3 p, constexpr ivec2 offset, float bias) @@ -3028,7 +3029,7 @@ public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec3 p, con } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec4 p, constexpr ivec2 offset) @@ -3049,7 +3050,7 @@ public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec4 p, con } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec4 p, constexpr ivec2 offset, float bias) @@ -3070,7 +3071,7 @@ public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec4 p, con } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler3D<vector<T,N>> sampler, vec4 p, constexpr ivec3 offset) @@ -3087,7 +3088,7 @@ public vector<T,4> textureProjOffset(Sampler3D<vector<T,N>> sampler, vec4 p, con } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjOffset(Sampler3D<vector<T,N>> sampler, vec4 p, constexpr ivec3 offset, float bias) @@ -3192,7 +3193,7 @@ public float textureProjOffset(sampler2DShadow sampler, vec4 p, constexpr ivec2 // textureLodOffset // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureLodOffset(Sampler1D<vector<T,N>> sampler, float p, float lod, constexpr int offset) @@ -3200,7 +3201,7 @@ public vector<T,4> textureLodOffset(Sampler1D<vector<T,N>> sampler, float p, flo return __vectorReshape<4>(sampler.SampleLevel(p, lod, offset)); } -__generic<T:__BuiltinFloatingPointType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int> +__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureLodOffset(__TextureImpl< @@ -3282,7 +3283,7 @@ public float textureLodOffset(sampler1DArrayShadow sampler, vec3 p, float lod, c // textureProjLod // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLod(Sampler1D<vector<T,N>> sampler, vec2 p, float lod) @@ -3298,7 +3299,7 @@ public vector<T,4> textureProjLod(Sampler1D<vector<T,N>> sampler, vec2 p, float } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLod(Sampler1D<vector<T,N>> sampler, vec4 p, float lod) @@ -3318,7 +3319,7 @@ public vector<T,4> textureProjLod(Sampler1D<vector<T,N>> sampler, vec4 p, float } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLod(Sampler2D<vector<T,N>> sampler, vec3 p, float lod) @@ -3334,7 +3335,7 @@ public vector<T,4> textureProjLod(Sampler2D<vector<T,N>> sampler, vec3 p, float } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLod(Sampler2D<vector<T,N>> sampler, vec4 p, float lod) @@ -3354,7 +3355,7 @@ public vector<T,4> textureProjLod(Sampler2D<vector<T,N>> sampler, vec4 p, float } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLod(Sampler3D<vector<T,N>> sampler, vec4 p, float lod) @@ -3414,7 +3415,7 @@ public float textureProjLod(sampler2DShadow sampler, vec4 p, float lod) // textureProjLodOffset // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLodOffset(Sampler1D<vector<T,N>> sampler, vec2 p, float lod, constexpr int offset) @@ -3430,7 +3431,7 @@ public vector<T,4> textureProjLodOffset(Sampler1D<vector<T,N>> sampler, vec2 p, } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLodOffset(Sampler1D<vector<T,N>> sampler, vec4 p, float lod, constexpr int offset) @@ -3450,7 +3451,7 @@ public vector<T,4> textureProjLodOffset(Sampler1D<vector<T,N>> sampler, vec4 p, } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLodOffset(Sampler2D<vector<T,N>> sampler, vec3 p, float lod, constexpr ivec2 offset) @@ -3466,7 +3467,7 @@ public vector<T,4> textureProjLodOffset(Sampler2D<vector<T,N>> sampler, vec3 p, } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLodOffset(Sampler2D<vector<T,N>> sampler, vec4 p, float lod, constexpr ivec2 offset) @@ -3486,7 +3487,7 @@ public vector<T,4> textureProjLodOffset(Sampler2D<vector<T,N>> sampler, vec4 p, } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_fragment)] public vector<T,4> textureProjLodOffset(Sampler3D<vector<T,N>> sampler, vec4 p, float lod, constexpr ivec3 offset) @@ -3547,7 +3548,7 @@ public float textureProjLodOffset(sampler2DShadow sampler, vec4 p, float lod, co // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureGrad(Sampler1D<vector<T,N>> sampler, float p, float dPdx, float dPdy) @@ -3555,7 +3556,7 @@ public vector<T,4> textureGrad(Sampler1D<vector<T,N>> sampler, float p, float dP return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy)); } -__generic<T:__BuiltinFloatingPointType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int> +__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureGrad(__TextureImpl< @@ -3662,7 +3663,7 @@ public float textureGrad(sampler2DArrayShadow sampler, vec4 p, vec2 dPdx, vec2 d // textureGradOffset // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureGradOffset(Sampler1D<vector<T,N>> sampler, float p, float dPdx, float dPdy, constexpr int offset) @@ -3670,7 +3671,7 @@ public vector<T,4> textureGradOffset(Sampler1D<vector<T,N>> sampler, float p, fl return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy, offset)); } -__generic<T:__BuiltinFloatingPointType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int> +__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int> [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] [ForceInline] public vector<T,4> textureGradOffset(__TextureImpl< @@ -3760,7 +3761,7 @@ public float textureGradOffset(sampler2DArrayShadow sampler, vec4 p, vec2 dPdx, // textureProjGrad // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGrad(Sampler1D<vector<T,N>> sampler, vec2 p, float dPdx, float dPdy) @@ -3776,7 +3777,7 @@ public vector<T,4> textureProjGrad(Sampler1D<vector<T,N>> sampler, vec2 p, float } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGrad(Sampler1D<vector<T,N>> sampler, vec4 p, float dPdx, float dPdy) @@ -3796,7 +3797,7 @@ public vector<T,4> textureProjGrad(Sampler1D<vector<T,N>> sampler, vec4 p, float } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGrad(Sampler2D<vector<T,N>> sampler, vec3 p, vec2 dPdx, vec2 dPdy) @@ -3812,7 +3813,7 @@ public vector<T,4> textureProjGrad(Sampler2D<vector<T,N>> sampler, vec3 p, vec2 } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGrad(Sampler2D<vector<T,N>> sampler, vec4 p, vec2 dPdx, vec2 dPdy) @@ -3832,7 +3833,7 @@ public vector<T,4> textureProjGrad(Sampler2D<vector<T,N>> sampler, vec4 p, vec2 } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGrad(Sampler3D<vector<T,N>> sampler, vec4 p, vec3 dPdx, vec3 dPdy) @@ -3892,7 +3893,7 @@ public float textureProjGrad(sampler2DShadow sampler, vec4 p, vec2 dPdx, vec2 dP // textureProjGradOffset // ------------------- -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGradOffset(Sampler1D<vector<T,N>> sampler, vec2 p, float dPdx, float dPdy, constexpr int offset) @@ -3908,7 +3909,7 @@ public vector<T,4> textureProjGradOffset(Sampler1D<vector<T,N>> sampler, vec2 p, } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGradOffset(Sampler1D<vector<T,N>> sampler, vec4 p, float dPdx, float dPdy, constexpr int offset) @@ -3928,7 +3929,7 @@ public vector<T,4> textureProjGradOffset(Sampler1D<vector<T,N>> sampler, vec4 p, } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGradOffset(Sampler2D<vector<T,N>> sampler, vec3 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset) @@ -3944,7 +3945,7 @@ public vector<T,4> textureProjGradOffset(Sampler2D<vector<T,N>> sampler, vec3 p, } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGradOffset(Sampler2D<vector<T,N>> sampler, vec4 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset) @@ -3964,7 +3965,7 @@ public vector<T,4> textureProjGradOffset(Sampler2D<vector<T,N>> sampler, vec4 p, } } -__generic<T:__BuiltinFloatingPointType, let N:int> +__generic<T:__BuiltinArithmeticType, let N:int> [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] public vector<T,4> textureProjGradOffset(Sampler3D<vector<T,N>> sampler, vec4 p, vec3 dPdx, vec3 dPdy, constexpr ivec3 offset) diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index abc178317..1fac47588 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -510,8 +510,7 @@ float __glsl_texture_offset_level_zero_1d_shadow<TTexture, TCoord, TOffset>(TTex } } - -__generic<T:IFloat, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let isShadow:int, let format:int> +__generic<T, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let isShadow:int, let format:int> extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { static const int access = 0; @@ -536,10 +535,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> __target_switch { case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().CalculateLevelOfDetail(__getSampler(), location); case metal: - { - return __getTexture().CalculateLevelOfDetail(__getSampler(), location); - } + return __getTexture().CalculateLevelOfDetail(__getSampler(), location); case glsl: __intrinsic_asm "textureQueryLod($0, $1).x"; case spirv: @@ -559,10 +560,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> __target_switch { case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().CalculateLevelOfDetailUnclamped(__getSampler(), location); case metal: - { return __getTexture().CalculateLevelOfDetailUnclamped(__getSampler(), location); - } case glsl: __intrinsic_asm "textureQueryLod($0, $1).y"; case spirv: @@ -581,8 +584,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> __requireComputeDerivative(); __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().Sample(__getSampler(), location); + case cpp: case metal: return __getTexture().Sample(__getSampler(), location); case glsl: @@ -633,8 +640,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> __requireComputeDerivative(); __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().Sample(__getSampler(), location, offset); + case cpp: case metal: return __getTexture().Sample(__getSampler(), location, offset); case glsl: @@ -658,8 +669,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> __requireComputeDerivative(); __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().Sample(__getSampler(), location, offset, clamp); + case cpp: case metal: return __getTexture().Sample(__getSampler(), location, offset, clamp); case glsl: @@ -681,7 +696,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { __target_switch { - case hlsl: __intrinsic_asm ".Sample"; + case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + __intrinsic_asm ".Sample"; default: status = 0; return Sample(location, offset, clamp); @@ -696,8 +715,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> __requireComputeDerivative(); __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleBias(__getSampler(), location, bias); + case cpp: case metal: return __getTexture().SampleBias(__getSampler(), location, bias); case glsl: @@ -720,8 +743,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> __requireComputeDerivative(); __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleBias(__getSampler(), location, bias, offset); + case cpp: case metal: return __getTexture().SampleBias(__getSampler(), location, bias, offset); case glsl: @@ -757,6 +784,10 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> return __glsl_texture(this, __makeVector(location, compareValue)); } case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleCmp(__getComparisonSampler(), location, compareValue); case metal: return __getTexture().SampleCmp(__getComparisonSampler(), location, compareValue); case spirv: @@ -784,6 +815,10 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> return __glsl_texture_level_zero(this, __makeVector(location, compareValue)); } case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleCmpLevelZero(__getComparisonSampler(), location, compareValue); case metal: return __getTexture().SampleCmpLevelZero(__getComparisonSampler(), location, compareValue); case spirv: @@ -813,6 +848,10 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> return __glsl_texture_offset(this, __makeVector(location, compareValue), offset); } case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleCmp(__getComparisonSampler(), location, compareValue, offset); case metal: return __getTexture().SampleCmp(__getComparisonSampler(), location, compareValue, offset); case spirv: @@ -840,6 +879,10 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> return __glsl_texture_offset_level_zero(this, __makeVector(location, compareValue), offset); } case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleCmpLevelZero(__getComparisonSampler(), location, compareValue, offset); case metal: return __getTexture().SampleCmpLevelZero(__getComparisonSampler(), location, compareValue, offset); case spirv: @@ -858,8 +901,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleGrad(__getSampler(), location, gradX, gradY); + case cpp: case metal: return __getTexture().SampleGrad(__getSampler(), location, gradX, gradY); @@ -881,8 +928,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleGrad(__getSampler(), location, gradX, gradY, offset); + case cpp: case metal: return __getTexture().SampleGrad(__getSampler(), location, gradX, gradY, offset); case glsl: @@ -904,8 +955,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleGrad(__getSampler(), location, gradX, gradY, offset, lodClamp); + case cpp: case metal: return __getTexture().SampleGrad(__getSampler(), location, gradX, gradY, offset, lodClamp); case glsl: @@ -927,8 +982,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleLevel(__getSampler(), location, level); + case cpp: case metal: return __getTexture().SampleLevel(__getSampler(), location, level); case glsl: @@ -980,8 +1039,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { __target_switch { - case cpp: case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + return __getTexture().SampleLevel(__getSampler(), location, level, offset); + case cpp: case metal: return __getTexture().SampleLevel(__getSampler(), location, level, offset); @@ -1048,7 +1111,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,access,isShadow,0,forma } } -__generic<T:IFloat, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let isShadow:int, let format:int> +__generic<T, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let isShadow:int, let format:int> extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> { [__readNone] @@ -1060,7 +1123,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".Sample"; case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".Sample"; case metal: if (isArray == 1) @@ -1140,7 +1207,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".Sample"; case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".Sample"; case metal: if (isArray == 1) @@ -1184,7 +1255,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".Sample"; case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".Sample"; case metal: if (isArray == 1) @@ -1226,7 +1301,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> { __target_switch { - case hlsl: __intrinsic_asm ".Sample"; + case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + __intrinsic_asm ".Sample"; default: status = 0; return Sample(s, location, offset, clamp); @@ -1242,8 +1321,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".SampleBias"; case hlsl: - __intrinsic_asm ".SampleBias"; + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + __intrinsic_asm ".SampleBias"; case metal: if (isArray == 1) { @@ -1288,8 +1371,12 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".SampleBias"; case hlsl: - __intrinsic_asm ".SampleBias"; + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); + __intrinsic_asm ".SampleBias"; case metal: if (isArray == 1) { @@ -1344,6 +1431,9 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> return __glsl_texture(this, s, __makeVector(location,compareValue)); } case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".SampleCmp"; case metal: if (isArray == 1) @@ -1392,6 +1482,9 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> return __glsl_texture_level_zero(this, s, __makeVector(location,compareValue)); } case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".SampleCmpLevelZero"; case metal: if (isArray == 1) @@ -1442,6 +1535,9 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> return __glsl_texture_offset(this, s, __makeVector(location,compareValue), offset); } case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".SampleCmp"; case metal: if (isArray == 1) @@ -1487,6 +1583,9 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> return __glsl_texture_offset_level_zero(this, s, __makeVector(location,compareValue), offset); } case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".SampleCmpLevelZero"; case metal: if (isShadow == 1) @@ -1526,7 +1625,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".SampleGrad"; case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".SampleGrad"; case metal: if (isArray == 1) @@ -1573,7 +1676,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".SampleGrad"; case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".SampleGrad"; case metal: if (isArray == 1) @@ -1618,7 +1725,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".SampleGrad"; case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".SampleGrad"; case metal: if (isArray == 1) @@ -1662,7 +1773,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".SampleLevel"; case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".SampleLevel"; case metal: if (isArray == 1) @@ -1738,7 +1853,11 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format> __target_switch { case cpp: + __intrinsic_asm ".SampleLevel"; case hlsl: + static_assert(T is float || T is vector<float,2> || T is vector<float,3> || T is vector<float,4> + || T is half || T is vector<half,2> || T is vector<half,3> || T is vector<half,4> + , "HLSL supports only float and half type textures"); __intrinsic_asm ".SampleLevel"; case metal: if (isArray == 1) @@ -2138,8 +2257,9 @@ vector<TElement,4> __texture_gatherCmp_offsets(__TextureImpl<T, Shape, isArray, } ${{{{ -for (int isCombined = 0; isCombined<=1; isCombined++) { -for (int isScalarTexture = 0; isScalarTexture <= 1; isScalarTexture++) { +for (int isCombined = 0; isCombined < 2; isCombined++) +for (int isScalarTexture = 0; isScalarTexture < 2; isScalarTexture++) +{ if (isScalarTexture == 0) { sb << "__generic<T:__BuiltinArithmeticType, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let isShadow:int, let format:int>\n"; @@ -2153,24 +2273,12 @@ for (int isScalarTexture = 0; isScalarTexture <= 1; isScalarTexture++) { }}}} { // begin extension for gather ${{{{ - if (isCombined) - { -}}}} - __intrinsic_op($(kIROp_CombinedTextureSamplerGetTexture)) - __TextureImpl<T, Shape, isArray, 0, sampleCount, 0, isShadow, 0, format> __getTexture(); - - __intrinsic_op($(kIROp_CombinedTextureSamplerGetSampler)) - SamplerState __getSampler(); - - __intrinsic_op($(kIROp_CombinedTextureSamplerGetSampler)) - SamplerComparisonState __getComparisonSampler(); -${{{{ - } // Gather component const char* samplerStateParam = isCombined ? "" : " s,"; const char* getTexture = isCombined ? "__getTexture()" : "this"; - for (int isCmp = 0; isCmp < 2; ++isCmp) { + for (int isCmp = 0; isCmp < 2; ++isCmp) + { const char* cmp = isCmp ? "Cmp" : ""; const char* cmpParam = isCmp ? ", T compareValue" : ""; const char* compareArg = isCmp ? ", compareValue" : ""; @@ -2179,7 +2287,8 @@ ${{{{ const char* componentNames[] = { "", "Red", "Green", "Blue", "Alpha"}; const char* glslComponentNames[] = { ", 0", ", 1", ", 2", ", 3" }; - for (auto componentId = 0; componentId < 5; componentId++) { + for (auto componentId = 0; componentId < 5; componentId++) + { auto componentName = componentNames[componentId]; auto glslComponent = (isCmp ? "" :glslComponentNames[componentId == 0 ? 0 : componentId - 1]); }}}} @@ -2228,14 +2337,13 @@ ${{{{ } } ${{{{ - } // for (componentId) + } // for (componentId) } // for (isCmp) }}}} } // end extension for gather ${{{{ } // for (isScalarTexture) -} // for (isCombined) }}}} // Load/Subscript for readonly, no MS textures |
