瀏覽代碼

[spirv] Convert to use 2 as the depth value for OpTypeImage (#1261)

2 means no indication as to whether this is a depth or non-depth
image.

Reverted "Hack OpSampledImage for depth-comparison sampling".

This reverts commit 0f165c6483802f84a36ad7275a2c7dc541bddb31.
Lei Zhang 7 年之前
父節點
當前提交
babfc756c3

+ 16 - 16
docs/SPIR-V.rst

@@ -598,22 +598,22 @@ are translated into SPIR-V ``OpTypeImage``, with parameters:
 ----------------------- -------------------------- ------------------------------------------------------------------------------------------
 ----------------------- -------------------------- ------------------------------------------------------------------------------------------
      Texture Type         Descriptor Type    RO/RW    Storage Class        Dim    Depth Arrayed MS Sampled   Image Format      Capability
      Texture Type         Descriptor Type    RO/RW    Storage Class        Dim    Depth Arrayed MS Sampled   Image Format      Capability
 ======================= ==================== ===== =================== ========== ===== ======= == ======= ================ =================
 ======================= ==================== ===== =================== ========== ===== ======= == ======= ================ =================
-``Texture1D``           Sampled Image         RO   ``UniformConstant`` ``1D``      0       0    0    1     ``Unknown``
-``Texture2D``           Sampled Image         RO   ``UniformConstant`` ``2D``      0       0    0    1     ``Unknown``
-``Texture3D``           Sampled Image         RO   ``UniformConstant`` ``3D``      0       0    0    1     ``Unknown``
-``TextureCube``         Sampled Image         RO   ``UniformConstant`` ``Cube``    0       0    0    1     ``Unknown``
-``Texture1DArray``      Sampled Image         RO   ``UniformConstant`` ``1D``      0       1    0    1     ``Unknown``
-``Texture2DArray``      Sampled Image         RO   ``UniformConstant`` ``2D``      0       1    0    1     ``Unknown``
-``Texture2DMS``         Sampled Image         RO   ``UniformConstant`` ``2D``      0       0    1    1     ``Unknown``
-``Texture2DMSArray``    Sampled Image         RO   ``UniformConstant`` ``2D``      0       1    1    1     ``Unknown``      ``ImageMSArray``
-``TextureCubeArray``    Sampled Image         RO   ``UniformConstant`` ``3D``      0       1    0    1     ``Unknown``
-``Buffer<T>``           Uniform Texel Buffer  RO   ``UniformConstant`` ``Buffer``  0       0    0    1     Depends on ``T`` ``SampledBuffer``
-``RWBuffer<T>``         Storage Texel Buffer  RW   ``UniformConstant`` ``Buffer``  0       0    0    2     Depends on ``T`` ``SampledBuffer``
-``RWTexture1D<T>``      Storage Image         RW   ``UniformConstant`` ``1D``      0       0    0    2     Depends on ``T``
-``RWTexture2D<T>``      Storage Image         RW   ``UniformConstant`` ``2D``      0       0    0    2     Depends on ``T``
-``RWTexture3D<T>``      Storage Image         RW   ``UniformConstant`` ``3D``      0       0    0    2     Depends on ``T``
-``RWTexture1DArray<T>`` Storage Image         RW   ``UniformConstant`` ``1D``      0       1    0    2     Depends on ``T``
-``RWTexture2DArray<T>`` Storage Image         RW   ``UniformConstant`` ``2D``      0       1    0    2     Depends on ``T``
+``Texture1D``           Sampled Image         RO   ``UniformConstant`` ``1D``      2       0    0    1     ``Unknown``
+``Texture2D``           Sampled Image         RO   ``UniformConstant`` ``2D``      2       0    0    1     ``Unknown``
+``Texture3D``           Sampled Image         RO   ``UniformConstant`` ``3D``      2       0    0    1     ``Unknown``
+``TextureCube``         Sampled Image         RO   ``UniformConstant`` ``Cube``    2       0    0    1     ``Unknown``
+``Texture1DArray``      Sampled Image         RO   ``UniformConstant`` ``1D``      2       1    0    1     ``Unknown``
+``Texture2DArray``      Sampled Image         RO   ``UniformConstant`` ``2D``      2       1    0    1     ``Unknown``
+``Texture2DMS``         Sampled Image         RO   ``UniformConstant`` ``2D``      2       0    1    1     ``Unknown``
+``Texture2DMSArray``    Sampled Image         RO   ``UniformConstant`` ``2D``      2       1    1    1     ``Unknown``      ``ImageMSArray``
+``TextureCubeArray``    Sampled Image         RO   ``UniformConstant`` ``3D``      2       1    0    1     ``Unknown``
+``Buffer<T>``           Uniform Texel Buffer  RO   ``UniformConstant`` ``Buffer``  2       0    0    1     Depends on ``T`` ``SampledBuffer``
+``RWBuffer<T>``         Storage Texel Buffer  RW   ``UniformConstant`` ``Buffer``  2       0    0    2     Depends on ``T`` ``SampledBuffer``
+``RWTexture1D<T>``      Storage Image         RW   ``UniformConstant`` ``1D``      2       0    0    2     Depends on ``T``
+``RWTexture2D<T>``      Storage Image         RW   ``UniformConstant`` ``2D``      2       0    0    2     Depends on ``T``
+``RWTexture3D<T>``      Storage Image         RW   ``UniformConstant`` ``3D``      2       0    0    2     Depends on ``T``
+``RWTexture1DArray<T>`` Storage Image         RW   ``UniformConstant`` ``1D``      2       1    0    2     Depends on ``T``
+``RWTexture2DArray<T>`` Storage Image         RW   ``UniformConstant`` ``2D``      2       1    0    2     Depends on ``T``
 ======================= ==================== ===== =================== ========== ===== ======= == ======= ================ =================
 ======================= ==================== ===== =================== ========== ===== ======= == ======= ================ =================
 
 
 The meanings of the headers in the above table is explained in ``OpTypeImage``
 The meanings of the headers in the above table is explained in ``OpTypeImage``

+ 1 - 10
tools/clang/lib/SPIRV/SPIRVEmitter.cpp

@@ -4198,16 +4198,7 @@ SPIRVEmitter::processTextureSampleCmpCmpLevelZero(const CXXMemberCallExpr *expr,
   const uint32_t lod = isCmp ? 0 : theBuilder.getConstantFloat32(0);
   const uint32_t lod = isCmp ? 0 : theBuilder.getConstantFloat32(0);
 
 
   const auto retType = expr->getDirectCallee()->getReturnType();
   const auto retType = expr->getDirectCallee()->getReturnType();
-  // TODO: Hack. Drivers are expecting the Depth value in OpTypeImage to match
-  // the OpImageSample* instruction: Depth=0 for normal sampling, and Depth=1
-  // for depth-comparison sampling. That behavior is not what the spec says;
-  // Vulkan spec reads "The 'Depth' operand of OpTypeImage is ignored."
-  // We always generate OpTypeImage variables with Depth=0. Hack this only
-  // depth-comparison sampling code path to use Depth=1 for the OpTypeImage
-  // used by OpSampledImage. This causes inconsistent types in SPIR-V, but
-  // pleases drivers. Whatever.
-  const auto imageType = typeTranslator.translateResourceType(
-      imageExpr->getType(), LayoutRule::Void, /*isDepthCmp=*/true);
+  const auto imageType = typeTranslator.translateType(imageExpr->getType());
 
 
   return createImageSample(
   return createImageSample(
       retType, imageType, image, sampler,
       retType, imageType, image, sampler,

+ 5 - 6
tools/clang/lib/SPIRV/TypeTranslator.cpp

@@ -1312,8 +1312,7 @@ TypeTranslator::collectDeclsInDeclContext(const DeclContext *declContext) {
   return decls;
   return decls;
 }
 }
 
 
-uint32_t TypeTranslator::translateResourceType(QualType type, LayoutRule rule,
-                                               bool isDepthCmp) {
+uint32_t TypeTranslator::translateResourceType(QualType type, LayoutRule rule) {
   // Resource types are either represented like C struct or C++ class in the
   // Resource types are either represented like C struct or C++ class in the
   // AST. Samplers are represented like C struct, so isStructureType() will
   // AST. Samplers are represented like C struct, so isStructureType() will
   // return true for it; textures are represented like C++ class, so
   // return true for it; textures are represented like C++ class, so
@@ -1343,7 +1342,7 @@ uint32_t TypeTranslator::translateResourceType(QualType type, LayoutRule rule,
       const auto isMS = (name == "Texture2DMS" || name == "Texture2DMSArray");
       const auto isMS = (name == "Texture2DMS" || name == "Texture2DMSArray");
       const auto sampledType = hlsl::GetHLSLResourceResultType(type);
       const auto sampledType = hlsl::GetHLSLResourceResultType(type);
       return theBuilder.getImageType(translateType(getElementType(sampledType)),
       return theBuilder.getImageType(translateType(getElementType(sampledType)),
-                                     dim, isDepthCmp, isArray, isMS);
+                                     dim, /*depth*/ 2, isArray, isMS);
     }
     }
 
 
     // There is no RWTexture3DArray
     // There is no RWTexture3DArray
@@ -1355,7 +1354,7 @@ uint32_t TypeTranslator::translateResourceType(QualType type, LayoutRule rule,
       const auto sampledType = hlsl::GetHLSLResourceResultType(type);
       const auto sampledType = hlsl::GetHLSLResourceResultType(type);
       const auto format = translateSampledTypeToImageFormat(sampledType);
       const auto format = translateSampledTypeToImageFormat(sampledType);
       return theBuilder.getImageType(translateType(getElementType(sampledType)),
       return theBuilder.getImageType(translateType(getElementType(sampledType)),
-                                     dim, /*depth*/ 0, isArray, /*MS*/ 0,
+                                     dim, /*depth*/ 2, isArray, /*MS*/ 0,
                                      /*Sampled*/ 2u, format);
                                      /*Sampled*/ 2u, format);
     }
     }
   }
   }
@@ -1451,7 +1450,7 @@ uint32_t TypeTranslator::translateResourceType(QualType type, LayoutRule rule,
     const auto format = translateSampledTypeToImageFormat(sampledType);
     const auto format = translateSampledTypeToImageFormat(sampledType);
     return theBuilder.getImageType(
     return theBuilder.getImageType(
         translateType(getElementType(sampledType)), spv::Dim::Buffer,
         translateType(getElementType(sampledType)), spv::Dim::Buffer,
-        /*depth*/ 0, /*isArray*/ 0, /*ms*/ 0,
+        /*depth*/ 2, /*isArray*/ 0, /*ms*/ 0,
         /*sampled*/ name == "Buffer" ? 1 : 2, format);
         /*sampled*/ name == "Buffer" ? 1 : 2, format);
   }
   }
 
 
@@ -1481,7 +1480,7 @@ uint32_t TypeTranslator::translateResourceType(QualType type, LayoutRule rule,
     const auto sampledType = hlsl::GetHLSLResourceResultType(type);
     const auto sampledType = hlsl::GetHLSLResourceResultType(type);
     return theBuilder.getImageType(
     return theBuilder.getImageType(
         translateType(getElementType(sampledType)), spv::Dim::SubpassData,
         translateType(getElementType(sampledType)), spv::Dim::SubpassData,
-        /*depth*/ 0, /*isArray*/ false, /*ms*/ name == "SubpassInputMS",
+        /*depth*/ 2, /*isArray*/ false, /*ms*/ name == "SubpassInputMS",
         /*sampled*/ 2);
         /*sampled*/ 2);
   }
   }
 
 

+ 4 - 5
tools/clang/lib/SPIRV/TypeTranslator.h

@@ -55,11 +55,6 @@ public:
   uint32_t translateType(QualType type,
   uint32_t translateType(QualType type,
                          LayoutRule layoutRule = LayoutRule::Void);
                          LayoutRule layoutRule = LayoutRule::Void);
 
 
-  /// \brief Translates the given HLSL resource type into its SPIR-V
-  /// instructions and returns the <result-id>. Returns 0 on failure.
-  uint32_t translateResourceType(QualType type, LayoutRule rule,
-                                 bool isDepthCmp = false);
-
   /// \brief Generates the SPIR-V type for the counter associated with a
   /// \brief Generates the SPIR-V type for the counter associated with a
   /// {Append|Consume}StructuredBuffer: an OpTypeStruct with a single 32-bit
   /// {Append|Consume}StructuredBuffer: an OpTypeStruct with a single 32-bit
   /// integer value. This type will be decorated with BufferBlock.
   /// integer value. This type will be decorated with BufferBlock.
