Skip to content

fixed mat2xc alignment in spv#9369

Open
39ali wants to merge 2 commits intogfx-rs:trunkfrom
39ali:mat2-fix-spv
Open

fixed mat2xc alignment in spv#9369
39ali wants to merge 2 commits intogfx-rs:trunkfrom
39ali:mat2-fix-spv

Conversation

@39ali
Copy link
Copy Markdown
Contributor

@39ali 39ali commented Apr 4, 2026

Connections
#9011

Description
fix mat2xc alignment issues in spv when using uniforms, fix issues with uniform array as well

Testing
Explain how this change is tested.

Squash or Rebase?
either

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

Copy link
Copy Markdown
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

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

There are no tests, here, but if we need a fix, we need tests, too! Will you please add some tests (preferably snapshot tests emitting the "wrong" code from before) and then amend the current commit to add the snapshot changes?

Copy link
Copy Markdown
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

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

This also needs a CHANGELOG entry.

@39ali
Copy link
Copy Markdown
Contributor Author

39ali commented Apr 8, 2026

@ErichDonGubler i did the changes, i can't have an old snapshot because naga would crash

@cwfitzgerald
Copy link
Copy Markdown
Member

Could you explain what this fix is actually doing, I'm not sure I understand it

@39ali
Copy link
Copy Markdown
Contributor Author

39ali commented Apr 9, 2026

@cwfitzgerald
it checks to see if a sub-element (like an array index or a struct member) actually needs conversion, before
the code have been blindly attempting to call a conversion function for every element. the conversion function should only be called if a mapping for that specific type exists in std140_compat_uniform_types.
tldr :

  • check if the type is marked as needing std140 compatibility.

  • loop through the elements (of an array or struct).

  • for each element, see if it also needs a layout fix.

  • If yes, emit a FunctionCall to the conversion helper. If no, use the ID as-is.

and lastly create a new object that is aligned correctly.

@inner-daemons inner-daemons removed their request for review April 12, 2026 02:41
@inner-daemons inner-daemons removed their assignment Apr 12, 2026
@inner-daemons
Copy link
Copy Markdown
Collaborator

I'm gonna unassign myself since I'm not too familiar with this part of the codebase. Up to you @cwfitzgerald.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants