Disallow Dim=SubpassData for OpImageSparseRead
authorAndrey Tuganov <andreyt@google.com>
Thu, 21 Dec 2017 20:24:27 +0000 (15:24 -0500)
committerDavid Neto <dneto@google.com>
Fri, 22 Dec 2017 14:45:15 +0000 (09:45 -0500)
source/validate_image.cpp
test/val/val_image_test.cpp

index ffbd120..63bf69a 100644 (file)
@@ -1193,6 +1193,12 @@ spv_result_t ImagePass(ValidationState_t& _,
       }
 
       if (info.dim == SpvDimSubpassData) {
+        if (opcode == SpvOpImageSparseRead) {
+          return _.diag(SPV_ERROR_INVALID_DATA)
+                 << "Image Dim SubpassData cannot be used with "
+                 << spvOpcodeString(opcode);
+        }
+
         _.current_function().RegisterExecutionModelLimitation(
             SpvExecutionModelFragment,
             std::string("Dim SubpassData requires Fragment execution model: ") +
index fc0e9cc..9997c22 100644 (file)
@@ -3808,6 +3808,20 @@ TEST_F(ValidateImage, SparseReadWrongComponentTypeTexel) {
                         "ImageSparseRead"));
 }
 
+TEST_F(ValidateImage, SparseReadSubpassDataNotAllowed) {
+  const std::string body = R"(
+%img = OpLoad %type_image_f32_spd_0002 %uniform_image_f32_spd_0002
+%res1 = OpImageSparseRead %struct_u32_f32vec4 %img %u32vec2_01
+)";
+
+  const std::string extra = "\nOpCapability StorageImageReadWithoutFormat\n";
+  CompileSuccessfully(GenerateShaderCode(body, extra, "Fragment").c_str());
+  ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Image Dim SubpassData cannot be used with ImageSparseRead"));
+}
+
 TEST_F(ValidateImage, SparseGatherSuccess) {
   const std::string body = R"(
 %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001