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

Use naga::Module as a ShaderSource for non web targets #1507

Closed
Gordon-F opened this issue Jun 18, 2021 · 2 comments
Closed

Use naga::Module as a ShaderSource for non web targets #1507

Gordon-F opened this issue Jun 18, 2021 · 2 comments
Labels
area: api Issues related to API surface type: enhancement New feature or request

Comments

@Gordon-F
Copy link
Contributor

Gordon-F commented Jun 18, 2021

Is your feature request related to a problem? Please describe.
Use naga::Module as a ShaderSource for non web targets like spv.

Describe the solution you'd like
Accept naga::Module in ShaderSource. wgpu-core already accept it.

wgpu/wgpu/src/lib.rs

Lines 732 to 745 in 0c76819

pub enum ShaderSource<'a> {
/// SPIR-V module represented as a slice of words.
///
/// wgpu will attempt to parse and validate it, but the original binary
/// is passed to `gfx-rs` and `spirv_cross` for translation.
SpirV(Cow<'a, [u32]>),
/// WGSL module as a string slice.
///
/// wgpu-rs will parse it and use for validation. It will attempt
/// to build a SPIR-V module internally and panic otherwise.
///
/// Note: WGSL is not yet supported on the Web.
Wgsl(Cow<'a, str>),
}

Describe alternatives you've considered
Use naga to produce wgsl or spv from IR in user projects.

@kvark kvark added area: api Issues related to API surface type: enhancement New feature or request labels Jun 18, 2021
@kvark
Copy link
Member

kvark commented Jun 18, 2021

I think that would be fine from the API point of view. Now that there is a WGSL backend, we can generate the shader for the web target internally.
However, it may be less usable than it seems: naga modules are not clone-able. So if @Frizi wants to try it out and report back, we can use this input to figure out if this can be reasonably exposed.

@daxpedda
Copy link
Contributor

This can be closed I believe.
Has been implemented by #2801. I also made Module cloneable in gfx-rs/naga#2013.

Patryk27 pushed a commit to Patryk27/wgpu that referenced this issue Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants