[tint] Remove current_function_ from ValidateBuiltinAttribute.
The ValidateBuiltinAttribute function just needs the current functions pipeline stage, pass that in intead of using current_function_. Bug: tint:1313 Change-Id: Ie58b46e6115ee46bb0b86e53786cf17861cf7d4e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87141 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
94c2c2d44c
commit
98b19374b4
|
@ -252,6 +252,7 @@ class Resolver {
|
||||||
bool ValidateBreakStatement(const sem::Statement* stmt);
|
bool ValidateBreakStatement(const sem::Statement* stmt);
|
||||||
bool ValidateBuiltinAttribute(const ast::BuiltinAttribute* attr,
|
bool ValidateBuiltinAttribute(const ast::BuiltinAttribute* attr,
|
||||||
const sem::Type* storage_type,
|
const sem::Type* storage_type,
|
||||||
|
ast::PipelineStage stage,
|
||||||
const bool is_input);
|
const bool is_input);
|
||||||
bool ValidateContinueStatement(const sem::Statement* stmt);
|
bool ValidateContinueStatement(const sem::Statement* stmt);
|
||||||
bool ValidateDiscardStatement(const sem::Statement* stmt);
|
bool ValidateDiscardStatement(const sem::Statement* stmt);
|
||||||
|
|
|
@ -692,11 +692,9 @@ bool Resolver::ValidateFunctionParameter(const ast::Function* func,
|
||||||
|
|
||||||
bool Resolver::ValidateBuiltinAttribute(const ast::BuiltinAttribute* attr,
|
bool Resolver::ValidateBuiltinAttribute(const ast::BuiltinAttribute* attr,
|
||||||
const sem::Type* storage_ty,
|
const sem::Type* storage_ty,
|
||||||
|
ast::PipelineStage stage,
|
||||||
const bool is_input) {
|
const bool is_input) {
|
||||||
auto* type = storage_ty->UnwrapRef();
|
auto* type = storage_ty->UnwrapRef();
|
||||||
const auto stage = current_function_
|
|
||||||
? current_function_->Declaration()->PipelineStage()
|
|
||||||
: ast::PipelineStage::kNone;
|
|
||||||
std::stringstream stage_name;
|
std::stringstream stage_name;
|
||||||
stage_name << stage;
|
stage_name << stage;
|
||||||
bool is_stage_mismatch = false;
|
bool is_stage_mismatch = false;
|
||||||
|
@ -961,6 +959,9 @@ bool Resolver::ValidateEntryPoint(const sem::Function* func) {
|
||||||
Source source,
|
Source source,
|
||||||
ParamOrRetType param_or_ret,
|
ParamOrRetType param_or_ret,
|
||||||
bool is_struct_member) {
|
bool is_struct_member) {
|
||||||
|
auto stage = current_function_
|
||||||
|
? current_function_->Declaration()->PipelineStage()
|
||||||
|
: ast::PipelineStage::kNone;
|
||||||
// Scan attributes for pipeline IO attributes.
|
// Scan attributes for pipeline IO attributes.
|
||||||
// Check for overlap with attributes that have been seen previously.
|
// Check for overlap with attributes that have been seen previously.
|
||||||
const ast::Attribute* pipeline_io_attribute = nullptr;
|
const ast::Attribute* pipeline_io_attribute = nullptr;
|
||||||
|
@ -968,6 +969,7 @@ bool Resolver::ValidateEntryPoint(const sem::Function* func) {
|
||||||
const ast::InvariantAttribute* invariant_attribute = nullptr;
|
const ast::InvariantAttribute* invariant_attribute = nullptr;
|
||||||
for (auto* attr : attrs) {
|
for (auto* attr : attrs) {
|
||||||
auto is_invalid_compute_shader_attribute = false;
|
auto is_invalid_compute_shader_attribute = false;
|
||||||
|
|
||||||
if (auto* builtin = attr->As<ast::BuiltinAttribute>()) {
|
if (auto* builtin = attr->As<ast::BuiltinAttribute>()) {
|
||||||
if (pipeline_io_attribute) {
|
if (pipeline_io_attribute) {
|
||||||
AddError("multiple entry point IO attributes", attr->source);
|
AddError("multiple entry point IO attributes", attr->source);
|
||||||
|
@ -987,7 +989,7 @@ bool Resolver::ValidateEntryPoint(const sem::Function* func) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ValidateBuiltinAttribute(
|
if (!ValidateBuiltinAttribute(
|
||||||
builtin, ty,
|
builtin, ty, stage,
|
||||||
/* is_input */ param_or_ret == ParamOrRetType::kParameter)) {
|
/* is_input */ param_or_ret == ParamOrRetType::kParameter)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1003,9 +1005,6 @@ bool Resolver::ValidateEntryPoint(const sem::Function* func) {
|
||||||
|
|
||||||
bool is_input = param_or_ret == ParamOrRetType::kParameter;
|
bool is_input = param_or_ret == ParamOrRetType::kParameter;
|
||||||
|
|
||||||
auto stage = current_function_
|
|
||||||
? current_function_->Declaration()->PipelineStage()
|
|
||||||
: ast::PipelineStage::kNone;
|
|
||||||
if (!ValidateLocationAttribute(location, ty, locations, stage, source,
|
if (!ValidateLocationAttribute(location, ty, locations, stage, source,
|
||||||
is_input)) {
|
is_input)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2099,19 +2098,19 @@ bool Resolver::ValidateStructure(const sem::Struct* str) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto stage = current_function_
|
||||||
|
? current_function_->Declaration()->PipelineStage()
|
||||||
|
: ast::PipelineStage::kNone;
|
||||||
if (auto* invariant = attr->As<ast::InvariantAttribute>()) {
|
if (auto* invariant = attr->As<ast::InvariantAttribute>()) {
|
||||||
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,
|
||||||
stage, 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>()) {
|
||||||
if (!ValidateBuiltinAttribute(builtin, member->Type(),
|
if (!ValidateBuiltinAttribute(builtin, member->Type(), stage,
|
||||||
/* is_input */ false)) {
|
/* is_input */ false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue