Skip to content

Commit

Permalink
Make ShaderSource own a Naga module
Browse files Browse the repository at this point in the history
  • Loading branch information
rttad committed Jun 23, 2022
1 parent dabdc6e commit 9477180
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion wgpu/src/backend/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ impl crate::Context for Context {
}
ShaderSource::Wgsl(ref code) => wgc::pipeline::ShaderModuleSource::Wgsl(Borrowed(code)),
#[cfg(feature = "naga")]
ShaderSource::Naga(ref module) => wgc::pipeline::ShaderModuleSource::Naga(module.take()),
ShaderSource::Naga(module) => wgc::pipeline::ShaderModuleSource::Naga(module),
};
let (id, error) = wgc::gfx_select!(
device.id => global.device_create_shader_module(device.id, &descriptor, source, PhantomData)
Expand Down
5 changes: 2 additions & 3 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ impl crate::Context for Context {
fn device_create_shader_module(
&self,
device: &Self::DeviceId,
desc: &crate::ShaderModuleDescriptor,
desc: crate::ShaderModuleDescriptor,
_shader_bound_checks: wgt::ShaderBoundChecks,
) -> Self::ShaderModuleId {
let mut descriptor = match desc.source {
Expand Down Expand Up @@ -1266,10 +1266,9 @@ impl crate::Context for Context {
}
crate::ShaderSource::Wgsl(ref code) => web_sys::GpuShaderModuleDescriptor::new(code),
#[cfg(feature = "naga")]
crate::ShaderSource::Naga(ref cell) => {
crate::ShaderSource::Naga(module) => {
use naga::{back, valid};

let module = cell.take();
let mut validator = valid::Validator::new(
valid::ValidationFlags::all(),
valid::Capabilities::all(),
Expand Down
2 changes: 1 addition & 1 deletion wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ pub enum ShaderSource<'a> {
/// Naga module.
#[cfg(feature = "naga")]
#[cfg_attr(docsrs, doc(cfg(feature = "naga")))]
Naga(std::cell::Cell<naga::Module>),
Naga(naga::Module),
}

/// Descriptor for use with [`Device::create_shader_module`].
Expand Down

0 comments on commit 9477180

Please sign in to comment.