diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-05-14 20:28:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-14 20:28:28 -0700 |
| commit | cc88530a722cc2ce7a09f2a39dadeeb504e2f221 (patch) | |
| tree | 2b2c3e56a4f4e13044a370f792e3d386b3d3f2ac | |
| parent | 4edc72e4dea47cf549b4e28940e3509a5ab61439 (diff) | |
Support combined textures for Metal target (#4169)
| -rw-r--r-- | source/slang/hlsl.meta.slang | 106 | ||||
| -rw-r--r-- | source/slang/slang-emit.cpp | 11 | ||||
| -rw-r--r-- | tests/metal/texture-sampler-less.slang | 558 | ||||
| -rw-r--r-- | tests/metal/texture.slang | 28 |
4 files changed, 659 insertions, 44 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index f318eb79e..176c7c0e4 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -529,13 +529,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(glsl_hlsl_spirv, texture_querylod)] + [require(glsl_hlsl_metal_spirv, texture_querylod)] float CalculateLevelOfDetail(TextureCoord location) { __requireComputeDerivative(); __target_switch { case hlsl: + case metal: { return __getTexture().CalculateLevelOfDetail(__getSampler(), location); } @@ -551,13 +552,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(glsl_hlsl_spirv, texture_querylod)] + [require(glsl_hlsl_metal_spirv, texture_querylod)] float CalculateLevelOfDetailUnclamped(TextureCoord location) { __requireComputeDerivative(); __target_switch { case hlsl: + case metal: { return __getTexture().CalculateLevelOfDetailUnclamped(__getSampler(), location); } @@ -573,7 +575,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1_fragment)] + [require(cpp_cuda_glsl_hlsl_metal_spirv, texture_sm_4_1_fragment)] T Sample(vector<float, Shape.dimensions+isArray> location) { __requireComputeDerivative(); @@ -581,6 +583,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { case cpp: case hlsl: + case metal: return __getTexture().Sample(__getSampler(), location); case glsl: __intrinsic_asm "$ctexture($0, $1)$z"; @@ -624,8 +627,32 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1_fragment)] + T Sample(vector<float, Shape.dimensions+isArray> location, constexpr vector<int, Shape.planeDimensions> offset) + { + __requireComputeDerivative(); + __target_switch + { + case cpp: + case hlsl: + case metal: + return __getTexture().Sample(__getSampler(), location, offset); + case glsl: + __intrinsic_asm "$ctextureOffsetClampARB($0, $1, $2)$z"; + case spirv: + return spirv_asm + { + OpCapability MinLod; + %sampled : __sampledType(T) = OpImageSampleImplicitLod $this $location None|ConstOffset $offset; + __truncate $$T result __sampledType(T) %sampled; + }; + } + } + + [__readNone] + [ForceInline] __glsl_extension(GL_ARB_sparse_texture_clamp) - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1_fragment)] T Sample(vector<float, Shape.dimensions+isArray> location, vector<int, Shape.planeDimensions> offset, float clamp) { __requireComputeDerivative(); @@ -633,6 +660,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { case cpp: case hlsl: + case metal: return __getTexture().Sample(__getSampler(), location, offset, clamp); case glsl: __intrinsic_asm "$ctextureOffsetClampARB($0, $1, $2, $3)$z"; @@ -648,7 +676,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1_fragment)] T Sample(vector<float, Shape.dimensions+isArray> location, vector<int, Shape.planeDimensions> offset, float clamp, out uint status) { __target_switch @@ -662,7 +690,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1_fragment)] T SampleBias(vector<float, Shape.dimensions+isArray> location, float bias) { __requireComputeDerivative(); @@ -670,6 +698,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { case cpp: case hlsl: + case metal: return __getTexture().SampleBias(__getSampler(), location, bias); case glsl: __intrinsic_asm "$ctexture($0, $1, $2)$z"; @@ -685,7 +714,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_fragment)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1_fragment)] T SampleBias(vector<float, Shape.dimensions+isArray> location, float bias, constexpr vector<int, Shape.planeDimensions> offset) { __requireComputeDerivative(); @@ -693,6 +722,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> { case cpp: case hlsl: + case metal: return __getTexture().SampleBias(__getSampler(), location, bias, offset); case glsl: __intrinsic_asm "$ctextureOffset($0, $1, $3, $2)$z"; @@ -707,7 +737,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(glsl_hlsl_spirv, texture_shadowlod)] + [require(glsl_hlsl_metal_spirv, texture_shadowlod)] float SampleCmp(vector<float, Shape.dimensions+isArray> location, float compareValue) { __target_switch @@ -726,6 +756,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> return __glsl_texture(this, __makeVector(location, compareValue)); } case hlsl: + case metal: return __getTexture().SampleCmp(__getComparisonSampler(), location, compareValue); case spirv: return spirv_asm @@ -737,7 +768,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(glsl_hlsl_spirv, texture_shadowlod)] + [require(glsl_hlsl_metal_spirv, texture_shadowlod)] float SampleCmpLevelZero(vector<float, Shape.dimensions+isArray> location, float compareValue) { __target_switch @@ -752,6 +783,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> return __glsl_texture_level_zero(this, __makeVector(location, compareValue)); } case hlsl: + case metal: return __getTexture().SampleCmpLevelZero(__getComparisonSampler(), location, compareValue); case spirv: const float zeroFloat = 0.0f; @@ -764,7 +796,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(glsl_hlsl_spirv, texture_shadowlod)] + [require(glsl_hlsl_metal_spirv, texture_shadowlod)] float SampleCmp(vector<float, Shape.dimensions+isArray> location, float compareValue, constexpr vector<int, Shape.planeDimensions> offset) { __target_switch @@ -779,6 +811,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> return __glsl_texture_offset(this, __makeVector(location, compareValue), offset); } case hlsl: + case metal: return __getTexture().SampleCmp(__getComparisonSampler(), location, compareValue, offset); case spirv: return spirv_asm @@ -790,7 +823,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(glsl_hlsl_spirv, texture_shadowlod)] + [require(glsl_hlsl_metal_spirv, texture_shadowlod)] float SampleCmpLevelZero(vector<float, Shape.dimensions+isArray> location, float compareValue, constexpr vector<int, Shape.planeDimensions> offset) { __target_switch @@ -805,6 +838,7 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> return __glsl_texture_offset_level_zero(this, __makeVector(location, compareValue), offset); } case hlsl: + case metal: return __getTexture().SampleCmpLevelZero(__getComparisonSampler(), location, compareValue, offset); case spirv: const float zeroFloat = 0.0f; @@ -817,13 +851,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1)] T SampleGrad(vector<float, Shape.dimensions+isArray> location, vector<float, Shape.dimensions> gradX, vector<float, Shape.dimensions> gradY) { __target_switch { case cpp: case hlsl: + case metal: return __getTexture().SampleGrad(__getSampler(), location, gradX, gradY); case glsl: @@ -839,13 +874,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1)] 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 { case cpp: case hlsl: + case metal: return __getTexture().SampleGrad(__getSampler(), location, gradX, gradY, offset); case glsl: __intrinsic_asm "$ctextureGradOffset($0, $1, $2, $3, $4)$z"; @@ -861,13 +897,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] __glsl_extension(GL_ARB_sparse_texture_clamp) - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1)] 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 { case cpp: case hlsl: + case metal: return __getTexture().SampleGrad(__getSampler(), location, gradX, gradY, offset, lodClamp); case glsl: __intrinsic_asm "$ctextureGradOffsetClampARB($0, $1, $2, $3, $4, $5)$z"; @@ -883,13 +920,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(cpp_cuda_glsl_hlsl_spirv, texture_sm_4_1)] + [require(cpp_cuda_glsl_hlsl_metal_spirv, texture_sm_4_1)] T SampleLevel(vector<float, Shape.dimensions+isArray> location, float level) { __target_switch { case cpp: case hlsl: + case metal: return __getTexture().SampleLevel(__getSampler(), location, level); case glsl: __intrinsic_asm "$ctextureLod($0, $1, $2)$z"; @@ -935,13 +973,14 @@ extension __TextureImpl<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format> [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1)] T SampleLevel(vector<float, Shape.dimensions+isArray> location, float level, constexpr vector<int, Shape.planeDimensions> offset) { __target_switch { case cpp: case hlsl: + case metal: return __getTexture().SampleLevel(__getSampler(), location, level, offset); case glsl: @@ -2109,15 +2148,29 @@ for (int isScalarTexture = 0; isScalarTexture <= 1; isScalarTexture++) { }}}} { // begin extension for gather ${{{{ + if (isCombined) + { +}}}} + __intrinsic_op($(kIROp_CombinedTextureSamplerGetTexture)) + __TextureImpl<T, Shape, isArray, isMS, sampleCount, 0, isShadow, 0, format> __getTexture(); + + __intrinsic_op($(kIROp_CombinedTextureSamplerGetSampler)) + SamplerState __getSampler(); + + __intrinsic_op($(kIROp_CombinedTextureSamplerGetSampler)) + SamplerComparisonState __getComparisonSampler(); +${{{{ + } + // Gather component const char* samplerStateParam = isCombined ? "" : " s,"; - const char* metalSupport = isCombined ? "" : "metal_"; - const char* caseMetal = isCombined ? "" : "case metal:"; + const char* getTexture = isCombined ? "__getTexture()" : "this"; for (int isCmp = 0; isCmp < 2; ++isCmp) { const char* cmp = isCmp ? "Cmp" : ""; const char* cmpParam = isCmp ? ", T compareValue" : ""; const char* compareArg = isCmp ? ", compareValue" : ""; const char* samplerStateType = isCombined ? "" : (isCmp ? "SamplerComparisonState" : "SamplerState"); + const char* getSampler = isCombined ? (isCmp ? " __getComparisonSampler()," : " __getSampler(),") : samplerStateParam; const char* componentNames[] = { "", "Red", "Green", "Blue", "Alpha"}; const char* glslComponentNames[] = { ", 0", ", 1", ", 2", ", 3" }; @@ -2126,26 +2179,28 @@ ${{{{ auto glslComponent = (isCmp ? "" :glslComponentNames[componentId == 0 ? 0 : componentId - 1]); }}}} [ForceInline] - [require(glsl_hlsl_$(metalSupport)spirv, texture_gather)] + [require(glsl_hlsl_metal_spirv, texture_gather)] vector<T,4> Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector<float, Shape.dimensions+isArray> location $(cmpParam)) { __target_switch { case hlsl: __intrinsic_asm ".Gather$(cmp)$(componentName)"; - $(caseMetal) + case metal: + return __texture_gather$(cmp)<T>($(getTexture),$(getSampler) location $(compareArg) $(glslComponent)); case glsl: case spirv: return __texture_gather$(cmp)<T>(this,$(samplerStateParam) location $(compareArg) $(glslComponent)); } } [ForceInline] - [require(glsl_hlsl_$(metalSupport)spirv, texture_gather)] + [require(glsl_hlsl_metal_spirv, texture_gather)] 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)$(componentName)"; - $(caseMetal) + case metal: + return __texture_gather$(cmp)_offset<T>($(getTexture),$(getSampler) location $(compareArg), offset $(glslComponent)); case glsl: case spirv: return __texture_gather$(cmp)_offset<T>(this,$(samplerStateParam) location $(compareArg), offset $(glslComponent)); @@ -2347,7 +2402,7 @@ extension __TextureImpl<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,form __glsl_extension(GL_EXT_samplerless_texture_functions) [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_samplerless)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1_samplerless)] get { __target_switch @@ -2355,6 +2410,8 @@ extension __TextureImpl<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,form case cpp: case hlsl: __intrinsic_asm ".operator[]"; + case metal: + return Load(__makeVector(location, 0)); case glsl: return __glsl_load(location); case spirv: @@ -2511,7 +2568,7 @@ extension __TextureImpl<T,Shape,isArray,1,sampleCount,0,isShadow,isCombined,form __glsl_extension(GL_EXT_samplerless_texture_functions) [__readNone] [ForceInline] - [require(cpp_glsl_hlsl_spirv, texture_sm_4_1_samplerless)] + [require(cpp_glsl_hlsl_metal_spirv, texture_sm_4_1_samplerless)] get { __target_switch @@ -2519,6 +2576,7 @@ extension __TextureImpl<T,Shape,isArray,1,sampleCount,0,isShadow,isCombined,form case cpp: case hlsl: __intrinsic_asm "($0).sample[$2][$1]"; + case metal: case glsl: case spirv: return Load(location, sampleIndex); diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index ab22e1f90..7cc056009 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -550,9 +550,18 @@ Result linkAndOptimizeIR( lowerAppendConsumeStructuredBuffers(targetProgram, irModule, sink); } - if (target == CodeGenTarget::HLSL || ArtifactDescUtil::isCpuLikeTarget(artifactDesc)) + switch (target) { + default: + if (!ArtifactDescUtil::isCpuLikeTarget(artifactDesc)) + break; + [[fallthrough]]; + case CodeGenTarget::HLSL: + case CodeGenTarget::Metal: + case CodeGenTarget::MetalLib: + case CodeGenTarget::MetalLibAssembly: lowerCombinedTextureSamplers(irModule, sink); + break; } addUserTypeHintDecorations(irModule); diff --git a/tests/metal/texture-sampler-less.slang b/tests/metal/texture-sampler-less.slang new file mode 100644 index 000000000..70b805ce7 --- /dev/null +++ b/tests/metal/texture-sampler-less.slang @@ -0,0 +1,558 @@ +//TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal -DEMIT_SOURCE +//TEST:SIMPLE(filecheck=METALLIB): -stage compute -entry computeMain -target metallib -DEMIT_SOURCE -DMETALLIB +//TEST:SIMPLE(filecheck=HLSL): -stage compute -entry computeMain -target hlsl -DEMIT_SOURCE + +// It appears that when kIROp_CombinedTextureSamplerGetSampler is used, +// "$1" refers to a sampler not the first parameter of the function. +// This causes to emit an invalid code when the implementation is shared +// between the combined and not-combined. +// The following code, +// void GetDimensions(out float width) { __intrinsic_asm "*$1 = $0.get_width(0)"; } +// gets emitted as following, +// (*(kernelContext_0->t1D_sampler_0) = (kernelContext_0->t1D_texture_0).get_width(0)); +// when it is expected to be, +// (*&width = (kernelContext_0->t1D_texture_0).get_width(0)); +//#define TEST_WHEN_DEFAULT_SAMPLER_WORKS_PROPERLY + +//TEST_INPUT: ubuffer(data=[0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +// TODO: `SamplerXD` cannot be setup with TEST_INPUT method. + +Sampler1D<float> t1D; +Sampler2D<float> t2D; +Sampler3D<float> t3D; +SamplerCube<float> tCube; + +Sampler1DArray<float> t1DArray; +Sampler2DArray<float> t2DArray; +SamplerCubeArray<float> tCubeArray; + +// Metal doc says "For depth texture types, T must be float." +__generic<T : __BuiltinType, let sampleCount:int=0, let format:int=0> +typealias depth2d = __TextureImpl< + T, + __Shape2D, + 0, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +__generic<T : __BuiltinType, let sampleCount:int=0, let format:int=0> +typealias depth2d_array = __TextureImpl< + T, + __Shape2D, + 1, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +__generic<T : __BuiltinType, let sampleCount:int=0, let format:int=0> +typealias depthcube = __TextureImpl< + T, + __ShapeCube, + 0, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +__generic<T : __BuiltinType, let sampleCount:int=0, let format:int=0> +typealias depthcube_array = __TextureImpl< + T, + __ShapeCube, + 1, // isArray + 0, // isMS + sampleCount, + 0, // access + 1, // isShadow + 1, // isCombined + format +>; + +depth2d<float> d2D; +depthcube<float> dCube; +depth2d_array<float> d2DArray; +depthcube_array<float> dCubeArray; + +bool TEST_texture_float() +{ + // Metal textures support `Tv` types, which "denotes a 4-component vector + // type based on the templated type <T> for declaring the texture type: + // - If T is float, Tv is float4. + // - If T is half, Tv is half4. + // - If T is int, Tv is int4. + // - If T is uint, Tv is uint4. + // - If T is short, Tv is short4. + // - If T is ushort, Tv is ushort4." + typealias Tv = vector<float,4>; + + float u = 0; + float u2 = 0.5; + constexpr const float ddx = 0.0f; + constexpr const float ddy = 0.0f; + + uint width = 0, height = 0, depth = 0; + float fwidth = 0.0f, fheight = 0.0f, fdepth = 0.0f; + uint numLevels = 0, elements = 0, sampleCount = 0; + float fnumLevels = 0.0f, felements = 0.0f; + + bool voidResult = true; + + // ====================== + // void GetDimensions() + // ====================== + +#if defined(TEST_WHEN_DEFAULT_SAMPLER_WORKS_PROPERLY) + // M-ETAL: .get_width( + // M-ETALLIB: call {{.*}}.get_width_texture_1d( + t1D.GetDimensions(width); + voidResult = voidResult && (uint(4) == width); + + // M-ETAL: .get_width({{.*}}.get_num_mip_levels() + // M-ETALLIB: call {{.*}}.get_num_mip_levels_texture_1d( + t1D.GetDimensions(0, width, numLevels); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(3) == numLevels); + + // M-ETAL: .get_width({{.*}}.get_height( + // M-ETALLIB: call {{.*}}.get_height_texture_2d( + t2D.GetDimensions(width, height); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + + // M-ETAL: .get_width({{.*}}.get_height({{.*}}.get_num_mip_levels() + // M-ETALLIB: call {{.*}}.get_num_mip_levels_texture_2d( + t2D.GetDimensions(0, width, height, numLevels); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + voidResult = voidResult && (uint(3) == numLevels); + + // M-ETAL: .get_width({{.*}}.get_height({{.*}}.get_depth( + // M-ETALLIB: call {{.*}}.get_depth_texture_3d( + t3D.GetDimensions(width, height, depth); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + voidResult = voidResult && (uint(4) == depth); + + // M-ETAL: .get_width({{.*}}.get_height({{.*}}.get_depth({{.*}}.get_num_mip_levels() + // M-ETALLIB: call {{.*}}.get_num_mip_levels_texture_3d( + t3D.GetDimensions(0, width, height, depth, numLevels); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + voidResult = voidResult && (uint(4) == depth); + voidResult = voidResult && (uint(3) == numLevels); + + // M-ETAL: .get_width({{.*}}.get_height({{.*}} + // M-ETALLIB: call {{.*}}.get_height_texture_cube( + tCube.GetDimensions(width, height); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + + // M-ETAL: .get_width({{.*}}.get_height({{.*}}.get_num_mip_levels() + // M-ETALLIB: call {{.*}}.get_num_mip_levels_texture_cube( + tCube.GetDimensions(0, width, height, numLevels); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + voidResult = voidResult && (uint(3) == numLevels); + + // M-ETAL: .get_width({{.*}}.get_array_size( + // M-ETALLIB: call {{.*}}.get_array_size_texture_1d_array( + t1DArray.GetDimensions(width, elements); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(2) == elements); + + // M-ETAL: .get_width({{.*}}.get_num_mip_levels( + // M-ETALLIB: call {{.*}}.get_num_mip_levels_texture_1d_array( + t1DArray.GetDimensions(0, width, elements, numLevels); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(2) == elements); + voidResult = voidResult && (uint(3) == numLevels); + + // M-ETAL: .get_width({{.*}}.get_height({{.*}}.get_array_size( + // M-ETALLIB: call {{.*}}.get_array_size_texture_2d_array( + t2DArray.GetDimensions(width, height, elements); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + voidResult = voidResult && (uint(2) == elements); + + // M-ETAL: .get_width({{.*}}.get_height({{.*}}.get_num_mip_levels( + // M-ETALLIB: call {{.*}}.get_num_mip_levels_texture_2d_array( + t2DArray.GetDimensions(0, width, height, elements, numLevels); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + voidResult = voidResult && (uint(2) == elements); + voidResult = voidResult && (uint(3) == numLevels); + + // M-ETAL: .get_width({{.*}}.get_height({{.*}}.get_array_size( + // M-ETALLIB: call {{.*}}.get_array_size_texture_cube_array( + tCubeArray.GetDimensions(width, height, elements); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + voidResult = voidResult && (uint(2) == elements); + + // M-ETAL: .get_width({{.*}}.get_height({{.*}}.get_num_mip_levels( + // M-ETALLIB: call {{.*}}.get_num_mip_levels_texture_cube_array( + tCubeArray.GetDimensions(0, width, height, elements, numLevels); + voidResult = voidResult && (uint(4) == width); + voidResult = voidResult && (uint(4) == height); + voidResult = voidResult && (uint(2) == elements); + voidResult = voidResult && (uint(3) == numLevels); +#endif + + bool result = voidResult + // =============================== + // float CalculateLevelOfDetail() + // =============================== + + // METAL: t2D{{.*}}.calculate_clamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_clamped_lod_texture_2d( + && float(0) == t2D.CalculateLevelOfDetail(float2(u, u)) + + // METAL: t3D{{.*}}.calculate_clamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_clamped_lod_texture_3d( + && float(0) == t3D.CalculateLevelOfDetail(float3(u, u, u)) + + // METAL: tCube{{.*}}.calculate_clamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_clamped_lod_texture_cube( + && float(0) == tCube.CalculateLevelOfDetail(normalize(float3(u, 1 - u, u))) + + // METAL: t2DArray{{.*}}.calculate_clamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_clamped_lod_texture_2d_array( + && float(0) == t2DArray.CalculateLevelOfDetail(float2(u, u)) + + // METAL: tCubeArray{{.*}}.calculate_clamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_clamped_lod_texture_cube_array( + && float(0) == tCubeArray.CalculateLevelOfDetail(normalize(float3(u, 1 - u, u))) + + // ======================================== + // float CalculateLevelOfDetailUnclamped() + // ======================================== + + // METAL: t2D{{.*}}.calculate_unclamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_unclamped_lod_texture_2d( + && float(0) >= t2D.CalculateLevelOfDetailUnclamped(float2(u, u)) + + // METAL: t3D{{.*}}.calculate_unclamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_unclamped_lod_texture_3d( + && float(0) >= t3D.CalculateLevelOfDetailUnclamped(float3(u, u, u)) + + // METAL: tCube{{.*}}.calculate_unclamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_unclamped_lod_texture_cube( + && float(0) >= tCube.CalculateLevelOfDetailUnclamped(normalize(float3(u, 1 - u, u))) + + // METAL: t2DArray{{.*}}.calculate_unclamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_unclamped_lod_texture_2d_array( + && float(0) >= t2DArray.CalculateLevelOfDetailUnclamped(float2(u, u)) + + // METAL: tCubeArray{{.*}}.calculate_unclamped_lod({{.*}} + // METALLIB: call {{.*}}.calculate_unclamped_lod_texture_cube_array( + && float(0) >= tCubeArray.CalculateLevelOfDetailUnclamped(normalize(float3(u, 1 - u, u))) + + // =========== + // T Sample() + // =========== + + // METAL: t1D{{.*}}.sample( + // METALLIB: call {{.*}}.sample_texture_1d.v4f32( + && all(Tv(1) == t1D.Sample(u)) + + // METAL: t2D{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_2d.v4f32( + && all(Tv(1) == t2D.Sample(float2(u, u))) + + // METAL: t3D{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_3d.v4f32( + && all(Tv(1) == t3D.Sample(float3(u, u, u))) + + // METAL: tCube{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_cube.v4f32( + && all(Tv(1) == tCube.Sample(normalize(float3(u, 1 - u, u)))) + + // METAL: t1DArray{{.*}}.sample( + // METALLIB: call {{.*}}.sample_texture_1d_array.v4f32( + && all(Tv(1) == t1DArray.Sample(float2(u, 0))) + + // METAL: t2DArray{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.Sample(float3(u, u, 0))) + + // METAL: tCubeArray{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_cube_array.v4f32( + && all(Tv(1) == tCubeArray.Sample(float4(normalize(float3(u, 1 - u, u)), 0))) + + // Offset variant + + // METAL: t2D{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_2d.v4f32( + && all(Tv(1) == t2D.Sample(float2(u, u), int2(1, 1))) + + // METAL: t3D{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_3d.v4f32( + && all(Tv(1) == t3D.Sample(float3(u, u, u), int3(1, 1, 1))) + + // METAL: t2DArray{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.Sample(float3(u, u, 0), int2(1, 1))) + + // Clamp variant + + // METAL: t2D{{.*}}.sample({{.*}} min_lod_clamp( + // METALLIB: call {{.*}}.sample_texture_2d.v4f32( + && all(Tv(1) == t2D.Sample(float2(u, u), int2(1, 1), float(1))) + + // METAL: t3D{{.*}}.sample({{.*}} min_lod_clamp( + // METALLIB: call {{.*}}.sample_texture_3d.v4f32( + && all(Tv(1) == t3D.Sample(float3(u, u, u), int3(1, 1, 1), float(1))) + + // METAL: t2DArray{{.*}}.sample({{.*}} min_lod_clamp( + // METALLIB: call {{.*}}.sample_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.Sample(float3(u, u, 0), int2(1, 1), float(1))) + + // =============== + // T SampleBias() + // =============== + + // METAL: t2D{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_2d.v4f32( + && all(Tv(1) == t2D.SampleBias(float2(u, u), float(-1))) + + // METAL: t3D{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_3d.v4f32( + && all(Tv(1) == t3D.SampleBias(float3(u, u, u), float(-1))) + + // METAL: tCube{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_cube.v4f32( + && all(Tv(1) == tCube.SampleBias(normalize(float3(u, 1 - u, u)), float(-1))) + + // METAL: t2DArray{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.SampleBias(float3(u, u, 0), float(-1))) + + // METAL: tCubeArray{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_cube_array.v4f32( + && all(Tv(1) == tCubeArray.SampleBias(float4(normalize(float3(u, 1 - u, u)), 0), float(-1))) + + // Offset variant + + // METAL: t2D{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_2d.v4f32( + && all(Tv(1) == t2D.SampleBias(float2(u, u), float(-1), int2(1, 1))) + + // METAL: t3D{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_3d.v4f32( + && all(Tv(1) == t3D.SampleBias(float3(u, u, u), float(-1), int3(1, 1, 1))) + + // METAL: t2DArray{{.*}}.sample({{.*}} + // METALLIB: call {{.*}}.sample_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.SampleBias(float3(u, u, 0), float(-1), int2(1, 1))) + + // =================================== + // T SampleLevel() + // =================================== + + // METAL: t2D{{.*}}.sample({{.*}} level( + // METALLIB: call {{.*}}.sample_texture_2d.v4f32( + && all(Tv(1) == t2D.SampleLevel(float2(u, u), 0)) + + // METAL: t3D{{.*}}.sample({{.*}} level( + // METALLIB: call {{.*}}.sample_texture_3d.v4f32( + && all(Tv(1) == t3D.SampleLevel(float3(u, u, u), 0)) + + // METAL: tCube{{.*}}.sample({{.*}} level( + // METALLIB: call {{.*}}.sample_texture_cube.v4f32( + && all(Tv(1) == tCube.SampleLevel(normalize(float3(u, 1 - u, u)), 0)) + + // METAL: t2DArray{{.*}}.sample({{.*}} level( + // METALLIB: call {{.*}}.sample_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.SampleLevel(float3(u, u, 0), 0)) + + // METAL: tCubeArray{{.*}}.sample({{.*}} level( + // METALLIB: call {{.*}}.sample_texture_cube_array.v4f32( + && all(Tv(1) == tCubeArray.SampleLevel(float4(normalize(float3(u, 1 - u, u)), 0), 0)) + + // Offset variant + + // METAL: t2D{{.*}}.sample({{.*}} level( + // METALLIB: call {{.*}}.sample_texture_2d.v4f32( + && all(Tv(1) == t2D.SampleLevel(float2(u, u), 0, int2(1, 1))) + + // METAL: t3D{{.*}}.sample({{.*}} level( + // METALLIB: call {{.*}}.sample_texture_3d.v4f32( + && all(Tv(1) == t3D.SampleLevel(float3(u, u, u), 0, int3(1, 1, 1))) + + // METAL: t2DArray{{.*}}.sample({{.*}} level( + // METALLIB: call {{.*}}.sample_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.SampleLevel(float3(u, u, 0), 0, int2(1, 1))) + + // ================== + // float SampleCmp() + // ================== + + // METAL: d2D{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_2d.f32( + && float(1) == d2D.SampleCmp(float2(u, u), 0) + + // METAL: d2DArray{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_2d_array.f32( + && float(1) == d2DArray.SampleCmp(float3(u, u, 0), 0) + + // METAL: dCube{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_cube.f32( + && float(1) == dCube.SampleCmp(normalize(float3(u, 1 - u, u)), 0) + + // METAL: dCubeArray{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_cube_array.f32( + && float(1) == dCubeArray.SampleCmp(float4(normalize(float3(u, 1 - u, u)), 0), 0) + + // Offset variant + + // METAL: d2D{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_2d.f32( + && float(1) == d2D.SampleCmp(float2(u2, u), 0, int2(0, 0)) + + // =================================== + // float SampleCmpLevelZero() + // =================================== + + // METAL: d2D{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_2d.f32( + && float(1) == d2D.SampleCmpLevelZero(float2(u, u), 0) + + // METAL: d2DArray{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_2d_array.f32( + && float(1) == d2DArray.SampleCmpLevelZero(float3(u, u, 0), 0) + + // METAL: dCube{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_cube.f32( + && float(1) == dCube.SampleCmpLevelZero(normalize(float3(u, 1 - u, u)), 0) + + // METAL: dCubeArray{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_cube_array.f32( + && float(1) == dCubeArray.SampleCmpLevelZero(float4(normalize(float3(u, 1-u, u)), 0), 0) + + // Offset variant + + // METAL: d2D{{.*}}.sample_compare( + // METALLIB: call {{.*}}.sample_compare_depth_2d.f32( + && float(1) == d2D.SampleCmpLevelZero(float2(u2, u), 0, int2(0, 0)) + + // ================================== + // vector<T,4> Gather() + // ================================== + + // METAL: t2D{{.*}}.gather( + // METALLIB: call {{.*}}.gather_texture_2d.v4f32( + && all(Tv(1) == t2D.Gather(float2(u, u))) + + // METAL: tCube{{.*}}.gather( + // METALLIB: call {{.*}}.gather_texture_cube.v4f32( + && all(Tv(1) == tCube.Gather(normalize(float3(u, 1 - u, u)))) + + // METAL: t2DArray{{.*}}.gather( + // METALLIB: call {{.*}}.gather_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.Gather(float3(u, u, 0))) + + // METAL: tCubeArray{{.*}}.gather( + // METALLIB: call {{.*}}.gather_texture_cube_array.v4f32( + && all(Tv(1) == tCubeArray.Gather(float4(normalize(float3(u, 1 - u, u)), 0))) + + // Offset variant + + // METAL: t2D{{.*}}.gather( + // METALLIB: call {{.*}}.gather_texture_2d.v4f32( + && all(Tv(1) == t2D.Gather(float2(u2, u), int2(0, 0))) + + // METAL: t2DArray{{.*}}.gather( + // METALLIB: call {{.*}}.gather_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.Gather(float3(u2, u, 0), int2(0, 0))) + + // ===================================== + // T SampleGrad() + // ===================================== + + // METAL: t2D{{.*}}.sample( + // METALLIB: call {{.*}}.sample_texture_2d_grad.v4f32( + && all(Tv(1) == t2D.SampleGrad(float2(u, u), float2(ddx, ddx), float2(ddy, ddy))) + + // METAL: t3D{{.*}}.sample( + // METALLIB: call {{.*}}.sample_texture_3d_grad.v4f32( + && all(Tv(1) == t3D.SampleGrad(float3(u, u, u), float3(ddx, ddx, ddx), float3(ddy, ddy, ddy))) + + // METAL: tCube{{.*}}.sample( + // METALLIB: call {{.*}}.sample_texture_cube_grad.v4f32( + && all(Tv(1) == tCube.SampleGrad(normalize(float3(u, 1 - u, u)), float3(ddx, ddx, ddx), float3(ddy, ddy, ddy))) + + // METAL: t2DArray{{.*}}.sample( + // METALLIB: call {{.*}}.sample_texture_2d_array_grad.v4f32( + && all(Tv(1) == t2DArray.SampleGrad(float3(u, u, 0.0f), float2(ddx, ddx), float2(ddy, ddy))) + + // Offset variant + + // METAL: t2D{{.*}}.sample( + // METALLIB: call {{.*}}.sample_texture_2d_grad.v4f32( + && all(Tv(1) == t2D.SampleGrad(float2(u2, u), float2(ddx, ddx), float2(ddy, ddy), int2(0, 0))) + + // METAL: t3D{{.*}}.sample( + // METALLIB: call {{.*}}.sample_texture_3d_grad.v4f32( + && all(Tv(1) == t3D.SampleGrad(float3(u2, u, u), float3(ddx, ddx, ddx), float3(ddy, ddy, ddy), int3(0, 0, 0))) + + // METAL: t2DArray{{.*}}.sample( + // METALLIB: call {{.*}}.sample_texture_2d_array_grad.v4f32( + && all(Tv(1) == t2DArray.SampleGrad(float3(u2, u, 0.0f), float2(ddx, ddx), float2(ddy, ddy), int2(0, 0))) + + // =================== + // T Load() + // =================== + +#if defined(TEST_WHEN_DEFAULT_SAMPLER_WORKS_PROPERLY) + // M-ETAL: t1D{{.*}}.read( + // M-ETALLIB: call {{.*}}.read_texture_1d.v4f32( + && all(Tv(1) == t1D.Load(int2(0, 0))) + + // M-ETAL: t2D{{.*}}.read( + // M-ETALLIB: call {{.*}}.read_texture_2d.v4f32( + && all(Tv(1) == t2D.Load(int3(0, 0, 0))) + + // M-ETAL: t3D{{.*}}.read( + // M-ETALLIB: call {{.*}}.read_texture_3d.v4f32( + && all(Tv(1) == t3D.Load(int4(0, 0, 0, 0))) + + // M-ETAL: t1DArray{{.*}}.read( + // M-ETALLIB: call {{.*}}.read_texture_1d_array.v4f32( + && all(Tv(1) == t1DArray.Load(int3(0, 0, 0))) + + // M-ETAL: t2DArray{{.*}}.read( + // M-ETALLIB: call {{.*}}.read_texture_2d_array.v4f32( + && all(Tv(1) == t2DArray.Load(int4(0, 0, 0, 0))) +#endif + ; + + return result; +} + + +[numthreads(1, 1, 1)] +void computeMain() +{ + // SPIR: OpEntryPoint + // HLSL: void computeMain( + + bool result = true + && TEST_texture_float() + ; + + // FUNCTIONAL: 1 + outputBuffer[0] = int(result); +} diff --git a/tests/metal/texture.slang b/tests/metal/texture.slang index fc9347bea..be93d3a5f 100644 --- a/tests/metal/texture.slang +++ b/tests/metal/texture.slang @@ -12,12 +12,6 @@ #define NEED_TO_TEST_FOR_METAL_CAPABILITY 1 #endif -#if defined(EMIT_SOURCE) - // It appears that Slang-test doesn't initialize the depth cube texture - // properly. - #define TEST_WHEN_DEPTH_CUBE_WORKS -#endif - //TEST_INPUT: ubuffer(data=[0], stride=4):out,name outputBuffer RWStructuredBuffer<int> outputBuffer; @@ -92,7 +86,7 @@ typealias depthcube_array = __TextureImpl< //TEST_INPUT: Texture2D(size=4, content = one):name d2D depth2d<float> d2D; -//TEST_INPUT: Texture2D(size=4, content = one):name dCube +//TEST_INPUT: TextureCube(size=4, content = one):name dCube depthcube<float> dCube; //TEST_INPUT: Texture2D(size=4, content = one, arrayLength=2):name d2DArray depth2d_array<float> d2DArray; @@ -248,7 +242,7 @@ bool TEST_texture_float() // METAL: tCube{{.*}}.calculate_clamped_lod({{.*}} // METALLIB: call {{.*}}.calculate_clamped_lod_texture_cube( - && float(0) == tCube.CalculateLevelOfDetail(samplerState, float3(u, u, u)) + && float(0) == tCube.CalculateLevelOfDetail(samplerState, normalize(float3(u, 1 - u, u))) // METAL: t2DArray{{.*}}.calculate_clamped_lod({{.*}} // METALLIB: call {{.*}}.calculate_clamped_lod_texture_2d_array( @@ -256,7 +250,7 @@ bool TEST_texture_float() // METAL: tCubeArray{{.*}}.calculate_clamped_lod({{.*}} // METALLIB: call {{.*}}.calculate_clamped_lod_texture_cube_array( - && float(0) == tCubeArray.CalculateLevelOfDetail(samplerState, float3(u, u, u)) + && float(0) == tCubeArray.CalculateLevelOfDetail(samplerState, normalize(float3(u, 1 - u, u))) // ======================================== // float CalculateLevelOfDetailUnclamped() @@ -317,7 +311,7 @@ bool TEST_texture_float() // METAL: tCubeArray{{.*}}.sample({{.*}} // METALLIB: call {{.*}}.sample_texture_cube_array.v4f32( - && all(Tv(1) == tCubeArray.Sample(samplerState, normalize(float4(u, 1 - u, u, 0)))) + && all(Tv(1) == tCubeArray.Sample(samplerState, float4(normalize(float3(u, 1 - u, u)), 0))) // Offset variant @@ -387,7 +381,7 @@ bool TEST_texture_float() // METAL: tCubeArray{{.*}}.sample({{.*}} // METALLIB: call {{.*}}.sample_texture_cube_array.v4f32( - && all(Tv(1) == tCubeArray.SampleBias(samplerState, normalize(float4(u, 1 - u, u, 0)), float(-1))) + && all(Tv(1) == tCubeArray.SampleBias(samplerState, float4(normalize(float3(u, 1 - u, u)), 0), float(-1))) // Offset variant @@ -469,17 +463,15 @@ bool TEST_texture_float() // METAL: d2DArray{{.*}}.sample_compare( // METALLIB: call {{.*}}.sample_compare_depth_2d_array.f32( - && float(1) == d2DArray.SampleCmp(shadowSampler, normalize(float3(u, 1 - u, u)), 0) + && float(1) == d2DArray.SampleCmp(shadowSampler, float3(u, u, 0), 0) -#if defined(TEST_WHEN_DEPTH_CUBE_WORKS) // METAL: dCube{{.*}}.sample_compare( // METALLIB: call {{.*}}.sample_compare_depth_cube.f32( && float(1) == dCube.SampleCmp(shadowSampler, normalize(float3(u, 1 - u, u)), 0) // METAL: dCubeArray{{.*}}.sample_compare( // METALLIB: call {{.*}}.sample_compare_depth_cube_array.f32( - && float(1) == dCubeArray.SampleCmp(shadowSampler, normalize(float4(u, 1-u, u, u)), 0) -#endif + && float(1) == dCubeArray.SampleCmp(shadowSampler, float4(normalize(float3(u, 1 - u, u)), 0), 0) // Offset variant @@ -497,17 +489,15 @@ bool TEST_texture_float() // METAL: d2DArray{{.*}}.sample_compare( // METALLIB: call {{.*}}.sample_compare_depth_2d_array.f32( - && float(1) == d2DArray.SampleCmpLevelZero(shadowSampler, normalize(float3(u, 1 - u, u)), 0) + && float(1) == d2DArray.SampleCmpLevelZero(shadowSampler, float3(u, u, 0), 0) -#if defined(TEST_WHEN_DEPTH_CUBE_WORKS) // METAL: dCube{{.*}}.sample_compare( // METALLIB: call {{.*}}.sample_compare_depth_cube.f32( && float(1) == dCube.SampleCmpLevelZero(shadowSampler, normalize(float3(u, 1 - u, u)), 0) // METAL: dCubeArray{{.*}}.sample_compare( // METALLIB: call {{.*}}.sample_compare_depth_cube_array.f32( - && float(1) == dCubeArray.SampleCmpLevelZero(shadowSampler, normalize(float4(u, 1-u, u, u)), 0) -#endif + && float(1) == dCubeArray.SampleCmpLevelZero(shadowSampler, float4(normalize(float3(u, 1-u, u)), 0), 0) // Offset variant |