@@ -290,6 +285,10 @@ private:
   /// constnesss and literalness.
   /// constnesss and literalness.
   static bool canTreatAsSameScalarType(QualType type1, QualType type2);
   static bool canTreatAsSameScalarType(QualType type1, QualType type2);
 
 
+  /// \brief Translates the given HLSL resource type into its SPIR-V
+  /// instructions and returns the <result-id>. Returns 0 on failure.
+  uint32_t translateResourceType(QualType type, LayoutRule rule);
+
   /// \brief For the given sampled type, returns the corresponding image format
   /// \brief For the given sampled type, returns the corresponding image format
   /// that can be used to create an image object.
   /// that can be used to create an image object.
   spv::ImageFormat translateSampledTypeToImageFormat(QualType type);
   spv::ImageFormat translateSampledTypeToImageFormat(QualType type);

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

@@ -1,33 +0,0 @@
-// Run: %dxc -T ps_6_0 -E main
-
-// CHECK:        %type_2d_image = OpTypeImage %float 2D 0 0 0 1 Unknown
-// CHECK:   %type_sampled_image = OpTypeSampledImage %type_2d_image
-// CHECK:      %type_2d_image_0 = OpTypeImage %float 2D 1 0 0 1 Unknown
-// CHECK: %type_sampled_image_0 = OpTypeSampledImage %type_2d_image_0
-
-// CHECK: %gTexture = OpVariable %_ptr_UniformConstant_type_2d_image UniformConstant
-Texture2D              gTexture;
-SamplerState           gSampler;
-SamplerComparisonState gCmpSampler;
-
-float4 main(float3 input : A) : SV_Target {
-  // Use OpSampledImage with Depth=0 OpTypeImage for normal sampling
-// CHECK: [[tex:%\d+]] = OpLoad %type_2d_image %gTexture
-// CHECK:  [[si:%\d+]] = OpSampledImage %type_sampled_image [[tex]]
-// CHECK:                OpImageSampleImplicitLod %v4float [[si]]
-
-  // Use OpSampledImage with Depth=1 OpTypeImage for depth-comparison sampling
-    float4 a = gTexture.Sample(gSampler, input.xy);
-// CHECK: [[tex:%\d+]] = OpLoad %type_2d_image %gTexture
-// CHECK:  [[si:%\d+]] = OpSampledImage %type_sampled_image_0 [[tex]]
-// CHECK:                OpImageSampleDrefImplicitLod %float [[si]]
-    float4 b = gTexture.SampleCmp(gCmpSampler, input.xy, input.z);
-
-  // Use OpSampledImage with Depth=1 OpTypeImage for depth-comparison sampling
-// CHECK: [[tex:%\d+]] = OpLoad %type_2d_image %gTexture
-// CHECK:  [[si:%\d+]] = OpSampledImage %type_sampled_image_0 [[tex]]
-// CHECK:                OpImageSampleDrefExplicitLod %float [[si]]
-    float4 c = gTexture.SampleCmpLevelZero(gCmpSampler, input.xy, input.z);
-
-    return a + b + c;
-}

+ 18 - 18
tools/clang/test/CodeGenSPIRV/type.buffer.hlsl

@@ -3,68 +3,68 @@
 // CHECK: OpCapability SampledBuffer
 // CHECK: OpCapability SampledBuffer
 // CHECK: OpCapability StorageImageExtendedFormats
 // CHECK: OpCapability StorageImageExtendedFormats
 
 
