Skip to content

Commit

Permalink
Don't crash if the shader static analysis fails.
Browse files Browse the repository at this point in the history
SPIRV-cross will throw an exception if it fails to parse/process
a shader. Don't bring down the entire server if this happens.

We will need to do proper error reporting/handling here in the
future, but this commit fixes the crash.
  • Loading branch information
pmuetschard committed Jul 26, 2021
1 parent 2132399 commit 165061e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions gapis/shadertools/cc/staticanalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void processInstructionForPressure(spirv_cross::ParsedIR pir,
}
}

instruction_counters_t performStaticAnalysis(const uint32_t* spirv_binary,
size_t length) {
instruction_counters_t performStaticAnalysisInternal(
const uint32_t* spirv_binary, size_t length) {
spirv_cross::Parser parser(spirv_binary, length);
parser.parse();
spirv_cross::ParsedIR pir = parser.get_parsed_ir();
Expand Down Expand Up @@ -562,3 +562,13 @@ instruction_counters_t performStaticAnalysis(const uint32_t* spirv_binary,

return counters;
}

instruction_counters_t performStaticAnalysis(const uint32_t* spirv_binary,
size_t length) {
try {
return performStaticAnalysisInternal(spirv_binary, length);
} catch (...) {
// TODO: do proper error handling and reporting.
return instruction_counters_t{0, 0, 0, 0};
}
}

0 comments on commit 165061e

Please sign in to comment.