From 2b76466c4bc8a47bd4ac69994bafdbb2924272c2 Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Thu, 9 Jan 2025 23:49:59 -0500 Subject: Add CalculateLevelOfDetail* overloads for comparison samplers (#6018) * add CalculateLevelOfDetail* intrinsics for comparison samplers * fix dx12 test * fix metallib test * fix merge conflict --------- Co-authored-by: Yong He --- source/slang/hlsl.meta.slang | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'source/slang') diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 07bf2ffbd..5fb82d875 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -814,6 +814,7 @@ extension _Texture case spirv: return (spirv_asm { + OpCapability ImageQuery; result:$$float2 = OpImageQueryLod $this $location }).x; } @@ -839,6 +840,7 @@ extension _Texture case spirv: return (spirv_asm { + OpCapability ImageQuery; result:$$float2 = OpImageQueryLod $this $location }).y; } @@ -1517,6 +1519,7 @@ extension _Texture __intrinsic_asm "textureQueryLod($p, $2).x"; case spirv: return (spirv_asm { + OpCapability ImageQuery; %sampledImage : __sampledImageType(this) = OpSampledImage $this $s; result:$$float2 = OpImageQueryLod %sampledImage $location; }).x; @@ -1539,6 +1542,53 @@ extension _Texture __intrinsic_asm "textureQueryLod($p, $2).y"; case spirv: return (spirv_asm { + OpCapability ImageQuery; + %sampledImage : __sampledImageType(this) = OpSampledImage $this $s; + result:$$float2 = OpImageQueryLod %sampledImage $location; + }).y; + } + } + + [__readNone] + [ForceInline] + [require(glsl_hlsl_metal_spirv, texture_querylod)] + float CalculateLevelOfDetail(SamplerComparisonState s, TextureCoord location) + { + __requireComputeDerivative(); + __target_switch + { + case hlsl: + __intrinsic_asm ".CalculateLevelOfDetail"; + case metal: + __intrinsic_asm ".calculate_clamped_lod"; + case glsl: + __intrinsic_asm "textureQueryLod($p, $2).x"; + case spirv: + return (spirv_asm { + OpCapability ImageQuery; + %sampledImage : __sampledImageType(this) = OpSampledImage $this $s; + result:$$float2 = OpImageQueryLod %sampledImage $location; + }).x; + } + } + + [__readNone] + [ForceInline] + [require(glsl_hlsl_metal_spirv, texture_querylod)] + float CalculateLevelOfDetailUnclamped(SamplerComparisonState s, TextureCoord location) + { + __requireComputeDerivative(); + __target_switch + { + case hlsl: + __intrinsic_asm ".CalculateLevelOfDetailUnclamped"; + case metal: + __intrinsic_asm ".calculate_unclamped_lod"; + case glsl: + __intrinsic_asm "textureQueryLod($p, $2).y"; + case spirv: + return (spirv_asm { + OpCapability ImageQuery; %sampledImage : __sampledImageType(this) = OpSampledImage $this $s; result:$$float2 = OpImageQueryLod %sampledImage $location; }).y; -- cgit v1.2.3