-// CHECK: %type_buffer_image = OpTypeImage %int Buffer 0 0 0 1 R32i
+// CHECK: %type_buffer_image = OpTypeImage %int Buffer 2 0 0 1 R32i
 // CHECK: %_ptr_UniformConstant_type_buffer_image = OpTypePointer UniformConstant %type_buffer_image
 // CHECK: %_ptr_UniformConstant_type_buffer_image = OpTypePointer UniformConstant %type_buffer_image
 Buffer<int> intbuf;
 Buffer<int> intbuf;
-// CHECK: %type_buffer_image_0 = OpTypeImage %uint Buffer 0 0 0 1 R32ui
+// CHECK: %type_buffer_image_0 = OpTypeImage %uint Buffer 2 0 0 1 R32ui
 // CHECK: %_ptr_UniformConstant_type_buffer_image_0 = OpTypePointer UniformConstant %type_buffer_image_0
 // CHECK: %_ptr_UniformConstant_type_buffer_image_0 = OpTypePointer UniformConstant %type_buffer_image_0
 Buffer<uint> uintbuf;
 Buffer<uint> uintbuf;
-// CHECK: %type_buffer_image_1 = OpTypeImage %float Buffer 0 0 0 1 R32f
+// CHECK: %type_buffer_image_1 = OpTypeImage %float Buffer 2 0 0 1 R32f
 // CHECK: %_ptr_UniformConstant_type_buffer_image_1 = OpTypePointer UniformConstant %type_buffer_image_1
 // CHECK: %_ptr_UniformConstant_type_buffer_image_1 = OpTypePointer UniformConstant %type_buffer_image_1
 Buffer<float> floatbuf;
 Buffer<float> floatbuf;
 
 
-// CHECK: %type_buffer_image_2 = OpTypeImage %int Buffer 0 0 0 2 R32i
+// CHECK: %type_buffer_image_2 = OpTypeImage %int Buffer 2 0 0 2 R32i
 // CHECK: %_ptr_UniformConstant_type_buffer_image_2 = OpTypePointer UniformConstant %type_buffer_image_2
 // CHECK: %_ptr_UniformConstant_type_buffer_image_2 = OpTypePointer UniformConstant %type_buffer_image_2
 RWBuffer<int> intrwbuf;
 RWBuffer<int> intrwbuf;
-// CHECK: %type_buffer_image_3 = OpTypeImage %uint Buffer 0 0 0 2 R32ui
+// CHECK: %type_buffer_image_3 = OpTypeImage %uint Buffer 2 0 0 2 R32ui
 // CHECK: %_ptr_UniformConstant_type_buffer_image_3 = OpTypePointer UniformConstant %type_buffer_image_3
 // CHECK: %_ptr_UniformConstant_type_buffer_image_3 = OpTypePointer UniformConstant %type_buffer_image_3
 RWBuffer<uint> uintrwbuf;
 RWBuffer<uint> uintrwbuf;
-// CHECK: %type_buffer_image_4 = OpTypeImage %float Buffer 0 0 0 2 R32f
+// CHECK: %type_buffer_image_4 = OpTypeImage %float Buffer 2 0 0 2 R32f
 // CHECK: %_ptr_UniformConstant_type_buffer_image_4 = OpTypePointer UniformConstant %type_buffer_image_4
 // CHECK: %_ptr_UniformConstant_type_buffer_image_4 = OpTypePointer UniformConstant %type_buffer_image_4
 RWBuffer<float> floatrwbuf;
 RWBuffer<float> floatrwbuf;
 
 
-// CHECK: %type_buffer_image_5 = OpTypeImage %int Buffer 0 0 0 1 Rg32i
+// CHECK: %type_buffer_image_5 = OpTypeImage %int Buffer 2 0 0 1 Rg32i
 // CHECK: %_ptr_UniformConstant_type_buffer_image_5 = OpTypePointer UniformConstant %type_buffer_image_5
 // CHECK: %_ptr_UniformConstant_type_buffer_image_5 = OpTypePointer UniformConstant %type_buffer_image_5
 Buffer<int2> int2buf;
 Buffer<int2> int2buf;
-// CHECK: %type_buffer_image_6 = OpTypeImage %uint Buffer 0 0 0 1 Rg32ui
+// CHECK: %type_buffer_image_6 = OpTypeImage %uint Buffer 2 0 0 1 Rg32ui
 // CHECK: %_ptr_UniformConstant_type_buffer_image_6 = OpTypePointer UniformConstant %type_buffer_image_6
 // CHECK: %_ptr_UniformConstant_type_buffer_image_6 = OpTypePointer UniformConstant %type_buffer_image_6
 Buffer<uint2> uint2buf;
 Buffer<uint2> uint2buf;
-// CHECK: %type_buffer_image_7 = OpTypeImage %float Buffer 0 0 0 1 Rg32f
+// CHECK: %type_buffer_image_7 = OpTypeImage %float Buffer 2 0 0 1 Rg32f
 // CHECK: %_ptr_UniformConstant_type_buffer_image_7 = OpTypePointer UniformConstant %type_buffer_image_7
 // CHECK: %_ptr_UniformConstant_type_buffer_image_7 = OpTypePointer UniformConstant %type_buffer_image_7
 Buffer<float2> float2buf;
 Buffer<float2> float2buf;
 
 
-// CHECK: %type_buffer_image_8 = OpTypeImage %int Buffer 0 0 0 2 Rg32i
+// CHECK: %type_buffer_image_8 = OpTypeImage %int Buffer 2 0 0 2 Rg32i
 // CHECK: %_ptr_UniformConstant_type_buffer_image_8 = OpTypePointer UniformConstant %type_buffer_image_8
 // CHECK: %_ptr_UniformConstant_type_buffer_image_8 = OpTypePointer UniformConstant %type_buffer_image_8
 RWBuffer<int2> int2rwbuf;
 RWBuffer<int2> int2rwbuf;
-// CHECK: %type_buffer_image_9 = OpTypeImage %uint Buffer 0 0 0 2 Rg32ui
+// CHECK: %type_buffer_image_9 = OpTypeImage %uint Buffer 2 0 0 2 Rg32ui
 // CHECK: %_ptr_UniformConstant_type_buffer_image_9 = OpTypePointer UniformConstant %type_buffer_image_9
 // CHECK: %_ptr_UniformConstant_type_buffer_image_9 = OpTypePointer UniformConstant %type_buffer_image_9
 RWBuffer<uint2> uint2rwbuf;
 RWBuffer<uint2> uint2rwbuf;
-// CHECK: %type_buffer_image_10 = OpTypeImage %float Buffer 0 0 0 2 Rg32f
+// CHECK: %type_buffer_image_10 = OpTypeImage %float Buffer 2 0 0 2 Rg32f
 // CHECK: %_ptr_UniformConstant_type_buffer_image_10 = OpTypePointer UniformConstant %type_buffer_image_10
 // CHECK: %_ptr_UniformConstant_type_buffer_image_10 = OpTypePointer UniformConstant %type_buffer_image_10
 RWBuffer<float2> float2rwbuf;
 RWBuffer<float2> float2rwbuf;
 
 
-// CHECK: %type_buffer_image_11 = OpTypeImage %int Buffer 0 0 0 1 Rgba32i
+// CHECK: %type_buffer_image_11 = OpTypeImage %int Buffer 2 0 0 1 Rgba32i
 // CHECK: %_ptr_UniformConstant_type_buffer_image_11 = OpTypePointer UniformConstant %type_buffer_image_11
 // CHECK: %_ptr_UniformConstant_type_buffer_image_11 = OpTypePointer UniformConstant %type_buffer_image_11
 Buffer<int3> int3buf;
 Buffer<int3> int3buf;
 Buffer<int4> int4buf;
 Buffer<int4> int4buf;
-// CHECK: %type_buffer_image_12 = OpTypeImage %uint Buffer 0 0 0 1 Rgba32ui
+// CHECK: %type_buffer_image_12 = OpTypeImage %uint Buffer 2 0 0 1 Rgba32ui
 // CHECK: %_ptr_UniformConstant_type_buffer_image_12 = OpTypePointer UniformConstant %type_buffer_image_12
 // CHECK: %_ptr_UniformConstant_type_buffer_image_12 = OpTypePointer UniformConstant %type_buffer_image_12
 Buffer<uint3> uint3buf;
 Buffer<uint3> uint3buf;
 Buffer<uint4> uint4buf;
 Buffer<uint4> uint4buf;
-// CHECK: %type_buffer_image_13 = OpTypeImage %float Buffer 0 0 0 1 Rgba32f
+// CHECK: %type_buffer_image_13 = OpTypeImage %float Buffer 2 0 0 1 Rgba32f
 // CHECK: %_ptr_UniformConstant_type_buffer_image_13 = OpTypePointer UniformConstant %type_buffer_image_13
 // CHECK: %_ptr_UniformConstant_type_buffer_image_13 = OpTypePointer UniformConstant %type_buffer_image_13
 Buffer<float3> float3buf;
 Buffer<float3> float3buf;
 Buffer<float4> float4buf;
 Buffer<float4> float4buf;
 
 
-// CHECK: %type_buffer_image_14 = OpTypeImage %int Buffer 0 0 0 2 Rgba32i
+// CHECK: %type_buffer_image_14 = OpTypeImage %int Buffer 2 0 0 2 Rgba32i
 // CHECK: %_ptr_UniformConstant_type_buffer_image_14 = OpTypePointer UniformConstant %type_buffer_image_14
 // CHECK: %_ptr_UniformConstant_type_buffer_image_14 = OpTypePointer UniformConstant %type_buffer_image_14
 RWBuffer<int3> int3rwbuf;
 RWBuffer<int3> int3rwbuf;
 RWBuffer<int4> int4rwbuf;
 RWBuffer<int4> int4rwbuf;
-// CHECK: %type_buffer_image_15 = OpTypeImage %uint Buffer 0 0 0 2 Rgba32ui
+// CHECK: %type_buffer_image_15 = OpTypeImage %uint Buffer 2 0 0 2 Rgba32ui
 // CHECK: %_ptr_UniformConstant_type_buffer_image_15 = OpTypePointer UniformConstant %type_buffer_image_15
 // CHECK: %_ptr_UniformConstant_type_buffer_image_15 = OpTypePointer UniformConstant %type_buffer_image_15
 RWBuffer<uint3> uint3rwbuf;
 RWBuffer<uint3> uint3rwbuf;
 RWBuffer<uint4> uint4rwbuf;
 RWBuffer<uint4> uint4rwbuf;
