Image Operand Sample allows sparse image opcodes
authorAndrey Tuganov <andreyt@google.com>
Mon, 18 Dec 2017 16:21:38 +0000 (11:21 -0500)
committerAndrey Tuganov <andreyt@google.com>
Mon, 18 Dec 2017 16:21:38 +0000 (11:21 -0500)
@ehsannas had filed an issue against SPIR-V spec, concerning
Image Operands section (3.14):
Sample
A following operand is the sample number of the sample to use. Only
valid with OpImageFetch, OpImageRead, and OpImageWrite.

Relaxing the check to allow OpImageSparseRead and
OpImageSparseFetch to fix failing tests.

source/validate_image.cpp
test/val/val_image_test.cpp

index 9bc2632..ffbd120 100644 (file)
@@ -469,10 +469,12 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
 
   if (mask & SpvImageOperandsSampleMask) {
     if (opcode != SpvOpImageFetch && opcode != SpvOpImageRead &&
-        opcode != SpvOpImageWrite) {
+        opcode != SpvOpImageWrite && opcode != SpvOpImageSparseFetch &&
+        opcode != SpvOpImageSparseRead) {
       return _.diag(SPV_ERROR_INVALID_DATA)
              << "Image Operand Sample can only be used with OpImageFetch, "
-             << "OpImageRead and OpImageWrite: " << spvOpcodeString(opcode);
+             << "OpImageRead, OpImageWrite, OpImageSparseFetch and "
+             << "OpImageSparseRead: " << spvOpcodeString(opcode);
     }
 
     if (info.multisampled == 0) {
index 24f04ad..fc0e9cc 100644 (file)
@@ -2858,8 +2858,9 @@ TEST_F(ValidateImage, SampleWrongOpcode) {
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
   EXPECT_THAT(getDiagnosticString(),
               HasSubstr("Image Operand Sample can only be used with "
-                        "OpImageFetch, OpImageRead "
-                        "and OpImageWrite: ImageSampleExplicitLod"));
+                        "OpImageFetch, OpImageRead, OpImageWrite, "
+                        "OpImageSparseFetch and OpImageSparseRead: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImageToImageSuccess) {