Bladeren bron

[spirv] Support Sparse Residency struct

Also update tests to reflect the new order of instructions
Ehsan Nasiri 6 jaren geleden
bovenliggende
commit
5619892aa6
27 gewijzigde bestanden met toevoegingen van 92 en 113 verwijderingen
  1. 4 0
      tools/clang/include/clang/SPIRV/LowerTypeVisitor.h
  2. 17 0
      tools/clang/lib/SPIRV/LowerTypeVisitor.cpp
  3. 2 3
      tools/clang/test/CodeGenSPIRV/texture.array.gather-alpha.hlsl
  4. 3 5
      tools/clang/test/CodeGenSPIRV/texture.array.gather-blue.hlsl
  5. 3 5
      tools/clang/test/CodeGenSPIRV/texture.array.gather-green.hlsl
  6. 3 5
      tools/clang/test/CodeGenSPIRV/texture.array.gather-red.hlsl
  7. 2 2
      tools/clang/test/CodeGenSPIRV/texture.array.gather.hlsl
  8. 1 2
      tools/clang/test/CodeGenSPIRV/texture.array.load.hlsl
  9. 3 7
      tools/clang/test/CodeGenSPIRV/texture.array.sample-bias.hlsl
  10. 2 2
      tools/clang/test/CodeGenSPIRV/texture.array.sample-cmp-level-zero.hlsl
  11. 2 2
      tools/clang/test/CodeGenSPIRV/texture.array.sample-cmp.hlsl
  12. 4 7
      tools/clang/test/CodeGenSPIRV/texture.array.sample-grad.hlsl
  13. 4 6
      tools/clang/test/CodeGenSPIRV/texture.array.sample-level.hlsl
  14. 4 6
      tools/clang/test/CodeGenSPIRV/texture.array.sample.hlsl
  15. 3 5
      tools/clang/test/CodeGenSPIRV/texture.gather-alpha.hlsl
  16. 2 5
      tools/clang/test/CodeGenSPIRV/texture.gather-blue.hlsl
  17. 2 3
      tools/clang/test/CodeGenSPIRV/texture.gather-cmp.hlsl
  18. 3 5
      tools/clang/test/CodeGenSPIRV/texture.gather-green.hlsl
  19. 2 5
      tools/clang/test/CodeGenSPIRV/texture.gather-red.hlsl
  20. 3 3
      tools/clang/test/CodeGenSPIRV/texture.gather.hlsl
  21. 4 4
      tools/clang/test/CodeGenSPIRV/texture.load.hlsl
  22. 4 6
      tools/clang/test/CodeGenSPIRV/texture.sample-bias.hlsl
  23. 2 2
      tools/clang/test/CodeGenSPIRV/texture.sample-cmp-level-zero.hlsl
  24. 2 2
      tools/clang/test/CodeGenSPIRV/texture.sample-cmp.hlsl
  25. 5 9
      tools/clang/test/CodeGenSPIRV/texture.sample-grad.hlsl
  26. 3 6
      tools/clang/test/CodeGenSPIRV/texture.sample-level.hlsl
  27. 3 6
      tools/clang/test/CodeGenSPIRV/texture.sample.hlsl

+ 4 - 0
tools/clang/include/clang/SPIRV/LowerTypeVisitor.h

@@ -42,6 +42,10 @@ public:
   // underlying image.
   bool visit(SpirvSampledImage *);
 
+  // Custom visitor for sparse image operations: the result type must be the
+  // Sparse Residency Struct.
+  bool visit(SpirvImageOp *);
+
   /// The "sink" visit function for all instructions.
   ///
   /// By default, all other visit instructions redirect to this visit function.

+ 17 - 0
tools/clang/lib/SPIRV/LowerTypeVisitor.cpp

@@ -91,6 +91,23 @@ bool LowerTypeVisitor::visit(SpirvSampledImage *instr) {
   return true;
 }
 