-// CHECK: %type_buffer_image_16 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f
+// CHECK: %type_buffer_image_16 = OpTypeImage %float Buffer 2 0 0 2 Rgba32f
 // CHECK: %_ptr_UniformConstant_type_buffer_image_16 = OpTypePointer UniformConstant %type_buffer_image_16
 // CHECK: %_ptr_UniformConstant_type_buffer_image_16 = OpTypePointer UniformConstant %type_buffer_image_16
 RWBuffer<float3> float3rwbuf;
 RWBuffer<float3> float3rwbuf;
 RWBuffer<float4> float4rwbuf;
 RWBuffer<float4> float4rwbuf;

+ 1 - 1
tools/clang/test/CodeGenSPIRV/type.runtime-array.hlsl

@@ -10,7 +10,7 @@ struct S {
     float  c;
     float  c;
 };
 };
 
 
-// CHECK: %type_2d_image = OpTypeImage %float 2D 0 0 0 1 Unknow
+// CHECK: %type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknow
 // CHECK: %_runtimearr_type_2d_image = OpTypeRuntimeArray %type_2d_image
 // CHECK: %_runtimearr_type_2d_image = OpTypeRuntimeArray %type_2d_image
 
 
 // CHECK: %type_sampler = OpTypeSampler
 // CHECK: %type_sampler = OpTypeSampler

+ 7 - 7
tools/clang/test/CodeGenSPIRV/type.rwtexture.hlsl

@@ -2,19 +2,19 @@
 
 
 // CHECK: OpCapability Image1D
 // CHECK: OpCapability Image1D
 
 
-// CHECK: %type_1d_image = OpTypeImage %int 1D 0 0 0 2 R32i
+// CHECK: %type_1d_image = OpTypeImage %int 1D 2 0 0 2 R32i
 // CHECK: %_ptr_UniformConstant_type_1d_image = OpTypePointer UniformConstant %type_1d_image
 // CHECK: %_ptr_UniformConstant_type_1d_image = OpTypePointer UniformConstant %type_1d_image
-// CHECK: %type_2d_image = OpTypeImage %uint 2D 0 0 0 2 Rg32ui
+// CHECK: %type_2d_image = OpTypeImage %uint 2D 2 0 0 2 Rg32ui
 // CHECK: %_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image
 // CHECK: %_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image
-// CHECK: %type_3d_image = OpTypeImage %float 3D 0 0 0 2 Rgba32f
+// CHECK: %type_3d_image = OpTypeImage %float 3D 2 0 0 2 Rgba32f
 // CHECK: %_ptr_UniformConstant_type_3d_image = OpTypePointer UniformConstant %type_3d_image
 // CHECK: %_ptr_UniformConstant_type_3d_image = OpTypePointer UniformConstant %type_3d_image
-// CHECK: %type_1d_image_array = OpTypeImage %int 1D 0 1 0 2 R32i
+// CHECK: %type_1d_image_array = OpTypeImage %int 1D 2 1 0 2 R32i
 // CHECK: %_ptr_UniformConstant_type_1d_image_array = OpTypePointer UniformConstant %type_1d_image_array
 // CHECK: %_ptr_UniformConstant_type_1d_image_array = OpTypePointer UniformConstant %type_1d_image_array
-// CHECK: %type_2d_image_array = OpTypeImage %uint 2D 0 1 0 2 Rg32ui
+// CHECK: %type_2d_image_array = OpTypeImage %uint 2D 2 1 0 2 Rg32ui
 // CHECK: %_ptr_UniformConstant_type_2d_image_array = OpTypePointer UniformConstant %type_2d_image_array
 // CHECK: %_ptr_UniformConstant_type_2d_image_array = OpTypePointer UniformConstant %type_2d_image_array
-// CHECK: %type_1d_image_array_0 = OpTypeImage %float 1D 0 1 0 2 Rgba32f
+// CHECK: %type_1d_image_array_0 = OpTypeImage %float 1D 2 1 0 2 Rgba32f
 // CHECK: %_ptr_UniformConstant_type_1d_image_array_0 = OpTypePointer UniformConstant %type_1d_image_array_0
 // CHECK: %_ptr_UniformConstant_type_1d_image_array_0 = OpTypePointer UniformConstant %type_1d_image_array_0
-// CHECK: %type_2d_image_array_0 = OpTypeImage %float 2D 0 1 0 2 Rgba32f
+// CHECK: %type_2d_image_array_0 = OpTypeImage %float 2D 2 1 0 2 Rgba32f
 // CHECK: %_ptr_UniformConstant_type_2d_image_array_0 = OpTypePointer UniformConstant %type_2d_image_array_0
 // CHECK: %_ptr_UniformConstant_type_2d_image_array_0 = OpTypePointer UniformConstant %type_2d_image_array_0
 
 
 
 

+ 9 - 9
tools/clang/test/CodeGenSPIRV/type.texture.hlsl

@@ -3,31 +3,31 @@
 // CHECK: OpCapability Sampled1D
 // CHECK: OpCapability Sampled1D
 // CHECK: OpCapability ImageMSArray
 // CHECK: OpCapability ImageMSArray
 
 
-// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
+// CHECK: %type_1d_image = OpTypeImage %float 1D 2 0 0 1 Unknown
 // CHECK: %_ptr_UniformConstant_type_1d_image = OpTypePointer UniformConstant %type_1d_image
 // CHECK: %_ptr_UniformConstant_type_1d_image = OpTypePointer UniformConstant %type_1d_image
 
 
