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 Naga variant to ShaderSource #2801

Merged
merged 2 commits into from
Jun 27, 2022
Merged

Add Naga variant to ShaderSource #2801

merged 2 commits into from
Jun 27, 2022

Conversation

atadier
Copy link
Contributor

@atadier atadier commented Jun 22, 2022

Connections
Implemention of #2788

Description
Adds a new Naga(Cell<naga::Module>) variant to ShaderSource. The module has to be wrapped in std::cell::Cell because naga::Module does not implement Copy.

Testing
cargo check --features naga passed on native target and WebAssembly.

wgpu/src/lib.rs Outdated Show resolved Hide resolved
@jimblandy
Copy link
Member

If we use Cell in wgpu::ShaderSource, then that makes it not implement Sync, which can be a pain. I think it should be fine if we simply pass in the naga::Module by value:

  • give ShaderSource a variant Naga(naga::Module), that owns the module,
  • change create_shader_module to simply take the ShaderModuleDescriptor by value, not by reference, and
  • plumb that through wgpu::Context::device_create_shader_module.

Then the direct back end can just move the naga::Module into the wgpu_hal::ShaderInput it creates.

This is a breaking API change, but now's the time to make such changes. I've pushed changes to pass ShaderModuleDescriptor by value here, in case you want to rebase your change on that: https://github.com/jimblandy/wgpu/tree/pass-ShaderModuleDescriptor-by-value
It's a big patch, but it's mechanical.

@atadier
Copy link
Contributor Author

atadier commented Jun 23, 2022

Had to force push to fix a git manipulation. The change should now be rebased correctly.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Cool beans

@cwfitzgerald cwfitzgerald enabled auto-merge (squash) June 27, 2022 02:28
jimblandy and others added 2 commits June 26, 2022 23:19
This will allow us to pass module representations that are neither
`Copy` nor `Clone`, like `naga::Module`.
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.

3 participants