[tint] Remove current_function_ usage from ValidateLocationAttribute.
The ValidateLocationAttribute function needs to know the stage of the current function so, pass that in instead of accessing current_function_ directly. Bug: tint:1313 Change-Id: Ifa0ac912f5e78f14b6512fd74ae951545abd9b22 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87140 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
e4c799071b
commit
94c2c2d44c
|
@ -271,6 +271,7 @@ class Resolver {
|
||||||
bool ValidateLocationAttribute(const ast::LocationAttribute* location,
|
bool ValidateLocationAttribute(const ast::LocationAttribute* location,
|
||||||
const sem::Type* type,
|
const sem::Type* type,
|
||||||
std::unordered_set<uint32_t>& locations,
|
std::unordered_set<uint32_t>& locations,
|
||||||
|
ast::PipelineStage stage,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const bool is_input = false);
|
const bool is_input = false);
|
||||||
bool ValidateLoopStatement(const sem::LoopStatement* stmt);
|
bool ValidateLoopStatement(const sem::LoopStatement* stmt);
|
||||||
|
|
|
@ -1002,7 +1002,11 @@ bool Resolver::ValidateEntryPoint(const sem::Function* func) {
|
||||||
pipeline_io_attribute = attr;
|
pipeline_io_attribute = attr;
|
||||||
|
|
||||||
bool is_input = param_or_ret == ParamOrRetType::kParameter;
|
bool is_input = param_or_ret == ParamOrRetType::kParameter;
|
||||||
if (!ValidateLocationAttribute(location, ty, locations, source,
|
|
||||||
|
auto stage = current_function_
|
||||||
|
? current_function_->Declaration()->PipelineStage()
|
||||||
|
: ast::PipelineStage::kNone;
|
||||||
|
if (!ValidateLocationAttribute(location, ty, locations, stage, source,
|
||||||
is_input)) {
|
is_input)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2099,8 +2103,11 @@ bool Resolver::ValidateStructure(const sem::Struct* str) {
|
||||||
invariant_attribute = invariant;
|
invariant_attribute = invariant;
|
||||||
} else if (auto* location = attr->As<ast::LocationAttribute>()) {
|
} else if (auto* location = attr->As<ast::LocationAttribute>()) {
|
||||||
has_location = true;
|
has_location = true;
|
||||||
|
auto stage = current_function_
|
||||||
|
? current_function_->Declaration()->PipelineStage()
|
||||||
|
: ast::PipelineStage::kNone;
|
||||||
if (!ValidateLocationAttribute(location, member->Type(), locations,
|
if (!ValidateLocationAttribute(location, member->Type(), locations,
|
||||||
member->Declaration()->source)) {
|
stage, member->Declaration()->source)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (auto* builtin = attr->As<ast::BuiltinAttribute>()) {
|
} else if (auto* builtin = attr->As<ast::BuiltinAttribute>()) {
|
||||||
|
@ -2146,11 +2153,11 @@ bool Resolver::ValidateLocationAttribute(
|
||||||
const ast::LocationAttribute* location,
|
const ast::LocationAttribute* location,
|
||||||
const sem::Type* type,
|
const sem::Type* type,
|
||||||
std::unordered_set<uint32_t>& locations,
|
std::unordered_set<uint32_t>& locations,
|
||||||
|
ast::PipelineStage stage,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const bool is_input) {
|
const bool is_input) {
|
||||||
std::string inputs_or_output = is_input ? "inputs" : "output";
|
std::string inputs_or_output = is_input ? "inputs" : "output";
|
||||||
if (current_function_ && current_function_->Declaration()->PipelineStage() ==
|
if (stage == ast::PipelineStage::kCompute) {
|
||||||
ast::PipelineStage::kCompute) {
|
|
||||||
AddError("attribute is not valid for compute shader " + inputs_or_output,
|
AddError("attribute is not valid for compute shader " + inputs_or_output,
|
||||||
location->source);
|
location->source);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue