From fc77070fdc9bfa599e8d66b21743778de3011e53 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 17 Jan 2025 14:37:27 -0800 Subject: Refactor _Texture to constrain on texel types. (#6115) * Refactor _Texture to constrain on texel types. * Fix tests. * Fix. * Disable glsl texture test because rhi can't run it correctly. --- source/slang/glsl.meta.slang | 513 ++++++++++++++++--------------- source/slang/hlsl.meta.slang | 298 +++++++++++------- source/slang/slang-check-inheritance.cpp | 4 + source/slang/slang-emit-cpp.cpp | 5 +- source/slang/slang-ir-peephole.cpp | 2 + 5 files changed, 461 insertions(+), 361 deletions(-) (limited to 'source') diff --git a/source/slang/glsl.meta.slang b/source/slang/glsl.meta.slang index ba26b5d84..1b44c7825 100644 --- a/source/slang/glsl.meta.slang +++ b/source/slang/glsl.meta.slang @@ -1354,6 +1354,9 @@ public vector not(vector x) return !x; } +__intrinsic_op(vectorReshape) +vector __vectorReshape2(U vin); + // // Section 8.9.1. Texture Query Functions // @@ -1472,7 +1475,7 @@ public typealias sampler2DMSArray = Sampler2DMSArray; public typealias isampler2DMSArray = Sampler2DMSArray; public typealias usampler2DMSArray = Sampler2DMSArray; -__generic +__generic public typealias Sampler2DRect = _Texture; public typealias sampler2DRect = Sampler2DRect; public typealias isampler2DRect = Sampler2DRect; @@ -1491,7 +1494,7 @@ public typealias sampler2DRectShadow = _Texture< format >; -__generic +__generic public typealias SamplerBuffer = _Texture< T, __ShapeBuffer, @@ -1512,10 +1515,10 @@ public typealias usamplerBuffer = SamplerBuffer; // textureSize // ------------------- -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_size)] -public int textureSize(Sampler1D> sampler, int lod) +public int textureSize(Sampler1D sampler, int lod) { int result; int numberOfLevels; @@ -1523,10 +1526,10 @@ public int textureSize(Sampler1D> sampler, int lod) return result; } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_size)] -public ivec2 textureSize(Sampler2D> sampler, int lod) +public ivec2 textureSize(Sampler2D sampler, int lod) { vector result; int numberOfLevels; @@ -1534,10 +1537,10 @@ public ivec2 textureSize(Sampler2D> sampler, int lod) return result; } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_size)] -public ivec3 textureSize(Sampler3D> sampler, int lod) +public ivec3 textureSize(Sampler3D sampler, int lod) { vector result; int numberOfLevels; @@ -1545,10 +1548,10 @@ public ivec3 textureSize(Sampler3D> sampler, int lod) return result; } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_size)] -public ivec2 textureSize(SamplerCube> sampler, int lod) +public ivec2 textureSize(SamplerCube sampler, int lod) { vector result; int numberOfLevels; @@ -1587,9 +1590,9 @@ public ivec2 textureSize(samplerCubeShadow sampler, int lod) } [require(glsl_hlsl_spirv, texture_size)] -__generic +__generic [ForceInline] -public ivec3 textureSize(SamplerCubeArray> sampler, int lod) +public ivec3 textureSize(SamplerCubeArray sampler, int lod) { vector result; int numberOfLevels; @@ -1608,9 +1611,9 @@ public ivec3 textureSize(samplerCubeArrayShadow sampler, int lod) } [require(glsl_hlsl_spirv, texture_size)] -__generic +__generic [ForceInline] -public ivec2 textureSize(Sampler2DRect> sampler) +public ivec2 textureSize(Sampler2DRect sampler) { vector result; int numberOfLevels; @@ -1629,9 +1632,9 @@ public ivec2 textureSize(sampler2DRectShadow sampler) } [require(glsl_hlsl_spirv, texture_size)] -__generic +__generic [ForceInline] -public ivec2 textureSize(Sampler1DArray> sampler, int lod) +public ivec2 textureSize(Sampler1DArray sampler, int lod) { vector result; int numberOfLevels; @@ -1650,9 +1653,9 @@ public ivec2 textureSize(sampler1DArrayShadow sampler, int lod) } [require(glsl_hlsl_spirv, texture_size)] -__generic +__generic [ForceInline] -public ivec3 textureSize(Sampler2DArray> sampler, int lod) +public ivec3 textureSize(Sampler2DArray sampler, int lod) { vector result; int numberOfLevels; @@ -1671,9 +1674,9 @@ public ivec3 textureSize(sampler2DArrayShadow sampler, int lod) } [require(glsl_hlsl_spirv, texture_size)] -__generic +__generic [ForceInline] -public int textureSize(SamplerBuffer,format> sampler) +public int textureSize(SamplerBuffer sampler) { uint result; sampler.GetDimensions(result); @@ -1681,9 +1684,9 @@ public int textureSize(SamplerBuffer,format> sampler) } [require(glsl_hlsl_spirv, texture_size)] -__generic +__generic [ForceInline] -public ivec2 textureSize(Sampler2DMS,sampleCount> sampler) +public ivec2 textureSize(Sampler2DMS sampler) { vector result; int sampleCount; @@ -1693,9 +1696,9 @@ public ivec2 textureSize(Sampler2DMS,sampleCount> sampler) } [require(glsl_hlsl_spirv, texture_size)] -__generic +__generic [ForceInline] -public ivec3 textureSize(Sampler2DMSArray,sampleCount> sampler) +public ivec3 textureSize(Sampler2DMSArray sampler) { vector result; int sampleCount; @@ -1708,7 +1711,7 @@ public ivec3 textureSize(Sampler2DMSArray,sampleCount> sampler) // textureQueryLod // ------------------- -__generic +__generic [ForceInline] [require(glsl_hlsl_metal_spirv, texture_querylod)] public vec2 textureQueryLod(_Texture< @@ -1741,7 +1744,7 @@ public vec2 textureQueryLod(_Texture< } } -__generic +__generic [ForceInline] [require(glsl_hlsl_metal_spirv, texture_querylod)] public vec2 textureQueryLod(_Texture< @@ -1778,10 +1781,10 @@ public vec2 textureQueryLod(_Texture< // textureQueryLevels // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_metal_spirv, texture_querylevels)] -public int textureQueryLevels(Sampler1D> sampler) +public int textureQueryLevels(Sampler1D sampler) { int width; int numberOfLevels; @@ -1789,10 +1792,10 @@ public int textureQueryLevels(Sampler1D> sampler) return numberOfLevels; } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_metal_spirv, texture_querylevels)] -public int textureQueryLevels(Sampler2D> sampler) +public int textureQueryLevels(Sampler2D sampler) { vector dim; int numberOfLevels; @@ -1800,10 +1803,10 @@ public int textureQueryLevels(Sampler2D> sampler) return numberOfLevels; } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_metal_spirv, texture_querylevels)] -public int textureQueryLevels(Sampler3D> sampler) +public int textureQueryLevels(Sampler3D sampler) { vector dim; int numberOfLevels; @@ -1811,10 +1814,10 @@ public int textureQueryLevels(Sampler3D> sampler) return numberOfLevels; } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_metal_spirv, texture_querylevels)] -public int textureQueryLevels(SamplerCube> sampler) +public int textureQueryLevels(SamplerCube sampler) { vector dim; int numberOfLevels; @@ -1822,10 +1825,10 @@ public int textureQueryLevels(SamplerCube> sampler) return numberOfLevels; } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_metal_spirv, texture_querylevels)] -public int textureQueryLevels(Sampler1DArray> sampler) +public int textureQueryLevels(Sampler1DArray sampler) { vector dim; int numberOfLevels; @@ -1833,10 +1836,10 @@ public int textureQueryLevels(Sampler1DArray> sampler) return numberOfLevels; } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_metal_spirv, texture_querylevels)] -public int textureQueryLevels(Sampler2DArray> sampler) +public int textureQueryLevels(Sampler2DArray sampler) { vector dim; int numberOfLevels; @@ -1844,10 +1847,10 @@ public int textureQueryLevels(Sampler2DArray> sampler) return numberOfLevels; } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_metal_spirv, texture_querylevels)] -public int textureQueryLevels(SamplerCubeArray> sampler) +public int textureQueryLevels(SamplerCubeArray sampler) { vector dim; int numberOfLevels; @@ -1919,7 +1922,7 @@ public int textureQueryLevels(samplerCubeArrayShadow sampler) // textureSamples // ------------------- -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, image_samples)] public int textureSamples(Sampler2DMS sampler) @@ -1931,7 +1934,7 @@ public int textureSamples(Sampler2DMS sampler) return sampleCount; } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, image_samples)] public int textureSamples(Sampler2DMSArray sampler) @@ -1951,27 +1954,27 @@ public int textureSamples(Sampler2DMSArray sampler) // texture // ------------------- -__generic +__generic [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector texture(Sampler1D> sampler, float p) +public vector texture(Sampler1D sampler, float p) { - return __vectorReshape<4>(sampler.Sample(p)); + return __vectorReshape2(sampler.Sample(p)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector texture(Sampler1D> sampler, float p, constexpr float bias) +public vector texture(Sampler1D sampler, float p, constexpr float bias) { - return __vectorReshape<4>(sampler.SampleBias(p, bias)); + return __vectorReshape2(sampler.SampleBias(p, bias)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector texture(_Texture< - vector, +public vector texture(_Texture< + T, Shape, isArray, 0, // isMS @@ -1982,14 +1985,14 @@ public vector texture(_Texture< format > sampler, vector p) { - return __vectorReshape<4>(sampler.Sample(p)); + return __vectorReshape2(sampler.Sample(p)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector texture(_Texture< - vector, +public vector texture(_Texture< + T, Shape, isArray, 0, // isMS @@ -2000,7 +2003,7 @@ public vector texture(_Texture< format > sampler, vector p, constexpr float bias) { - return __vectorReshape<4>(sampler.SampleBias(p, bias)); + return __vectorReshape2(sampler.SampleBias(p, bias)); } [ForceInline] @@ -2137,170 +2140,170 @@ public float texture(samplerCubeArrayShadow sampler, vec4 p, float compare) // textureProj // ------------------- -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler1D> sampler, vec2 p) +public vector textureProj(Sampler1D sampler, vec2 p) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p + result:$$vector = OpImageSampleProjImplicitLod $sampler $p }; default: return texture(sampler, p.x / p.y); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler1D> sampler, vec2 p, float bias) +public vector textureProj(Sampler1D sampler, vec2 p, float bias) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias + result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias }; default: return texture(sampler, p.x / p.y, bias); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler1D> sampler, vec4 p) +public vector textureProj(Sampler1D sampler, vec4 p) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p + result:$$vector = OpImageSampleProjImplicitLod $sampler $p }; default: return texture(sampler, p.x / p.w); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler1D> sampler, vec4 p, float bias) +public vector textureProj(Sampler1D sampler, vec4 p, float bias) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias + result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias }; default: return texture(sampler, p.x / p.w, bias); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler2D> sampler, vec3 p) +public vector textureProj(Sampler2D sampler, vec3 p) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p + result:$$vector = OpImageSampleProjImplicitLod $sampler $p }; default: return texture(sampler, p.xy / p.z); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler2D> sampler, vec3 p, float bias) +public vector textureProj(Sampler2D sampler, vec3 p, float bias) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias + result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias }; default: return texture(sampler, p.xy / p.z, bias); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler2D> sampler, vec4 p) +public vector textureProj(Sampler2D sampler, vec4 p) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p + result:$$vector = OpImageSampleProjImplicitLod $sampler $p }; default: return texture(sampler, p.xy / p.w); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler2D> sampler, vec4 p, float bias) +public vector textureProj(Sampler2D sampler, vec4 p, float bias) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias + result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias }; default: return texture(sampler, p.xy / p.w, bias); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler3D> sampler, vec4 p) +public vector textureProj(Sampler3D sampler, vec4 p) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p + result:$$vector = OpImageSampleProjImplicitLod $sampler $p }; default: return texture(sampler, p.xyz / p.w); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProj(Sampler3D> sampler, vec4 p, float bias) +public vector textureProj(Sampler3D sampler, vec4 p, float bias) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProj"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias + result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias $bias }; default: return texture(sampler, p.xyz / p.w, bias); @@ -2395,19 +2398,19 @@ public float textureProj(sampler2DShadow sampler, vec4 p, float bias) // textureLod // ------------------- -__generic +__generic [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureLod(Sampler1D> sampler, float p, float lod) +public vector textureLod(Sampler1D sampler, float p, float lod) { - return __vectorReshape<4>(sampler.SampleLevel(p, lod)); + return __vectorReshape2(sampler.SampleLevel(p, lod)); } -__generic +__generic [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureLod(_Texture< - vector, +public vector textureLod(_Texture< + T, Shape, isArray, 0, // isMS @@ -2418,7 +2421,7 @@ public vector textureLod(_Texture< format > sampler, vector p, float lod) { - return __vectorReshape<4>(sampler.SampleLevel(p, lod)); + return __vectorReshape2(sampler.SampleLevel(p, lod)); } [ForceInline] @@ -2501,28 +2504,28 @@ public float textureLod(sampler1DArrayShadow sampler, vec3 p, float lod) // textureOffset // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureOffset(Sampler1D> sampler, float p, constexpr int offset, float bias = 0.0) +public vector textureOffset(Sampler1D sampler, float p, constexpr int offset, float bias = 0.0) { - return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); + return __vectorReshape2(sampler.SampleBias(p, bias, offset)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureOffset(Sampler2D> sampler, vec2 p, constexpr ivec2 offset, float bias = 0.0) +public vector textureOffset(Sampler2D sampler, vec2 p, constexpr ivec2 offset, float bias = 0.0) { - return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); + return __vectorReshape2(sampler.SampleBias(p, bias, offset)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureOffset(Sampler3D> sampler, vec3 p, constexpr ivec3 offset, float bias = 0.0) +public vector textureOffset(Sampler3D sampler, vec3 p, constexpr ivec3 offset, float bias = 0.0) { - return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); + return __vectorReshape2(sampler.SampleBias(p, bias, offset)); } [ForceInline] @@ -2591,20 +2594,20 @@ public float textureOffset(sampler1DShadow sampler, vec3 p, constexpr int offset } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureOffset(Sampler1DArray> sampler, vec2 p, constexpr int offset, float bias = 0.0) +public vector textureOffset(Sampler1DArray sampler, vec2 p, constexpr int offset, float bias = 0.0) { - return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); + return __vectorReshape2(sampler.SampleBias(p, bias, offset)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureOffset(Sampler2DArray> sampler, vec3 p, constexpr ivec2 offset, float bias = 0.0) +public vector textureOffset(Sampler2DArray sampler, vec3 p, constexpr ivec2 offset, float bias = 0.0) { - return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); + return __vectorReshape2(sampler.SampleBias(p, bias, offset)); } [ForceInline] @@ -2662,19 +2665,19 @@ public float textureOffset(sampler2DArrayShadow sampler, vec4 p, constexpr ivec2 // texelFetch // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_samplerless)] -public vector texelFetch(Sampler1D> sampler, int p, int lod) +public vector texelFetch(Sampler1D sampler, int p, int lod) { - return __vectorReshape<4>(sampler.Load(int2(p, lod))); + return __vectorReshape2(sampler.Load(int2(p, lod))); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_samplerless)] -public vector texelFetch(_Texture< - vector, +public vector texelFetch(_Texture< + T, Shape, isArray, 0, // isMS @@ -2685,30 +2688,30 @@ public vector texelFetch(_Texture< format > sampler, vector p, int lod) { - return __vectorReshape<4>(sampler.Load(__makeVector(p,lod))); + return __vectorReshape2(sampler.Load(__makeVector(p,lod))); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_samplerless)] -public vector texelFetch(Sampler2DRect> sampler, ivec2 p) +public vector texelFetch(Sampler2DRect sampler, ivec2 p) { - return __vectorReshape<4>(sampler.Load(int3(p.xy,0))); + return __vectorReshape2(sampler.Load(int3(p.xy,0))); } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_1_samplerless)] -public vector texelFetch(SamplerBuffer,format> sampler, int p) +public vector texelFetch(SamplerBuffer sampler, int p) { - return __vectorReshape<4>(sampler.Load(p)); + return __vectorReshape2(sampler.Load(p)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_samplerless)] -public vector texelFetch(_Texture< - vector, +public vector texelFetch(_Texture< + T, __Shape2D, isArray, 1, // isMS @@ -2724,7 +2727,7 @@ public vector texelFetch(_Texture< case glsl: __intrinsic_asm "texelFetch"; default: // TODO: Need to apply lod - return __vectorReshape<4>(sampler.Load(__makeVector(p, 0))); + return __vectorReshape2(sampler.Load(__makeVector(p, 0))); } } @@ -2732,19 +2735,19 @@ public vector texelFetch(_Texture< // texelFetchOffset // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_samplerless)] -public vector texelFetchOffset(Sampler1D> sampler, int p, int lod, constexpr int offset) +public vector texelFetchOffset(Sampler1D sampler, int p, int lod, constexpr int offset) { - return __vectorReshape<4>(sampler.Load(int2(p, lod), offset)); + return __vectorReshape2(sampler.Load(int2(p, lod), offset)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_samplerless)] -public vector texelFetchOffset(_Texture< - vector, +public vector texelFetchOffset(_Texture< + T, Shape, isArray, 0, // isMS @@ -2755,59 +2758,59 @@ public vector texelFetchOffset(_Texture< format > sampler, vector p, int lod, constexpr vector offset) { - return __vectorReshape<4>(sampler.Load(__makeVector(p,lod), offset)); + return __vectorReshape2(sampler.Load(__makeVector(p,lod), offset)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_samplerless)] -public vector texelFetchOffset(Sampler2DRect> sampler, ivec2 p, constexpr ivec2 offset) +public vector texelFetchOffset(Sampler2DRect sampler, ivec2 p, constexpr ivec2 offset) { - return __vectorReshape<4>(sampler.Load(__makeVector(p, 0), offset)); + return __vectorReshape2(sampler.Load(__makeVector(p, 0), offset)); } // ------------------- // textureProjOffset // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler1D> sampler, vec2 p, constexpr int offset) +public vector textureProjOffset(Sampler1D sampler, vec2 p, constexpr int offset) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProjOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p ConstOffset $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $p ConstOffset $offset }; default: return textureOffset(sampler, p.x / p.y, offset); } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler1D> sampler, vec2 p, constexpr int offset, float bias) +public vector textureProjOffset(Sampler1D sampler, vec2 p, constexpr int offset, float bias) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProjOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias|ConstOffset $bias $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias|ConstOffset $bias $offset }; default: return textureOffset(sampler, p.x / p.y, offset, bias); } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler1D> sampler, vec4 p, constexpr int offset) +public vector textureProjOffset(Sampler1D sampler, vec4 p, constexpr int offset) { __requireComputeDerivative(); __target_switch @@ -2817,7 +2820,7 @@ public vector textureProjOffset(Sampler1D> sampler, vec4 p, con { vec4 xw__ = p.xwww; return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $xw__ ConstOffset $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $xw__ ConstOffset $offset }; } default: @@ -2825,10 +2828,10 @@ public vector textureProjOffset(Sampler1D> sampler, vec4 p, con } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler1D> sampler, vec4 p, constexpr int offset, float bias) +public vector textureProjOffset(Sampler1D sampler, vec4 p, constexpr int offset, float bias) { __requireComputeDerivative(); __target_switch @@ -2838,7 +2841,7 @@ public vector textureProjOffset(Sampler1D> sampler, vec4 p, con { vec4 xw__ = p.xwww; return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $xw__ Bias|ConstOffset $bias $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $xw__ Bias|ConstOffset $bias $offset }; } default: @@ -2846,44 +2849,44 @@ public vector textureProjOffset(Sampler1D> sampler, vec4 p, con } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler2D> sampler, vec3 p, constexpr ivec2 offset) +public vector textureProjOffset(Sampler2D sampler, vec3 p, constexpr ivec2 offset) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProjOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p ConstOffset $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $p ConstOffset $offset }; default: return textureOffset(sampler, p.xy / p.z, offset); } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler2D> sampler, vec3 p, constexpr ivec2 offset, float bias) +public vector textureProjOffset(Sampler2D sampler, vec3 p, constexpr ivec2 offset, float bias) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProjOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias|ConstOffset $bias $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias|ConstOffset $bias $offset }; default: return textureOffset(sampler, p.xy / p.z, offset, bias); } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler2D> sampler, vec4 p, constexpr ivec2 offset) +public vector textureProjOffset(Sampler2D sampler, vec4 p, constexpr ivec2 offset) { __requireComputeDerivative(); __target_switch @@ -2893,7 +2896,7 @@ public vector textureProjOffset(Sampler2D> sampler, vec4 p, con { vec4 xyw__ = p.xyww; return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $xyw__ ConstOffset $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $xyw__ ConstOffset $offset }; } default: @@ -2901,10 +2904,10 @@ public vector textureProjOffset(Sampler2D> sampler, vec4 p, con } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler2D> sampler, vec4 p, constexpr ivec2 offset, float bias) +public vector textureProjOffset(Sampler2D sampler, vec4 p, constexpr ivec2 offset, float bias) { __requireComputeDerivative(); __target_switch @@ -2914,7 +2917,7 @@ public vector textureProjOffset(Sampler2D> sampler, vec4 p, con { vec4 xyw_ = p.xyww; return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $xyw_ Bias|ConstOffset $bias $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $xyw_ Bias|ConstOffset $bias $offset }; } default: @@ -2922,34 +2925,34 @@ public vector textureProjOffset(Sampler2D> sampler, vec4 p, con } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler3D> sampler, vec4 p, constexpr ivec3 offset) +public vector textureProjOffset(Sampler3D sampler, vec4 p, constexpr ivec3 offset) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProjOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p ConstOffset $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $p ConstOffset $offset }; default: return textureOffset(sampler, p.xyz / p.w, offset); } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjOffset(Sampler3D> sampler, vec4 p, constexpr ivec3 offset, float bias) +public vector textureProjOffset(Sampler3D sampler, vec4 p, constexpr ivec3 offset, float bias) { __requireComputeDerivative(); __target_switch { case glsl: __intrinsic_asm "textureProjOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias|ConstOffset $bias $offset + result:$$vector = OpImageSampleProjImplicitLod $sampler $p Bias|ConstOffset $bias $offset }; default: return textureOffset(sampler, p.xyz / p.w, offset, bias); @@ -3044,19 +3047,19 @@ public float textureProjOffset(sampler2DShadow sampler, vec4 p, constexpr ivec2 // textureLodOffset // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0)] -public vector textureLodOffset(Sampler1D> sampler, float p, float lod, constexpr int offset) +public vector textureLodOffset(Sampler1D sampler, float p, float lod, constexpr int offset) { - return __vectorReshape<4>(sampler.SampleLevel(p, lod, offset)); + return __vectorReshape2(sampler.SampleLevel(p, lod, offset)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_0)] -public vector textureLodOffset(_Texture< - vector, +public vector textureLodOffset(_Texture< + T, Shape, isArray, 0, // isMS @@ -3067,7 +3070,7 @@ public vector textureLodOffset(_Texture< format > sampler, vector p, float lod, constexpr vector offset) { - return __vectorReshape<4>(sampler.SampleLevel(p, lod, offset)); + return __vectorReshape2(sampler.SampleLevel(p, lod, offset)); } [ForceInline] @@ -3134,26 +3137,26 @@ public float textureLodOffset(sampler1DArrayShadow sampler, vec3 p, float lod, c // textureProjLod // ------------------- -__generic +__generic [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLod(Sampler1D> sampler, vec2 p, float lod) +public vector textureProjLod(Sampler1D sampler, vec2 p, float lod) { __target_switch { case glsl: __intrinsic_asm "textureProjLod"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod $lod + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod $lod }; default: return textureLod(sampler, p.x / p.y, lod); } } -__generic +__generic [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLod(Sampler1D> sampler, vec4 p, float lod) +public vector textureProjLod(Sampler1D sampler, vec4 p, float lod) { __target_switch { @@ -3162,7 +3165,7 @@ public vector textureProjLod(Sampler1D> sampler, vec4 p, float { vec4 xw__ = p.xwww; return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $xw__ Lod $lod + result:$$vector = OpImageSampleProjExplicitLod $sampler $xw__ Lod $lod }; } default: @@ -3170,26 +3173,26 @@ public vector textureProjLod(Sampler1D> sampler, vec4 p, float } } -__generic +__generic [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLod(Sampler2D> sampler, vec3 p, float lod) +public vector textureProjLod(Sampler2D sampler, vec3 p, float lod) { __target_switch { case glsl: __intrinsic_asm "textureProjLod"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod $lod + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod $lod }; default: return textureLod(sampler, p.xy / p.z, lod); } } -__generic +__generic [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLod(Sampler2D> sampler, vec4 p, float lod) +public vector textureProjLod(Sampler2D sampler, vec4 p, float lod) { __target_switch { @@ -3198,7 +3201,7 @@ public vector textureProjLod(Sampler2D> sampler, vec4 p, float { vec4 xyw_ = p.xyww; return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $xyw_ Lod $lod + result:$$vector = OpImageSampleProjExplicitLod $sampler $xyw_ Lod $lod }; } default: @@ -3206,16 +3209,16 @@ public vector textureProjLod(Sampler2D> sampler, vec4 p, float } } -__generic +__generic [ForceInline] [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLod(Sampler3D> sampler, vec4 p, float lod) +public vector textureProjLod(Sampler3D sampler, vec4 p, float lod) { __target_switch { case glsl: __intrinsic_asm "textureProjLod"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod $lod + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod $lod }; default: return textureLod(sampler, p.xyz / p.w, lod); @@ -3266,26 +3269,26 @@ public float textureProjLod(sampler2DShadow sampler, vec4 p, float lod) // textureProjLodOffset // ------------------- -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLodOffset(Sampler1D> sampler, vec2 p, float lod, constexpr int offset) +public vector textureProjLodOffset(Sampler1D sampler, vec2 p, float lod, constexpr int offset) { __target_switch { case glsl: __intrinsic_asm "textureProjLodOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod|ConstOffset $lod $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod|ConstOffset $lod $offset }; default: return textureLodOffset(sampler, p.x / p.y, lod, offset); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLodOffset(Sampler1D> sampler, vec4 p, float lod, constexpr int offset) +public vector textureProjLodOffset(Sampler1D sampler, vec4 p, float lod, constexpr int offset) { __target_switch { @@ -3294,7 +3297,7 @@ public vector textureProjLodOffset(Sampler1D> sampler, vec4 p, { vec4 xw__ = p.xwww; return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $xw__ Lod|ConstOffset $lod $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $xw__ Lod|ConstOffset $lod $offset }; } default: @@ -3302,26 +3305,26 @@ public vector textureProjLodOffset(Sampler1D> sampler, vec4 p, } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLodOffset(Sampler2D> sampler, vec3 p, float lod, constexpr ivec2 offset) +public vector textureProjLodOffset(Sampler2D sampler, vec3 p, float lod, constexpr ivec2 offset) { __target_switch { case glsl: __intrinsic_asm "textureProjLodOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod|ConstOffset $lod $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod|ConstOffset $lod $offset }; default: return textureLodOffset(sampler, p.xy / p.z, lod, offset); } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLodOffset(Sampler2D> sampler, vec4 p, float lod, constexpr ivec2 offset) +public vector textureProjLodOffset(Sampler2D sampler, vec4 p, float lod, constexpr ivec2 offset) { __target_switch { @@ -3330,7 +3333,7 @@ public vector textureProjLodOffset(Sampler2D> sampler, vec4 p, { vec4 xyw_ = p.xyww; return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $xyw_ Lod|ConstOffset $lod $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $xyw_ Lod|ConstOffset $lod $offset }; } default: @@ -3338,16 +3341,16 @@ public vector textureProjLodOffset(Sampler2D> sampler, vec4 p, } } -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_sm_4_0_fragment)] -public vector textureProjLodOffset(Sampler3D> sampler, vec4 p, float lod, constexpr ivec3 offset) +public vector textureProjLodOffset(Sampler3D sampler, vec4 p, float lod, constexpr ivec3 offset) { __target_switch { case glsl: __intrinsic_asm "textureProjLodOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod|ConstOffset $lod $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Lod|ConstOffset $lod $offset }; default: return textureLodOffset(sampler, p.xyz / p.w, lod, offset); @@ -3399,19 +3402,19 @@ public float textureProjLodOffset(sampler2DShadow sampler, vec4 p, float lod, co // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureGrad(Sampler1D> sampler, float p, float dPdx, float dPdy) +public vector textureGrad(Sampler1D sampler, float p, float dPdx, float dPdy) { - return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy)); + return __vectorReshape2(sampler.SampleGrad(p, dPdx, dPdy)); } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureGrad(_Texture< - vector, +public vector textureGrad(_Texture< + T, Shape, isArray, 0, // isMS @@ -3422,7 +3425,7 @@ public vector textureGrad(_Texture< format > sampler, vector p, vector dPdx, vector dPdy) { - return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy)); + return __vectorReshape2(sampler.SampleGrad(p, dPdx, dPdy)); } [ForceInline] @@ -3514,19 +3517,19 @@ public float textureGrad(sampler2DArrayShadow sampler, vec4 p, vec2 dPdx, vec2 d // textureGradOffset // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureGradOffset(Sampler1D> sampler, float p, float dPdx, float dPdy, constexpr int offset) +public vector textureGradOffset(Sampler1D sampler, float p, float dPdx, float dPdy, constexpr int offset) { - return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy, offset)); + return __vectorReshape2(sampler.SampleGrad(p, dPdx, dPdy, offset)); } -__generic +__generic [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] [ForceInline] -public vector textureGradOffset(_Texture< - vector, +public vector textureGradOffset(_Texture< + T, Shape, isArray, 0, // isMS @@ -3537,7 +3540,7 @@ public vector textureGradOffset(_Texture< format > sampler, vector p, vector dPdx, vector dPdy, constexpr vector offset) { - return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy, offset)); + return __vectorReshape2(sampler.SampleGrad(p, dPdx, dPdy, offset)); } [ForceInline] @@ -3612,26 +3615,26 @@ public float textureGradOffset(sampler2DArrayShadow sampler, vec4 p, vec2 dPdx, // textureProjGrad // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGrad(Sampler1D> sampler, vec2 p, float dPdx, float dPdy) +public vector textureProjGrad(Sampler1D sampler, vec2 p, float dPdx, float dPdy) { __target_switch { case glsl: __intrinsic_asm "textureProjGrad"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad $dPdx $dPdy + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad $dPdx $dPdy }; default: return textureGrad(sampler, p.x / p.y, dPdx, dPdy); } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGrad(Sampler1D> sampler, vec4 p, float dPdx, float dPdy) +public vector textureProjGrad(Sampler1D sampler, vec4 p, float dPdx, float dPdy) { __target_switch { @@ -3640,7 +3643,7 @@ public vector textureProjGrad(Sampler1D> sampler, vec4 p, float { vec4 xw__ = p.xwww; return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $xw__ Grad $dPdx $dPdy + result:$$vector = OpImageSampleProjExplicitLod $sampler $xw__ Grad $dPdx $dPdy }; } default: @@ -3648,26 +3651,26 @@ public vector textureProjGrad(Sampler1D> sampler, vec4 p, float } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGrad(Sampler2D> sampler, vec3 p, vec2 dPdx, vec2 dPdy) +public vector textureProjGrad(Sampler2D sampler, vec3 p, vec2 dPdx, vec2 dPdy) { __target_switch { case glsl: __intrinsic_asm "textureProjGrad"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad $dPdx $dPdy + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad $dPdx $dPdy }; default: return textureGrad(sampler, p.xy / p.z, dPdx, dPdy); } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGrad(Sampler2D> sampler, vec4 p, vec2 dPdx, vec2 dPdy) +public vector textureProjGrad(Sampler2D sampler, vec4 p, vec2 dPdx, vec2 dPdy) { __target_switch { @@ -3676,7 +3679,7 @@ public vector textureProjGrad(Sampler2D> sampler, vec4 p, vec2 { vec4 xyw_ = p.xyww; return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $xyw_ Grad $dPdx $dPdy + result:$$vector = OpImageSampleProjExplicitLod $sampler $xyw_ Grad $dPdx $dPdy }; } default: @@ -3684,16 +3687,16 @@ public vector textureProjGrad(Sampler2D> sampler, vec4 p, vec2 } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGrad(Sampler3D> sampler, vec4 p, vec3 dPdx, vec3 dPdy) +public vector textureProjGrad(Sampler3D sampler, vec4 p, vec3 dPdx, vec3 dPdy) { __target_switch { case glsl: __intrinsic_asm "textureProjGrad"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad $dPdx $dPdy + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad $dPdx $dPdy }; default: return textureGrad(sampler, p.xyz / p.w, dPdx, dPdy); @@ -3744,26 +3747,26 @@ public float textureProjGrad(sampler2DShadow sampler, vec4 p, vec2 dPdx, vec2 dP // textureProjGradOffset // ------------------- -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGradOffset(Sampler1D> sampler, vec2 p, float dPdx, float dPdy, constexpr int offset) +public vector textureProjGradOffset(Sampler1D sampler, vec2 p, float dPdx, float dPdy, constexpr int offset) { __target_switch { case glsl: __intrinsic_asm "textureProjGradOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad|ConstOffset $dPdx $dPdy $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad|ConstOffset $dPdx $dPdy $offset }; default: return textureGradOffset(sampler, p.x / p.y, dPdx, dPdy, offset); } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGradOffset(Sampler1D> sampler, vec4 p, float dPdx, float dPdy, constexpr int offset) +public vector textureProjGradOffset(Sampler1D sampler, vec4 p, float dPdx, float dPdy, constexpr int offset) { __target_switch { @@ -3772,7 +3775,7 @@ public vector textureProjGradOffset(Sampler1D> sampler, vec4 p, { vec4 xw__ = p.xwww; return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $xw__ Grad|ConstOffset $dPdx $dPdy $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $xw__ Grad|ConstOffset $dPdx $dPdy $offset }; } default: @@ -3780,26 +3783,26 @@ public vector textureProjGradOffset(Sampler1D> sampler, vec4 p, } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGradOffset(Sampler2D> sampler, vec3 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset) +public vector textureProjGradOffset(Sampler2D sampler, vec3 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset) { __target_switch { case glsl: __intrinsic_asm "textureProjGradOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad|ConstOffset $dPdx $dPdy $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad|ConstOffset $dPdx $dPdy $offset }; default: return textureGradOffset(sampler, p.xy / p.z, dPdx, dPdy, offset); } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGradOffset(Sampler2D> sampler, vec4 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset) +public vector textureProjGradOffset(Sampler2D sampler, vec4 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset) { __target_switch { @@ -3808,7 +3811,7 @@ public vector textureProjGradOffset(Sampler2D> sampler, vec4 p, { vec4 xyw_ = p.xyww; return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $xyw_ Grad|ConstOffset $dPdx $dPdy $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $xyw_ Grad|ConstOffset $dPdx $dPdy $offset }; } default: @@ -3816,16 +3819,16 @@ public vector textureProjGradOffset(Sampler2D> sampler, vec4 p, } } -__generic +__generic [ForceInline] [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] -public vector textureProjGradOffset(Sampler3D> sampler, vec4 p, vec3 dPdx, vec3 dPdy, constexpr ivec3 offset) +public vector textureProjGradOffset(Sampler3D sampler, vec4 p, vec3 dPdx, vec3 dPdy, constexpr ivec3 offset) { __target_switch { case glsl: __intrinsic_asm "textureProjGradOffset"; case spirv: return spirv_asm { - result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad|ConstOffset $dPdx $dPdy $offset + result:$$vector = OpImageSampleProjExplicitLod $sampler $p Grad|ConstOffset $dPdx $dPdy $offset }; default: return textureGradOffset(sampler, p.xyz / p.w, dPdx, dPdy, offset); @@ -3880,11 +3883,11 @@ public float textureProjGradOffset(sampler2DShadow sampler, vec4 p, vec2 dPdx, v // textureGather // ------------------- -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_gather)] -public vector textureGather(_Texture< - vector, +public vector textureGather(_Texture< + T, Shape, isArray, 0, // isMS @@ -3926,11 +3929,11 @@ public vec4 textureGather(_Texture< // textureGatherOffset // ------------------- -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_gather)] -public vector textureGatherOffset(_Texture< - vector, +public vector textureGatherOffset(_Texture< + T, __Shape2D, isArray, 0, // isMS @@ -3972,11 +3975,11 @@ public vec4 textureGatherOffset(_Texture< // textureGatherOffsets // ------------------- -__generic +__generic [ForceInline] [require(glsl_hlsl_spirv, texture_gather)] -public vector textureGatherOffsets(_Texture< - vector, +public vector textureGatherOffsets(_Texture< + T, __Shape2D, isArray, 0, // isMS diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index d620197f3..9d6a81f84 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -10,6 +10,7 @@ void __requireGLSLExtension(String extensionName); /// Represents an interface for buffer data layout. /// This interface is used as a base for defining specific data layouts for buffers. [sealed] +[builtin] __magic_type(IBufferDataLayoutType) interface IBufferDataLayout { @@ -512,6 +513,86 @@ __intrinsic_op(makeVector) __generic vector __makeVector(vector vec, T scalar); +//@public: +/// Represent types that can be used as texel element. +[sealed] +[builtin] +interface ITexelElement +{ + associatedtype Element : __BuiltinArithmeticType; + static const int elementCount; + __init(Element x); +} + +${{{ +// Scalar types that can be used as texel element. +const char* texeElementScalarTypes[] = { + "half", + "float", + "int", + "uint", + "int8_t", + "int16_t", + "uint8_t", + "uint16_t" +}; +for (auto elementType : texeElementScalarTypes) +{ +}}} +extension $(elementType) : ITexelElement +{ + typealias Element = $(elementType); + static const int elementCount = 1; + __intrinsic_op(0) __init(Element x); +} +extension vector<$(elementType), N> : ITexelElement +{ + typealias Element = $(elementType); + static const int elementCount = N; + __intrinsic_op($(kIROp_MakeVectorFromScalar)) __init(Element x); +} +${{{ +} // end for texelElementScalarTypes. +}}} + +// Additional 64-bit types that can be used as texel element. +extension double:ITexelElement +{ + typealias Element = double; + static const int elementCount = 1; + __intrinsic_op(0) __init(Element x); +} +extension double2:ITexelElement +{ + typealias Element = double; + static const int elementCount = 2; + __intrinsic_op($(kIROp_MakeVectorFromScalar)) __init(Element x); +} +extension uint64_t:ITexelElement +{ + typealias Element = uint64_t; + static const int elementCount = 1; + __intrinsic_op(0) __init(Element x); +} +extension int64_t:ITexelElement +{ + typealias Element = int64_t; + static const int elementCount = 1; + __intrinsic_op(0) __init(Element x); +} +extension vector:ITexelElement +{ + typealias Element = uint64_t; + static const int elementCount = 2; + __intrinsic_op($(kIROp_MakeVectorFromScalar)) __init(Element x); +} +extension vector:ITexelElement +{ + typealias Element = int64_t; + static const int elementCount = 2; + __intrinsic_op($(kIROp_MakeVectorFromScalar)) __init(Element x); +} + //@public: /// A parameterized type that represents all flavors of texture types supported by the Slang language. /// Please note that this type is not intended to be used directly in user code, and not all combinations @@ -591,7 +672,7 @@ vector __makeVector(vector vec, T scalar); /// @category texture_types Texture types __magic_type(TextureType) __intrinsic_type($(kIROp_TextureType)) -struct _Texture +struct _Texture { } @@ -776,7 +857,7 @@ float __glsl_texture_level_offset_1d_shadow(TTexture //@public: -__generic +__generic extension _Texture { //@hidden: @@ -1498,7 +1579,7 @@ extension _Texture // Non-combined texture types specific functions -__generic +__generic extension _Texture { typealias TextureCoord = vector; @@ -1596,7 +1677,7 @@ extension _Texture } } -__generic +__generic extension _Texture { [__readNone] @@ -2720,7 +2801,7 @@ for (int isMS = 0; isMS <= 1; isMS++) { TextureTypeInfo textureTypeInfo(kBaseTextureShapes[shapeIndex], isArray, isMS, 0, sb, path); }}}} -__generic +__generic extension _Texture { ${{{{ @@ -2733,7 +2814,7 @@ ${{{{ }}}} // Texture.GetSamplePosition(int s); -__generic +__generic extension _Texture { [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_vertex_fragment_geometry)] @@ -2745,10 +2826,10 @@ Array __makeArray(T v0, T v1, T v2, T v3); // Beginning of Texture Gather -__generic +__generic [ForceInline] [require(glsl_metal_spirv_wgsl, texture_gather)] -vector __texture_gather( +vector __texture_gather( _Texture texture, SamplerState s, vector location, @@ -2781,7 +2862,7 @@ vector __texture_gather( case spirv: return spirv_asm { %sampledImage : __sampledImageType(texture) = OpSampledImage $texture $s; - result:$$vector = OpImageGather %sampledImage $location $component; + result:$$vector = OpImageGather %sampledImage $location $component; }; case wgsl: if (isShadow == 1) @@ -2814,10 +2895,10 @@ vector __texture_gather( } } -__generic +__generic [ForceInline] [require(glsl_spirv, texture_gather)] -vector __texture_gather( +vector __texture_gather( _Texture sampler, vector location, int component) @@ -2828,15 +2909,15 @@ vector __texture_gather( __intrinsic_asm "textureGather($0, $1, $2)"; case spirv: return spirv_asm { - result:$$vector = OpImageGather $sampler $location $component; + result:$$vector = OpImageGather $sampler $location $component; }; } } -__generic +__generic [ForceInline] [require(glsl_metal_spirv_wgsl, texture_gather)] -vector __texture_gather_offset( +vector __texture_gather_offset( _Texture texture, SamplerState s, vector location, @@ -2862,7 +2943,7 @@ vector __texture_gather_offset( return spirv_asm { OpCapability ImageGatherExtended; %sampledImage : __sampledImageType(texture) = OpSampledImage $texture $s; - result:$$vector = OpImageGather %sampledImage $location $component Offset $offset; + result:$$vector = OpImageGather %sampledImage $location $component Offset $offset; }; case wgsl: if (isShadow == 1) @@ -2895,10 +2976,10 @@ vector __texture_gather_offset( } } -__generic +__generic [ForceInline] [require(glsl_spirv, texture_gather)] -vector __texture_gather_offset( +vector __texture_gather_offset( _Texture sampler, vector location, constexpr vector offset, @@ -2911,15 +2992,15 @@ vector __texture_gather_offset( case spirv: return spirv_asm { OpCapability ImageGatherExtended; - result:$$vector = OpImageGather $sampler $location $component Offset $offset; + result:$$vector = OpImageGather $sampler $location $component Offset $offset; }; } } -__generic +__generic [ForceInline] [require(glsl_spirv, texture_gather)] -vector __texture_gather_offsets( +vector __texture_gather_offsets( _Texture texture, SamplerState s, vector location, @@ -2938,15 +3019,15 @@ vector __texture_gather_offsets( return spirv_asm { OpCapability ImageGatherExtended; %sampledImage : __sampledImageType(texture) = OpSampledImage $texture $s; - result:$$vector = OpImageGather %sampledImage $location $component ConstOffsets $offsets; + result:$$vector = OpImageGather %sampledImage $location $component ConstOffsets $offsets; }; } } -__generic +__generic [ForceInline] [require(glsl_spirv, texture_gather)] -vector __texture_gather_offsets( +vector __texture_gather_offsets( _Texture sampler, vector location, constexpr vector offset1, @@ -2963,19 +3044,19 @@ vector __texture_gather_offsets( let offsets = __makeArray(offset1,offset2,offset3,offset4); return spirv_asm { OpCapability ImageGatherExtended; - result:$$vector = OpImageGather $sampler $location $component ConstOffsets $offsets; + result:$$vector = OpImageGather $sampler $location $component ConstOffsets $offsets; }; } } -__generic +__generic [ForceInline] [require(glsl_metal_spirv_wgsl, texture_gather)] -vector __texture_gatherCmp( +vector __texture_gatherCmp( _Texture texture, SamplerComparisonState s, vector location, - TElement compareValue) + T.Element compareValue) { __target_switch { @@ -2999,7 +3080,7 @@ vector __texture_gatherCmp( case spirv: return spirv_asm { %sampledImage : __sampledImageType(texture) = OpSampledImage $texture $s; - result:$$vector = OpImageDrefGather %sampledImage $location $compareValue; + result:$$vector = OpImageDrefGather %sampledImage $location $compareValue; }; case wgsl: static_assert(isShadow == 1, "WGSL supports textureGatherCompare only for depth textures."); @@ -3018,13 +3099,13 @@ vector __texture_gatherCmp( } } -__generic +__generic [ForceInline] [require(glsl_spirv, texture_gather)] -vector __texture_gatherCmp( +vector __texture_gatherCmp( _Texture sampler, vector location, - TElement compareValue) + T.Element compareValue) { __target_switch { @@ -3032,19 +3113,19 @@ vector __texture_gatherCmp( __intrinsic_asm "textureGather($0, $1, $2)"; case spirv: return spirv_asm { - result:$$vector = OpImageDrefGather $sampler $location $compareValue; + result:$$vector = OpImageDrefGather $sampler $location $compareValue; }; } } -__generic +__generic [ForceInline] [require(glsl_metal_spirv_wgsl, texture_gather)] -vector __texture_gatherCmp_offset( +vector __texture_gatherCmp_offset( _Texture texture, SamplerComparisonState s, vector location, - TElement compareValue, + T.Element compareValue, constexpr vector offset) { __target_switch @@ -3065,7 +3146,7 @@ vector __texture_gatherCmp_offset( case spirv: return spirv_asm { %sampledImage : __sampledImageType(texture) = OpSampledImage $texture $s; - result:$$vector = OpImageDrefGather %sampledImage $location $compareValue ConstOffset $offset; + result:$$vector = OpImageDrefGather %sampledImage $location $compareValue ConstOffset $offset; }; case wgsl: static_assert(isShadow == 1, "WGSL supports textureGatherCompare only for depth textures."); @@ -3084,13 +3165,13 @@ vector __texture_gatherCmp_offset( } } -__generic +__generic [ForceInline] [require(glsl_spirv, texture_gather)] -vector __texture_gatherCmp_offset( +vector __texture_gatherCmp_offset( _Texture sampler, vector location, - TElement compareValue, + T.Element compareValue, constexpr vector offset) { __target_switch @@ -3099,19 +3180,19 @@ vector __texture_gatherCmp_offset( __intrinsic_asm "textureGatherOffset($0, $1, $2, $3)"; case spirv: return spirv_asm { - result:$$vector = OpImageDrefGather $sampler $location $compareValue ConstOffset $offset; + result:$$vector = OpImageDrefGather $sampler $location $compareValue ConstOffset $offset; }; } } -__generic +__generic [ForceInline] [require(glsl_spirv, texture_gather)] -vector __texture_gatherCmp_offsets( +vector __texture_gatherCmp_offsets( _Texture texture, SamplerComparisonState s, vector location, - TElement compareValue, + T.Element compareValue, vector offset1, vector offset2, vector offset3, @@ -3126,18 +3207,18 @@ vector __texture_gatherCmp_offsets( return spirv_asm { OpCapability ImageGatherExtended; %sampledImage : __sampledImageType(texture) = OpSampledImage $texture $s; - result:$$vector = OpImageDrefGather %sampledImage $location $compareValue ConstOffsets $offsets; + result:$$vector = OpImageDrefGather %sampledImage $location $compareValue ConstOffsets $offsets; }; } } -__generic +__generic [ForceInline] [require(glsl_spirv, texture_gather)] -vector __texture_gatherCmp_offsets( +vector __texture_gatherCmp_offsets( _Texture sampler, vector location, - TElement compareValue, + T.Element compareValue, vector offset1, vector offset2, vector offset3, @@ -3151,30 +3232,26 @@ vector __texture_gatherCmp_offsets( let offsets = __makeArray(offset1,offset2,offset3,offset4); return spirv_asm { OpCapability ImageGatherExtended; - result:$$vector = OpImageDrefGather $sampler $location $compareValue ConstOffsets $offsets; + result:$$vector = OpImageDrefGather $sampler $location $compareValue ConstOffsets $offsets; }; } } ${{{{ for (int isCombined = 0; isCombined < 2; isCombined++) -for (int isScalarTexture = 0; isScalarTexture < 2; isScalarTexture++) { - const char* extSizeParam = isScalarTexture ? "" : ", let N:int"; - const char* extTexType = isScalarTexture ? "T" : "vector"; - }}}} -// Gather for [TextureType = $(extTexType), isCombined = $(isCombined)] +// Gather for [isCombined = $(isCombined)] -__generic -extension _Texture<$(extTexType),Shape,isArray,0,sampleCount,0,isShadow,$(isCombined),format> +__generic +extension _Texture { ${{{{ for (int isShadow = 0; isShadow < 2; isShadow++) for (auto componentId = 0; componentId < 5; componentId++) { const char* compareFunc = isShadow ? "Cmp" : ""; - const char* compareParam = isShadow ? ", T compareValue" : ""; + const char* compareParam = isShadow ? ", T.Element compareValue" : ""; const char* compareArg = isShadow ? ", compareValue" : ""; // Some targets support the combined texture natively @@ -3190,7 +3267,7 @@ ${{{{ }}}} [ForceInline] [require(glsl_hlsl_metal_spirv_wgsl, texture_gather)] - vector Gather$(compareFunc)$(componentFunc)( + vector Gather$(compareFunc)$(componentFunc)( $(samplerParam) vector location $(compareParam)) @@ -3203,16 +3280,16 @@ ${{{{ case hlsl: __intrinsic_asm ".Gather$(compareFunc)$(componentFunc)"; case metal: case wgsl: - return __texture_gather$(compareFunc)($(getTexture) $(getSampler), location $(compareArg) $(componentArg)); + return __texture_gather$(compareFunc)($(getTexture) $(getSampler), location $(compareArg) $(componentArg)); case glsl: case spirv: - return __texture_gather$(compareFunc)(this $(samplerArg), location $(compareArg) $(componentArg)); + return __texture_gather$(compareFunc)(this $(samplerArg), location $(compareArg) $(componentArg)); } } [ForceInline] [require(hlsl, texture_gather)] - vector Gather$(compareFunc)$(componentFunc)( + vector Gather$(compareFunc)$(componentFunc)( $(samplerParam) vector location $(compareParam), @@ -3229,7 +3306,7 @@ ${{{{ [ForceInline] [require(glsl_hlsl_metal_spirv_wgsl, texture_gather)] - vector Gather$(compareFunc)$(componentFunc)( + vector Gather$(compareFunc)$(componentFunc)( $(samplerParam) vector location $(compareParam), @@ -3243,16 +3320,16 @@ ${{{{ case hlsl: __intrinsic_asm ".Gather$(compareFunc)$(componentFunc)"; case metal: case wgsl: - return __texture_gather$(compareFunc)_offset($(getTexture) $(getSampler), location $(compareArg), offset $(componentArg)); + return __texture_gather$(compareFunc)_offset($(getTexture) $(getSampler), location $(compareArg), offset $(componentArg)); case glsl: case spirv: - return __texture_gather$(compareFunc)_offset(this $(samplerArg), location $(compareArg), offset $(componentArg)); + return __texture_gather$(compareFunc)_offset(this $(samplerArg), location $(compareArg), offset $(componentArg)); } } [ForceInline] [require(hlsl, texture_gather)] - vector Gather$(compareFunc)$(componentFunc)( + vector Gather$(compareFunc)$(componentFunc)( $(samplerParam) vector location $(compareParam), @@ -3270,7 +3347,7 @@ ${{{{ [ForceInline] [require(glsl_hlsl_spirv, texture_gather)] - vector Gather$(compareFunc)$(componentFunc)( + vector Gather$(compareFunc)$(componentFunc)( $(samplerParam) vector location $(compareParam), @@ -3293,7 +3370,7 @@ ${{{{ [ForceInline] [require(hlsl, texture_gather)] - vector Gather$(compareFunc)$(componentFunc)( + vector Gather$(compareFunc)$(componentFunc)( $(samplerParam) vector location $(compareParam), @@ -3315,7 +3392,7 @@ ${{{{ ${{{{ } // for (componentId) }}}} -} // End of: Gather for [TextureType = $(extTexType), isCombined = $(isCombined)] +} // End of: Gather for [isCombined = $(isCombined)] ${{{{ } // for (isScalarTexture) @@ -3325,7 +3402,7 @@ ${{{{ // Load/Subscript for readonly, no MS textures -__generic +__generic extension _Texture { //@hidden: @@ -3453,7 +3530,7 @@ extension _Texture case $(SLANG_TEXTURE_3D): __intrinsic_asm "textureLoad($0, ($1).xyz, ($1).w)$z"; } - return T(); + return __default(); } } @@ -3555,7 +3632,7 @@ extension _Texture // Texture Load/Subscript for readonly, MS textures -__generic +__generic extension _Texture { //@hidden: @@ -3746,7 +3823,7 @@ ${{{{ const char* glslIntrinsicMSOffset = "$cimageLoad($0, ($1)+($3), $2)$z"; }}}} -__generic +__generic extension _Texture { ${{{{ @@ -4081,7 +4158,7 @@ if (access == kCoreModule_ResourceAccessReadWrite) { // RW MS textures. -__generic +__generic extension _Texture { [__readNone] @@ -4234,7 +4311,7 @@ ${{{{ }}}} // Definitions to support the legacy texture .mips[][] operator. -struct __TextureMip +struct __TextureMip { _Texture tex; int mip; @@ -4245,7 +4322,7 @@ struct __TextureMip +struct __TextureMips { _Texture tex; __subscript(int mip)->__TextureMip @@ -4256,7 +4333,7 @@ struct __TextureMips +__generic extension _Texture { property __TextureMips mips @@ -4267,7 +4344,7 @@ extension _Texture +struct __TextureSample { _Texture tex; int sample; @@ -4278,7 +4355,7 @@ struct __TextureSample +struct __TextureSampleMS { _Texture tex; __subscript(int sample)->__TextureSample @@ -4288,7 +4365,7 @@ struct __TextureSampleMS +__generic extension _Texture { property __TextureSampleMS sample @@ -4345,7 +4422,7 @@ ${{{{ /// @param format The storage format of the texture. /// @see Please refer to `_Texture` for more information about texture types. /// @category texture_types -typealias $(accessPrefix[access])$(textureTypeName)$(shapeTypeNames[shape])$(msPostFix[isMS])$(arrayPostFix[isArray]) = _Texture; +typealias $(accessPrefix[access])$(textureTypeName)$(shapeTypeNames[shape])$(msPostFix[isMS])$(arrayPostFix[isArray]) = _Texture; ${{{{ } }}}} @@ -15633,7 +15710,7 @@ for (int aa = 0; aa < kBaseBufferAccessLevelCount; ++aa) { auto access = kBaseBufferAccessLevels[aa].access; sb << "/// @category texture_types\n"; - sb << "__generic\n"; + sb << "__generic\n"; sb << "typealias "; sb << kBaseBufferAccessLevels[aa].name; sb << "Buffer = _Texture;\n"; @@ -15648,7 +15725,7 @@ for (int aa = 0; aa < kBaseBufferAccessLevelCount; ++aa) char const* requireToSet_onlyHLSL = (isReadOnly) ? "[require(hlsl, texture_sm_4_1)]" : "[require(hlsl, texture_sm_4_1_compute_fragment)]"; }}}} -__generic +__generic extension _Texture { [__readNone] @@ -16920,23 +16997,33 @@ interface __BuiltinSamplerFeedbackType {}; [sealed] __magic_type(FeedbackType, $(int(FeedbackType::Kind::MinMip))) __target_intrinsic(hlsl, SAMPLER_FEEDBACK_MIN_MIP) -struct SAMPLER_FEEDBACK_MIN_MIP : __BuiltinSamplerFeedbackType {}; +struct SAMPLER_FEEDBACK_MIN_MIP : __BuiltinSamplerFeedbackType, ITexelElement { + typealias Element = float; + static const int elementCount = 1; + __intrinsic_op(0) __init(float x){} +}; /// @category texture_types [sealed] __magic_type(FeedbackType, $(int(FeedbackType::Kind::MipRegionUsed))) __target_intrinsic(hlsl, SAMPLER_FEEDBACK_MIP_REGION_USED) -struct SAMPLER_FEEDBACK_MIP_REGION_USED : __BuiltinSamplerFeedbackType {}; +struct SAMPLER_FEEDBACK_MIP_REGION_USED : __BuiltinSamplerFeedbackType, ITexelElement +{ + typealias Element = float; + static const int elementCount = 1; + __intrinsic_op(0) __init(float x){} +}; // All of these objects are write-only resources that point to a special kind of unordered access view meant for sampler feedback. -__generic -extension _Texture +extension _Texture + where T:ITexelElement + where T:__BuiltinSamplerFeedbackType { // With Clamp [require(cpp_hlsl)] - void WriteSamplerFeedback(Texture2D tex, SamplerState samp, float2 location, float clamp) + void WriteSamplerFeedback(Texture2D tex, SamplerState samp, float2 location, float clamp) { __target_switch { @@ -16946,7 +17033,7 @@ extension _Texture(Texture2D tex, SamplerState samp, float2 location, float bias, float clamp) + void WriteSamplerFeedbackBias(Texture2D tex, SamplerState samp, float2 location, float bias, float clamp) { __target_switch { @@ -16956,7 +17043,7 @@ extension _Texture(Texture2D tex, SamplerState samp, float2 location, float2 ddx, float2 ddy, float clamp) + void WriteSamplerFeedbackGrad(Texture2D tex, SamplerState samp, float2 location, float2 ddx, float2 ddy, float clamp) { __target_switch { @@ -16968,7 +17055,7 @@ extension _Texture(Texture2D tex, SamplerState samp, float2 location, float lod) + void WriteSamplerFeedbackLevel(Texture2D tex, SamplerState samp, float2 location, float lod) { __target_switch { @@ -16980,7 +17067,7 @@ extension _Texture(Texture2D tex, SamplerState samp, float2 location) + void WriteSamplerFeedback(Texture2D tex, SamplerState samp, float2 location) { __target_switch { @@ -16990,7 +17077,7 @@ extension _Texture(Texture2D tex, SamplerState samp, float2 location, float bias) + void WriteSamplerFeedbackBias(Texture2D tex, SamplerState samp, float2 location, float bias) { __target_switch { @@ -17000,7 +17087,7 @@ extension _Texture(Texture2D tex, SamplerState samp, float2 location, float2 ddx, float2 ddy) + void WriteSamplerFeedbackGrad(Texture2D tex, SamplerState samp, float2 location, float2 ddx, float2 ddy) { __target_switch { @@ -17010,13 +17097,14 @@ extension _Texture -extension _Texture +extension _Texture + where T:__BuiltinSamplerFeedbackType + where T:ITexelElement { // With Clamp [require(cpp_hlsl)] - void WriteSamplerFeedback(Texture2DArray texArray, SamplerState samp, float3 location, float clamp) + void WriteSamplerFeedback(Texture2DArray texArray, SamplerState samp, float3 location, float clamp) { __target_switch { @@ -17026,7 +17114,7 @@ extension _Texture(Texture2DArray texArray, SamplerState samp, float3 location, float bias, float clamp) + void WriteSamplerFeedbackBias(Texture2DArray texArray, SamplerState samp, float3 location, float bias, float clamp) { __target_switch { @@ -17036,7 +17124,7 @@ extension _Texture(Texture2DArray texArray, SamplerState samp, float3 location, float3 ddx, float3 ddy, float clamp) + void WriteSamplerFeedbackGrad(Texture2DArray texArray, SamplerState samp, float3 location, float3 ddx, float3 ddy, float clamp) { __target_switch { @@ -17048,7 +17136,7 @@ extension _Texture(Texture2DArray texArray, SamplerState samp, float3 location, float lod) + void WriteSamplerFeedbackLevel(Texture2DArray texArray, SamplerState samp, float3 location, float lod) { __target_switch { @@ -17060,7 +17148,7 @@ extension _Texture(Texture2DArray texArray, SamplerState samp, float3 location) + void WriteSamplerFeedback(Texture2DArray texArray, SamplerState samp, float3 location) { __target_switch { @@ -17070,7 +17158,7 @@ extension _Texture(Texture2DArray texArray, SamplerState samp, float3 location, float bias) + void WriteSamplerFeedbackBias(Texture2DArray texArray, SamplerState samp, float3 location, float bias) { __target_switch { @@ -17080,7 +17168,7 @@ extension _Texture(Texture2DArray texArray, SamplerState samp, float3 location, float3 ddx, float3 ddy) + void WriteSamplerFeedbackGrad(Texture2DArray texArray, SamplerState samp, float3 location, float3 ddx, float3 ddy) { __target_switch { @@ -20025,10 +20113,10 @@ ${ // for any resource type. } -__intrinsic_op($(kIROp_GetRegisterSpace)) uint __getRegisterSpace(_Texture texture); +__intrinsic_op($(kIROp_GetRegisterSpace)) uint __getRegisterSpace(_Texture texture); __intrinsic_op($(kIROp_GetRegisterSpace)) uint __getRegisterSpace(SamplerState sampler); -__intrinsic_op($(kIROp_GetRegisterIndex)) uint __getRegisterIndex(_Texture texture); +__intrinsic_op($(kIROp_GetRegisterIndex)) uint __getRegisterIndex(_Texture texture); __intrinsic_op($(kIROp_GetRegisterIndex)) uint __getRegisterIndex(SamplerState sampler); //@public: @@ -20218,7 +20306,7 @@ ${ // further clutter the original type declarations. } -__generic +__generic extension _Texture { ${ @@ -21035,7 +21123,7 @@ enum __DynamicResourceKind Sampler = 1 } -__generic +__generic extension _Texture : __IDynamicResourceCastable<__DynamicResourceKind.General> { __intrinsic_op($(kIROp_CastDynamicResource)) diff --git a/source/slang/slang-check-inheritance.cpp b/source/slang/slang-check-inheritance.cpp index f774aae38..7af2d2e81 100644 --- a/source/slang/slang-check-inheritance.cpp +++ b/source/slang/slang-check-inheritance.cpp @@ -1149,6 +1149,10 @@ InheritanceInfo SharedSemanticsContext::_calcInheritanceInfo( info.facets = FacetList(directFacet); return info; } + else if (auto modifiedType = as(type)) + { + return _calcInheritanceInfo(modifiedType->getBase(), circularityInfo); + } else { // As a fallback, any type not covered by the above cases will diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index b0d1fbb4c..13a85e8ab 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -614,7 +614,10 @@ void CPPSourceEmitter::emitGlobalRTTISymbolPrefix() void CPPSourceEmitter::emitWitnessTable(IRWitnessTable* witnessTable) { - auto interfaceType = cast(witnessTable->getConformanceType()); + auto interfaceType = as(witnessTable->getConformanceType()); + + if (!interfaceType) + return; // Ignore witness tables for builtin interface types. if (isBuiltin(interfaceType)) diff --git a/source/slang/slang-ir-peephole.cpp b/source/slang/slang-ir-peephole.cpp index 0a08c67ff..ced0b5eb0 100644 --- a/source/slang/slang-ir-peephole.cpp +++ b/source/slang/slang-ir-peephole.cpp @@ -829,6 +829,8 @@ struct PeepholeContext : InstPassBase case kIROp_VectorReshape: { auto fromType = as(inst->getOperand(0)->getDataType()); + if (!fromType) + break; auto resultType = as(inst->getDataType()); if (!resultType) { -- cgit v1.2.3