Relaxed OpImageWrite texel type check
authorAndrey Tuganov <andreyt@google.com>
Fri, 24 Nov 2017 15:55:05 +0000 (10:55 -0500)
committerDavid Neto <dneto@google.com>
Fri, 24 Nov 2017 19:31:08 +0000 (14:31 -0500)
CHANGES
source/validate_image.cpp
test/val/val_image_test.cpp

diff --git a/CHANGES b/CHANGES
index 0122e42..c6b92a1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,7 @@ v2017.2-dev 2017-11-23
    #1004: Use after free of an instruction, in remove-duplicates transform
    #1007: OpImageRead not required to return 4-component vector
    #1009: OpImageRead can return scalar int/float types
+   #1011: OpImageRead should allow scalar int/float texel types
 
 v2017.1 2017-11-23
  - Update README with details on the public_spirv_tools_dev@khronos.org mailing list.
index e6a6f35..c2eef22 100644 (file)
@@ -1068,19 +1068,24 @@ spv_result_t ImagePass(ValidationState_t& _,
             << spvOpcodeString(opcode);
       }
 
+      // TODO(atgoo@github.com) The spec doesn't explicitely say what the type
+      // of texel should be.
       const uint32_t texel_type = _.GetOperandTypeId(inst, 2);
-      if (!_.IsIntVectorType(texel_type) &&
-          !_.IsFloatVectorType(texel_type)) {
+      if (!_.IsIntScalarOrVectorType(texel_type) &&
+          !_.IsFloatScalarOrVectorType(texel_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
             << "Expected Texel to be int or float vector or scalar: "
             << spvOpcodeString(opcode);
       }
 
+#if 0
+      // TODO: See above.
       if (_.GetDimension(texel_type) != 4) {
         return _.diag(SPV_ERROR_INVALID_DATA)
             << "Expected Texel to have 4 components: "
             << spvOpcodeString(opcode);
       }
+#endif
 
       if (_.GetIdOpcode(info.sampled_type) != SpvOpTypeVoid) {
         const uint32_t texel_component_type = _.GetComponentType(texel_type);
index 2bc126c..559bc65 100644 (file)
@@ -2524,10 +2524,10 @@ TEST_F(ValidateImage, WriteCoordinateSizeTooSmall) {
       "ImageWrite"));
 }
 
-TEST_F(ValidateImage, WriteTexelNotVector) {
+TEST_F(ValidateImage, WriteTexelWrongType) {
   const std::string body = R"(
 %img = OpLoad %type_image_u32_2d_0000 %uniform_image_u32_2d_0000
-%res1 = OpImageWrite %img %u32vec2_01 %u32_0
+%res1 = OpImageWrite %img %u32vec2_01 %img
 )";
 
   const std::string extra = "\nOpCapability StorageImageWriteWithoutFormat\n";
@@ -2537,7 +2537,7 @@ TEST_F(ValidateImage, WriteTexelNotVector) {
       "Expected Texel to be int or float vector or scalar: ImageWrite"));
 }
 
-TEST_F(ValidateImage, WriteTexelNotVector4) {
+TEST_F(ValidateImage, DISABLED_WriteTexelNotVector4) {
   const std::string body = R"(
 %img = OpLoad %type_image_u32_2d_0000 %uniform_image_u32_2d_0000
 %res1 = OpImageWrite %img %u32vec2_01 %u32vec3_012