-// CHECK: %type_2d_image = OpTypeImage %int 2D 0 0 0 1 Unknown
+// CHECK: %type_2d_image = OpTypeImage %int 2D 2 0 0 1 Unknown
 // CHECK: %_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image
 // CHECK: %_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image
 
 
-// CHECK: %type_3d_image = OpTypeImage %uint 3D 0 0 0 1 Unknown
+// CHECK: %type_3d_image = OpTypeImage %uint 3D 2 0 0 1 Unknown
 // CHECK: %_ptr_UniformConstant_type_3d_image = OpTypePointer UniformConstant %type_3d_image
 // CHECK: %_ptr_UniformConstant_type_3d_image = OpTypePointer UniformConstant %type_3d_image
 
 
-// CHECK: %type_cube_image = OpTypeImage %float Cube 0 0 0 1 Unknown
+// CHECK: %type_cube_image = OpTypeImage %float Cube 2 0 0 1 Unknown
 // CHECK: %_ptr_UniformConstant_type_cube_image = OpTypePointer UniformConstant %type_cube_image
 // CHECK: %_ptr_UniformConstant_type_cube_image = OpTypePointer UniformConstant %type_cube_image
 
 
-// CHECK: %type_1d_image_array = OpTypeImage %float 1D 0 1 0 1 Unknown
+// CHECK: %type_1d_image_array = OpTypeImage %float 1D 2 1 0 1 Unknown
 // CHECK: %_ptr_UniformConstant_type_1d_image_array = OpTypePointer UniformConstant %type_1d_image_array
 // CHECK: %_ptr_UniformConstant_type_1d_image_array = OpTypePointer UniformConstant %type_1d_image_array
 
 
-// CHECK: %type_2d_image_array = OpTypeImage %int 2D 0 1 0 1 Unknown
+// CHECK: %type_2d_image_array = OpTypeImage %int 2D 2 1 0 1 Unknown
 // CHECK: %_ptr_UniformConstant_type_2d_image_array = OpTypePointer UniformConstant %type_2d_image_array
 // CHECK: %_ptr_UniformConstant_type_2d_image_array = OpTypePointer UniformConstant %type_2d_image_array
 
 
-// CHECK: %type_cube_image_array = OpTypeImage %float Cube 0 1 0 1 Unknown
+// CHECK: %type_cube_image_array = OpTypeImage %float Cube 2 1 0 1 Unknown
 // CHECK: %_ptr_UniformConstant_type_cube_image_array = OpTypePointer UniformConstant %type_cube_image_array
 // CHECK: %_ptr_UniformConstant_type_cube_image_array = OpTypePointer UniformConstant %type_cube_image_array
 
 
-// CHECK: %type_2d_image_0 = OpTypeImage %int 2D 0 0 1 1 Unknown
+// CHECK: %type_2d_image_0 = OpTypeImage %int 2D 2 0 1 1 Unknown
 // CHECK: %_ptr_UniformConstant_type_2d_image_0 = OpTypePointer UniformConstant %type_2d_image_0
 // CHECK: %_ptr_UniformConstant_type_2d_image_0 = OpTypePointer UniformConstant %type_2d_image_0
 
 
-// CHECK: %type_2d_image_array_0 = OpTypeImage %uint 2D 0 1 1 1 Unknown
+// CHECK: %type_2d_image_array_0 = OpTypeImage %uint 2D 2 1 1 1 Unknown
 // CHECK: %_ptr_UniformConstant_type_2d_image_array_0 = OpTypePointer UniformConstant %type_2d_image_array_0
 // CHECK: %_ptr_UniformConstant_type_2d_image_array_0 = OpTypePointer UniformConstant %type_2d_image_array_0
 
 
 
 

+ 4 - 4
tools/clang/test/CodeGenSPIRV/var.resource.array.hlsl

@@ -13,16 +13,16 @@
 // CHECK: OpDecorate %MyCompSamplers DescriptorSet 0
 // CHECK: OpDecorate %MyCompSamplers DescriptorSet 0
 // CHECK: OpDecorate %MyCompSamplers Binding 5
 // CHECK: OpDecorate %MyCompSamplers Binding 5
 
 
-// CHECK: %type_buffer_image = OpTypeImage %float Buffer 0 0 0 1 Rgba32f
+// CHECK: %type_buffer_image = OpTypeImage %float Buffer 2 0 0 1 Rgba32f
 // CHECK: %_arr_type_buffer_image_uint_1 = OpTypeArray %type_buffer_image %uint_1
 // CHECK: %_arr_type_buffer_image_uint_1 = OpTypeArray %type_buffer_image %uint_1
 
 
-// CHECK: %type_buffer_image_0 = OpTypeImage %float Buffer 0 0 0 2 Rgba32f
+// CHECK: %type_buffer_image_0 = OpTypeImage %float Buffer 2 0 0 2 Rgba32f
 // CHECK: %_arr_type_buffer_image_0_uint_2 = OpTypeArray %type_buffer_image_0 %uint_2
 // CHECK: %_arr_type_buffer_image_0_uint_2 = OpTypeArray %type_buffer_image_0 %uint_2
 
 
-// CHECK: %type_2d_image = OpTypeImage %float 2D 0 0 0 1 Unknown
+// CHECK: %type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknown
 // CHECK: %_arr_type_2d_image_uint_3 = OpTypeArray %type_2d_image %uint_3
 // CHECK: %_arr_type_2d_image_uint_3 = OpTypeArray %type_2d_image %uint_3
 
 