+bool LowerTypeVisitor::visit(SpirvImageOp *instr) {
+  if (!visitInstruction(instr))
+    return false;
+
+  // Sparse image operations return a sparse residency struct.
+  const auto *resultType = instr->getResultType();
+  if (instr->isSparse()) {
+    const auto *uintType = spvContext.getUIntType(32);
+    const auto *sparseResidencyStruct = spvContext.getStructType(
+        {StructType::FieldInfo(uintType, "Residency.Code"),
+         StructType::FieldInfo(resultType, "Result.Type")},
+        "SparseResidencyStruct");
+    instr->setResultType(sparseResidencyStruct);
+  }
+  return true;
+}
+
 const SpirvType *LowerTypeVisitor::lowerType(const SpirvType *type,
                                              SpirvLayoutRule rule,
                                              SourceLocation loc) {

+ 2 - 3
tools/clang/test/CodeGenSPIRV/texture.array.gather-alpha.hlsl

@@ -9,14 +9,13 @@ TextureCubeArray<uint4> tCubeArray : register(t3);
 
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
+
 // CHECK:      [[c12:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
 // CHECK:      [[c34:%\d+]] = OpConstantComposite %v2int %int_3 %int_4
 // CHECK:      [[c56:%\d+]] = OpConstantComposite %v2int %int_5 %int_6
 // CHECK:      [[c78:%\d+]] = OpConstantComposite %v2int %int_7 %int_8
 // CHECK:    [[c1to8:%\d+]] = OpConstantComposite %_arr_v2int_uint_4 [[c12]] [[c34]] [[c56]] [[c78]]
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
-
 // CHECK: [[cv4f_1_5:%\d+]] = OpConstantComposite %v4float %float_1_5 %float_1_5 %float_1_5 %float_1_5
 
 float4 main(float3 location: A) : SV_Target {

+ 3 - 5
tools/clang/test/CodeGenSPIRV/texture.array.gather-blue.hlsl

@@ -10,18 +10,16 @@ TextureCubeArray<uint4> tCubeArray : register(t3);
 // CHECK: OpCapability ImageGatherExtended
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4int
+// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4uint
+
 // CHECK:      [[c12:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
 // CHECK:      [[c34:%\d+]] = OpConstantComposite %v2int %int_3 %int_4
 // CHECK:      [[c56:%\d+]] = OpConstantComposite %v2int %int_5 %int_6
 // CHECK:      [[c78:%\d+]] = OpConstantComposite %v2int %int_7 %int_8
 // CHECK:    [[c1to8:%\d+]] = OpConstantComposite %_arr_v2int_uint_4 [[c12]] [[c34]] [[c56]] [[c78]]
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4int
-
 // CHECK: [[cv4f_1_5:%\d+]] = OpConstantComposite %v4float %float_1_5 %float_1_5 %float_1_5 %float_1_5
 
-// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4uint
-
 float4 main(float3 location: A) : SV_Target {
 // CHECK:            [[t2f4:%\d+]] = OpLoad %type_2d_image_array %t2f4
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 3 - 5
tools/clang/test/CodeGenSPIRV/texture.array.gather-green.hlsl

@@ -9,18 +9,16 @@ TextureCubeArray<int4> tCubeArray : register(t3);
 
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
+// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
+
 // CHECK:      [[c12:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
 // CHECK:      [[c34:%\d+]] = OpConstantComposite %v2int %int_3 %int_4
 // CHECK:      [[c56:%\d+]] = OpConstantComposite %v2int %int_5 %int_6
 // CHECK:      [[c78:%\d+]] = OpConstantComposite %v2int %int_7 %int_8
 // CHECK:    [[c1to8:%\d+]] = OpConstantComposite %_arr_v2int_uint_4 [[c12]] [[c34]] [[c56]] [[c78]]
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
-
 // CHECK: [[cv4f_1_5:%\d+]] = OpConstantComposite %v4float %float_1_5 %float_1_5 %float_1_5 %float_1_5
 
-// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
-
 float4 main(float3 location: A) : SV_Target {
 // CHECK:            [[t2f4:%\d+]] = OpLoad %type_2d_image_array %t2f4
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 3 - 5
tools/clang/test/CodeGenSPIRV/texture.array.gather-red.hlsl

@@ -9,18 +9,16 @@ TextureCubeArray<int4> tCubeArray : register(t3);
 
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
+// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
+
 // CHECK:      [[c12:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
 // CHECK:      [[c34:%\d+]] = OpConstantComposite %v2int %int_3 %int_4
 // CHECK:      [[c56:%\d+]] = OpConstantComposite %v2int %int_5 %int_6
 // CHECK:      [[c78:%\d+]] = OpConstantComposite %v2int %int_7 %int_8
 // CHECK:    [[c1to8:%\d+]] = OpConstantComposite %_arr_v2int_uint_4 [[c12]] [[c34]] [[c56]] [[c78]]
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
-
 // CHECK: [[cv4f_1_5:%\d+]] = OpConstantComposite %v4float %float_1_5 %float_1_5 %float_1_5 %float_1_5
 
-// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
-
 float4 main(float3 location: A, int2 offset : B) : SV_Target {
 // CHECK:            [[t2f4:%\d+]] = OpLoad %type_2d_image_array %t2f4
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 2 - 2
tools/clang/test/CodeGenSPIRV/texture.array.gather.hlsl

@@ -11,11 +11,11 @@ TextureCubeArray <float>  t8 : register(t8);
 // CHECK: OpCapability ImageGatherExtended
 // CHECK: OpCapability SparseResidency
 
-// CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4int
 // CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4float
 
+// CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4
+
 float4 main(float3 location: A, int2 offset: B) : SV_Target {
 
 // CHECK:              [[t2:%\d+]] = OpLoad %type_2d_image_array %t2

+ 1 - 2
tools/clang/test/CodeGenSPIRV/texture.array.load.hlsl

@@ -6,10 +6,9 @@ Texture2DArray <float4> t2 : register(t2);
 
 // CHECK: OpCapability SparseResidency
 
-// CHECK: [[v3ic:%\d+]] = OpConstantComposite %v3int %int_1 %int_2 %int_3
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 
+// CHECK: [[v3ic:%\d+]] = OpConstantComposite %v3int %int_1 %int_2 %int_3
 // CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
 
 float4 main(int4 location: A) : SV_Target {

+ 3 - 7
tools/clang/test/CodeGenSPIRV/texture.array.sample-bias.hlsl

@@ -14,18 +14,14 @@ TextureCubeArray <float3> t5 : register(t5);
 // CHECK: OpCapability MinLod
 // CHECK: OpCapability SparseResidency
 
-// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_1
 // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image_array
-
-// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_1
 // CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image_array
-
-// CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_1
 // CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_cube_image_array
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 
-
+// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_1
+// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_1
+// CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_1
 float4 main(int2 offset : A) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image_array %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 2 - 2
tools/clang/test/CodeGenSPIRV/texture.array.sample-cmp-level-zero.hlsl

@@ -8,12 +8,12 @@ TextureCubeArray <float>  t3 : register(t3);
 
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %float
+
 // CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_1
 // CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_1
 // CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_1
 
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %float
-
 float4 main(int2 offset: A, float comparator: B) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image_array %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 2 - 2
tools/clang/test/CodeGenSPIRV/texture.array.sample-cmp.hlsl

@@ -9,12 +9,12 @@ TextureCubeArray <float>  t3 : register(t3);
 // CHECK: OpCapability MinLod
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %float
+
 // CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_1
 // CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_1
 // CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_1
 
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %float
-
 float4 main(int2 offset: A, float comparator: B) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image_array %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 4 - 7
tools/clang/test/CodeGenSPIRV/texture.array.sample-grad.hlsl

@@ -15,21 +15,18 @@ TextureCubeArray <float2> t5 : register(t5);
 // CHECK: OpCapability MinLod
 // CHECK: OpCapability SparseResidency
 
-// CHECK: [[v2f_1:%\d+]] = OpConstantComposite %v2float %float_1 %float_1
 // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image_array
+// CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image_array
+// CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_cube_image_array
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 
+// CHECK: [[v2f_1:%\d+]] = OpConstantComposite %v2float %float_1 %float_1
 // CHECK: [[v3f_1:%\d+]] = OpConstantComposite %v3float %float_1 %float_1 %float_1
 // CHECK: [[v2f_2:%\d+]] = OpConstantComposite %v2float %float_2 %float_2
 // CHECK: [[v2f_3:%\d+]] = OpConstantComposite %v2float %float_3 %float_3
-// CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image_array
-
 // CHECK: [[v4f_1:%\d+]] = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
 // CHECK: [[v3f_2:%\d+]] = OpConstantComposite %v3float %float_2 %float_2 %float_2
 // CHECK: [[v3f_3:%\d+]] = OpConstantComposite %v3float %float_3 %float_3 %float_3
-// CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_cube_image_array
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
-
 float4 main(int2 offset : A) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image_array %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 4 - 6
tools/clang/test/CodeGenSPIRV/texture.array.sample-level.hlsl

@@ -13,17 +13,15 @@ TextureCubeArray <float3> t5 : register(t5);
 // CHECK: OpCapability ImageGatherExtended
 // CHECK: OpCapability SparseResidency
 
-// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_1
 // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image_array
-
-// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_1
 // CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image_array
-
-// CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_1
 // CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_cube_image_array
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 
+// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_1
+// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_1
+// CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_1
+
 float4 main(int2 offset : A) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image_array %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 4 - 6
tools/clang/test/CodeGenSPIRV/texture.array.sample.hlsl

@@ -13,17 +13,15 @@ TextureCubeArray <float3> t5 : register(t5);
 // CHECK: OpCapability MinLod
 // CHECK: OpCapability SparseResidency
 
-// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_0_5 %float_1
 // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image_array
-
-// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_1
 // CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image_array
-
-// CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_0_5 %float_0_25 %float_0_125 %float_1
 // CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_cube_image_array
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 
+// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_0_5 %float_1
+// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_1
+// CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_0_5 %float_0_25 %float_0_125 %float_1
+
 float4 main() : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image_array %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 3 - 5
tools/clang/test/CodeGenSPIRV/texture.gather-alpha.hlsl

@@ -10,18 +10,16 @@ TextureCube<uint4> tCube : register(t3);
 // CHECK: OpCapability ImageGatherExtended
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4int
+// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4uint
+
 // CHECK:      [[c12:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
 // CHECK:      [[c34:%\d+]] = OpConstantComposite %v2int %int_3 %int_4
 // CHECK:      [[c56:%\d+]] = OpConstantComposite %v2int %int_5 %int_6
 // CHECK:      [[c78:%\d+]] = OpConstantComposite %v2int %int_7 %int_8
 // CHECK:    [[c1to8:%\d+]] = OpConstantComposite %_arr_v2int_uint_4 [[c12]] [[c34]] [[c56]] [[c78]]
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4int
-
 // CHECK: [[cv3f_1_5:%\d+]] = OpConstantComposite %v3float %float_1_5 %float_1_5 %float_1_5
 
-// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4uint
-
 float4 main(float2 location: A) : SV_Target {
 // CHECK:            [[t2f4:%\d+]] = OpLoad %type_2d_image %t2f4
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 2 - 5
tools/clang/test/CodeGenSPIRV/texture.gather-blue.hlsl

@@ -9,19 +9,16 @@ TextureCube<int4> tCube : register(t3);
 
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
+// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
 
 // CHECK:      [[c12:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
 // CHECK:      [[c34:%\d+]] = OpConstantComposite %v2int %int_3 %int_4
 // CHECK:      [[c56:%\d+]] = OpConstantComposite %v2int %int_5 %int_6
 // CHECK:      [[c78:%\d+]] = OpConstantComposite %v2int %int_7 %int_8
 // CHECK:    [[c1to8:%\d+]] = OpConstantComposite %_arr_v2int_uint_4 [[c12]] [[c34]] [[c56]] [[c78]]
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
-
 // CHECK: [[cv3f_1_5:%\d+]] = OpConstantComposite %v3float %float_1_5 %float_1_5 %float_1_5
 
-// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
-
 float4 main(float2 location: A) : SV_Target {
 // CHECK:            [[t2f4:%\d+]] = OpLoad %type_2d_image %t2f4
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 2 - 3
tools/clang/test/CodeGenSPIRV/texture.gather-cmp.hlsl

@@ -8,11 +8,10 @@ Texture2D<float>  t3 : register(t3);
 TextureCube<float>t4 : register(t4);
 // .GatherCmp() does not support Texture1D and Texture3D.
 
-// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
-// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_2
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 
+// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
+// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_2
 // CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1_5 %float_1_5 %float_1_5
 
 float4 main(float2 location: A, float comparator: B, int2 offset: C) : SV_Target {

+ 3 - 5
tools/clang/test/CodeGenSPIRV/texture.gather-green.hlsl

@@ -10,18 +10,16 @@ TextureCube<int4> tCube : register(t3);
 // CHECK: OpCapability ImageGatherExtended
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
+// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
+
 // CHECK:      [[c12:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
 // CHECK:      [[c34:%\d+]] = OpConstantComposite %v2int %int_3 %int_4
 // CHECK:      [[c56:%\d+]] = OpConstantComposite %v2int %int_5 %int_6
 // CHECK:      [[c78:%\d+]] = OpConstantComposite %v2int %int_7 %int_8
 // CHECK:    [[c1to8:%\d+]] = OpConstantComposite %_arr_v2int_uint_4 [[c12]] [[c34]] [[c56]] [[c78]]
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
-
 // CHECK: [[cv3f_1_5:%\d+]] = OpConstantComposite %v3float %float_1_5 %float_1_5 %float_1_5
 
-// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
-
 float4 main(float2 location: A) : SV_Target {
 // CHECK:            [[t2f4:%\d+]] = OpLoad %type_2d_image %t2f4
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 2 - 5
tools/clang/test/CodeGenSPIRV/texture.gather-red.hlsl

@@ -9,19 +9,16 @@ TextureCube<int4> tCube : register(t3);
 
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
+// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
 
 // CHECK:      [[c12:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
 // CHECK:      [[c34:%\d+]] = OpConstantComposite %v2int %int_3 %int_4
 // CHECK:      [[c56:%\d+]] = OpConstantComposite %v2int %int_5 %int_6
 // CHECK:      [[c78:%\d+]] = OpConstantComposite %v2int %int_7 %int_8
 // CHECK:    [[c1to8:%\d+]] = OpConstantComposite %_arr_v2int_uint_4 [[c12]] [[c34]] [[c56]] [[c78]]
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
-
 // CHECK: [[cv3f_1_5:%\d+]] = OpConstantComposite %v3float %float_1_5 %float_1_5 %float_1_5
 
-// CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
-
 float4 main(float2 location: A, int2 offset : B) : SV_Target {
 // CHECK:            [[t2f4:%\d+]] = OpLoad %type_2d_image %t2f4
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 3 - 3
tools/clang/test/CodeGenSPIRV/texture.gather.hlsl

@@ -10,12 +10,12 @@ TextureCube <float>  t8 : register(t8);
 
 // CHECK: OpCapability SparseResidency
 
-// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
-// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_3
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4int
 // CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4float
 
+// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
+// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_3
+
 float4 main(float2 location: A) : SV_Target {
 
 // CHECK:              [[t2:%\d+]] = OpLoad %type_2d_image %t2

+ 4 - 4
tools/clang/test/CodeGenSPIRV/texture.load.hlsl

@@ -15,14 +15,14 @@ Texture2DMSArray<float3> t8 : register(t8);
 // CHECK: OpCapability ImageGatherExtended
 // CHECK: OpCapability SparseResidency
 
-// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
-// CHECK: [[v4ic:%\d+]] = OpConstantComposite %v4int %int_1 %int_2 %int_3 %int_4
-// CHECK: [[v3ic:%\d+]] = OpConstantComposite %v3int %int_3 %int_3 %int_3
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 // CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
 // CHECK: %SparseResidencyStruct_1 = OpTypeStruct %uint %v4uint
 
+// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
+// CHECK: [[v4ic:%\d+]] = OpConstantComposite %v4int %int_1 %int_2 %int_3 %int_4
+// CHECK: [[v3ic:%\d+]] = OpConstantComposite %v3int %int_3 %int_3 %int_3
+
 float4 main(int3 location: A, int offset: B) : SV_Target {
     uint status;
 

+ 4 - 6
tools/clang/test/CodeGenSPIRV/texture.sample-bias.hlsl

@@ -16,17 +16,15 @@ Texture3D   <float2> t6 : register(t6);
 // CHECK: OpCapability SparseResidency
 
 // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
-// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_2
-// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_2 %int_2
-
 // CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image
-// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_3
-
 // CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_3d_image
 // CHECK: %type_sampled_image_2 = OpTypeSampledImage %type_cube_image
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 
+// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_2
+// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_2 %int_2
+// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_3
+
 float4 main(int3 offset: A) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 2 - 2
tools/clang/test/CodeGenSPIRV/texture.sample-cmp-level-zero.hlsl

@@ -9,11 +9,11 @@ TextureCube <float>  t4 : register(t4);
 
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %float
+
 // CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_2
 // CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_3
 
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %float
-
 float4 main(int2 offset: A, float comparator: B) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 2 - 2
tools/clang/test/CodeGenSPIRV/texture.sample-cmp.hlsl

@@ -10,11 +10,11 @@ TextureCube <float>  t4 : register(t4);
 // CHECK: OpCapability MinLod
 // CHECK: OpCapability SparseResidency
 
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %float
+
 // CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_2
 // CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_3
 
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %float
-
 float4 main(int2 offset: A, float comparator: B) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 5 - 9
tools/clang/test/CodeGenSPIRV/texture.sample-grad.hlsl

@@ -16,22 +16,18 @@ Texture2D   <float2> t6 : register(t6);
 // CHECK: OpCapability SparseResidency
 
 // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
+// CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image
+// CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_3d_image
+// CHECK: %type_sampled_image_2 = OpTypeSampledImage %type_cube_image
+// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
+
 // CHECK: [[v2f_1:%\d+]] = OpConstantComposite %v2float %float_1 %float_1
 // CHECK: [[v2f_2:%\d+]] = OpConstantComposite %v2float %float_2 %float_2
 // CHECK: [[v2f_3:%\d+]] = OpConstantComposite %v2float %float_3 %float_3
-
-// CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image
 // CHECK: [[v3f_1:%\d+]] = OpConstantComposite %v3float %float_1 %float_1 %float_1
 // CHECK: [[v3f_2:%\d+]] = OpConstantComposite %v3float %float_2 %float_2 %float_2
 // CHECK: [[v3f_3:%\d+]] = OpConstantComposite %v3float %float_3 %float_3 %float_3
 // CHECK:   [[v3i_3:%\d+]] = OpConstantComposite %v3int %int_3 %int_3 %int_3
-
-// CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_3d_image
-// CHECK: %type_sampled_image_2 = OpTypeSampledImage %type_cube_image
-
-// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
-
-
 float4 main(int2 offset : A) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image %t1
 // CHECK-NEXT:   [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler

+ 3 - 6
tools/clang/test/CodeGenSPIRV/texture.sample-level.hlsl

@@ -15,17 +15,14 @@ TextureCube <float2> t6 : register(t6);
 // CHECK: OpCapability SparseResidency
 
 // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
-// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_2
-// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_2 %int_2
-
 // CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image
-// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_3
-
 // CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_3d_image
 // CHECK: %type_sampled_image_2 = OpTypeSampledImage %type_cube_image
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 
+// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_1 %float_2
+// CHECK: [[v2ic:%\d+]] = OpConstantComposite %v2int %int_2 %int_2
+// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_1 %float_2 %float_3
 
 float4 main(int3 offset: A) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image %t1

+ 3 - 6
tools/clang/test/CodeGenSPIRV/texture.sample.hlsl

@@ -16,17 +16,14 @@ TextureCube <float3> t6 : register(t6);
 // CHECK: OpCapability SparseResidency
 
 // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
-// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_0_5 %float_0_25
-
 // CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image
-// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0_3
-// CHECK: [[v3ic:%\d+]] = OpConstantComposite %v3int %int_3 %int_3 %int_3
-
 // CHECK: %type_sampled_image_1 = OpTypeSampledImage %type_3d_image
 // CHECK: %type_sampled_image_2 = OpTypeSampledImage %type_cube_image
-
 // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float
 
+// CHECK: [[v2fc:%\d+]] = OpConstantComposite %v2float %float_0_5 %float_0_25
+// CHECK: [[v3fc:%\d+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0_3
+// CHECK: [[v3ic:%\d+]] = OpConstantComposite %v3int %int_3 %int_3 %int_3
 
 float4 main(int2 offset: A) : SV_Target {
 // CHECK:              [[t1:%\d+]] = OpLoad %type_1d_image %t1