spirv-reader: set failure bit when SPIR-V validation fails

The error message was already being logged, but the status
flag was not being set.

Change-Id: I7f6f2f45c15a64dd089e221c62218afe9e774edd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49643
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
David Neto 2021-05-05 16:03:02 +00:00 committed by Commit Bot service account
parent 01c3ce7c03
commit 6e2461096a
3 changed files with 9 additions and 7 deletions

View File

@ -291,6 +291,7 @@ bool ParserImpl::Parse() {
// Only consider modules valid for Vulkan 1.0. On failure, the message // Only consider modules valid for Vulkan 1.0. On failure, the message
// consumer will set the error status. // consumer will set the error status.
if (!spv_tools.Validate(spv_binary_)) { if (!spv_tools.Validate(spv_binary_)) {
success_ = false;
return false; return false;
} }
if (!BuildInternalModule()) { if (!BuildInternalModule()) {

View File

@ -2184,13 +2184,13 @@ TEST_F(SpvModuleScopeVarParserTest, SampleId_I32_FunctParam) {
OpFunctionEnd OpFunctionEnd
)"; )";
auto p = parser(test::Assemble(assembly)); auto p = parser(test::Assemble(assembly));
// TODO(dneto): We can handle this if we make a shadow variable and mutate
// the parameter type. // This example is invalid because you can't pass pointer-to-Input
ASSERT_FALSE(p->BuildAndParseInternalModule()); // as a function parameter.
EXPECT_THAT( EXPECT_FALSE(p->Parse());
p->error(), EXPECT_FALSE(p->success());
HasSubstr( EXPECT_THAT(p->error(),
"unhandled use of a pointer to the SampleId builtin, with ID: 1")); HasSubstr("Invalid storage class for pointer operand 1"));
} }
TEST_F(SpvModuleScopeVarParserTest, SampleId_U32_Load_Direct) { TEST_F(SpvModuleScopeVarParserTest, SampleId_U32_Load_Direct) {

View File

@ -64,6 +64,7 @@ class ParserImplWrapperForTest {
Namer& namer() { return impl_.namer(); } Namer& namer() { return impl_.namer(); }
ProgramBuilder& builder() { return impl_.builder(); } ProgramBuilder& builder() { return impl_.builder(); }
const std::string error() { return impl_.error(); } const std::string error() { return impl_.error(); }
bool success() { return impl_.success(); }
FailStream& Fail() { return impl_.Fail(); } FailStream& Fail() { return impl_.Fail(); }
spvtools::opt::IRContext* ir_context() { return impl_.ir_context(); } spvtools::opt::IRContext* ir_context() { return impl_.ir_context(); }