Relaxed OpImageWrite texel type check

This commit is contained in:
Andrey Tuganov 2017-11-24 10:55:05 -05:00 committed by David Neto
parent e1a6f8d1c3
commit c170afd93b
3 changed files with 11 additions and 5 deletions

View File

@ -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.

View 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);

View 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