[spirv-reader][ir] Remove struct attributes after processing inputs
When processing inputs/outputs in the SPIR-V lowering ShaderIO we need
to make sure the attributes exist on the structures when processing the
input variables. Move the removal of the attributes into the main
process call after input processing.
Bug: 42250952
Change-Id: I1620de2f0cd79bb9c2032d294ec7f6549147ce3b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/247414
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/spirv/reader/lower/shader_io.cc b/src/tint/lang/spirv/reader/lower/shader_io.cc
index 5fabd86..949641f 100644
--- a/src/tint/lang/spirv/reader/lower/shader_io.cc
+++ b/src/tint/lang/spirv/reader/lower/shader_io.cc
@@ -75,6 +75,19 @@
// be propagated through.
ProcessOutputs();
ProcessInputs();
+
+ // Remove attributes from all of the original structs and module-scope output variables.
+ // This is done last as we need to copy attributes during `ProcessEntryPointOutputs()` and
+ // we need access to any struct locations during processing of inputs.
+ for (auto& var : output_variables) {
+ var->ResetAttributes();
+ if (auto* str = var->Result()->Type()->UnwrapPtr()->As<core::type::Struct>()) {
+ for (auto* member : str->Members()) {
+ // TODO(crbug.com/tint/745): Remove the const_cast.
+ const_cast<core::type::StructMember*>(member)->ResetAttributes();
+ }
+ }
+ }
}
/// Process output variables.
@@ -93,18 +106,6 @@
for (auto& ep : entry_points) {
ProcessEntryPointOutputs(ep);
}
-
- // Remove attributes from all of the original structs and module-scope output variables.
- // This is done last as we need to copy attributes during `ProcessEntryPointOutputs()`.
- for (auto& var : output_variables) {
- var->ResetAttributes();
- if (auto* str = var->Result()->Type()->UnwrapPtr()->As<core::type::Struct>()) {
- for (auto* member : str->Members()) {
- // TODO(crbug.com/tint/745): Remove the const_cast.
- const_cast<core::type::StructMember*>(member)->ResetAttributes();
- }
- }
- }
}
/// Process input variables.