Merge pull request #829 from atgoo/fix_val_logicals

Validator: fix logicals pass for OpSelect pointers
This commit is contained in:
Ehsan 2017-09-21 18:50:09 -04:00 committed by GitHub
commit cf6c20ee06
2 changed files with 24 additions and 4 deletions

View File

@ -179,10 +179,11 @@ spv_result_t LogicalsPass(ValidationState_t& _,
const SpvOp type_opcode = type_inst->opcode();
switch (type_opcode) {
case SpvOpTypePointer: {
if (!_.features().variable_pointers)
if (!_.features().variable_pointers &&
!_.features().variable_pointers_storage_buffer)
return _.diag(SPV_ERROR_INVALID_DATA)
<< "Using pointers with OpSelect requires capability "
<< "VariablePointers";
<< "VariablePointers or VariablePointersStorageBuffer";
break;
}

View File

@ -570,10 +570,11 @@ OpStore %y %f32vec4_1234
CompileSuccessfully(GenerateShaderCode(body).c_str());
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(), HasSubstr(
"Using pointers with OpSelect requires capability VariablePointers"));
"Using pointers with OpSelect requires capability VariablePointers "
"or VariablePointersStorageBuffer"));
}
TEST_F(ValidateLogicals, OpSelectPointerWithCapability) {
TEST_F(ValidateLogicals, OpSelectPointerWithCapability1) {
const std::string body = R"(
%x = OpVariable %f32vec4ptr Function
%y = OpVariable %f32vec4ptr Function
@ -591,6 +592,24 @@ OpExtension "SPV_KHR_variable_pointers"
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_F(ValidateLogicals, OpSelectPointerWithCapability2) {
const std::string body = R"(
%x = OpVariable %f32vec4ptr Function
%y = OpVariable %f32vec4ptr Function
OpStore %x %f32vec4_0123
OpStore %y %f32vec4_1234
%val1 = OpSelect %f32vec4ptr %true %x %y
)";
const std::string extra_cap_ext = R"(
OpCapability VariablePointersStorageBuffer
OpExtension "SPV_KHR_variable_pointers"
)";
CompileSuccessfully(GenerateShaderCode(body, extra_cap_ext).c_str());
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_F(ValidateLogicals, OpSelectWrongCondition) {
const std::string body = R"(
%val1 = OpSelect %u32 %u32_1 %u32_0 %u32_1