summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/glsl.meta.slang1877
-rw-r--r--source/slang/hlsl.meta.slang310
-rw-r--r--source/slang/slang-stdlib-textures.cpp7
3 files changed, 1983 insertions, 211 deletions
diff --git a/source/slang/glsl.meta.slang b/source/slang/glsl.meta.slang
index 3cab1232e..4fe56acf8 100644
--- a/source/slang/glsl.meta.slang
+++ b/source/slang/glsl.meta.slang
@@ -78,6 +78,185 @@ public typealias dmat4x2 = matrix<double, 2, 4>;
public typealias dmat4x3 = matrix<double, 3, 4>;
public typealias dmat4x4 = matrix<double, 4, 4>;
+
+public out float4 gl_Position : SV_Position;
+public out float gl_PointSize : SV_PointSize;
+public in vec4 gl_FragCoord : SV_Position;
+public out float gl_FragDepth : SV_Depth;
+public out int gl_FragStencilRef : SV_StencilRef;
+
+public in uvec3 gl_GlobalInvocationID : SV_DispatchThreadID;
+public in uvec3 gl_WorkGroupID : SV_GroupID;
+public in uvec3 gl_LocalInvocationIndex : SV_GroupIndex;
+public in uvec3 gl_LocalInvocationID : SV_GroupThreadID;
+
+// TODO: define overload for tessellation control stage.
+public in int gl_InvocationID : SV_GSInstanceID;
+
+public in int gl_InstanceIndex : SV_InstanceID;
+public in bool gl_FrontFacing : SV_IsFrontFace;
+
+// TODO: define overload for geometry stage.
+public in int gl_Layer : SV_RenderTargetArrayIndex;
+
+public in int gl_SampleID : SV_SampleIndex;
+public in int gl_VertexIndex : SV_VertexID;
+public in int gl_ViewIndex : SV_ViewID;
+public in int gl_ViewportIndex : SV_ViewportArrayIndex;
+
+
+// Override operator* behavior to compute algebric product of matrices and vectors.
+
+[OverloadRank(15)]
+[ForceInline]
+public matrix<float, N, N> operator*<let N : int>(matrix<float, N, N> m1, matrix<float, N, N> m2)
+{
+ return mul(m2, m1);
+}
+
+[OverloadRank(15)]
+[ForceInline]
+public matrix<half, N, N> operator*<let N : int>(matrix<half, N, N> m1, matrix<half, N, N> m2)
+{
+ return mul(m2, m1);
+}
+
+[OverloadRank(15)]
+[ForceInline]
+public matrix<double, N, N> operator*<let N : int>(matrix<double, N, N> m1, matrix<double, N, N> m2)
+{
+ return mul(m2, m1);
+}
+
+[ForceInline]
+[OverloadRank(15)]
+public matrix<T, R, L> operator*<T:__BuiltinFloatingPointType, let L : int, let C : int, let R : int>(matrix<T, C, L> m1, matrix<T, R, C> m2)
+{
+ return mul(m2, m1);
+}
+
+[ForceInline]
+[OverloadRank(15)]
+public vector<T, R> operator*<T:__BuiltinFloatingPointType, let C : int, let R : int>(vector<T, C> v, matrix<T, R, C> m)
+{
+ return mul(m, v);
+}
+
+[ForceInline]
+[OverloadRank(15)]
+public vector<T, C> operator*<T:__BuiltinFloatingPointType, let C : int, let R : int>(matrix<T, R, C> m, vector<T, R> v)
+{
+ return mul(v, m);
+}
+
+__intrinsic_op(mul)
+public matrix<T, N, M> matrixCompMult<T:__BuiltinFloatingPointType, let N : int, let M : int>(matrix<T,N,M> left, matrix<T,N,M> right);
+
+__intrinsic_op(cmpLE)
+public vector<bool, N> lessThanEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
+__intrinsic_op(cmpLT)
+public vector<bool, N> lessThan<T, let N:int>(vector<T, N> x, vector<T, N> y);
+__intrinsic_op(cmpGT)
+public vector<bool, N> greaterThan<T, let N:int>(vector<T, N> x, vector<T, N> y);
+__intrinsic_op(cmpGE)
+public vector<bool, N> greaterThanEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
+__intrinsic_op(cmpEQ)
+public vector<bool, N> equal<T, let N:int>(vector<T, N> x, vector<T, N> y);
+__intrinsic_op(cmpNE)
+public vector<bool, N> notEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
+
+__generic<T>
+public extension vector<T, 2>
+{
+ [ForceInline] public __init(vector<T, 3> bigger) { this = bigger.xy; }
+ [ForceInline] public __init(vector<T, 4> bigger) { this = bigger.xy; }
+}
+
+__generic<T>
+public extension vector<T, 3>
+{
+ [ForceInline] public __init(vector<T, 4> bigger) { this = bigger.xyz; }
+}
+
+[ForceInline]
+[OverloadRank(15)]
+public bool operator==<T:__BuiltinArithmeticType, let N : int>(vector<T, N> left, vector<T, N> right)
+{
+ return all(equal(left, right));
+}
+
+[ForceInline]
+[OverloadRank(15)]
+public bool operator!=<T:__BuiltinArithmeticType, let N : int>(vector<T, N> left, vector<T, N> right)
+{
+ return any(notEqual(left, right));
+}
+
+[ForceInline]
+[OverloadRank(14)]
+public bool operator==<T:__BuiltinFloatingPointType, let N : int>(vector<T, N> left, vector<T, N> right)
+{
+ return all(equal(left, right));
+}
+
+[ForceInline]
+[OverloadRank(14)]
+public bool operator!=<T:__BuiltinFloatingPointType, let N : int>(vector<T, N> left, vector<T, N> right)
+{
+ return any(notEqual(left, right));
+}
+
+[ForceInline]
+[OverloadRank(14)]
+public bool operator==<T:__BuiltinLogicalType, let N : int>(vector<T, N> left, vector<T, N> right)
+{
+ return all(equal(left, right));
+}
+
+[ForceInline]
+[OverloadRank(14)]
+public bool operator!=<T:__BuiltinLogicalType, let N : int>(vector<T, N> left, vector<T, N> right)
+{
+ return any(notEqual(left, right));
+}
+
+${{{{
+for (auto type : kBaseTypes) {
+ char const* typeName = type.name;
+ if (!type.flags) continue;
+}}}}
+[ForceInline]
+[OverloadRank(15)]
+public bool operator==<let N : int>(vector<$(typeName), N> left, vector<$(typeName), N> right)
+{
+ return all(equal(left, right));
+}
+
+[ForceInline]
+[OverloadRank(15)]
+public bool operator!=<let N : int>(vector<$(typeName), N> left, vector<$(typeName), N> right)
+{
+ return any(notEqual(left, right));
+}
+${{{{
+}
+}}}}
+
+[ForceInline] public int findLSB(int v) { return firstbitlow(v); }
+[ForceInline] public uint findLSB(uint v) { return firstbitlow(v); }
+[ForceInline] public vector<int,N> findLSB<let N:int>(vector<int,N> value)
+{
+ return firstbitlow(value);
+}
+[ForceInline] public vector<uint,N> findLSB<let N:int>(vector<uint,N> value)
+{
+ return firstbitlow(value);
+}
+
+//
+// Section 8.9.1. Texture Query Functions
+//
+
public typealias usampler1D = Sampler1D<uint4>;
public typealias isampler1D = Sampler1D<int4>;
public typealias sampler1D = Sampler1D<float4>;
@@ -94,20 +273,44 @@ public typealias usamplerCube = SamplerCube<uint4>;
public typealias isamplerCube = SamplerCube<int4>;
public typealias samplerCube = SamplerCube<float4>;
-public typealias Sampler1DShadow<T=float> = __TextureImpl<T, __Shape1D, /*isArray:*/ 0, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-public typealias usampler1DShadow = Sampler1DShadow<uint>;
-public typealias isampler1DShadow = Sampler1DShadow<int>;
-public typealias sampler1DShadow = Sampler1DShadow<float>;
-
-public typealias Sampler2DShadow<T=float> = __TextureImpl<T, __Shape2D, /*isArray:*/ 0, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-public typealias usampler2DShadow = Sampler2DShadow<uint>;
-public typealias isampler2DShadow = Sampler2DShadow<int>;
-public typealias sampler2DShadow = Sampler2DShadow<float>;
-
-public typealias SamplerCubeShadow<T=float> = __TextureImpl<T, __ShapeCube, /*isArray:*/ 0, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-public typealias usamplerCubeShadow = SamplerCubeShadow<uint>;
-public typealias isamplerCubeShadow = SamplerCubeShadow<int>;
-public typealias samplerCubeShadow = SamplerCubeShadow<float>;
+__generic<let sampleCount:int=0, let format:int=0>
+public typealias sampler1DShadow = __TextureImpl<
+ float,
+ __Shape1D,
+ 0, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+>;
+
+__generic<let sampleCount:int=0, let format:int=0>
+public typealias sampler2DShadow = __TextureImpl<
+ float,
+ __Shape2D,
+ 0, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+>;
+
+__generic<let sampleCount:int=0, let format:int=0>
+public typealias samplerCubeShadow = __TextureImpl<
+ float,
+ __ShapeCube,
+ 0, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+>;
public typealias usampler1DArray = Sampler1DArray<uint4>;
public typealias isampler1DArray = Sampler1DArray<int4>;
@@ -121,299 +324,1665 @@ public typealias usamplerCubeArray = SamplerCubeArray<uint4>;
public typealias isamplerCubeArray = SamplerCubeArray<int4>;
public typealias samplerCubeArray = SamplerCubeArray<float4>;
-public typealias Sampler1DArrayShadow<T=float> = __TextureImpl<T, __Shape1D, /*isArray:*/ 1, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-public typealias usampler1DArrayShadow = Sampler1DArrayShadow<uint>;
-public typealias isampler1DArrayShadow = Sampler1DArrayShadow<int>;
-public typealias sampler1DArrayShadow = Sampler1DArrayShadow<float>;
+__generic<let sampleCount:int=0, let format:int=0>
+public typealias sampler1DArrayShadow = __TextureImpl<
+ float,
+ __Shape1D,
+ 1, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+>;
+
+__generic<let sampleCount:int=0, let format:int=0>
+public typealias sampler2DArrayShadow = __TextureImpl<
+ float,
+ __Shape2D,
+ 1, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+>;
+
+__generic<let sampleCount:int=0, let format:int=0>
+public typealias samplerCubeArrayShadow = __TextureImpl<
+ float,
+ __ShapeCube,
+ 1, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+>;
+
+public typealias sampler2DMS = Sampler2DMS<float4>;
+public typealias isampler2DMS = Sampler2DMS<int4>;
+public typealias usampler2DMS = Sampler2DMS<uint4>;
+
+__generic<T=float4, let sampleCount:int=0, let format:int=0>
+public typealias Sampler2DMSArray = Sampler2DArrayMS<T, sampleCount, format>;
+public typealias sampler2DMSArray = Sampler2DMSArray<float4>;
+public typealias isampler2DMSArray = Sampler2DMSArray<int4>;
+public typealias usampler2DMSArray = Sampler2DMSArray<uint4>;
+
+__generic<T=float4, let sampleCount:int=0, let format:int=0>
+public typealias Sampler2DRect = __TextureImpl<T, __Shape2D, 0, 0, sampleCount, 0, 0, 1, format>;
+public typealias sampler2DRect = Sampler2DRect<float4>;
+public typealias isampler2DRect = Sampler2DRect<int4>;
+public typealias usampler2DRect = Sampler2DRect<uint4>;
+
+__generic<let sampleCount:int=0, let format:int=0>
+public typealias sampler2DRectShadow = __TextureImpl<
+ float,
+ __Shape2D,
+ 0, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+>;
+
+__generic<T, let format:int=0>
+public typealias SamplerBuffer = __TextureImpl<
+ T,
+ __ShapeBuffer,
+ 0, // isArray
+ 0, // isMS
+ 0, // sampleCount
+ 1, // RW
+ 0, // isShadow
+ 0, // isCombined
+ format
+>;
+public typealias samplerBuffer = SamplerBuffer<vec4>;
+public typealias isamplerBuffer = SamplerBuffer<int4>;
+public typealias usamplerBuffer = SamplerBuffer<uint4>;
+
+
+// -------------------
+// textureSize
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public int textureSize(Sampler1D<vector<T,N>> sampler, int lod)
+{
+ int result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result, numberOfLevels);
+ return result;
+}
-public typealias Sampler2DArrayShadow<T=float> = __TextureImpl<T, __Shape2D, /*isArray:*/ 1, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-public typealias usampler2DArrayShadow = Sampler2DArrayShadow<uint>;
-public typealias isampler2DArrayShadow = Sampler2DArrayShadow<int>;
-public typealias sampler2DArrayShadow = Sampler2DArrayShadow<float>;
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public ivec2 textureSize(Sampler2D<vector<T,N>> sampler, int lod)
+{
+ vector<int,2> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, numberOfLevels);
+ return result;
+}
-public typealias SamplerCubeArrayShadow<T=float> = __TextureImpl<T, __ShapeCube, /*isArray:*/ 1, /*isMS:*/ 0, /*sampleCount:*/ 0, /*access:*/ 0, /*isShadow: */ 1, /*isCombined: */ 1, /*format*/ 0>;
-public typealias usamplerCubeArrayShadow = SamplerCubeArrayShadow<uint>;
-public typealias isamplerCubeArrayShadow = SamplerCubeArrayShadow<int>;
-public typealias samplerCubeArrayShadow = SamplerCubeArrayShadow<float>;
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public ivec3 textureSize(Sampler3D<vector<T,N>> sampler, int lod)
+{
+ vector<int,3> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels);
+ return result;
+}
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler1D<vector<T,N>> sampler, int p, int lod)
+public ivec2 textureSize(SamplerCube<vector<T,N>> sampler, int lod)
{
- return __vectorReshape<4>(sampler.Load(int2(p, lod)));
+ vector<int,2> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, numberOfLevels);
+ return result;
}
[ForceInline]
-public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler2D<vector<T,N>> sampler, ivec2 p, int lod)
+public int textureSize(sampler1DShadow sampler, int lod)
{
- return __vectorReshape<4>(sampler.Load(int3(p, lod)));
+ int result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result, numberOfLevels);
+ return result;
}
[ForceInline]
-public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler3D<vector<T,N>> sampler, ivec3 p, int lod)
+public ivec2 textureSize(sampler2DShadow sampler, int lod)
{
- return __vectorReshape<4>(sampler.Load(int4(p, lod)));
+ vector<int,2> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, numberOfLevels);
+ return result;
}
[ForceInline]
-public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler1DArray<vector<T,N>> sampler, ivec2 p, int lod)
+public ivec2 textureSize(samplerCubeShadow sampler, int lod)
{
- return __vectorReshape<4>(sampler.Load(int3(p, lod)));
+ vector<int,2> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, numberOfLevels);
+ return result;
}
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-public vector<T,4> texelFetch<T:__BuiltinArithmeticType, let N : int> (Sampler2DArray<vector<T,N>> sampler, ivec3 p, int lod)
+public ivec3 textureSize(SamplerCubeArray<vector<T,N>> sampler, int lod)
{
- return __vectorReshape<4>(sampler.Load(int4(p, lod)));
+ vector<int,3> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels);
+ return result;
}
[ForceInline]
-public vector<T,4> texture<T:__BuiltinFloatingPointType, let N : int> (Sampler1D<vector<T,N>> sampler, float p, float bias = 0.0)
+public ivec3 textureSize(samplerCubeArrayShadow sampler, int lod)
{
- return __vectorReshape<4>(sampler.SampleBias(p, bias));
+ vector<int,3> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels);
+ return result;
}
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-public vector<T,4> texture<T:__BuiltinFloatingPointType, let N : int> (Sampler2D<vector<T,N>> sampler, float2 p, float bias = 0.0)
+public ivec2 textureSize(Sampler2DRect<vector<T,N>> sampler)
{
- return __vectorReshape<4>(sampler.SampleBias(p, bias));
+ vector<int,2> result;
+ int numberOfLevels;
+ sampler.GetDimensions(0, result.x, result.y, numberOfLevels);
+ return result;
+}
+
+[ForceInline]
+public ivec2 textureSize(sampler2DRectShadow sampler)
+{
+ vector<int,2> result;
+ int numberOfLevels;
+ sampler.GetDimensions(result.x, result.y);
+ return result;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public ivec2 textureSize(Sampler1DArray<vector<T,N>> sampler, int lod)
+{
+ vector<int,2> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, numberOfLevels);
+ return result;
+}
+
+[ForceInline]
+public ivec2 textureSize(sampler1DArrayShadow sampler, int lod)
+{
+ vector<int,2> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, numberOfLevels);
+ return result;
}
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-public vector<T,4> texture<T:__BuiltinFloatingPointType, let N : int> (Sampler3D<vector<T,N>> sampler, float3 p, float bias = 0.0)
+public ivec3 textureSize(Sampler2DArray<vector<T,N>> sampler, int lod)
+{
+ vector<int,3> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels);
+ return result;
+}
+
+[ForceInline]
+public ivec3 textureSize(sampler2DArrayShadow sampler, int lod)
+{
+ vector<int,3> result;
+ int numberOfLevels;
+ sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels);
+ return result;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, let format:int>
+[ForceInline]
+public int textureSize(SamplerBuffer<vector<T,N>,format> sampler)
+{
+ uint result;
+ sampler.GetDimensions(result);
+ return int(result);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, let sampleCount:int>
+[ForceInline]
+public ivec2 textureSize(Sampler2DMS<vector<T,N>,sampleCount> sampler)
+{
+ vector<int,2> result;
+ int sampleCount;
+ int numberOfLevels;
+ sampler.GetDimensions(result.x, result.y, sampleCount);
+ return result;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, let sampleCount:int>
+[ForceInline]
+public ivec3 textureSize(Sampler2DMSArray<vector<T,N>,sampleCount> sampler)
+{
+ vector<int,3> result;
+ int sampleCount;
+ int numberOfLevels;
+ sampler.GetDimensions(result.x, result.y, result.z, sampleCount);
+ return result;
+}
+
+// -------------------
+// textureQueryLod
+// -------------------
+
+__generic<T, let isArray:int, let sampleCount:int, let isShadow:int, let format:int>
+[ForceInline]
+public vec2 textureQueryLod(__TextureImpl<
+ T,
+ __Shape1D,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ isShadow,
+ 1, // isCombined
+ format
+ > sampler, float p)
+{
+ return vec2(
+ sampler.CalculateLevelOfDetail(p),
+ sampler.CalculateLevelOfDetailUnclamped(p)
+ );
+}
+
+__generic<T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let isShadow:int, let format:int>
+[ForceInline]
+public vec2 textureQueryLod(__TextureImpl<T,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ isShadow,
+ 1, // isCombined
+ format
+ > sampler, vector<float,Shape.dimensions> p)
+{
+ return vec2(
+ sampler.CalculateLevelOfDetail(p),
+ sampler.CalculateLevelOfDetailUnclamped(p)
+ );
+}
+
+// -------------------
+// textureQueryLevels
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public int textureQueryLevels(Sampler1D<vector<T,N>> sampler)
+{
+ int width;
+ int numberOfLevels;
+ sampler.GetDimensions(0, width, numberOfLevels);
+ return numberOfLevels;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public int textureQueryLevels(Sampler2D<vector<T,N>> sampler)
+{
+ vector<int,2> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels);
+ return numberOfLevels;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public int textureQueryLevels(Sampler3D<vector<T,N>> sampler)
+{
+ vector<int,3> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, dim.z, numberOfLevels);
+ return numberOfLevels;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public int textureQueryLevels(SamplerCube<vector<T,N>> sampler)
+{
+ vector<int,2> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels);
+ return numberOfLevels;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public int textureQueryLevels(Sampler1DArray<vector<T,N>> sampler)
+{
+ vector<int,2> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels);
+ return numberOfLevels;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public int textureQueryLevels(Sampler2DArray<vector<T,N>> sampler)
+{
+ vector<int,3> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, dim.z, numberOfLevels);
+ return numberOfLevels;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public int textureQueryLevels(SamplerCubeArray<vector<T,N>> sampler)
+{
+ vector<int,3> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, dim.z, numberOfLevels);
+ return numberOfLevels;
+}
+
+[ForceInline]
+public int textureQueryLevels(sampler1DShadow sampler)
+{
+ int dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim, numberOfLevels);
+ return numberOfLevels;
+}
+
+[ForceInline]
+public int textureQueryLevels(sampler2DShadow sampler)
+{
+ vector<int,2> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels);
+ return numberOfLevels;
+}
+
+[ForceInline]
+public int textureQueryLevels(samplerCubeShadow sampler)
+{
+ vector<int,2> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels);
+ return numberOfLevels;
+}
+
+[ForceInline]
+public int textureQueryLevels(sampler1DArrayShadow sampler)
+{
+ vector<int,2> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels);
+ return numberOfLevels;
+}
+
+[ForceInline]
+public int textureQueryLevels(sampler2DArrayShadow sampler)
+{
+ vector<int,3> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, dim.z, numberOfLevels);
+ return numberOfLevels;
+}
+
+[ForceInline]
+public int textureQueryLevels(samplerCubeArrayShadow sampler)
+{
+ vector<int,3> dim;
+ int numberOfLevels;
+ sampler.GetDimensions(0, dim.x, dim.y, dim.z, numberOfLevels);
+ return numberOfLevels;
+}
+
+// -------------------
+// textureSamples
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int, let sampleCount:int>
+[ForceInline]
+public int textureSamples(Sampler2DMS<vector<T,N>,sampleCount> sampler)
+{
+ vector<int,2> dim;
+ int sampleCount;
+ int numberOfLevels;
+ sampler.GetDimensions( dim.x, dim.y, sampleCount);
+ return sampleCount;
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, let sampleCount:int>
+[ForceInline]
+public int textureSamples(Sampler2DMSArray<vector<T,N>,sampleCount> sampler)
+{
+ vector<int,3> dim;
+ int sampleCount;
+ int numberOfLevels;
+ sampler.GetDimensions(dim.x, dim.y, dim.z, sampleCount);
+ return sampleCount;
+}
+
+//
+// Section 8.9.2. Texel Lookup Functions
+//
+
+// -------------------
+// texture
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> texture(Sampler1D<vector<T,N>> sampler, float p)
+{
+ return __vectorReshape<4>(sampler.Sample(p));
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> texture(Sampler1D<vector<T,N>> sampler, float p, constexpr float bias)
{
return __vectorReshape<4>(sampler.SampleBias(p, bias));
}
+__generic<T:__BuiltinArithmeticType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> texture(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,Shape.dimensions+isArray> p)
+{
+ return __vectorReshape<4>(sampler.Sample(p));
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let format:int>
[ForceInline]
-public vector<T,4> texture<T:__BuiltinFloatingPointType, let N : int> (SamplerCube<vector<T,N>> sampler, float3 p, float bias = 0.0)
+public vector<T,4> texture(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,Shape.dimensions+isArray> p, constexpr float bias)
{
return __vectorReshape<4>(sampler.SampleBias(p, bias));
}
[ForceInline]
-public float texture<T:__BuiltinFloatingPointType, let N : int> (Sampler1DShadow<vector<T,N>> sampler, float2 p)
+public float texture(sampler1DShadow sampler, vec3 p)
{
- return sampler.SampleCmp(p.x, p.y);
+ return sampler.SampleCmp(p.x, p.z);
}
[ForceInline]
-public float texture<T:__BuiltinFloatingPointType, let N : int> (Sampler2DShadow<vector<T,N>> sampler, float3 p)
+public float texture(sampler1DShadow sampler, vec3 p, float bias)
+{
+ // TODO: Need to apply bias
+ return sampler.SampleCmp(p.x, p.z);
+}
+
+[ForceInline]
+public float texture(sampler2DShadow sampler, vec3 p)
{
return sampler.SampleCmp(p.xy, p.z);
}
[ForceInline]
-public float texture<T:__BuiltinFloatingPointType, let N : int> (SamplerCubeShadow<vector<T,N>> sampler, float4 p)
+public float texture(sampler2DShadow sampler, vec3 p, float bias)
{
- return sampler.SampleCmp(p.xyz, p.w);
+ // TODO: Need to apply bias
+ return sampler.SampleCmp(p.xy, p.z);
}
[ForceInline]
-public vector<T,4> texture<T:__BuiltinFloatingPointType, let N : int> (Sampler1DArray<vector<T,N>> sampler, float2 p, float bias = 0.0)
+public float texture(samplerCubeShadow sampler, vec4 p)
{
- return __vectorReshape<4>(sampler.SampleBias(p, bias));
+ return sampler.SampleCmp(p.xyz, p.w);
}
[ForceInline]
-public vector<T,4> texture<T:__BuiltinFloatingPointType, let N : int> (Sampler2DArray<vector<T,N>> sampler, float3 p, float bias = 0.0)
+public float texture(samplerCubeShadow sampler, vec4 p, float bias)
{
- return __vectorReshape<4>(sampler.SampleBias(p, bias));
+ // TODO: Need to apply bias
+ return sampler.SampleCmp(p.xyz, p.w);
}
[ForceInline]
-public vector<T,4> texture<T:__BuiltinFloatingPointType, let N : int> (SamplerCubeArray<vector<T,N>> sampler, float4 p, float bias = 0.0)
+public float texture(sampler1DArrayShadow sampler, vec3 p)
{
- return __vectorReshape<4>(sampler.SampleBias(p, bias));
+ return sampler.SampleCmp(p.xy, p.z);
}
[ForceInline]
-public float texture<T:__BuiltinFloatingPointType, let N : int> (Sampler1DArrayShadow<vector<T,N>> sampler, float3 p)
+public float texture(sampler1DArrayShadow sampler, vec3 p, float bias)
{
+ // TODO: Need to apply bias
return sampler.SampleCmp(p.xy, p.z);
}
[ForceInline]
-public float texture<T:__BuiltinFloatingPointType, let N : int> (Sampler2DArrayShadow<vector<T,N>> sampler, float4 p)
+public float texture(sampler2DArrayShadow sampler, vec4 p)
{
return sampler.SampleCmp(p.xyz, p.w);
}
-__generic<T:__BuiltinFloatingPointType, let N : int, shape:__ITextureShape, let sampleCount: int, let isArray:int, let format:int>
-public vector<T,4> textureGrad(__TextureImpl<vector<T,N>, shape, isArray, 0, sampleCount, 0, 1, 1, format> sampler, vector<float, shape.dimensions+isArray> P, vector<float,shape.planeDimensions> dPdx, vector<float,shape.planeDimensions> dPdy)
+[ForceInline]
+public float texture(samplerCubeArrayShadow sampler, vec4 p, float compare)
{
- return __vectorReshape<4>(sampler.SampleGrad(P, dPdx, dPdy));
+ return sampler.SampleCmp(p, compare);
}
-public out float4 gl_Position : SV_Position;
-public out float gl_PointSize : SV_PointSize;
-public in vec4 gl_FragCoord : SV_Position;
-public out float gl_FragDepth : SV_Depth;
-public out int gl_FragStencilRef : SV_StencilRef;
+// -------------------
+// textureProj
+// -------------------
-public in uvec3 gl_GlobalInvocationID : SV_DispatchThreadID;
-public in uvec3 gl_WorkGroupID : SV_GroupID;
-public in uvec3 gl_LocalInvocationIndex : SV_GroupIndex;
-public in uvec3 gl_LocalInvocationID : SV_GroupThreadID;
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec2 p)
+{
+ return texture(sampler, p.x / p.y);
+}
-// TODO: define overload for tessellation control stage.
-public in int gl_InvocationID : SV_GSInstanceID;
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec2 p, float bias)
+{
+ return texture(sampler, p.x / p.y, bias);
+}
-public in int gl_InstanceIndex : SV_InstanceID;
-public in bool gl_FrontFacing : SV_IsFrontFace;
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec4 p)
+{
+ return texture(sampler, p.x / p.w);
+}
-// TODO: define overload for geometry stage.
-public in int gl_Layer : SV_RenderTargetArrayIndex;
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProj(Sampler1D<vector<T,N>> sampler, vec4 p, float bias)
+{
+ return texture(sampler, p.x / p.w, bias);
+}
-public in int gl_SampleID : SV_SampleIndex;
-public in int gl_VertexIndex : SV_VertexID;
-public in int gl_ViewIndex : SV_ViewID;
-public in int gl_ViewportIndex : SV_ViewportArrayIndex;
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec3 p)
+{
+ return texture(sampler, p.xy / p.z);
+}
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec3 p, float bias)
+{
+ return texture(sampler, p.xy / p.z, bias);
+}
-// Override operator* behavior to compute algebric product of matrices and vectors.
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec4 p)
+{
+ return texture(sampler, p.xy / p.w);
+}
-[OverloadRank(15)]
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-public matrix<float, N, N> operator*<let N : int>(matrix<float, N, N> m1, matrix<float, N, N> m2)
+public vector<T,4> textureProj(Sampler2D<vector<T,N>> sampler, vec4 p, float bias)
{
- return mul(m2, m1);
+ return texture(sampler, p.xy / p.w, bias);
}
-[OverloadRank(15)]
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-public matrix<half, N, N> operator*<let N : int>(matrix<half, N, N> m1, matrix<half, N, N> m2)
+public vector<T,4> textureProj(Sampler3D<vector<T,N>> sampler, vec4 p)
{
- return mul(m2, m1);
+ return texture(sampler, p.xyz / p.w);
}
-[OverloadRank(15)]
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-public matrix<double, N, N> operator*<let N : int>(matrix<double, N, N> m1, matrix<double, N, N> m2)
+public vector<T,4> textureProj(Sampler3D<vector<T,N>> sampler, vec4 p, float bias)
{
- return mul(m2, m1);
+ return texture(sampler, p.xyz / p.w, bias);
}
[ForceInline]
-[OverloadRank(15)]
-public matrix<T, R, L> operator*<T:__BuiltinFloatingPointType, let L : int, let C : int, let R : int>(matrix<T, C, L> m1, matrix<T, R, C> m2)
+public float textureProj(sampler1DShadow sampler, vec4 p)
{
- return mul(m2, m1);
+ return texture(sampler, p.xyz / p.w);
}
[ForceInline]
-[OverloadRank(15)]
-public vector<T, R> operator*<T:__BuiltinFloatingPointType, let C : int, let R : int>(vector<T, C> v, matrix<T, R, C> m)
+public float textureProj(sampler1DShadow sampler, vec4 p, float bias)
{
- return mul(m, v);
+ return texture(sampler, p.xyz / p.w, bias);
}
[ForceInline]
-[OverloadRank(15)]
-public vector<T, C> operator*<T:__BuiltinFloatingPointType, let C : int, let R : int>(matrix<T, R, C> m, vector<T, R> v)
+public float textureProj(sampler2DShadow sampler, vec4 p)
{
- return mul(v, m);
+ return texture(sampler, p.xyz / p.w);
}
-__intrinsic_op(mul)
-public matrix<T, N, M> matrixCompMult<T:__BuiltinFloatingPointType, let N : int, let M : int>(matrix<T,N,M> left, matrix<T,N,M> right);
+[ForceInline]
+public float textureProj(sampler2DShadow sampler, vec4 p, float bias)
+{
+ return texture(sampler, p.xyz / p.w, bias);
+}
-__intrinsic_op(cmpLE)
-public vector<bool, N> lessThanEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
-__intrinsic_op(cmpLT)
-public vector<bool, N> lessThan<T, let N:int>(vector<T, N> x, vector<T, N> y);
-__intrinsic_op(cmpGT)
-public vector<bool, N> greaterThan<T, let N:int>(vector<T, N> x, vector<T, N> y);
-__intrinsic_op(cmpGE)
-public vector<bool, N> greaterThanEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
-__intrinsic_op(cmpEQ)
-public vector<bool, N> equal<T, let N:int>(vector<T, N> x, vector<T, N> y);
-__intrinsic_op(cmpNE)
-public vector<bool, N> notEqual<T, let N:int>(vector<T, N> x, vector<T, N> y);
+// -------------------
+// textureLod
+// -------------------
-__generic<T>
-public extension vector<T, 2>
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureLod(Sampler1D<vector<T,N>> sampler, float p, float lod)
{
- [ForceInline] public __init(vector<T, 3> bigger) { this = bigger.xy; }
- [ForceInline] public __init(vector<T, 4> bigger) { this = bigger.xy; }
+ return __vectorReshape<4>(sampler.SampleLevel(p, lod));
}
-__generic<T>
-public extension vector<T, 3>
+__generic<T:__BuiltinArithmeticType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> textureLod(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,Shape.dimensions+isArray> p, float lod)
{
- [ForceInline] public __init(vector<T, 4> bigger) { this = bigger.xyz; }
+ return __vectorReshape<4>(sampler.SampleLevel(p, lod));
}
[ForceInline]
-[OverloadRank(15)]
-public bool operator==<T:__BuiltinArithmeticType, let N : int>(vector<T, N> left, vector<T, N> right)
+public float textureLod(sampler2DShadow sampler, vec3 p, float lod)
{
- return all(equal(left, right));
+ // TODO: Need to apply lod
+ return sampler.SampleCmp(p.xy, p.z);
}
[ForceInline]
-[OverloadRank(15)]
-public bool operator!=<T:__BuiltinArithmeticType, let N : int>(vector<T, N> left, vector<T, N> right)
+public float textureLod(sampler1DShadow sampler, vec3 p, float lod)
{
- return any(notEqual(left, right));
+ // TODO: Need to apply lod
+ return sampler.SampleCmp(p.x, p.z);
}
[ForceInline]
-[OverloadRank(14)]
-public bool operator==<T:__BuiltinFloatingPointType, let N : int>(vector<T, N> left, vector<T, N> right)
+public float textureLod(sampler1DArrayShadow sampler, vec3 p, float lod)
{
- return all(equal(left, right));
+ // TODO: Need to apply lod
+ return sampler.SampleCmp(p.xy, p.z);
}
+// -------------------
+// textureOffset
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-[OverloadRank(14)]
-public bool operator!=<T:__BuiltinFloatingPointType, let N : int>(vector<T, N> left, vector<T, N> right)
+public vector<T,4> textureOffset(Sampler1D<vector<T,N>> sampler, float p, constexpr int offset, float bias = 0.0)
{
- return any(notEqual(left, right));
+ return __vectorReshape<4>(sampler.SampleBias(p, bias, offset));
}
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-[OverloadRank(14)]
-public bool operator==<T:__BuiltinLogicalType, let N : int>(vector<T, N> left, vector<T, N> right)
+public vector<T,4> textureOffset(Sampler2D<vector<T,N>> sampler, vec2 p, constexpr ivec2 offset, float bias = 0.0)
{
- return all(equal(left, right));
+ return __vectorReshape<4>(sampler.SampleBias(p, bias, offset));
}
+__generic<T:__BuiltinArithmeticType, let N:int>
[ForceInline]
-[OverloadRank(14)]
-public bool operator!=<T:__BuiltinLogicalType, let N : int>(vector<T, N> left, vector<T, N> right)
+public vector<T,4> textureOffset(Sampler3D<vector<T,N>> sampler, vec3 p, constexpr ivec3 offset, float bias = 0.0)
{
- return any(notEqual(left, right));
+ return __vectorReshape<4>(sampler.SampleBias(p, bias, offset));
}
-${{{{
-for (auto type : kBaseTypes) {
- char const* typeName = type.name;
- if (!type.flags) continue;
-}}}}
[ForceInline]
-[OverloadRank(15)]
-public bool operator==<let N : int>(vector<$(typeName), N> left, vector<$(typeName), N> right)
+public float textureOffset(sampler2DShadow sampler, vec3 p, constexpr ivec2 offset, float bias = 0.0)
{
- return all(equal(left, right));
+ // TODO: Need to apply bias
+ return sampler.SampleCmp(p.xy, p.z, offset);
}
[ForceInline]
-[OverloadRank(15)]
-public bool operator!=<let N : int>(vector<$(typeName), N> left, vector<$(typeName), N> right)
+public float textureOffset(sampler1DShadow sampler, vec3 p, constexpr int offset, float bias = 0.0)
{
- return any(notEqual(left, right));
+ // TODO: Need to apply bias
+ return sampler.SampleCmp(p.x, p.z, offset);
}
-${{{{
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureOffset(Sampler1DArray<vector<T,N>> sampler, vec2 p, constexpr int offset, float bias = 0.0)
+{
+ return __vectorReshape<4>(sampler.SampleBias(p, bias, offset));
}
-}}}}
-[ForceInline] public int findLSB(int v) { return firstbitlow(v); }
-[ForceInline] public uint findLSB(uint v) { return firstbitlow(v); }
-[ForceInline] public vector<int,N> findLSB<let N:int>(vector<int,N> value)
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureOffset(Sampler2DArray<vector<T,N>> sampler, vec3 p, constexpr ivec2 offset, float bias = 0.0)
{
- return firstbitlow(value);
+ return __vectorReshape<4>(sampler.SampleBias(p, bias, offset));
}
-[ForceInline] public vector<uint,N> findLSB<let N:int>(vector<uint,N> value)
+
+[ForceInline]
+public float textureOffset(sampler1DArrayShadow sampler, vec3 p, constexpr int offset, float bias = 0.0)
{
- return firstbitlow(value);
+ // TODO: Need to apply bias
+ return sampler.SampleCmp(p.xy, p.z, vector<int,1>(offset));
+}
+
+[ForceInline]
+public float textureOffset(sampler2DArrayShadow sampler, vec4 p, constexpr ivec2 offset)
+{
+ return sampler.SampleCmp(p.xyz, p.w, offset);
+}
+
+// -------------------
+// texelFetch
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> texelFetch(Sampler1D<vector<T,N>> sampler, int p, int lod)
+{
+ return __vectorReshape<4>(sampler.Load(int2(p, lod)));
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> texelFetch(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<int,Shape.dimensions+isArray> p, int lod)
+{
+ return __vectorReshape<4>(sampler.Load(__makeVector(p,lod)));
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> texelFetch(Sampler2DRect<vector<T,N>> sampler, ivec2 p)
+{
+ return __vectorReshape<4>(sampler.Load(int3(p.xy,0)));
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, let format:int>
+[ForceInline]
+public vector<T,4> texelFetch(SamplerBuffer<vector<T,N>,format> sampler, int p)
+{
+ return __vectorReshape<4>(sampler.Load(p));
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> texelFetch(__TextureImpl<
+ vector<T,N>,
+ __Shape2D,
+ isArray,
+ 1, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<int,2+isArray> p, int lod)
+{
+ return __vectorReshape<4>(sampler.Load(p, lod));
+}
+
+// -------------------
+// texelFetchOffset
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> texelFetchOffset(Sampler1D<vector<T,N>> sampler, int p, int lod, constexpr int offset)
+{
+ return texelFetch(sampler, p + offset, lod);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> texelFetchOffset(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ 0, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<int,Shape.dimensions> p, int lod, constexpr vector<int,Shape.dimensions> offset)
+{
+ return texelFetch(sampler, p + offset, lod);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> texelFetchOffset(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ 1, // isArray
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<int,Shape.dimensions+1> p, int lod, constexpr vector<int,Shape.dimensions> offset)
+{
+ return texelFetch(sampler, p + __makeVector(offset,0), lod);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> texelFetchOffset(Sampler2DRect<vector<T,N>> sampler, ivec2 p, constexpr ivec2 offset)
+{
+ return texelFetch(sampler, p + offset);
+}
+
+// -------------------
+// textureProjOffset
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec2 p, constexpr int offset, float bias = 0.0)
+{
+ return textureOffset(sampler, p.x / p.y, offset, bias);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjOffset(Sampler1D<vector<T,N>> sampler, vec4 p, constexpr int offset, float bias = 0.0)
+{
+ return textureOffset(sampler, p.x / p.w, offset, bias);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec3 p, constexpr ivec2 offset, float bias = 0.0)
+{
+ return textureOffset(sampler, p.xy / p.z, offset, bias);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjOffset(Sampler2D<vector<T,N>> sampler, vec4 p, constexpr ivec2 offset, float bias = 0.0)
+{
+ return textureOffset(sampler, p.xy / p.w, offset, bias);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjOffset(Sampler3D<vector<T,N>> sampler, vec4 p, constexpr ivec3 offset, float bias = 0.0)
+{
+ return textureOffset(sampler, p.xyz / p.w, offset, bias);
+}
+
+[ForceInline]
+public float textureProjOffset(sampler1DShadow sampler, vec4 p, constexpr int offset, float bias = 0.0)
+{
+ return textureOffset(sampler, p.xyz / p.w, offset, bias);
+}
+
+[ForceInline]
+public float textureProjOffset(sampler2DShadow sampler, vec4 p, constexpr ivec2 offset, float bias = 0.0)
+{
+ return textureOffset(sampler, p.xyz / p.w, offset, bias);
+}
+
+// -------------------
+// textureLodOffset
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureLodOffset(Sampler1D<vector<T,N>> sampler, float p, float lod, constexpr int offset)
+{
+ return __vectorReshape<4>(sampler.SampleLevel(p, lod, offset));
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> textureLodOffset(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,Shape.dimensions+isArray> p, float lod, constexpr vector<int,Shape.planeDimensions> offset)
+{
+ return __vectorReshape<4>(sampler.SampleLevel(p, lod, offset));
+}
+
+[ForceInline]
+public float textureLodOffset(sampler1DShadow sampler, vec3 p, float lod, constexpr int offset)
+{
+ // TODO: Need to apply lod
+ return sampler.SampleCmpLevelZero(p.x, p.z, offset);
+}
+
+[ForceInline]
+public float textureLodOffset(sampler2DShadow sampler, vec3 p, float lod, constexpr ivec2 offset)
+{
+ // TODO: Need to apply lod
+ return sampler.SampleCmpLevelZero(p.xy, p.z, offset);
+}
+
+[ForceInline]
+public float textureLodOffset(sampler1DArrayShadow sampler, vec3 p, float lod, constexpr int offset)
+{
+ // TODO: Need to apply lod
+ return sampler.SampleCmpLevelZero(p.xy, p.z, offset);
+}
+
+// -------------------
+// textureProjLod
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLod(Sampler1D<vector<T,N>> sampler, vec2 p, float lod)
+{
+ return textureLod(sampler, p.x / p.y, lod);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLod(Sampler1D<vector<T,N>> sampler, vec4 p, float lod)
+{
+ return textureLod(sampler, p.x / p.w, lod);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLod(Sampler2D<vector<T,N>> sampler, vec3 p, float lod)
+{
+ return textureLod(sampler, p.xy / p.z, lod);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLod(Sampler2D<vector<T,N>> sampler, vec4 p, float lod)
+{
+ return textureLod(sampler, p.xy / p.w, lod);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLod(Sampler3D<vector<T,N>> sampler, vec4 p, float lod)
+{
+ return textureLod(sampler, p.xyz / p.w, lod);
+}
+
+[ForceInline]
+public float textureProjLod(sampler1DShadow sampler, vec4 p, float lod)
+{
+ return textureLod(sampler, p.xyz / p.w, lod);
+}
+
+[ForceInline]
+public float textureProjLod(sampler2DShadow sampler, vec4 p, float lod)
+{
+ return textureLod(sampler, p.xyz / p.w, lod);
+}
+
+// -------------------
+// textureProjLodOffset
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLodOffset(Sampler1D<vector<T,N>> sampler, vec2 p, float lod, constexpr int offset)
+{
+ return textureLodOffset(sampler, p.x / p.y, lod, offset);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLodOffset(Sampler1D<vector<T,N>> sampler, vec4 p, float lod, constexpr int offset)
+{
+ return textureLodOffset(sampler, p.x / p.w, lod, offset);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLodOffset(Sampler2D<vector<T,N>> sampler, vec3 p, float lod, constexpr ivec2 offset)
+{
+ return textureLodOffset(sampler, p.xy / p.z, lod, offset);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLodOffset(Sampler2D<vector<T,N>> sampler, vec4 p, float lod, constexpr ivec2 offset)
+{
+ return textureLodOffset(sampler, p.xy / p.w, lod, offset);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjLodOffset(Sampler3D<vector<T,N>> sampler, vec4 p, float lod, constexpr ivec3 offset)
+{
+ return textureLodOffset(sampler, p.xyz / p.w, lod, offset);
+}
+
+[ForceInline]
+public float textureProjLodOffset(sampler1DShadow sampler, vec4 p, float lod, constexpr int offset)
+{
+ return textureLodOffset(sampler, p.xyz / p.w, lod, offset);
+}
+
+[ForceInline]
+public float textureProjLodOffset(sampler2DShadow sampler, vec4 p, float lod, constexpr ivec2 offset)
+{
+ return textureLodOffset(sampler, p.xyz / p.w, lod, offset);
+}
+
+// -------------------
+// textureGrad
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureGrad(Sampler1D<vector<T,N>> sampler, float p, float dPdx, float dPdy)
+{
+ return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy));
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> textureGrad(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,Shape.dimensions+isArray> p, vector<float,Shape.dimensions> dPdx, vector<float,Shape.dimensions> dPdy)
+{
+ return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy));
+}
+
+[ForceInline]
+public float textureGrad(sampler1DShadow sampler, vec3 p, float dPdx, float dPdy)
+{
+ // TODO: Not implemented
+ return 0;
+}
+
+[ForceInline]
+public float textureGrad(sampler1DArrayShadow sampler, vec3 p, float dPdx, float dPdy)
+{
+ // TODO: Not implemented
+ return 0;
+}
+
+[ForceInline]
+public float textureGrad(sampler2DShadow sampler, vec3 p, vec2 dPdx, vec2 dPdy)
+{
+ // TODO: Not implemented on HLSL side yet.
+ return 0;
+}
+
+[ForceInline]
+public float textureGrad(samplerCubeShadow sampler, vec4 p, vec3 dPdx, vec3 dPdy)
+{
+ // TODO: Not implemented on HLSL side yet.
+ return 0;
+}
+
+[ForceInline]
+public float textureGrad(sampler2DArrayShadow sampler, vec4 p, vec2 dPdx, vec2 dPdy)
+{
+ // TODO: Not implemented on HLSL side yet.
+ return 0;
+}
+
+// -------------------
+// textureGradOffset
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureGradOffset(Sampler1D<vector<T,N>> sampler, float p, float dPdx, float dPdy, constexpr int offset)
+{
+ return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy, offset));
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> textureGradOffset(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,Shape.dimensions+isArray> p, vector<float,Shape.dimensions> dPdx, vector<float,Shape.dimensions> dPdy, constexpr vector<int,Shape.dimensions> offset)
+{
+ return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy, offset));
+}
+
+[ForceInline]
+public float textureGradOffset(sampler1DShadow sampler, vec3 p, float dPdx, float dPdy, constexpr int offset)
+{
+ // TODO: Not implemented on HLSL side yet.
+ return 0;
+}
+
+[ForceInline]
+public float textureGradOffset(sampler2DShadow sampler, vec3 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset)
+{
+ // TODO: Not implemented on HLSL side yet.
+ return 0;
+}
+
+[ForceInline]
+public float textureGradOffset(sampler1DArrayShadow sampler, vec3 p, float dPdx, float dPdy, constexpr int offset)
+{
+ // TODO: Not implemented on HLSL side yet.
+ return 0;
+}
+
+[ForceInline]
+public float textureGradOffset(sampler2DArrayShadow sampler, vec4 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset)
+{
+ // TODO: Not implemented on HLSL side yet.
+ return 0;
+}
+
+// -------------------
+// textureProjGrad
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGrad(Sampler1D<vector<T,N>> sampler, vec2 p, float dPdx, float dPdy)
+{
+ return textureGrad(sampler, p.x / p.y, dPdx, dPdy);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGrad(Sampler1D<vector<T,N>> sampler, vec4 p, float dPdx, float dPdy)
+{
+ return textureGrad(sampler, p.x / p.w, dPdx, dPdy);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGrad(Sampler2D<vector<T,N>> sampler, vec3 p, vec2 dPdx, vec2 dPdy)
+{
+ return textureGrad(sampler, p.xy / p.z, dPdx, dPdy);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGrad(Sampler2D<vector<T,N>> sampler, vec4 p, vec2 dPdx, vec2 dPdy)
+{
+ return textureGrad(sampler, p.xy / p.w, dPdx, dPdy);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGrad(Sampler3D<vector<T,N>> sampler, vec4 p, vec3 dPdx, vec3 dPdy)
+{
+ return textureGrad(sampler, p.xyz / p.w, dPdx, dPdy);
+}
+
+[ForceInline]
+public float textureProjGrad(sampler1DShadow sampler, vec4 p, float dPdx, float dPdy)
+{
+ return textureGrad(sampler, p.xyz / p.w, dPdx, dPdy);
+}
+
+[ForceInline]
+public float textureProjGrad(sampler2DShadow sampler, vec4 p, vec2 dPdx, vec2 dPdy)
+{
+ return textureGrad(sampler, p.xyz / p.w, dPdx, dPdy);
+}
+
+// -------------------
+// textureProjGradOffset
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGradOffset(Sampler1D<vector<T,N>> sampler, vec2 p, float dPdx, float dPdy, constexpr int offset)
+{
+ return textureGradOffset(sampler, p.x / p.y, dPdx, dPdy, offset);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGradOffset(Sampler1D<vector<T,N>> sampler, vec4 p, float dPdx, float dPdy, constexpr int offset)
+{
+ return textureGradOffset(sampler, p.x / p.w, dPdx, dPdy, offset);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGradOffset(Sampler2D<vector<T,N>> sampler, vec3 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset)
+{
+ return textureGradOffset(sampler, p.xy / p.z, dPdx, dPdy, offset);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGradOffset(Sampler2D<vector<T,N>> sampler, vec4 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset)
+{
+ return textureGradOffset(sampler, p.xy / p.w, dPdx, dPdy, offset);
+}
+
+__generic<T:__BuiltinArithmeticType, let N:int>
+[ForceInline]
+public vector<T,4> textureProjGradOffset(Sampler3D<vector<T,N>> sampler, vec4 p, vec3 dPdx, vec3 dPdy, constexpr ivec3 offset)
+{
+ return textureGradOffset(sampler, p.xyz / p.w, dPdx, dPdy, offset);
+}
+
+[ForceInline]
+public float textureProjGradOffset(sampler1DShadow sampler, vec4 p, float dPdx, float dPdy, constexpr int offset)
+{
+ return textureGradOffset(sampler, p.xyz / p.w, dPdx, dPdy, offset);
+}
+
+[ForceInline]
+public float textureProjGradOffset(sampler2DShadow sampler, vec4 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset)
+{
+ return textureGradOffset(sampler, p.xyz / p.w, dPdx, dPdy, offset);
+}
+
+//
+// Section 8.9.4. Texture Gather Functions
+//
+
+// -------------------
+// textureGather
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int, Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> textureGather(__TextureImpl<
+ vector<T,N>,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,Shape.dimensions+isArray> p, int comp = 0)
+{
+ switch (comp)
+ {
+ case 1: return sampler.GatherGreen(p);
+ case 2: return sampler.GatherBlue(p);
+ case 3: return sampler.GatherAlpha(p);
+ }
+ return sampler.GatherRed(p);
+}
+
+__generic<Shape:__ITextureShape, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vec4 textureGather(__TextureImpl<
+ float,
+ Shape,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,Shape.dimensions+isArray> p, float refZ)
+{
+ return sampler.GatherCmp(p, refZ);
+}
+
+// -------------------
+// textureGatherOffset
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> textureGatherOffset(__TextureImpl<
+ vector<T,N>,
+ __Shape2D,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,2+isArray> p, constexpr vector<int,2> offset, int comp = 0)
+{
+ switch (comp)
+ {
+ case 1: return sampler.GatherGreen(p, offset);
+ case 2: return sampler.GatherBlue(p, offset);
+ case 3: return sampler.GatherAlpha(p, offset);
+ }
+ return sampler.Gather(p, offset);
+}
+
+__generic<let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vec4 textureGatherOffset(__TextureImpl<
+ float,
+ __Shape2D,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,2+isArray> p, float refZ, constexpr vector<int,2> offset)
+{
+ return sampler.GatherCmp(p, refZ, offset);
+}
+
+// -------------------
+// textureGatherOffsets
+// -------------------
+
+__generic<T:__BuiltinArithmeticType, let N:int, let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vector<T,4> textureGatherOffsets(__TextureImpl<
+ vector<T,N>,
+ __Shape2D,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 0, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,2+isArray> p, constexpr vector<int,2> offsets[4], int comp = 0)
+{
+ switch (comp)
+ {
+ case 1: return sampler.GatherGreen(p, offsets[0], offsets[1], offsets[2], offsets[3]);
+ case 2: return sampler.GatherBlue(p, offsets[0], offsets[1], offsets[2], offsets[3]);
+ case 3: return sampler.GatherAlpha(p, offsets[0], offsets[1], offsets[2], offsets[3]);
+ }
+ return sampler.Gather(p, offsets[0], offsets[1], offsets[2], offsets[3]);
+}
+
+__generic<let isArray:int, let sampleCount:int, let format:int>
+[ForceInline]
+public vec4 textureGatherOffsets(__TextureImpl<
+ float,
+ __Shape2D,
+ isArray,
+ 0, // isMS
+ sampleCount,
+ 0, // access
+ 1, // isShadow
+ 1, // isCombined
+ format
+ > sampler, vector<float,2+isArray> p, float refZ, constexpr vector<int,2> offsets[4])
+{
+ return sampler.GatherCmp(p, refZ, offsets[0], offsets[1], offsets[2], offsets[3]);
+}
+
+//
+// Section 8.9.5. Compatibility Profile Texture Functions
+//
+
+public vec4 texture1D(sampler1D sampler, float coord)
+{
+ return texture(sampler, coord);
+}
+
+public vec4 texture1D(sampler1D sampler, float coord, float bias)
+{
+ return texture(sampler, coord, bias);
+}
+
+public vec4 texture1DProj(sampler1D sampler, vec2 coord)
+{
+ return textureProj(sampler, coord);
+}
+
+public vec4 texture1DProj(sampler1D sampler, vec2 coord, float bias)
+{
+ return textureProj(sampler, coord, bias);
+}
+
+public vec4 texture1DProj(sampler1D sampler, vec4 coord)
+{
+ return textureProj(sampler, coord);
+}
+
+public vec4 texture1DProj(sampler1D sampler, vec4 coord, float bias)
+{
+ return textureProj(sampler, coord, bias);
+}
+
+public vec4 texture1DLod(sampler1D sampler, float coord, float lod)
+{
+ return textureLod(sampler, coord, lod);
+}
+
+public vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod)
+{
+ return textureProjLod(sampler, coord, lod);
+}
+
+public vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod)
+{
+ return textureProjLod(sampler, coord, lod);
+}
+
+public vec4 texture2D(sampler2D sampler, vec2 coord)
+{
+ return texture(sampler, coord);
+}
+
+public vec4 texture2D(sampler2D sampler, vec2 coord, float bias)
+{
+ return texture(sampler, coord, bias);
+}
+
+public vec4 texture2DProj(sampler2D sampler, vec3 coord)
+{
+ return textureProj(sampler, coord);
+}
+
+public vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias)
+{
+ return textureProj(sampler, coord, bias);
+}
+
+public vec4 texture2DProj(sampler2D sampler, vec4 coord)
+{
+ return textureProj(sampler, coord);
+}
+
+public vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias)
+{
+ return textureProj(sampler, coord, bias);
+}
+
+public vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod)
+{
+ return textureLod(sampler, coord, lod);
+}
+
+public vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod)
+{
+ return textureProjLod(sampler, coord, lod);
+}
+
+public vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod)
+{
+ return textureProjLod(sampler, coord, lod);
+}
+
+public vec4 texture3D(sampler3D sampler, vec3 coord)
+{
+ return texture(sampler, coord);
+}
+
+public vec4 texture3D(sampler3D sampler, vec3 coord, float bias)
+{
+ return texture(sampler, coord, bias);
+}
+
+public vec4 texture3DProj(sampler3D sampler, vec4 coord)
+{
+ return textureProj(sampler, coord);
+}
+
+public vec4 texture3DProj(sampler3D sampler, vec4 coord, float bias)
+{
+ return textureProj(sampler, coord, bias);
+}
+
+public vec4 texture3DLod(sampler3D sampler, vec3 coord, float lod)
+{
+ return textureLod(sampler, coord, lod);
+}
+
+public vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod)
+{
+ return textureProjLod(sampler, coord, lod);
+}
+
+public vec4 textureCube(samplerCube sampler, vec3 coord)
+{
+ return texture(sampler, coord);
+}
+
+public vec4 textureCube(samplerCube sampler, vec3 coord, float bias)
+{
+ return texture(sampler, coord, bias);
+}
+
+public vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod)
+{
+ return textureLod(sampler, coord, lod);
+}
+
+public vec4 shadow1D(sampler1DShadow sampler, vec3 coord)
+{
+ return texture(sampler, coord);
+}
+
+public vec4 shadow1D(sampler1DShadow sampler, vec3 coord, float bias)
+{
+ return texture(sampler, coord, bias);
+}
+
+public vec4 shadow2D(sampler2DShadow sampler, vec3 coord)
+{
+ return texture(sampler, coord);
+}
+
+public vec4 shadow2D(sampler2DShadow sampler, vec3 coord, float bias)
+{
+ return texture(sampler, coord, bias);
+}
+
+public vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord)
+{
+ return textureProj(sampler, coord);
+}
+
+public vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord, float bias)
+{
+ return textureProj(sampler, coord, bias);
+}
+
+public vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord)
+{
+ return textureProj(sampler, coord);
+}
+
+public vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord, float bias)
+{
+ return textureProj(sampler, coord, bias);
}
+
+public vec4 shadow1DLod(sampler1DShadow sampler, vec3 coord, float lod)
+{
+ return textureLod(sampler, coord, lod);
+}
+
+public vec4 shadow2DLod(sampler2DShadow sampler, vec3 coord, float lod)
+{
+ return textureLod(sampler, coord, lod);
+}
+
+public vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod)
+{
+ return textureProjLod(sampler, coord, lod);
+}
+
+public vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod)
+{
+ return textureProjLod(sampler, coord, lod);
+}
+
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index e5ebc8409..29c9d4c51 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -223,22 +223,36 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
__target_intrinsic(glsl, "texture($0, $1)")
float __glsl_texture(vector<float, Shape.dimensions+isArray+1> value);
+ __target_intrinsic(glsl, "texture($0, $1)")
+ float __glsl_texture_1d_shadow(vector<float, Shape.dimensions+isArray+2> value);
+
+ __target_intrinsic(glsl, "texture($0, $1, $2)")
+ float __glsl_texture_3d_array_shadow(vector<float, Shape.dimensions+isArray> value, float compare);
+
__glsl_extension(GL_EXT_texture_shadow_lod)
__target_intrinsic(glsl, "textureOffset($0, $1, $2)")
float __glsl_texture_offset(vector<float, Shape.dimensions+isArray+1> value, constexpr vector<int, Shape.planeDimensions> offset);
__glsl_extension(GL_EXT_texture_shadow_lod)
+ __target_intrinsic(glsl, "textureOffset($0, $1, $2)")
+ float __glsl_texture_offset_1d_shadow(vector<float, Shape.dimensions+isArray+2> value, constexpr vector<int, Shape.planeDimensions> offset);
+
+ __glsl_extension(GL_EXT_texture_shadow_lod)
__target_intrinsic(glsl, "textureLod($0, $1, 0)")
float __glsl_texture_level_zero(vector<float, Shape.dimensions+isArray+1> value);
__glsl_extension(GL_EXT_texture_shadow_lod)
+ __target_intrinsic(glsl, "textureLod($0, $1, 0)")
+ float __glsl_texture_level_zero_1d_shadow(vector<float, Shape.dimensions+isArray+2> value);
+
+ __glsl_extension(GL_EXT_texture_shadow_lod)
__target_intrinsic(glsl, "textureLodOffset($0, $1, 0, $2)")
float __glsl_texture_offset_level_zero(vector<float, Shape.dimensions+isArray+1> value, constexpr vector<int, Shape.planeDimensions> offset);
-}
-__generic<T:IFloat, 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>
-{
+ __glsl_extension(GL_EXT_texture_shadow_lod)
+ __target_intrinsic(glsl, "textureLodOffset($0, $1, 0, $2)")
+ float __glsl_texture_offset_level_zero_1d_shadow(vector<float, Shape.dimensions+isArray+2> value, constexpr vector<int, Shape.planeDimensions> offset);
+
[__readNone]
T Sample(vector<float, Shape.dimensions+isArray> location)
{
@@ -362,7 +376,18 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
__target_switch
{
case glsl:
- return __glsl_texture(__makeVector(location, compareValue));
+ if (Shape.dimensions == 1 && isArray == 0)
+ {
+ return __glsl_texture_1d_shadow(__makeVector(__makeVector(location, 0.0), compareValue));
+ }
+ else if (Shape.dimensions == 3 && isArray == 1)
+ {
+ return __glsl_texture_3d_array_shadow(location, compareValue);
+ }
+ else
+ {
+ return __glsl_texture(__makeVector(location, compareValue));
+ }
case hlsl:
__intrinsic_asm ".SampleCmp";
case spirv:
@@ -380,7 +405,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
__target_switch
{
case glsl:
- return __glsl_texture_level_zero(__makeVector(location, compareValue));
+ if (Shape.dimensions == 1 && isArray == 0)
+ {
+ return __glsl_texture_level_zero_1d_shadow(__makeVector(__makeVector(location, 0.0), compareValue));
+ }
+ else
+ {
+ return __glsl_texture_level_zero(__makeVector(location, compareValue));
+ }
case hlsl:
__intrinsic_asm ".SampleCmpLevelZero";
case spirv:
@@ -399,7 +431,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
__target_switch
{
case glsl:
- return __glsl_texture_offset(__makeVector(location, compareValue), offset);
+ if (Shape.dimensions == 1 && isArray == 0)
+ {
+ return __glsl_texture_offset_1d_shadow(__makeVector(__makeVector(location, 0.0), compareValue), offset);
+ }
+ else
+ {
+ return __glsl_texture_offset(__makeVector(location, compareValue), offset);
+ }
case hlsl:
__intrinsic_asm ".SampleCmp";
case spirv:
@@ -417,7 +456,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
__target_switch
{
case glsl:
- return __glsl_texture_offset_level_zero(__makeVector(location, compareValue), offset);
+ if (Shape.dimensions == 1 && isArray == 0)
+ {
+ return __glsl_texture_offset_level_zero_1d_shadow(__makeVector(__makeVector(location,0.0), compareValue), offset);
+ }
+ else
+ {
+ return __glsl_texture_offset_level_zero(__makeVector(location, compareValue), offset);
+ }
case hlsl:
__intrinsic_asm ".SampleCmpLevelZero";
case spirv:
@@ -430,7 +476,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
}
[__readNone]
- T SampleGrad(vector<float, Shape.dimensions+isArray> location, vector<float, Shape.planeDimensions> gradX, vector<float, Shape.planeDimensions> gradY)
+ T SampleGrad(vector<float, Shape.dimensions+isArray> location, vector<float, Shape.dimensions> gradX, vector<float, Shape.dimensions> gradY)
{
__target_switch
{
@@ -449,7 +495,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
}
[__readNone]
- T SampleGrad(vector<float, Shape.dimensions+isArray> location, vector<float, Shape.planeDimensions> gradX, vector<float, Shape.planeDimensions> gradY, constexpr vector<int, Shape.planeDimensions> offset)
+ T SampleGrad(vector<float, Shape.dimensions+isArray> location, vector<float, Shape.dimensions> gradX, vector<float, Shape.dimensions> gradY, constexpr vector<int, Shape.dimensions> offset)
{
__target_switch
{
@@ -469,7 +515,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
__glsl_extension(GL_ARB_sparse_texture_clamp)
[__readNone]
- T SampleGrad(vector<float, Shape.dimensions+isArray> location, vector<float, Shape.planeDimensions> gradX, vector<float, Shape.planeDimensions> gradY, constexpr vector<int, Shape.planeDimensions> offset, float lodClamp)
+ T SampleGrad(vector<float, Shape.dimensions+isArray> location, vector<float, Shape.dimensions> gradX, vector<float, Shape.dimensions> gradY, constexpr vector<int, Shape.dimensions> offset, float lodClamp)
{
__target_switch
{
@@ -603,18 +649,36 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,access,isShadow,0,forma
__target_intrinsic(glsl, "texture($p, $2)")
float __glsl_texture(SamplerComparisonState s, vector<float, Shape.dimensions+isArray+1> value);
+ __target_intrinsic(glsl, "texture($p, $2)")
+ float __glsl_texture_1d_shadow(SamplerComparisonState s, vector<float, Shape.dimensions+isArray+2> value);
+
+ __target_intrinsic(glsl, "texture($p, $2, $3)")
+ float __glsl_texture_3d_array_shadow(SamplerComparisonState s, vector<float, Shape.dimensions+isArray> value, float compare);
+
__glsl_extension(GL_EXT_texture_shadow_lod)
__target_intrinsic(glsl, "textureOffset($p, $2, $3)")
float __glsl_texture_offset(SamplerComparisonState s, vector<float, Shape.dimensions+isArray+1> value, constexpr vector<int, Shape.planeDimensions> offset);
__glsl_extension(GL_EXT_texture_shadow_lod)
+ __target_intrinsic(glsl, "textureOffset($p, $2, $3)")
+ float __glsl_texture_offset_1d_shadow(SamplerComparisonState s, vector<float, Shape.dimensions+isArray+2> value, constexpr vector<int, Shape.planeDimensions> offset);
+
+ __glsl_extension(GL_EXT_texture_shadow_lod)
__target_intrinsic(glsl, "textureLod($p, $2, 0)")
float __glsl_texture_level_zero(SamplerComparisonState s, vector<float, Shape.dimensions+isArray+1> value);
__glsl_extension(GL_EXT_texture_shadow_lod)
+ __target_intrinsic(glsl, "textureLod($p, $2, 0)")
+ float __glsl_texture_level_zero_1d_shadow(SamplerComparisonState s, vector<float, Shape.dimensions+isArray+2> value);
+
+ __glsl_extension(GL_EXT_texture_shadow_lod)
__target_intrinsic(glsl, "textureLodOffset($p, $2, 0, $3)")
float __glsl_texture_offset_level_zero(SamplerComparisonState s, vector<float, Shape.dimensions+isArray+1> value, constexpr vector<int, Shape.planeDimensions> offset);
+ __glsl_extension(GL_EXT_texture_shadow_lod)
+ __target_intrinsic(glsl, "textureLodOffset($p, $2, 0, $3)")
+ float __glsl_texture_offset_level_zero_1d_shadow(SamplerComparisonState s, vector<float, Shape.dimensions+isArray+2> value, constexpr vector<int, Shape.planeDimensions> offset);
+
}
__generic<T:IFloat, Shape: __ITextureShape, let isArray:int, let isMS:int, let sampleCount:int, let isShadow:int, let format:int>
@@ -767,7 +831,18 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
__target_switch
{
case glsl:
- return __glsl_texture(s, __makeVector(location,compareValue));
+ if (Shape.dimensions == 1 && isArray == 0)
+ {
+ return __glsl_texture_1d_shadow(s, __makeVector(__makeVector(location, 0.0), compareValue));
+ }
+ else if (Shape.dimensions == 3 && isArray == 1)
+ {
+ return __glsl_texture_3d_array_shadow(s, location, compareValue);
+ }
+ else
+ {
+ return __glsl_texture(s, __makeVector(location,compareValue));
+ }
case hlsl:
__intrinsic_asm ".SampleCmp";
case spirv:
@@ -785,7 +860,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
__target_switch
{
case glsl:
- return __glsl_texture_level_zero(s, __makeVector(location,compareValue));
+ if (Shape.dimensions == 1 && isArray == 0)
+ {
+ return __glsl_texture_level_zero_1d_shadow(s, __makeVector(__makeVector(location, 0.0), compareValue));
+ }
+ else
+ {
+ return __glsl_texture_level_zero(s, __makeVector(location,compareValue));
+ }
case hlsl:
__intrinsic_asm ".SampleCmpLevelZero";
case spirv:
@@ -804,7 +886,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
__target_switch
{
case glsl:
- return __glsl_texture_offset(s, __makeVector(location,compareValue), offset);
+ if (Shape.dimensions == 1 && isArray == 0)
+ {
+ return __glsl_texture_offset_1d_shadow(s, __makeVector(__makeVector(location, 0.0), compareValue), offset);
+ }
+ else
+ {
+ return __glsl_texture_offset(s, __makeVector(location,compareValue), offset);
+ }
case hlsl:
__intrinsic_asm ".SampleCmp";
case spirv:
@@ -822,7 +911,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
__target_switch
{
case glsl:
- return __glsl_texture_offset_level_zero(s, __makeVector(location,compareValue), offset);
+ if (Shape.dimensions == 1 && isArray == 0)
+ {
+ return __glsl_texture_offset_level_zero_1d_shadow(s, __makeVector(__makeVector(location,0.0),compareValue), offset);
+ }
+ else
+ {
+ return __glsl_texture_offset_level_zero(s, __makeVector(location,compareValue), offset);
+ }
case hlsl:
__intrinsic_asm ".SampleCmpLevelZero";
case spirv:
@@ -836,7 +932,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
}
[__readNone]
- T SampleGrad(SamplerState s, vector<float, Shape.dimensions+isArray> location, vector<float, Shape.planeDimensions> gradX, vector<float, Shape.planeDimensions> gradY)
+ T SampleGrad(SamplerState s, vector<float, Shape.dimensions+isArray> location, vector<float, Shape.dimensions> gradX, vector<float, Shape.dimensions> gradY)
{
__target_switch
{
@@ -856,7 +952,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
}
[__readNone]
- T SampleGrad(SamplerState s, vector<float, Shape.dimensions+isArray> location, vector<float, Shape.planeDimensions> gradX, vector<float, Shape.planeDimensions> gradY, constexpr vector<int, Shape.planeDimensions> offset)
+ T SampleGrad(SamplerState s, vector<float, Shape.dimensions+isArray> location, vector<float, Shape.dimensions> gradX, vector<float, Shape.dimensions> gradY, constexpr vector<int, Shape.dimensions> offset)
{
__target_switch
{
@@ -878,7 +974,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,0,format>
__glsl_extension(GL_ARB_sparse_texture_clamp)
[__readNone]
- T SampleGrad(SamplerState s, vector<float, Shape.dimensions+isArray> location, vector<float, Shape.planeDimensions> gradX, vector<float, Shape.planeDimensions> gradY, constexpr vector<int, Shape.planeDimensions> offset, float lodClamp)
+ T SampleGrad(SamplerState s, vector<float, Shape.dimensions+isArray> location, vector<float, Shape.dimensions> gradX, vector<float, Shape.dimensions> gradY, constexpr vector<int, Shape.dimensions> offset, float lodClamp)
{
__target_switch
{
@@ -1031,7 +1127,21 @@ vector<TElement,4> __glsl_gather(__TextureImpl<T, Shape, isArray, 0, sampleCount
}
__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
[ForceInline]
-vector<TElement,4> __glsl_gather_offset(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerState s, vector<float, Shape.dimensions+isArray> location, int component, vector<int, Shape.planeDimensions> offset)
+vector<TElement,4> __glsl_gather(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 1, format> sampler, vector<float, Shape.dimensions+isArray> location, int component)
+{
+ __target_switch
+ {
+ case glsl:
+ __intrinsic_asm "textureGather($0, $1, $2)";
+ case spirv:
+ return spirv_asm {
+ result:$$vector<TElement,4> = OpImageGather $sampler $location $component;
+ };
+ }
+}
+__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
+[ForceInline]
+vector<TElement,4> __glsl_gather_offset(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerState s, constexpr vector<float, Shape.dimensions+isArray> location, constexpr vector<int, Shape.planeDimensions> offset, int component)
{
__target_switch
{
@@ -1046,16 +1156,31 @@ vector<TElement,4> __glsl_gather_offset(__TextureImpl<T, Shape, isArray, 0, samp
}
__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
[ForceInline]
-vector<TElement,4> __glsl_gather_offsets(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerState s, vector<float, Shape.dimensions+isArray> location, int component,
- vector<int, Shape.planeDimensions> offset1,
- vector<int, Shape.planeDimensions> offset2,
- vector<int, Shape.planeDimensions> offset3,
- vector<int, Shape.planeDimensions> offset4)
+vector<TElement,4> __glsl_gather_offset(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 1, format> sampler, vector<float, Shape.dimensions+isArray> location, constexpr vector<int, Shape.planeDimensions> offset, int component)
{
__target_switch
{
case glsl:
- __intrinsic_asm "textureGatherOffsets($p, $2, $3, $T4[]($4, $5, $6, $7))";
+ __intrinsic_asm "textureGatherOffset($0, $1, $2, $3)";
+ case spirv:
+ return spirv_asm {
+ result:$$vector<TElement,4> = OpImageGather $sampler $location $component ConstOffset $offset;
+ };
+ }
+}
+__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
+[ForceInline]
+vector<TElement,4> __glsl_gather_offsets(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerState s, vector<float, Shape.dimensions+isArray> location,
+ constexpr vector<int, Shape.planeDimensions> offset1,
+ constexpr vector<int, Shape.planeDimensions> offset2,
+ constexpr vector<int, Shape.planeDimensions> offset3,
+ constexpr vector<int, Shape.planeDimensions> offset4,
+ int component)
+{
+ __target_switch
+ {
+ case glsl:
+ __intrinsic_asm "textureGatherOffsets($p, $2, $T3[]($3, $4, $5, $6)), $7";
case spirv:
let offsets = __makeArray(offset1,offset2,offset3,offset4);
return spirv_asm {
@@ -1067,12 +1192,33 @@ vector<TElement,4> __glsl_gather_offsets(__TextureImpl<T, Shape, isArray, 0, sam
}
__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
[ForceInline]
-vector<TElement,4> __glsl_gatherCmp(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, int componentIndex, TElement compareValue)
+vector<TElement,4> __glsl_gather_offsets(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 1, format> sampler, vector<float, Shape.dimensions+isArray> location,
+ constexpr vector<int, Shape.planeDimensions> offset1,
+ constexpr vector<int, Shape.planeDimensions> offset2,
+ constexpr vector<int, Shape.planeDimensions> offset3,
+ constexpr vector<int, Shape.planeDimensions> offset4,
+ int component)
{
__target_switch
{
case glsl:
- __intrinsic_asm "textureGather($p, $2, $4)";
+ __intrinsic_asm "textureGatherOffsets($0, $1, $T2[]($2, $3, $4, $5), $6)";
+ case spirv:
+ let offsets = __makeArray(offset1,offset2,offset3,offset4);
+ return spirv_asm {
+ OpCapability ImageGatherExtended;
+ result:$$vector<TElement,4> = OpImageGather $sampler $location $component ConstOffsets $offsets;
+ };
+ }
+}
+__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
+[ForceInline]
+vector<TElement,4> __glsl_gatherCmp(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, TElement compareValue)
+{
+ __target_switch
+ {
+ case glsl:
+ __intrinsic_asm "textureGather($p, $2, $3)";
case spirv:
return spirv_asm {
%sampledImage : __sampledImageType(texture) = OpSampledImage $texture $s;
@@ -1082,12 +1228,26 @@ vector<TElement,4> __glsl_gatherCmp(__TextureImpl<T, Shape, isArray, 0, sampleCo
}
__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
[ForceInline]
-vector<TElement,4> __glsl_gatherCmp_offset(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, int componentIndex, TElement compareValue, vector<int, Shape.planeDimensions> offset)
+vector<TElement,4> __glsl_gatherCmp(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 1, format> sampler, vector<float, Shape.dimensions+isArray> location, TElement compareValue)
{
__target_switch
{
case glsl:
- __intrinsic_asm "textureGatherOffset($p, $2, $4, $5)";
+ __intrinsic_asm "textureGather($0, $1, $2)";
+ case spirv:
+ return spirv_asm {
+ result:$$vector<TElement,4> = OpImageDrefGather $sampler $location $compareValue;
+ };
+ }
+}
+__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
+[ForceInline]
+vector<TElement,4> __glsl_gatherCmp_offset(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, TElement compareValue, constexpr vector<int, Shape.planeDimensions> offset)
+{
+ __target_switch
+ {
+ case glsl:
+ __intrinsic_asm "textureGatherOffset($p, $2, $3, $4)";
case spirv:
return spirv_asm {
%sampledImage : __sampledImageType(texture) = OpSampledImage $texture $s;
@@ -1097,17 +1257,30 @@ vector<TElement,4> __glsl_gatherCmp_offset(__TextureImpl<T, Shape, isArray, 0, s
}
__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
[ForceInline]
-vector<TElement,4> __glsl_gatherCmp_offsets(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, int componentIndex, TElement compareValue,
+vector<TElement,4> __glsl_gatherCmp_offset(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 1, format> sampler, vector<float, Shape.dimensions+isArray> location, TElement compareValue, constexpr vector<int, Shape.planeDimensions> offset)
+{
+ __target_switch
+ {
+ case glsl:
+ __intrinsic_asm "textureGatherOffset($0, $1, $2, $3)";
+ case spirv:
+ return spirv_asm {
+ result:$$vector<TElement,4> = OpImageDrefGather $sampler $location $compareValue ConstOffset $offset;
+ };
+ }
+}
+__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
+[ForceInline]
+vector<TElement,4> __glsl_gatherCmp_offsets(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerComparisonState s, vector<float, Shape.dimensions+isArray> location, TElement compareValue,
vector<int, Shape.planeDimensions> offset1,
vector<int, Shape.planeDimensions> offset2,
vector<int, Shape.planeDimensions> offset3,
- vector<int, Shape.planeDimensions> offset4
- )
+ vector<int, Shape.planeDimensions> offset4)
{
__target_switch
{
case glsl:
- __intrinsic_asm "textureGatherOffsets($p, $2, $4, $T5[]($5, $6, $7, $8))";
+ __intrinsic_asm "textureGatherOffsets($p, $2, $3, $T4[]($4, $5, $6, $7))";
case spirv:
let offsets = __makeArray(offset1,offset2,offset3,offset4);
return spirv_asm {
@@ -1117,78 +1290,103 @@ vector<TElement,4> __glsl_gatherCmp_offsets(__TextureImpl<T, Shape, isArray, 0,
};
}
}
+__generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let access:int, let isShadow:int, let format:int>
+[ForceInline]
+vector<TElement,4> __glsl_gatherCmp_offsets(__TextureImpl<T, Shape, isArray, 0, sampleCount, access, isShadow, 1, format> sampler, vector<float, Shape.dimensions+isArray> location, TElement compareValue,
+ vector<int, Shape.planeDimensions> offset1,
+ vector<int, Shape.planeDimensions> offset2,
+ vector<int, Shape.planeDimensions> offset3,
+ vector<int, Shape.planeDimensions> offset4)
+{
+ __target_switch
+ {
+ case glsl:
+ __intrinsic_asm "textureGatherOffsets($0, $1, $2, $T3[]($3, $4, $5, $6))";
+ case spirv:
+ let offsets = __makeArray(offset1,offset2,offset3,offset4);
+ return spirv_asm {
+ OpCapability ImageGatherExtended;
+ result:$$vector<TElement,4> = OpImageDrefGather $sampler $location $compareValue ConstOffsets $offsets;
+ };
+ }
+}
${{{{
+for (int isCombined = 0; isCombined<=1; isCombined++) {
for (int isScalarTexture = 0; isScalarTexture <= 1; isScalarTexture++) {
if (isScalarTexture == 0)
{
sb << "__generic<T:__BuiltinArithmeticType, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let isShadow:int, let format:int>\n";
- sb << "extension __TextureImpl<T,Shape,isArray,0,sampleCount,0,isShadow,0,format>\n";
+ sb << "extension __TextureImpl<T,Shape,isArray,0,sampleCount,0,isShadow," << isCombined << ",format>\n";
}
else
{
sb << "__generic<T:__BuiltinArithmeticType, let N:int, Shape: __ITextureShape, let isArray:int, let sampleCount:int, let isShadow:int, let format:int>\n";
- sb << "extension __TextureImpl<vector<T,N>,Shape,isArray,0,sampleCount,0,isShadow,0,format>\n";
+ sb << "extension __TextureImpl<vector<T,N>,Shape,isArray,0,sampleCount,0,isShadow," << isCombined << ",format>\n";
}
}}}}
{ // begin extension for gather
${{{{
// Gather component
+ const char* samplerStateParam = isCombined ? "" : " s,";
for (int isCmp = 0; isCmp <= 1; ++isCmp) {
const char* cmp = isCmp ? "Cmp" : "";
- const char* cmpParam = isCmp? "T compareValue, " : "";
- const char* compareArg = isCmp ? "compareValue, " : "";
- const char* samplerStateType = isCmp ? "SamplerComparisonState" : "SamplerState";
- const char* componentNames[] = {"", "Red", "Green", "Blue", "Alpha"};
- for (auto componentId = 0; componentId < 4; componentId++) {
- auto component = componentNames[componentId];
- auto componentIndex = componentId == 0 ? 0 : componentId - 1;
+ const char* cmpParam = isCmp ? ", T compareValue" : "";
+ const char* compareArg = isCmp ? ", compareValue" : "";
+ const char* samplerStateType = isCombined ? "" : (isCmp ? "SamplerComparisonState" : "SamplerState");
+ const char* componentNames[] = { "", "Red", "Green", "Blue", "Alpha"};
+ const char* glslComponentNames[] = { ", 0", ", 1", ", 2", ", 3" };
+
+ for (auto componentId = 0; componentId <= 4; componentId++) {
+ auto componentName = componentNames[componentId];
+ auto glslComponent = (isCmp ? "" :glslComponentNames[componentId == 0 ? 0 : componentId - 1]);
}}}}
[ForceInline]
- vector<T,4> Gather$(cmp)$(component)($(samplerStateType) s, vector<float, Shape.dimensions+isArray> location, $(cmpParam))
+ vector<T,4> Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector<float, Shape.dimensions+isArray> location $(cmpParam))
{
__target_switch
{
- case hlsl: __intrinsic_asm ".Gather$(cmp)$(component)";
+ case hlsl: __intrinsic_asm ".Gather$(cmp)$(componentName)";
case glsl:
case spirv:
- return __glsl_gather$(cmp)<T>(this, s, location, $(componentIndex), $(compareArg));
+ return __glsl_gather$(cmp)<T>(this,$(samplerStateParam) location $(compareArg) $(glslComponent));
}
}
[ForceInline]
- vector<T,4> Gather$(cmp)$(component)($(samplerStateType) s, vector<float, Shape.dimensions+isArray> location, $(cmpParam) vector<int, Shape.planeDimensions> offset)
+ vector<T,4> Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector<float, Shape.dimensions+isArray> location $(cmpParam), constexpr vector<int, Shape.planeDimensions> offset)
{
__target_switch
{
- case hlsl: __intrinsic_asm ".Gather$(cmp)$(component)";
+ case hlsl: __intrinsic_asm ".Gather$(cmp)$(componentName)";
case glsl:
case spirv:
- return __glsl_gather$(cmp)_offset<T>(this, s, location, $(componentIndex), $(compareArg) offset);
+ return __glsl_gather$(cmp)_offset<T>(this,$(samplerStateParam) location $(compareArg), offset $(glslComponent));
}
}
[ForceInline]
- vector<T,4> Gather$(cmp)$(component)($(samplerStateType) s, vector<float, Shape.dimensions+isArray> location, $(cmpParam)
- vector<int, Shape.planeDimensions> offset1,
- vector<int, Shape.planeDimensions> offset2,
- vector<int, Shape.planeDimensions> offset3,
- vector<int, Shape.planeDimensions> offset4)
+ vector<T,4> Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector<float, Shape.dimensions+isArray> location $(cmpParam),
+ constexpr vector<int, Shape.planeDimensions> offset1,
+ constexpr vector<int, Shape.planeDimensions> offset2,
+ constexpr vector<int, Shape.planeDimensions> offset3,
+ constexpr vector<int, Shape.planeDimensions> offset4)
{
__target_switch
{
- case hlsl: __intrinsic_asm ".Gather$(cmp)$(component)";
+ case hlsl: __intrinsic_asm ".Gather$(cmp)$(componentName)";
case glsl:
case spirv:
- return __glsl_gather$(cmp)_offsets<T>(this, s, location, $(componentIndex), $(compareArg) offset1,offset2,offset3,offset4);
+ return __glsl_gather$(cmp)_offsets<T>(this,$(samplerStateParam) location $(compareArg), offset1,offset2,offset3,offset4 $(glslComponent));
}
}
${{{{
- } // for (component)
+ } // for (componentId)
} // for (isCmp)
}}}}
} // end extension for gather
${{{{
} // for (isScalarTexture)
+} // for (isCombined)
}}}}
// Load/Subscript for readonly, no MS textures
diff --git a/source/slang/slang-stdlib-textures.cpp b/source/slang/slang-stdlib-textures.cpp
index a6c955b36..e6545f852 100644
--- a/source/slang/slang-stdlib-textures.cpp
+++ b/source/slang/slang-stdlib-textures.cpp
@@ -167,6 +167,11 @@ void TextureTypeInfo::writeGetDimensionFunctions()
for (int includeMipInfo = 0; includeMipInfo < 2; ++includeMipInfo)
{
+ if (includeMipInfo && isMultisample)
+ {
+ continue;
+ }
+
int sizeDimCount = 0;
StringBuilder params;
if (includeMipInfo)
@@ -281,7 +286,7 @@ void TextureTypeInfo::writeGetDimensionFunctions()
}
};
glsl << "if (access == " << kStdlibResourceAccessReadOnly << ") __intrinsic_asm \"";
- emitIntrinsic(toSlice("textureSize"), true);
+ emitIntrinsic(toSlice("textureSize"), !isMultisample);
glsl << "\";\n";
glsl << "__intrinsic_asm \"";
emitIntrinsic(toSlice("imageSize"), false);