summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2025-01-09 23:49:59 -0500
committerGitHub <noreply@github.com>2025-01-09 20:49:59 -0800
commit2b76466c4bc8a47bd4ac69994bafdbb2924272c2 (patch)
treec000028f7ae01e8f275dc18ea6431934bc8d6152 /source/slang
parent55ff4686e5685c414d82f16b9c1a4a331bd4f853 (diff)
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 <yonghe@outlook.com>
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/hlsl.meta.slang50
1 files changed, 50 insertions, 0 deletions
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<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
case spirv:
return (spirv_asm
{
+ OpCapability ImageQuery;
result:$$float2 = OpImageQueryLod $this $location
}).x;
}
@@ -839,6 +840,7 @@ extension _Texture<T,Shape,isArray,isMS,sampleCount,0,isShadow,1,format>
case spirv:
return (spirv_asm
{
+ OpCapability ImageQuery;
result:$$float2 = OpImageQueryLod $this $location
}).y;
}
@@ -1517,6 +1519,7 @@ extension _Texture<T,Shape,isArray,isMS,sampleCount,access,isShadow,0,format>
__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<T,Shape,isArray,isMS,sampleCount,access,isShadow,0,format>
__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;