summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDarrelFW321 <60972474+DarrelFW321@users.noreply.github.com>2025-04-03 19:54:02 -0400
committerGitHub <noreply@github.com>2025-04-03 23:54:02 +0000
commitdf7c66be49822d650f8956662b16db49bae31d09 (patch)
treee6da39abb3e1278e7f107f13a31802b850adaafc /source
parentac0dc491e1d39dc469b8879dc839b1ac2e76e33d (diff)
Add sparse texture Load intrinsic for SPIRV (#6702)
* Implement sparse texture Load intrinsics for SPIRV * changed test name from TEST_load to TEST_sparse --------- Co-authored-by: Darren Wihandi <65404740+fairywreath@users.noreply.github.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/hlsl.meta.slang71
1 files changed, 69 insertions, 2 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index 558ac6301..5f0edb3f9 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -3772,12 +3772,47 @@ extension _Texture<T,Shape,isArray,0,sampleCount,0,isShadow,isCombined,format>
[__readNone]
[ForceInline]
- [require(hlsl, texture_sm_4_1_samplerless)]
+ [require(hlsl_spirv, texture_sm_4_1_samplerless)]
T Load(vector<int, Shape.dimensions+isArray+1> location, constexpr vector<int, Shape.planeDimensions> offset, out uint status)
{
__target_switch
{
case hlsl: __intrinsic_asm ".Load";
+ case spirv:
+ const int lodLoc = Shape.dimensions+isArray;
+ let coord = __vectorReshape<Shape.dimensions+isArray>(location);
+ let lod = location[lodLoc];
+ if (isCombined != 0)
+ {
+ return spirv_asm
+ {
+ OpCapability SparseResidency;
+ %sparseResultType = OpTypeStruct $$uint __sampledType(T);
+ %image:__imageType(this) = OpImage $this;
+
+ %sparseResult:%sparseResultType = OpImageSparseFetch %image $coord Lod|ConstOffset $lod $offset;
+ %residentCode:$$uint = OpCompositeExtract %sparseResult 0;
+ %sampled:__sampledType(T) = OpCompositeExtract %sparseResult 1;
+
+ OpStore &status %residentCode;
+ __truncate $$T result __sampledType(T) %sampled;
+ };
+ }
+ else
+ {
+ return spirv_asm
+ {
+ OpCapability SparseResidency;
+ %sparseResultType = OpTypeStruct $$uint __sampledType(T);
+
+ %sparseResult:%sparseResultType = OpImageSparseFetch $this $coord Lod|ConstOffset $lod $offset;
+ %residentCode:$$uint = OpCompositeExtract %sparseResult 0;
+ %sampled:__sampledType(T) = OpCompositeExtract %sparseResult 1;
+
+ OpStore &status %residentCode;
+ __truncate $$T result __sampledType(T) %sampled;
+ };
+ }
default:
status = 0;
return Load(location, offset);
@@ -3952,12 +3987,44 @@ extension _Texture<T,Shape,isArray,1,sampleCount,0,isShadow,isCombined,format>
[__readNone]
[ForceInline]
- [require(hlsl, texture_sm_4_1_samplerless)]
+ [require(hlsl_spirv, texture_sm_4_1_samplerless)]
T Load(vector<int, Shape.dimensions+isArray> location, int sampleIndex, constexpr vector<int, Shape.planeDimensions> offset, out uint status)
{
__target_switch
{
case hlsl: __intrinsic_asm ".Load";
+ case spirv:
+ if (isCombined != 0)
+ {
+ return spirv_asm
+ {
+ OpCapability SparseResidency;
+ %sparseResultType = OpTypeStruct $$uint __sampledType(T);
+ %image:__imageType(this) = OpImage $this;
+
+ %sparseResult:%sparseResultType = OpImageSparseFetch %image $location ConstOffset|Sample $offset $sampleIndex;
+ %residentCode:$$uint = OpCompositeExtract %sparseResult 0;
+ %sampled:__sampledType(T) = OpCompositeExtract %sparseResult 1;
+
+ OpStore &status %residentCode;
+ __truncate $$T result __sampledType(T) %sampled;
+ };
+ }
+ else
+ {
+ return spirv_asm
+ {
+ OpCapability SparseResidency;
+ %sparseResultType = OpTypeStruct $$uint __sampledType(T);
+
+ %sparseResult:%sparseResultType = OpImageSparseFetch $this $location ConstOffset|Sample $offset $sampleIndex;
+ %residentCode:$$uint = OpCompositeExtract %sparseResult 0;
+ %sampled:__sampledType(T) = OpCompositeExtract %sparseResult 1;
+
+ OpStore &status %residentCode;
+ __truncate $$T result __sampledType(T) %sampled;
+ };
+ }
default:
status = 0;
return Load(location, sampleIndex, offset);