-// CHECK: %type_2d_image_0 = OpTypeImage %float 2D 0 0 0 2 Rgba32f
+// CHECK: %type_2d_image_0 = OpTypeImage %float 2D 2 0 0 2 Rgba32f
 // CHECK: %_arr_type_2d_image_0_uint_4 = OpTypeArray %type_2d_image_0 %uint_4
 // CHECK: %_arr_type_2d_image_0_uint_4 = OpTypeArray %type_2d_image_0 %uint_4
 
 
 // CHECK: %type_sampler = OpTypeSampler
 // CHECK: %type_sampler = OpTypeSampler

+ 6 - 6
tools/clang/test/CodeGenSPIRV/vk.subpass-input.hlsl

@@ -2,22 +2,22 @@
 
 
 // CHECK: OpCapability InputAttachment
 // CHECK: OpCapability InputAttachment
 
 
-// CHECK: %type_subpass_image = OpTypeImage %float SubpassData 0 0 0 2 Unknown
+// CHECK: %type_subpass_image = OpTypeImage %float SubpassData 2 0 0 2 Unknown
 // CHECK: %_ptr_UniformConstant_type_subpass_image = OpTypePointer UniformConstant %type_subpass_image
 // CHECK: %_ptr_UniformConstant_type_subpass_image = OpTypePointer UniformConstant %type_subpass_image
 
 
-// CHECK: %type_subpass_image_0 = OpTypeImage %int SubpassData 0 0 0 2 Unknown
+// CHECK: %type_subpass_image_0 = OpTypeImage %int SubpassData 2 0 0 2 Unknown
 // CHECK: %_ptr_UniformConstant_type_subpass_image_0 = OpTypePointer UniformConstant %type_subpass_image_0
 // CHECK: %_ptr_UniformConstant_type_subpass_image_0 = OpTypePointer UniformConstant %type_subpass_image_0
 
 
-// CHECK: %type_subpass_image_1 = OpTypeImage %uint SubpassData 0 0 0 2 Unknown
+// CHECK: %type_subpass_image_1 = OpTypeImage %uint SubpassData 2 0 0 2 Unknown
 // CHECK: %_ptr_UniformConstant_type_subpass_image_1 = OpTypePointer UniformConstant %type_subpass_image_1
 // CHECK: %_ptr_UniformConstant_type_subpass_image_1 = OpTypePointer UniformConstant %type_subpass_image_1
 
 
-// CHECK: %type_subpass_image_2 = OpTypeImage %uint SubpassData 0 0 1 2 Unknown
+// CHECK: %type_subpass_image_2 = OpTypeImage %uint SubpassData 2 0 1 2 Unknown
 // CHECK: %_ptr_UniformConstant_type_subpass_image_2 = OpTypePointer UniformConstant %type_subpass_image_2
 // CHECK: %_ptr_UniformConstant_type_subpass_image_2 = OpTypePointer UniformConstant %type_subpass_image_2
 
 
-// CHECK: %type_subpass_image_3 = OpTypeImage %float SubpassData 0 0 1 2 Unknown
+// CHECK: %type_subpass_image_3 = OpTypeImage %float SubpassData 2 0 1 2 Unknown
 // CHECK: %_ptr_UniformConstant_type_subpass_image_3 = OpTypePointer UniformConstant %type_subpass_image_3
 // CHECK: %_ptr_UniformConstant_type_subpass_image_3 = OpTypePointer UniformConstant %type_subpass_image_3
 
 
-// CHECK: %type_subpass_image_4 = OpTypeImage %int SubpassData 0 0 1 2 Unknown
+// CHECK: %type_subpass_image_4 = OpTypeImage %int SubpassData 2 0 1 2 Unknown
 // CHECK: %_ptr_UniformConstant_type_subpass_image_4 = OpTypePointer UniformConstant %type_subpass_image_4
 // CHECK: %_ptr_UniformConstant_type_subpass_image_4 = OpTypePointer UniformConstant %type_subpass_image_4
 
 
 // CHECK:  [[v2i00:%\d+]] = OpConstantComposite %v2int %int_0 %int_0
 // CHECK:  [[v2i00:%\d+]] = OpConstantComposite %v2int %int_0 %int_0

+ 0 - 6
tools/clang/unittests/SPIRV/CodeGenSPIRVTest.cpp

@@ -754,12 +754,6 @@ TEST_F(FileTest, TextureSampleCmpLevelZero) {
 TEST_F(FileTest, TextureArraySampleCmpLevelZero) {
 TEST_F(FileTest, TextureArraySampleCmpLevelZero) {
   runFileTest("texture.array.sample-cmp-level-zero.hlsl");
   runFileTest("texture.array.sample-cmp-level-zero.hlsl");
 }
 }
-TEST_F(FileTest, TextureNormalAndComparisonSample) {
-  // Check that we generate OpSampledImage derived from the appropriate
-  // OpTypeImage having the matching Depth value with the OpImageSample*
-  // instruction
-  runFileTest("texture.sample.sample-cmp.hlsl");
-}
 
 
 // For structured buffer methods
 // For structured buffer methods
 TEST_F(FileTest, StructuredBufferLoad) {
 TEST_F(FileTest, StructuredBufferLoad) {