Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for vecN<i32> and vecN<u32> to dot() function #1689

Merged
merged 18 commits into from
Feb 3, 2022

Conversation

francesco-cattoglio
Copy link
Contributor

Work-in-progress pull request to fix #1667

Right now I have only implemented this for glsl-out to get an early review.
By reading the discussion at gpuweb/gpuweb#2231 and the minutes in https://docs.google.com/document/d/1o3BrMEZnE3Yat95uLiY06opF2Hmcj5XGlQmBhTT-_dQ/edit# I understand that:

  • HLSL requires no extra changes, the dot() function will just work
  • MSL and Spir-V will require changes to the code similar to the ones made for GLSL: if vectors of integers are involved we need to turn the dot() call into an arithmetic expression.

src/back/glsl/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

This is looking good!
Just one more thing :)

src/back/glsl/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

very nice!

src/back/msl/writer.rs Outdated Show resolved Hide resolved
src/back/msl/writer.rs Outdated Show resolved Hide resolved
src/back/msl/writer.rs Outdated Show resolved Hide resolved
src/back/msl/writer.rs Outdated Show resolved Hide resolved
src/back/msl/writer.rs Outdated Show resolved Hide resolved
src/back/spv/block.rs Outdated Show resolved Hide resolved
src/back/spv/block.rs Outdated Show resolved Hide resolved
src/back/spv/block.rs Outdated Show resolved Hide resolved
@francesco-cattoglio
Copy link
Contributor Author

I implemented the requested changes. On MSL and GLSL back I think I did a pretty good job so far. When refactoring the sum of components into a loop I incorporated the x as well, and therefore there will be an extra "+" sign at the beginning of the produced expression. Let me know if you like it or not. If not, I will move the product of x outside of the loop.

On spv back, I tried my best to reduce repetition, but perhaps I wrote some "clever code" that is just "confusing and obscure" code for something that could have been done much easier.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

One last thing!

src/back/spv/block.rs Outdated Show resolved Hide resolved
This is because I wanted to highlight the fact that the correct
id is used in the last sum of the integer dot product expression
since it could not fail, changed it to simply return `void`
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

great!

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.

[wgsl-in] dot product on integers isn't implemented
2 participants