From a88a7db9b3c215be890d4a9da6414959f9f9a3c1 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:03:04 -0800 Subject: Implement GLSL build-in functions related to texture (#3544) * Implement GLSL texture related built-in functions Partially resolves #3362 This change implemented GLSL build-in functions described in the following sections of "OpenGL Spec" document. 8.9.1. Texture Query Functions 8.9.2. Texel Lookup Functions 8.9.4. Texture Gather Functions 8.9.5. Compatibility Profile Texture Functions About 200 functions are newly implemented. Most of the functions are calling the HLSL implementation so they are expected to work for all targets but they haven't been tested throughly yet. __TextureImpl got a new generic parameter, "isRectangle", to support sampler2DRect and sampler2DRectShadow. It is a sampler for rectangular texture with no mipmaps. For the reason, its "GetDimentions()" doesn't return mip information. The sampling needs to happen in an integer coordinate not in a normalized [0,1] range. but this hasn't been implemenented yet. Texture functions whose name include "Offset" takes an integer type parameter and those values are required to be a compile-time constant. However, our currentl implementation of slangc seems to make the values not-compile-time constant. As a workaround, the test case uses __LINE__ macro to use a unique numbers so that slangc wouldn't collect them into a runtime variable. I put "constexpr" on "offset" parameters as much as possible. But the issue was still reproduced when targetting SPIRV. Texture functions whose name include "Proj" are emulated by dividing the coordinate value with its last component. For that reason, they take one additional component for its coordinate value. As an example, following function takes two components for sampler1D, instead of one: vec4 textureProj(sampler1D sampler, vec2 p); All shadow samplers stores depth-compare-value at the last component. But sampler1DShadow take one extra component, which is vec3 not vec2. It is unclear what the reason is but the second component is unused in this case. Here is an example, float texture(sampler1DShadow sampler, vec3 p); samplerCubeArrayShadow takes five components for its coordinate and the depth-compare-value cannot be stored in the last component of the cooridnate. It is separated out as an independent parameter, float texture(samplerCubeArrayShadow sampler, vec4 p, float compare); TextureGather functions got some modifications. The existing implementation was calling textureGatherOffset[s] with the parameters in a wrong order. This mistake is corrected. * Bring back GatherCmpRed/Green/Blue/Alpha HLSL has GatherCmpRed/Green/Blue/Alpha functions and it was removed from my previous change by a mistake. This change brings them back. * Disabling two failing tests in intrinsic-texture The new test file, intrinsic-texture.slang, has five test settings and two of them are currently failing; they are targetting HLSL and CPP. This change disables them to avoid confusion. * Remove "isRectangle" parameter from __TextureInfo Partially resolves #3362 This commit has a few changes based on the feedback from the code reviews. 1. Remove "isRectangle" parameter from __TextureInfo, because "sampler2DRect" can be replaced with "sampler2D" that always uses lod level 0. All functions associated to "Rect" are also removed. 2. Enabled tests for "samplerBuffer". 3. Removed "__target_intrinsic(glsl)" from glsl.meta.slang, because we want to stay away from it in the future. 4. Some tests in intrinsic-texture.slang are disabled if the functions take constant offset values or take MultiSample samplers. --------- Co-authored-by: Yong He --- source/slang/glsl.meta.slang | 1899 +++++++++++++++++++++++++++++--- source/slang/hlsl.meta.slang | 310 +++++- source/slang/slang-stdlib-textures.cpp | 7 +- 3 files changed, 1994 insertions(+), 222 deletions(-) (limited to 'source') 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,171 +78,6 @@ public typealias dmat4x2 = matrix; public typealias dmat4x3 = matrix; public typealias dmat4x4 = matrix; -public typealias usampler1D = Sampler1D; -public typealias isampler1D = Sampler1D; -public typealias sampler1D = Sampler1D; - -public typealias usampler2D = Sampler2D; -public typealias isampler2D = Sampler2D; -public typealias sampler2D = Sampler2D; - -public typealias usampler3D = Sampler3D; -public typealias isampler3D = Sampler3D; -public typealias sampler3D = Sampler3D; - -public typealias usamplerCube = SamplerCube; -public typealias isamplerCube = SamplerCube; -public typealias samplerCube = SamplerCube; - -public typealias Sampler1DShadow = __TextureImpl; -public typealias usampler1DShadow = Sampler1DShadow; -public typealias isampler1DShadow = Sampler1DShadow; -public typealias sampler1DShadow = Sampler1DShadow; - -public typealias Sampler2DShadow = __TextureImpl; -public typealias usampler2DShadow = Sampler2DShadow; -public typealias isampler2DShadow = Sampler2DShadow; -public typealias sampler2DShadow = Sampler2DShadow; - -public typealias SamplerCubeShadow = __TextureImpl; -public typealias usamplerCubeShadow = SamplerCubeShadow; -public typealias isamplerCubeShadow = SamplerCubeShadow; -public typealias samplerCubeShadow = SamplerCubeShadow; - -public typealias usampler1DArray = Sampler1DArray; -public typealias isampler1DArray = Sampler1DArray; -public typealias sampler1DArray = Sampler1DArray; - -public typealias usampler2DArray = Sampler2DArray; -public typealias isampler2DArray = Sampler2DArray; -public typealias sampler2DArray = Sampler2DArray; - -public typealias usamplerCubeArray = SamplerCubeArray; -public typealias isamplerCubeArray = SamplerCubeArray; -public typealias samplerCubeArray = SamplerCubeArray; - -public typealias Sampler1DArrayShadow = __TextureImpl; -public typealias usampler1DArrayShadow = Sampler1DArrayShadow; -public typealias isampler1DArrayShadow = Sampler1DArrayShadow; -public typealias sampler1DArrayShadow = Sampler1DArrayShadow; - -public typealias Sampler2DArrayShadow = __TextureImpl; -public typealias usampler2DArrayShadow = Sampler2DArrayShadow; -public typealias isampler2DArrayShadow = Sampler2DArrayShadow; -public typealias sampler2DArrayShadow = Sampler2DArrayShadow; - -public typealias SamplerCubeArrayShadow = __TextureImpl; -public typealias usamplerCubeArrayShadow = SamplerCubeArrayShadow; -public typealias isamplerCubeArrayShadow = SamplerCubeArrayShadow; -public typealias samplerCubeArrayShadow = SamplerCubeArrayShadow; - -[ForceInline] -public vector texelFetch (Sampler1D> sampler, int p, int lod) -{ - return __vectorReshape<4>(sampler.Load(int2(p, lod))); -} - -[ForceInline] -public vector texelFetch (Sampler2D> sampler, ivec2 p, int lod) -{ - return __vectorReshape<4>(sampler.Load(int3(p, lod))); -} - -[ForceInline] -public vector texelFetch (Sampler3D> sampler, ivec3 p, int lod) -{ - return __vectorReshape<4>(sampler.Load(int4(p, lod))); -} - -[ForceInline] -public vector texelFetch (Sampler1DArray> sampler, ivec2 p, int lod) -{ - return __vectorReshape<4>(sampler.Load(int3(p, lod))); -} - -[ForceInline] -public vector texelFetch (Sampler2DArray> sampler, ivec3 p, int lod) -{ - return __vectorReshape<4>(sampler.Load(int4(p, lod))); -} - -[ForceInline] -public vector texture (Sampler1D> sampler, float p, float bias = 0.0) -{ - return __vectorReshape<4>(sampler.SampleBias(p, bias)); -} - -[ForceInline] -public vector texture (Sampler2D> sampler, float2 p, float bias = 0.0) -{ - return __vectorReshape<4>(sampler.SampleBias(p, bias)); -} - -[ForceInline] -public vector texture (Sampler3D> sampler, float3 p, float bias = 0.0) -{ - return __vectorReshape<4>(sampler.SampleBias(p, bias)); -} - -[ForceInline] -public vector texture (SamplerCube> sampler, float3 p, float bias = 0.0) -{ - return __vectorReshape<4>(sampler.SampleBias(p, bias)); -} - -[ForceInline] -public float texture (Sampler1DShadow> sampler, float2 p) -{ - return sampler.SampleCmp(p.x, p.y); -} - -[ForceInline] -public float texture (Sampler2DShadow> sampler, float3 p) -{ - return sampler.SampleCmp(p.xy, p.z); -} - -[ForceInline] -public float texture (SamplerCubeShadow> sampler, float4 p) -{ - return sampler.SampleCmp(p.xyz, p.w); -} - -[ForceInline] -public vector texture (Sampler1DArray> sampler, float2 p, float bias = 0.0) -{ - return __vectorReshape<4>(sampler.SampleBias(p, bias)); -} - -[ForceInline] -public vector texture (Sampler2DArray> sampler, float3 p, float bias = 0.0) -{ - return __vectorReshape<4>(sampler.SampleBias(p, bias)); -} - -[ForceInline] -public vector texture (SamplerCubeArray> sampler, float4 p, float bias = 0.0) -{ - return __vectorReshape<4>(sampler.SampleBias(p, bias)); -} - -[ForceInline] -public float texture (Sampler1DArrayShadow> sampler, float3 p) -{ - return sampler.SampleCmp(p.xy, p.z); -} - -[ForceInline] -public float texture (Sampler2DArrayShadow> sampler, float4 p) -{ - return sampler.SampleCmp(p.xyz, p.w); -} - -__generic -public vector textureGrad(__TextureImpl, shape, isArray, 0, sampleCount, 0, 1, 1, format> sampler, vector P, vector dPdx, vector dPdy) -{ - return __vectorReshape<4>(sampler.SampleGrad(P, dPdx, dPdy)); -} public out float4 gl_Position : SV_Position; public out float gl_PointSize : SV_PointSize; @@ -417,3 +252,1737 @@ ${{{{ { return firstbitlow(value); } + +// +// Section 8.9.1. Texture Query Functions +// + +public typealias usampler1D = Sampler1D; +public typealias isampler1D = Sampler1D; +public typealias sampler1D = Sampler1D; + +public typealias usampler2D = Sampler2D; +public typealias isampler2D = Sampler2D; +public typealias sampler2D = Sampler2D; + +public typealias usampler3D = Sampler3D; +public typealias isampler3D = Sampler3D; +public typealias sampler3D = Sampler3D; + +public typealias usamplerCube = SamplerCube; +public typealias isamplerCube = SamplerCube; +public typealias samplerCube = SamplerCube; + +__generic +public typealias sampler1DShadow = __TextureImpl< + float, + __Shape1D, + 0, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +__generic +public typealias sampler2DShadow = __TextureImpl< + float, + __Shape2D, + 0, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +__generic +public typealias samplerCubeShadow = __TextureImpl< + float, + __ShapeCube, + 0, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +public typealias usampler1DArray = Sampler1DArray; +public typealias isampler1DArray = Sampler1DArray; +public typealias sampler1DArray = Sampler1DArray; + +public typealias usampler2DArray = Sampler2DArray; +public typealias isampler2DArray = Sampler2DArray; +public typealias sampler2DArray = Sampler2DArray; + +public typealias usamplerCubeArray = SamplerCubeArray; +public typealias isamplerCubeArray = SamplerCubeArray; +public typealias samplerCubeArray = SamplerCubeArray; + +__generic +public typealias sampler1DArrayShadow = __TextureImpl< + float, + __Shape1D, + 1, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +__generic +public typealias sampler2DArrayShadow = __TextureImpl< + float, + __Shape2D, + 1, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +__generic +public typealias samplerCubeArrayShadow = __TextureImpl< + float, + __ShapeCube, + 1, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +public typealias sampler2DMS = Sampler2DMS; +public typealias isampler2DMS = Sampler2DMS; +public typealias usampler2DMS = Sampler2DMS; + +__generic +public typealias Sampler2DMSArray = Sampler2DArrayMS; +public typealias sampler2DMSArray = Sampler2DMSArray; +public typealias isampler2DMSArray = Sampler2DMSArray; +public typealias usampler2DMSArray = Sampler2DMSArray; + +__generic +public typealias Sampler2DRect = __TextureImpl; +public typealias sampler2DRect = Sampler2DRect; +public typealias isampler2DRect = Sampler2DRect; +public typealias usampler2DRect = Sampler2DRect; + +__generic +public typealias sampler2DRectShadow = __TextureImpl< + float, + __Shape2D, + 0, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +__generic +public typealias SamplerBuffer = __TextureImpl< + T, + __ShapeBuffer, + 0, // isArray + 0, // isMS + 0, // sampleCount + 1, // RW + 0, // isShadow + 0, // isCombined + format +>; +public typealias samplerBuffer = SamplerBuffer; +public typealias isamplerBuffer = SamplerBuffer; +public typealias usamplerBuffer = SamplerBuffer; + + +// ------------------- +// textureSize +// ------------------- + +__generic +[ForceInline] +public int textureSize(Sampler1D> sampler, int lod) +{ + int result; + int numberOfLevels; + sampler.GetDimensions(lod, result, numberOfLevels); + return result; +} + +__generic +[ForceInline] +public ivec2 textureSize(Sampler2D> sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, numberOfLevels); + return result; +} + +__generic +[ForceInline] +public ivec3 textureSize(Sampler3D> sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels); + return result; +} + +__generic +[ForceInline] +public ivec2 textureSize(SamplerCube> sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, numberOfLevels); + return result; +} + +[ForceInline] +public int textureSize(sampler1DShadow sampler, int lod) +{ + int result; + int numberOfLevels; + sampler.GetDimensions(lod, result, numberOfLevels); + return result; +} + +[ForceInline] +public ivec2 textureSize(sampler2DShadow sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, numberOfLevels); + return result; +} + +[ForceInline] +public ivec2 textureSize(samplerCubeShadow sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, numberOfLevels); + return result; +} + +__generic +[ForceInline] +public ivec3 textureSize(SamplerCubeArray> sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels); + return result; +} + +[ForceInline] +public ivec3 textureSize(samplerCubeArrayShadow sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels); + return result; +} + +__generic +[ForceInline] +public ivec2 textureSize(Sampler2DRect> sampler) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(0, result.x, result.y, numberOfLevels); + return result; +} + +[ForceInline] +public ivec2 textureSize(sampler2DRectShadow sampler) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(result.x, result.y); + return result; +} + +__generic +[ForceInline] +public ivec2 textureSize(Sampler1DArray> sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, numberOfLevels); + return result; +} + +[ForceInline] +public ivec2 textureSize(sampler1DArrayShadow sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, numberOfLevels); + return result; +} + +__generic +[ForceInline] +public ivec3 textureSize(Sampler2DArray> sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels); + return result; +} + +[ForceInline] +public ivec3 textureSize(sampler2DArrayShadow sampler, int lod) +{ + vector result; + int numberOfLevels; + sampler.GetDimensions(lod, result.x, result.y, result.z, numberOfLevels); + return result; +} + +__generic +[ForceInline] +public int textureSize(SamplerBuffer,format> sampler) +{ + uint result; + sampler.GetDimensions(result); + return int(result); +} + +__generic +[ForceInline] +public ivec2 textureSize(Sampler2DMS,sampleCount> sampler) +{ + vector result; + int sampleCount; + int numberOfLevels; + sampler.GetDimensions(result.x, result.y, sampleCount); + return result; +} + +__generic +[ForceInline] +public ivec3 textureSize(Sampler2DMSArray,sampleCount> sampler) +{ + vector result; + int sampleCount; + int numberOfLevels; + sampler.GetDimensions(result.x, result.y, result.z, sampleCount); + return result; +} + +// ------------------- +// textureQueryLod +// ------------------- + +__generic +[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 +[ForceInline] +public vec2 textureQueryLod(__TextureImpl sampler, vector p) +{ + return vec2( + sampler.CalculateLevelOfDetail(p), + sampler.CalculateLevelOfDetailUnclamped(p) + ); +} + +// ------------------- +// textureQueryLevels +// ------------------- + +__generic +[ForceInline] +public int textureQueryLevels(Sampler1D> sampler) +{ + int width; + int numberOfLevels; + sampler.GetDimensions(0, width, numberOfLevels); + return numberOfLevels; +} + +__generic +[ForceInline] +public int textureQueryLevels(Sampler2D> sampler) +{ + vector dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels); + return numberOfLevels; +} + +__generic +[ForceInline] +public int textureQueryLevels(Sampler3D> sampler) +{ + vector dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, dim.z, numberOfLevels); + return numberOfLevels; +} + +__generic +[ForceInline] +public int textureQueryLevels(SamplerCube> sampler) +{ + vector dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels); + return numberOfLevels; +} + +__generic +[ForceInline] +public int textureQueryLevels(Sampler1DArray> sampler) +{ + vector dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels); + return numberOfLevels; +} + +__generic +[ForceInline] +public int textureQueryLevels(Sampler2DArray> sampler) +{ + vector dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, dim.z, numberOfLevels); + return numberOfLevels; +} + +__generic +[ForceInline] +public int textureQueryLevels(SamplerCubeArray> sampler) +{ + vector 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 dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels); + return numberOfLevels; +} + +[ForceInline] +public int textureQueryLevels(samplerCubeShadow sampler) +{ + vector dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels); + return numberOfLevels; +} + +[ForceInline] +public int textureQueryLevels(sampler1DArrayShadow sampler) +{ + vector dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, numberOfLevels); + return numberOfLevels; +} + +[ForceInline] +public int textureQueryLevels(sampler2DArrayShadow sampler) +{ + vector dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, dim.z, numberOfLevels); + return numberOfLevels; +} + +[ForceInline] +public int textureQueryLevels(samplerCubeArrayShadow sampler) +{ + vector dim; + int numberOfLevels; + sampler.GetDimensions(0, dim.x, dim.y, dim.z, numberOfLevels); + return numberOfLevels; +} + +// ------------------- +// textureSamples +// ------------------- + +__generic +[ForceInline] +public int textureSamples(Sampler2DMS,sampleCount> sampler) +{ + vector dim; + int sampleCount; + int numberOfLevels; + sampler.GetDimensions( dim.x, dim.y, sampleCount); + return sampleCount; +} + +__generic +[ForceInline] +public int textureSamples(Sampler2DMSArray,sampleCount> sampler) +{ + vector 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 +[ForceInline] +public vector texture(Sampler1D> sampler, float p) +{ + return __vectorReshape<4>(sampler.Sample(p)); +} + +__generic +[ForceInline] +public vector texture(Sampler1D> sampler, float p, constexpr float bias) +{ + return __vectorReshape<4>(sampler.SampleBias(p, bias)); +} + +__generic +[ForceInline] +public vector texture(__TextureImpl< + vector, + Shape, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p) +{ + return __vectorReshape<4>(sampler.Sample(p)); +} + +__generic +[ForceInline] +public vector texture(__TextureImpl< + vector, + Shape, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, constexpr float bias) +{ + return __vectorReshape<4>(sampler.SampleBias(p, bias)); +} + +[ForceInline] +public float texture(sampler1DShadow sampler, vec3 p) +{ + return sampler.SampleCmp(p.x, p.z); +} + +[ForceInline] +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(sampler2DShadow sampler, vec3 p, float bias) +{ + // TODO: Need to apply bias + return sampler.SampleCmp(p.xy, p.z); +} + +[ForceInline] +public float texture(samplerCubeShadow sampler, vec4 p) +{ + return sampler.SampleCmp(p.xyz, p.w); +} + +[ForceInline] +public float texture(samplerCubeShadow sampler, vec4 p, float bias) +{ + // TODO: Need to apply bias + return sampler.SampleCmp(p.xyz, p.w); +} + +[ForceInline] +public float texture(sampler1DArrayShadow sampler, vec3 p) +{ + return sampler.SampleCmp(p.xy, p.z); +} + +[ForceInline] +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(sampler2DArrayShadow sampler, vec4 p) +{ + return sampler.SampleCmp(p.xyz, p.w); +} + +[ForceInline] +public float texture(samplerCubeArrayShadow sampler, vec4 p, float compare) +{ + return sampler.SampleCmp(p, compare); +} + +// ------------------- +// textureProj +// ------------------- + +__generic +[ForceInline] +public vector textureProj(Sampler1D> sampler, vec2 p) +{ + return texture(sampler, p.x / p.y); +} + +__generic +[ForceInline] +public vector textureProj(Sampler1D> sampler, vec2 p, float bias) +{ + return texture(sampler, p.x / p.y, bias); +} + +__generic +[ForceInline] +public vector textureProj(Sampler1D> sampler, vec4 p) +{ + return texture(sampler, p.x / p.w); +} + +__generic +[ForceInline] +public vector textureProj(Sampler1D> sampler, vec4 p, float bias) +{ + return texture(sampler, p.x / p.w, bias); +} + +__generic +[ForceInline] +public vector textureProj(Sampler2D> sampler, vec3 p) +{ + return texture(sampler, p.xy / p.z); +} + +__generic +[ForceInline] +public vector textureProj(Sampler2D> sampler, vec3 p, float bias) +{ + return texture(sampler, p.xy / p.z, bias); +} + +__generic +[ForceInline] +public vector textureProj(Sampler2D> sampler, vec4 p) +{ + return texture(sampler, p.xy / p.w); +} + +__generic +[ForceInline] +public vector textureProj(Sampler2D> sampler, vec4 p, float bias) +{ + return texture(sampler, p.xy / p.w, bias); +} + +__generic +[ForceInline] +public vector textureProj(Sampler3D> sampler, vec4 p) +{ + return texture(sampler, p.xyz / p.w); +} + +__generic +[ForceInline] +public vector textureProj(Sampler3D> sampler, vec4 p, float bias) +{ + return texture(sampler, p.xyz / p.w, bias); +} + +[ForceInline] +public float textureProj(sampler1DShadow sampler, vec4 p) +{ + return texture(sampler, p.xyz / p.w); +} + +[ForceInline] +public float textureProj(sampler1DShadow sampler, vec4 p, float bias) +{ + return texture(sampler, p.xyz / p.w, bias); +} + +[ForceInline] +public float textureProj(sampler2DShadow sampler, vec4 p) +{ + return texture(sampler, p.xyz / p.w); +} + +[ForceInline] +public float textureProj(sampler2DShadow sampler, vec4 p, float bias) +{ + return texture(sampler, p.xyz / p.w, bias); +} + +// ------------------- +// textureLod +// ------------------- + +__generic +[ForceInline] +public vector textureLod(Sampler1D> sampler, float p, float lod) +{ + return __vectorReshape<4>(sampler.SampleLevel(p, lod)); +} + +__generic +[ForceInline] +public vector textureLod(__TextureImpl< + vector, + Shape, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, float lod) +{ + return __vectorReshape<4>(sampler.SampleLevel(p, lod)); +} + +[ForceInline] +public float textureLod(sampler2DShadow sampler, vec3 p, float lod) +{ + // TODO: Need to apply lod + return sampler.SampleCmp(p.xy, p.z); +} + +[ForceInline] +public float textureLod(sampler1DShadow sampler, vec3 p, float lod) +{ + // TODO: Need to apply lod + return sampler.SampleCmp(p.x, p.z); +} + +[ForceInline] +public float textureLod(sampler1DArrayShadow sampler, vec3 p, float lod) +{ + // TODO: Need to apply lod + return sampler.SampleCmp(p.xy, p.z); +} + +// ------------------- +// textureOffset +// ------------------- + +__generic +[ForceInline] +public vector textureOffset(Sampler1D> sampler, float p, constexpr int offset, float bias = 0.0) +{ + return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); +} + +__generic +[ForceInline] +public vector textureOffset(Sampler2D> sampler, vec2 p, constexpr ivec2 offset, float bias = 0.0) +{ + return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); +} + +__generic +[ForceInline] +public vector textureOffset(Sampler3D> sampler, vec3 p, constexpr ivec3 offset, float bias = 0.0) +{ + return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); +} + +[ForceInline] +public float textureOffset(sampler2DShadow sampler, vec3 p, constexpr ivec2 offset, float bias = 0.0) +{ + // TODO: Need to apply bias + return sampler.SampleCmp(p.xy, p.z, offset); +} + +[ForceInline] +public float textureOffset(sampler1DShadow sampler, vec3 p, constexpr int offset, float bias = 0.0) +{ + // TODO: Need to apply bias + return sampler.SampleCmp(p.x, p.z, offset); +} + +__generic +[ForceInline] +public vector textureOffset(Sampler1DArray> sampler, vec2 p, constexpr int offset, float bias = 0.0) +{ + return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); +} + +__generic +[ForceInline] +public vector textureOffset(Sampler2DArray> sampler, vec3 p, constexpr ivec2 offset, float bias = 0.0) +{ + return __vectorReshape<4>(sampler.SampleBias(p, bias, offset)); +} + +[ForceInline] +public float textureOffset(sampler1DArrayShadow sampler, vec3 p, constexpr int offset, float bias = 0.0) +{ + // TODO: Need to apply bias + return sampler.SampleCmp(p.xy, p.z, vector(offset)); +} + +[ForceInline] +public float textureOffset(sampler2DArrayShadow sampler, vec4 p, constexpr ivec2 offset) +{ + return sampler.SampleCmp(p.xyz, p.w, offset); +} + +// ------------------- +// texelFetch +// ------------------- + +__generic +[ForceInline] +public vector texelFetch(Sampler1D> sampler, int p, int lod) +{ + return __vectorReshape<4>(sampler.Load(int2(p, lod))); +} + +__generic +[ForceInline] +public vector texelFetch(__TextureImpl< + vector, + Shape, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, int lod) +{ + return __vectorReshape<4>(sampler.Load(__makeVector(p,lod))); +} + +__generic +[ForceInline] +public vector texelFetch(Sampler2DRect> sampler, ivec2 p) +{ + return __vectorReshape<4>(sampler.Load(int3(p.xy,0))); +} + +__generic +[ForceInline] +public vector texelFetch(SamplerBuffer,format> sampler, int p) +{ + return __vectorReshape<4>(sampler.Load(p)); +} + +__generic +[ForceInline] +public vector texelFetch(__TextureImpl< + vector, + __Shape2D, + isArray, + 1, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, int lod) +{ + return __vectorReshape<4>(sampler.Load(p, lod)); +} + +// ------------------- +// texelFetchOffset +// ------------------- + +__generic +[ForceInline] +public vector texelFetchOffset(Sampler1D> sampler, int p, int lod, constexpr int offset) +{ + return texelFetch(sampler, p + offset, lod); +} + +__generic +[ForceInline] +public vector texelFetchOffset(__TextureImpl< + vector, + Shape, + 0, // isArray + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, int lod, constexpr vector offset) +{ + return texelFetch(sampler, p + offset, lod); +} + +__generic +[ForceInline] +public vector texelFetchOffset(__TextureImpl< + vector, + Shape, + 1, // isArray + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, int lod, constexpr vector offset) +{ + return texelFetch(sampler, p + __makeVector(offset,0), lod); +} + +__generic +[ForceInline] +public vector texelFetchOffset(Sampler2DRect> sampler, ivec2 p, constexpr ivec2 offset) +{ + return texelFetch(sampler, p + offset); +} + +// ------------------- +// textureProjOffset +// ------------------- + +__generic +[ForceInline] +public vector textureProjOffset(Sampler1D> sampler, vec2 p, constexpr int offset, float bias = 0.0) +{ + return textureOffset(sampler, p.x / p.y, offset, bias); +} + +__generic +[ForceInline] +public vector textureProjOffset(Sampler1D> sampler, vec4 p, constexpr int offset, float bias = 0.0) +{ + return textureOffset(sampler, p.x / p.w, offset, bias); +} + +__generic +[ForceInline] +public vector textureProjOffset(Sampler2D> sampler, vec3 p, constexpr ivec2 offset, float bias = 0.0) +{ + return textureOffset(sampler, p.xy / p.z, offset, bias); +} + +__generic +[ForceInline] +public vector textureProjOffset(Sampler2D> sampler, vec4 p, constexpr ivec2 offset, float bias = 0.0) +{ + return textureOffset(sampler, p.xy / p.w, offset, bias); +} + +__generic +[ForceInline] +public vector textureProjOffset(Sampler3D> 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 +[ForceInline] +public vector textureLodOffset(Sampler1D> sampler, float p, float lod, constexpr int offset) +{ + return __vectorReshape<4>(sampler.SampleLevel(p, lod, offset)); +} + +__generic +[ForceInline] +public vector textureLodOffset(__TextureImpl< + vector, + Shape, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, float lod, constexpr vector 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 +[ForceInline] +public vector textureProjLod(Sampler1D> sampler, vec2 p, float lod) +{ + return textureLod(sampler, p.x / p.y, lod); +} + +__generic +[ForceInline] +public vector textureProjLod(Sampler1D> sampler, vec4 p, float lod) +{ + return textureLod(sampler, p.x / p.w, lod); +} + +__generic +[ForceInline] +public vector textureProjLod(Sampler2D> sampler, vec3 p, float lod) +{ + return textureLod(sampler, p.xy / p.z, lod); +} + +__generic +[ForceInline] +public vector textureProjLod(Sampler2D> sampler, vec4 p, float lod) +{ + return textureLod(sampler, p.xy / p.w, lod); +} + +__generic +[ForceInline] +public vector textureProjLod(Sampler3D> 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 +[ForceInline] +public vector textureProjLodOffset(Sampler1D> sampler, vec2 p, float lod, constexpr int offset) +{ + return textureLodOffset(sampler, p.x / p.y, lod, offset); +} + +__generic +[ForceInline] +public vector textureProjLodOffset(Sampler1D> sampler, vec4 p, float lod, constexpr int offset) +{ + return textureLodOffset(sampler, p.x / p.w, lod, offset); +} + +__generic +[ForceInline] +public vector textureProjLodOffset(Sampler2D> sampler, vec3 p, float lod, constexpr ivec2 offset) +{ + return textureLodOffset(sampler, p.xy / p.z, lod, offset); +} + +__generic +[ForceInline] +public vector textureProjLodOffset(Sampler2D> sampler, vec4 p, float lod, constexpr ivec2 offset) +{ + return textureLodOffset(sampler, p.xy / p.w, lod, offset); +} + +__generic +[ForceInline] +public vector textureProjLodOffset(Sampler3D> 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 +[ForceInline] +public vector textureGrad(Sampler1D> sampler, float p, float dPdx, float dPdy) +{ + return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy)); +} + +__generic +[ForceInline] +public vector textureGrad(__TextureImpl< + vector, + Shape, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, vector dPdx, vector 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 +[ForceInline] +public vector textureGradOffset(Sampler1D> sampler, float p, float dPdx, float dPdy, constexpr int offset) +{ + return __vectorReshape<4>(sampler.SampleGrad(p, dPdx, dPdy, offset)); +} + +__generic +[ForceInline] +public vector textureGradOffset(__TextureImpl< + vector, + Shape, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, vector dPdx, vector dPdy, constexpr vector 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 +[ForceInline] +public vector textureProjGrad(Sampler1D> sampler, vec2 p, float dPdx, float dPdy) +{ + return textureGrad(sampler, p.x / p.y, dPdx, dPdy); +} + +__generic +[ForceInline] +public vector textureProjGrad(Sampler1D> sampler, vec4 p, float dPdx, float dPdy) +{ + return textureGrad(sampler, p.x / p.w, dPdx, dPdy); +} + +__generic +[ForceInline] +public vector textureProjGrad(Sampler2D> sampler, vec3 p, vec2 dPdx, vec2 dPdy) +{ + return textureGrad(sampler, p.xy / p.z, dPdx, dPdy); +} + +__generic +[ForceInline] +public vector textureProjGrad(Sampler2D> sampler, vec4 p, vec2 dPdx, vec2 dPdy) +{ + return textureGrad(sampler, p.xy / p.w, dPdx, dPdy); +} + +__generic +[ForceInline] +public vector textureProjGrad(Sampler3D> 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 +[ForceInline] +public vector textureProjGradOffset(Sampler1D> sampler, vec2 p, float dPdx, float dPdy, constexpr int offset) +{ + return textureGradOffset(sampler, p.x / p.y, dPdx, dPdy, offset); +} + +__generic +[ForceInline] +public vector textureProjGradOffset(Sampler1D> sampler, vec4 p, float dPdx, float dPdy, constexpr int offset) +{ + return textureGradOffset(sampler, p.x / p.w, dPdx, dPdy, offset); +} + +__generic +[ForceInline] +public vector textureProjGradOffset(Sampler2D> sampler, vec3 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset) +{ + return textureGradOffset(sampler, p.xy / p.z, dPdx, dPdy, offset); +} + +__generic +[ForceInline] +public vector textureProjGradOffset(Sampler2D> sampler, vec4 p, vec2 dPdx, vec2 dPdy, constexpr ivec2 offset) +{ + return textureGradOffset(sampler, p.xy / p.w, dPdx, dPdy, offset); +} + +__generic +[ForceInline] +public vector textureProjGradOffset(Sampler3D> 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 +[ForceInline] +public vector textureGather(__TextureImpl< + vector, + Shape, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector 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 +[ForceInline] +public vec4 textureGather(__TextureImpl< + float, + Shape, + isArray, + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format + > sampler, vector p, float refZ) +{ + return sampler.GatherCmp(p, refZ); +} + +// ------------------- +// textureGatherOffset +// ------------------- + +__generic +[ForceInline] +public vector textureGatherOffset(__TextureImpl< + vector, + __Shape2D, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, constexpr vector 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 +[ForceInline] +public vec4 textureGatherOffset(__TextureImpl< + float, + __Shape2D, + isArray, + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format + > sampler, vector p, float refZ, constexpr vector offset) +{ + return sampler.GatherCmp(p, refZ, offset); +} + +// ------------------- +// textureGatherOffsets +// ------------------- + +__generic +[ForceInline] +public vector textureGatherOffsets(__TextureImpl< + vector, + __Shape2D, + isArray, + 0, // isMS + sampleCount, + 0, // access + 0, // isShadow + 1, // isCombined + format + > sampler, vector p, constexpr vector 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 +[ForceInline] +public vec4 textureGatherOffsets(__TextureImpl< + float, + __Shape2D, + isArray, + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format + > sampler, vector p, float refZ, constexpr vector 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 __target_intrinsic(glsl, "texture($0, $1)") float __glsl_texture(vector value); + __target_intrinsic(glsl, "texture($0, $1)") + float __glsl_texture_1d_shadow(vector value); + + __target_intrinsic(glsl, "texture($0, $1, $2)") + float __glsl_texture_3d_array_shadow(vector value, float compare); + __glsl_extension(GL_EXT_texture_shadow_lod) __target_intrinsic(glsl, "textureOffset($0, $1, $2)") float __glsl_texture_offset(vector value, constexpr vector offset); + __glsl_extension(GL_EXT_texture_shadow_lod) + __target_intrinsic(glsl, "textureOffset($0, $1, $2)") + float __glsl_texture_offset_1d_shadow(vector value, constexpr vector offset); + __glsl_extension(GL_EXT_texture_shadow_lod) __target_intrinsic(glsl, "textureLod($0, $1, 0)") float __glsl_texture_level_zero(vector value); + __glsl_extension(GL_EXT_texture_shadow_lod) + __target_intrinsic(glsl, "textureLod($0, $1, 0)") + float __glsl_texture_level_zero_1d_shadow(vector value); + __glsl_extension(GL_EXT_texture_shadow_lod) __target_intrinsic(glsl, "textureLodOffset($0, $1, 0, $2)") float __glsl_texture_offset_level_zero(vector value, constexpr vector offset); -} -__generic -extension __TextureImpl -{ + __glsl_extension(GL_EXT_texture_shadow_lod) + __target_intrinsic(glsl, "textureLodOffset($0, $1, 0, $2)") + float __glsl_texture_offset_level_zero_1d_shadow(vector value, constexpr vector offset); + [__readNone] T Sample(vector location) { @@ -362,7 +376,18 @@ extension __TextureImpl __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 __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 __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 __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 } [__readNone] - T SampleGrad(vector location, vector gradX, vector gradY) + T SampleGrad(vector location, vector gradX, vector gradY) { __target_switch { @@ -449,7 +495,7 @@ extension __TextureImpl } [__readNone] - T SampleGrad(vector location, vector gradX, vector gradY, constexpr vector offset) + T SampleGrad(vector location, vector gradX, vector gradY, constexpr vector offset) { __target_switch { @@ -469,7 +515,7 @@ extension __TextureImpl __glsl_extension(GL_ARB_sparse_texture_clamp) [__readNone] - T SampleGrad(vector location, vector gradX, vector gradY, constexpr vector offset, float lodClamp) + T SampleGrad(vector location, vector gradX, vector gradY, constexpr vector offset, float lodClamp) { __target_switch { @@ -603,18 +649,36 @@ extension __TextureImpl value); + __target_intrinsic(glsl, "texture($p, $2)") + float __glsl_texture_1d_shadow(SamplerComparisonState s, vector value); + + __target_intrinsic(glsl, "texture($p, $2, $3)") + float __glsl_texture_3d_array_shadow(SamplerComparisonState s, vector value, float compare); + __glsl_extension(GL_EXT_texture_shadow_lod) __target_intrinsic(glsl, "textureOffset($p, $2, $3)") float __glsl_texture_offset(SamplerComparisonState s, vector value, constexpr vector offset); + __glsl_extension(GL_EXT_texture_shadow_lod) + __target_intrinsic(glsl, "textureOffset($p, $2, $3)") + float __glsl_texture_offset_1d_shadow(SamplerComparisonState s, vector value, constexpr vector offset); + __glsl_extension(GL_EXT_texture_shadow_lod) __target_intrinsic(glsl, "textureLod($p, $2, 0)") float __glsl_texture_level_zero(SamplerComparisonState s, vector 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 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 value, constexpr vector 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 value, constexpr vector offset); + } __generic @@ -767,7 +831,18 @@ extension __TextureImpl __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 __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 __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 __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 } [__readNone] - T SampleGrad(SamplerState s, vector location, vector gradX, vector gradY) + T SampleGrad(SamplerState s, vector location, vector gradX, vector gradY) { __target_switch { @@ -856,7 +952,7 @@ extension __TextureImpl } [__readNone] - T SampleGrad(SamplerState s, vector location, vector gradX, vector gradY, constexpr vector offset) + T SampleGrad(SamplerState s, vector location, vector gradX, vector gradY, constexpr vector offset) { __target_switch { @@ -878,7 +974,7 @@ extension __TextureImpl __glsl_extension(GL_ARB_sparse_texture_clamp) [__readNone] - T SampleGrad(SamplerState s, vector location, vector gradX, vector gradY, constexpr vector offset, float lodClamp) + T SampleGrad(SamplerState s, vector location, vector gradX, vector gradY, constexpr vector offset, float lodClamp) { __target_switch { @@ -1031,7 +1127,21 @@ vector __glsl_gather(__TextureImpl [ForceInline] -vector __glsl_gather_offset(__TextureImpl texture, SamplerState s, vector location, int component, vector offset) +vector __glsl_gather(__TextureImpl sampler, vector location, int component) +{ + __target_switch + { + case glsl: + __intrinsic_asm "textureGather($0, $1, $2)"; + case spirv: + return spirv_asm { + result:$$vector = OpImageGather $sampler $location $component; + }; + } +} +__generic +[ForceInline] +vector __glsl_gather_offset(__TextureImpl texture, SamplerState s, constexpr vector location, constexpr vector offset, int component) { __target_switch { @@ -1046,16 +1156,31 @@ vector __glsl_gather_offset(__TextureImpl [ForceInline] -vector __glsl_gather_offsets(__TextureImpl texture, SamplerState s, vector location, int component, - vector offset1, - vector offset2, - vector offset3, - vector offset4) +vector __glsl_gather_offset(__TextureImpl sampler, vector location, constexpr vector 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 = OpImageGather $sampler $location $component ConstOffset $offset; + }; + } +} +__generic +[ForceInline] +vector __glsl_gather_offsets(__TextureImpl texture, SamplerState s, vector location, + constexpr vector offset1, + constexpr vector offset2, + constexpr vector offset3, + constexpr vector 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 __glsl_gather_offsets(__TextureImpl [ForceInline] -vector __glsl_gatherCmp(__TextureImpl texture, SamplerComparisonState s, vector location, int componentIndex, TElement compareValue) +vector __glsl_gather_offsets(__TextureImpl sampler, vector location, + constexpr vector offset1, + constexpr vector offset2, + constexpr vector offset3, + constexpr vector 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 = OpImageGather $sampler $location $component ConstOffsets $offsets; + }; + } +} +__generic +[ForceInline] +vector __glsl_gatherCmp(__TextureImpl texture, SamplerComparisonState s, vector 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 __glsl_gatherCmp(__TextureImpl [ForceInline] -vector __glsl_gatherCmp_offset(__TextureImpl texture, SamplerComparisonState s, vector location, int componentIndex, TElement compareValue, vector offset) +vector __glsl_gatherCmp(__TextureImpl sampler, vector 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 = OpImageDrefGather $sampler $location $compareValue; + }; + } +} +__generic +[ForceInline] +vector __glsl_gatherCmp_offset(__TextureImpl texture, SamplerComparisonState s, vector location, TElement compareValue, constexpr vector 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 __glsl_gatherCmp_offset(__TextureImpl [ForceInline] -vector __glsl_gatherCmp_offsets(__TextureImpl texture, SamplerComparisonState s, vector location, int componentIndex, TElement compareValue, +vector __glsl_gatherCmp_offset(__TextureImpl sampler, vector location, TElement compareValue, constexpr vector offset) +{ + __target_switch + { + case glsl: + __intrinsic_asm "textureGatherOffset($0, $1, $2, $3)"; + case spirv: + return spirv_asm { + result:$$vector = OpImageDrefGather $sampler $location $compareValue ConstOffset $offset; + }; + } +} +__generic +[ForceInline] +vector __glsl_gatherCmp_offsets(__TextureImpl texture, SamplerComparisonState s, vector location, TElement compareValue, vector offset1, vector offset2, vector offset3, - vector offset4 - ) + vector 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 __glsl_gatherCmp_offsets(__TextureImpl +[ForceInline] +vector __glsl_gatherCmp_offsets(__TextureImpl sampler, vector location, TElement compareValue, + vector offset1, + vector offset2, + vector offset3, + vector 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 = 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\n"; - sb << "extension __TextureImpl\n"; + sb << "extension __TextureImpl\n"; } else { sb << "__generic\n"; - sb << "extension __TextureImpl,Shape,isArray,0,sampleCount,0,isShadow,0,format>\n"; + sb << "extension __TextureImpl,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 Gather$(cmp)$(component)($(samplerStateType) s, vector location, $(cmpParam)) + vector Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector 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)(this, s, location, $(componentIndex), $(compareArg)); + return __glsl_gather$(cmp)(this,$(samplerStateParam) location $(compareArg) $(glslComponent)); } } [ForceInline] - vector Gather$(cmp)$(component)($(samplerStateType) s, vector location, $(cmpParam) vector offset) + vector Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector location $(cmpParam), constexpr vector 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(this, s, location, $(componentIndex), $(compareArg) offset); + return __glsl_gather$(cmp)_offset(this,$(samplerStateParam) location $(compareArg), offset $(glslComponent)); } } [ForceInline] - vector Gather$(cmp)$(component)($(samplerStateType) s, vector location, $(cmpParam) - vector offset1, - vector offset2, - vector offset3, - vector offset4) + vector Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector location $(cmpParam), + constexpr vector offset1, + constexpr vector offset2, + constexpr vector offset3, + constexpr vector 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(this, s, location, $(componentIndex), $(compareArg) offset1,offset2,offset3,offset4); + return __glsl_gather$(cmp)_offsets(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); -- cgit v1.2.3