Convert `@location` to store expression internally.
This CL updates the internal storage for a `@location` attribute
to store the `Expression` instead of a raw `uint32_t`. The current
parser is updated to generate an `IntLiteralExpression` so we still
parse as a `uint32_t` at the moment.
Bug: tint:1633
Change-Id: I2b9684754a657b39554160c81727cf1541bee96c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101461
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc
index 3625db6..b05db3e 100644
--- a/src/tint/writer/hlsl/generator_impl.cc
+++ b/src/tint/writer/hlsl/generator_impl.cc
@@ -3947,23 +3947,24 @@
std::string pre, post;
if (auto* decl = mem->Declaration()) {
for (auto* attr : decl->attributes) {
- if (auto* location = attr->As<ast::LocationAttribute>()) {
+ if (attr->Is<ast::LocationAttribute>()) {
auto& pipeline_stage_uses = str->PipelineStageUses();
if (pipeline_stage_uses.size() != 1) {
TINT_ICE(Writer, diagnostics_) << "invalid entry point IO struct uses";
}
+ auto loc = mem->Location().value();
if (pipeline_stage_uses.count(sem::PipelineStageUsage::kVertexInput)) {
- post += " : TEXCOORD" + std::to_string(location->value);
+ post += " : TEXCOORD" + std::to_string(loc);
} else if (pipeline_stage_uses.count(
sem::PipelineStageUsage::kVertexOutput)) {
- post += " : TEXCOORD" + std::to_string(location->value);
+ post += " : TEXCOORD" + std::to_string(loc);
} else if (pipeline_stage_uses.count(
sem::PipelineStageUsage::kFragmentInput)) {
- post += " : TEXCOORD" + std::to_string(location->value);
+ post += " : TEXCOORD" + std::to_string(loc);
} else if (pipeline_stage_uses.count(
sem::PipelineStageUsage::kFragmentOutput)) {
- post += " : SV_Target" + std::to_string(location->value);
+ post += " : SV_Target" + std::to_string(loc);
} else {
TINT_ICE(Writer, diagnostics_) << "invalid use of location attribute";
}