-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPIRV][HLSL] Handle arrays of resources
This commit adds the ability to get a particular resource from an array of resources using the handle_fromBinding intrinsic. The main changes are: 1. Create an array when generating the type. 2. Add capabilities from [SPV_EXT_descriptor_indexing](https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/EXT/SPV_EXT_descriptor_indexing.html). We are still missing the ability to declare a runtime array. That will be done in a follow up PR.
- Loading branch information
Showing
18 changed files
with
813 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv1.5-vulkan-library %s -o - | FileCheck %s | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.5-vulkan-library %s -o - -filetype=obj | spirv-val %} | ||
|
||
; CHECK: OpCapability Shader | ||
; CHECK-NEXT: OpCapability SampledImageArrayDynamicIndexing | ||
; CHECK-NEXT: OpCapability Sampled1D | ||
; CHECK-NOT: OpCapability | ||
|
||
; CHECK-DAG: OpDecorate [[Var:%[0-9]+]] DescriptorSet 3 | ||
; CHECK-DAG: OpDecorate [[Var]] Binding 4 | ||
|
||
; CHECK-DAG: [[int:%[0-9]+]] = OpTypeInt 32 0 | ||
; CHECK-DAG: [[BufferType:%[0-9]+]] = OpTypeImage [[int]] 1D 2 0 0 1 R32i {{$}} | ||
; CHECK-DAG: [[CombindedType:%[0-9]+]] = OpTypeSampledImage [[BufferType]] | ||
; CHECK-DAG: [[BufferPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[CombindedType]] | ||
; CHECK-DAG: [[ArraySize:%[0-9]+]] = OpConstant [[int]] 3 | ||
; CHECK-DAG: [[One:%[0-9]+]] = OpConstant [[int]] 1 | ||
; CHECK-DAG: [[Zero:%[0-9]+]] = OpConstant [[int]] 0 | ||
; CHECK-DAG: [[BufferArrayType:%[0-9]+]] = OpTypeArray [[CombindedType]] [[ArraySize]] | ||
; CHECK-DAG: [[ArrayPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[BufferArrayType]] | ||
; CHECK-DAG: [[Var]] = OpVariable [[ArrayPtrType]] UniformConstant | ||
|
||
; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}} | ||
; CHECK-NEXT: OpLabel | ||
define void @main() #0 { | ||
; CHECK: [[ac:%[0-9]+]] = OpAccessChain [[BufferPtrType]] [[Var]] [[Zero]] | ||
; CHECK: [[buffer:%[0-9]+]] = OpLoad [[CombindedType]] [[ac]] | ||
%buffer0 = call target("spirv.SampledImage", i32, 0, 2, 0, 0, 1, 24) | ||
@llvm.spv.handle.fromBinding.tspirv.Image_f32_0_2_0_0_1_24( | ||
i32 3, i32 4, i32 3, i32 0, i1 false) | ||
|
||
; CHECK: [[ac:%[0-9]+]] = OpAccessChain [[BufferPtrType]] [[Var]] [[One]] | ||
; CHECK: [[buffer:%[0-9]+]] = OpLoad [[CombindedType]] [[ac]] | ||
%buffer1 = call target("spirv.SampledImage", i32, 0, 2, 0, 0, 1, 24) | ||
@llvm.spv.handle.fromBinding.tspirv.Image_f32_0_2_0_0_1_24( | ||
i32 3, i32 4, i32 3, i32 1, i1 false) | ||
ret void | ||
} | ||
|
||
attributes #0 = { convergent noinline norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
47 changes: 47 additions & 0 deletions
47
llvm/test/CodeGen/SPIRV/CombinedSamplerImageNonUniformIdx.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv1.5-vulkan-library %s -o - | FileCheck %s | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.5-vulkan-library %s -o - -filetype=obj | spirv-val %} | ||
|
||
; CHECK: OpCapability Shader | ||
; CHECK: OpCapability ShaderNonUniform | ||
; CHECK-NEXT: OpCapability SampledImageArrayNonUniformIndexing | ||
; CHECK-NEXT: OpCapability Sampled1D | ||
; CHECK-NOT: OpCapability | ||
|
||
; CHECK-DAG: OpDecorate [[Var:%[0-9]+]] DescriptorSet 3 | ||
; CHECK-DAG: OpDecorate [[Var]] Binding 4 | ||
; CHECK: OpDecorate [[Zero:%[0-9]+]] NonUniform | ||
; CHECK: OpDecorate [[ac0:%[0-9]+]] NonUniform | ||
; CHECK: OpDecorate [[ld0:%[0-9]+]] NonUniform | ||
; CHECK: OpDecorate [[One:%[0-9]+]] NonUniform | ||
; CHECK: OpDecorate [[ac1:%[0-9]+]] NonUniform | ||
; CHECK: OpDecorate [[ld1:%[0-9]+]] NonUniform | ||
|
||
; CHECK-DAG: [[int:%[0-9]+]] = OpTypeInt 32 0 | ||
; CHECK-DAG: [[BufferType:%[0-9]+]] = OpTypeImage [[int]] 1D 2 0 0 1 R32i {{$}} | ||
; CHECK-DAG: [[CombindedType:%[0-9]+]] = OpTypeSampledImage [[BufferType]] | ||
; CHECK-DAG: [[BufferPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[CombindedType]] | ||
; CHECK-DAG: [[ArraySize:%[0-9]+]] = OpConstant [[int]] 3 | ||
; CHECK-DAG: [[One]] = OpConstant [[int]] 1 | ||
; CHECK-DAG: [[Zero]] = OpConstant [[int]] 0 | ||
; CHECK-DAG: [[BufferArrayType:%[0-9]+]] = OpTypeArray [[CombindedType]] [[ArraySize]] | ||
; CHECK-DAG: [[ArrayPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[BufferArrayType]] | ||
; CHECK-DAG: [[Var]] = OpVariable [[ArrayPtrType]] UniformConstant | ||
|
||
; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}} | ||
; CHECK-NEXT: OpLabel | ||
define void @main() #0 { | ||
; CHECK: [[ac0]] = OpAccessChain [[BufferPtrType]] [[Var]] [[Zero]] | ||
; CHECK: [[ld0:%[0-9]+]] = OpLoad [[CombindedType]] [[ac0]] | ||
%buffer0 = call target("spirv.SampledImage", i32, 0, 2, 0, 0, 1, 24) | ||
@llvm.spv.handle.fromBinding.tspirv.Image_f32_0_2_0_0_1_24( | ||
i32 3, i32 4, i32 3, i32 0, i1 true) | ||
|
||
; CHECK: [[ac1]] = OpAccessChain [[BufferPtrType]] [[Var]] [[One]] | ||
; CHECK: [[ld1]] = OpLoad [[CombindedType]] [[ac1]] | ||
%buffer1 = call target("spirv.SampledImage", i32, 0, 2, 0, 0, 1, 24) | ||
@llvm.spv.handle.fromBinding.tspirv.Image_f32_0_2_0_0_1_24( | ||
i32 3, i32 4, i32 3, i32 1, i1 true) | ||
ret void | ||
} | ||
|
||
attributes #0 = { convergent noinline norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
Oops, something went wrong.