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

glsl-out: Add support for push constant emulation #1672

Merged
merged 2 commits into from
Jan 17, 2022

Conversation

JCapucho
Copy link
Collaborator

This PR allows for the glsl backend to output push constants as uniform buffers to allow for push constant emulation.

It only allows for one push constant per entry point, which is fine in my opinion since even vulkan glsl only allows one push_constant decoration per shader.

It also changes the ReflectionInfo to return a name of the uniform buffer used for the emulation if it was used and Options to take the binding to use for the buffer if explicit bindings are supported.

This interface is deeply tied with the changes for push constant emulation on wgpu, so it might be useful to also see it JCapucho/wgpu@ee3887e

Note: I don't have much experience with openGL so the code might not be the best.

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.

Looks great!
Can we have a small glsl test for this (or add it to an existing one)?

@JCapucho
Copy link
Collaborator Author

@kvark I've added a test, it's basically a stripped down version of extra.wgsl, I tried to reuse it but it uses f64s which gles doesn't support, so I've copied the push constant parts and made it only output to glsl with version 320 to also check if the explicit bindings are working.

@@ -439,6 +439,7 @@ fn convert_wgsl() {
Targets::SPIRV | Targets::METAL | Targets::HLSL | Targets::WGSL | Targets::GLSL,
),
("extra", Targets::SPIRV | Targets::METAL | Targets::WGSL),
("push-constants", Targets::GLSL),
Copy link
Member

Choose a reason for hiding this comment

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

Since extra enables push constants, could we just enable it instead of the new test?

Copy link
Collaborator Author

@JCapucho JCapucho Jan 16, 2022

Choose a reason for hiding this comment

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

I wrote about it in my comment, extra.wgsl uses f64s which gles doesn't support

Copy link
Member

Choose a reason for hiding this comment

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

oh sorry, didn't see this

@kvark kvark merged commit a1840be into gfx-rs:master Jan 17, 2022
@JCapucho JCapucho deleted the glsl-out-push-constant branch February 19, 2022 15:11
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.

2 participants