spirv-reader: Be slightly more defensive

Return early if error occurs converting decorations for pipeline
outputs.

Also add slightly better comments.

Bug: tint:508
Change-Id: I5a80f8bbc3bc9196ed70577be3884fe4ba4bba0a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54461
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
This commit is contained in:
David Neto 2021-06-11 20:03:56 +00:00 committed by Tint LUCI CQ
parent c5d59a66f5
commit 27067f5c1e
2 changed files with 8 additions and 0 deletions

View File

@ -994,7 +994,9 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() {
source, builder_.Symbols().Register(ep_info_->inner_name)), source, builder_.Symbols().Register(ep_info_->inner_name)),
ast::ExpressionList{}))); ast::ExpressionList{})));
// Pipeline outputs are mapped to the return value.
if (ep_info_->outputs.empty()) { if (ep_info_->outputs.empty()) {
// There is nothing to return.
return_type = ty_.Void()->Build(builder_); return_type = ty_.Void()->Build(builder_);
} else { } else {
// Pipeline outputs are converted to a structure that is written // Pipeline outputs are converted to a structure that is written
@ -1018,6 +1020,10 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() {
if (!parser_impl_.ConvertDecorationsForVariable( if (!parser_impl_.ConvertDecorationsForVariable(
var_id, &forced_store_type, &out_decos)) { var_id, &forced_store_type, &out_decos)) {
// This occurs, and is not an error, for the PointSize builtin. // This occurs, and is not an error, for the PointSize builtin.
if (!success()) {
// But exit early if an error was logged.
return false;
}
continue; continue;
} }

View File

@ -427,6 +427,8 @@ class FunctionEmitter {
ParserImpl* parser() { return &parser_impl_; } ParserImpl* parser() { return &parser_impl_; }
/// Emits the entry point as a wrapper around its implementation function. /// Emits the entry point as a wrapper around its implementation function.
/// Pipeline inputs become formal parameters, and pipeline outputs become
/// return values.
/// @returns false if emission failed. /// @returns false if emission failed.
bool EmitEntryPointAsWrapper(); bool EmitEntryPointAsWrapper();