Skip to content

Fix SPIRV struct reconstruction with bitfields - #5390

Merged
Nathan Gauër (Keenuts) merged 2 commits into
microsoft:mainfrom
Keenuts:struct-iteration
Jul 7, 2023
Merged

Nathan Gauër (Keenuts) merged 2 commits into
microsoft:mainfrom
Keenuts:struct-iteration

Conversation

@Keenuts

Copy link
Copy Markdown
Collaborator

HLSL/SPIR-V structs have some layout differences due to bitfields being squashed.
The reconstruction logic was using the AST layout, and not the new SPIR-V layout, meaning we could generate invalid indices during extraction/construction.

This PR fixes a potential bug with bitfields, while making the code reusable.

HLSL/SPIR-V structs have some layout differences due to
bitfields being squashed.
The reconstruction logic was using the AST layout, and not the
new SPIR-V layout, meaning we could generate invalid indices
during extraction/construction.

This PR a potential bug with bitfields, while making the code
reusable.

Signed-off-by: Nathan Gauër <[email protected]>
@Keenuts

Copy link
Copy Markdown
Collaborator Author

This PR is a split from #5388.
This is a different bug I needed to fix before. This one is can be submitted first, to make sure we focus on physical storage issue on the other PR.

@Keenuts
Nathan Gauër (Keenuts) enabled auto-merge (squash) July 5, 2023 16:42
@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

@dnovillo Diego Novillo (dnovillo) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a couple of nits and a question.

return output;
}

// Calls `operation` on for each field in the base and derives class defined by

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/on for/on/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/derives/derived/

// Calls `operation` on for each field in the base and derives class defined by
// `recordType`. The `operation` will receive the AST type linked to the field,
// the SPIRV type linked to the field, and the index of the field in the final
// SPIR-V representation. This index of the field can vary from the AST

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AST type is used to determine derived types exclusively, right?

@Keenuts
Nathan Gauër (Keenuts) merged commit dcf754c into microsoft:main Jul 7, 2023
@Keenuts
Nathan Gauër (Keenuts) deleted the struct-iteration branch September 9, 2025 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants