From 27067f5c1efb6fb36a7f2592d2e8b060b9928ebc Mon Sep 17 00:00:00 2001 From: David Neto Date: Fri, 11 Jun 2021 20:03:56 +0000 Subject: [PATCH] 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 Reviewed-by: James Price Kokoro: Kokoro Commit-Queue: David Neto --- src/reader/spirv/function.cc | 6 ++++++ src/reader/spirv/function.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index 9d6a615a11..25e8a4197b 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -994,7 +994,9 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() { source, builder_.Symbols().Register(ep_info_->inner_name)), ast::ExpressionList{}))); + // Pipeline outputs are mapped to the return value. if (ep_info_->outputs.empty()) { + // There is nothing to return. return_type = ty_.Void()->Build(builder_); } else { // Pipeline outputs are converted to a structure that is written @@ -1018,6 +1020,10 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() { if (!parser_impl_.ConvertDecorationsForVariable( var_id, &forced_store_type, &out_decos)) { // This occurs, and is not an error, for the PointSize builtin. + if (!success()) { + // But exit early if an error was logged. + return false; + } continue; } diff --git a/src/reader/spirv/function.h b/src/reader/spirv/function.h index 2bfe745680..944afd54a3 100644 --- a/src/reader/spirv/function.h +++ b/src/reader/spirv/function.h @@ -427,6 +427,8 @@ class FunctionEmitter { ParserImpl* parser() { return &parser_impl_; } /// 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. bool EmitEntryPointAsWrapper();