Relaxed OpImageRead validation rules
authorAndrey Tuganov <andreyt@google.com>
Fri, 24 Nov 2017 15:05:07 +0000 (10:05 -0500)
committerDavid Neto <dneto@google.com>
Fri, 24 Nov 2017 15:12:24 +0000 (10:12 -0500)
Removed the check that result type of OpImageRead should be a vector4.
Will reenable/adapt once the spec is clarified on what the right
dimension should be.

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

index 48179aa..e6a6f35 100644 (file)
@@ -954,18 +954,21 @@ spv_result_t ImagePass(ValidationState_t& _,
     }
 
     case SpvOpImageRead: {
-      if (!_.IsIntVectorType(result_type) &&
-          !_.IsFloatVectorType(result_type)) {
+      if (!_.IsIntScalarOrVectorType(result_type) &&
+          !_.IsFloatScalarOrVectorType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int or float vector type: "
+            << "Expected Result Type to be int or float scalar or vector type: "
             << spvOpcodeString(opcode);
       }
 
+#if 0
+      // TODO(atgoo@github.com) Disabled until the spec is clarified.
       if (_.GetDimension(result_type) != 4) {
         return _.diag(SPV_ERROR_INVALID_DATA)
             << "Expected Result Type to have 4 components: "
             << spvOpcodeString(opcode);
       }
+#endif
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeImage) {
index b19843b..2bc126c 100644 (file)
@@ -2268,7 +2268,8 @@ TEST_F(ValidateImage, ReadNeedCapabilityImageCubeArray) {
       "ImageRead"));
 }
 
-TEST_F(ValidateImage, ReadWrongResultType) {
+// TODO(atgoo@github.com) Disabled until the spec is clarified.
+TEST_F(ValidateImage, DISABLED_ReadWrongResultType) {
   const std::string body = R"(
 %img = OpLoad %type_image_u32_2d_0000 %uniform_image_u32_2d_0000
 %res1 = OpImageRead %f32 %img %u32vec2_01
@@ -2281,7 +2282,8 @@ TEST_F(ValidateImage, ReadWrongResultType) {
       "Expected Result Type to be int or float vector type: ImageRead"));
 }
 
-TEST_F(ValidateImage, ReadWrongNumComponentsResultType) {
+// TODO(atgoo@github.com) Disabled until the spec is clarified.
+TEST_F(ValidateImage, DISABLED_ReadWrongNumComponentsResultType) {
   const std::string body = R"(
 %img = OpLoad %type_image_u32_2d_0000 %uniform_image_u32_2d_0000
 %res1 = OpImageRead %f32vec3 %img %u32vec2_01