ShaderModule: Include extra information in shader errors

If the SPIR-V fails to validate, include the SPIR-V disassembly in the error.
If the shader fails to compile, include the shader source in the error.

Change-Id: I05f93b5dec7985c42ddf9cd14621af2a855ee640
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37282
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Ben Clayton 2021-01-13 22:27:08 +00:00 committed by Commit Bot service account
parent 2f1278e68b
commit 3639186e7e
1 changed files with 9 additions and 1 deletions

View File

@ -166,6 +166,12 @@ namespace dawn_native {
});
if (!spirvTools.Validate(code, codeSize)) {
std::string disassembly;
if (spirvTools.Disassemble(std::vector<uint32_t>(code, code + codeSize),
&disassembly)) {
errorStream << "disassembly:" << std::endl << disassembly;
}
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
@ -180,7 +186,9 @@ namespace dawn_native {
tint::reader::wgsl::Parser parser(file);
if (!parser.Parse()) {
auto err = tint::diag::Formatter{}.format(parser.diagnostics());
errorStream << "Parser: " << err << std::endl;
errorStream << "Parser: " << err << std::endl
<< "Shader: " << std::endl
<< file->content << std::endl;
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}