Image Operand Sample allows sparse image opcodes

@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.
This commit is contained in:
Andrey Tuganov 2017-12-18 11:21:38 -05:00
parent 8c05012593
commit dbc3a662c6
2 changed files with 7 additions and 4 deletions

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

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