From 49e56fef9d32e53ed20cae4bfcd0013f66d3fd21 Mon Sep 17 00:00:00 2001 From: rttad Date: Thu, 23 Jun 2022 09:51:28 +0200 Subject: [PATCH] Make ShaderSource own a Naga module --- wgpu/src/backend/direct.rs | 2 +- wgpu/src/backend/web.rs | 5 ++--- wgpu/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index b2645815fb..fbb41272cb 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -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) diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index b33adecf9e..84a1238721 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -1208,7 +1208,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 { @@ -1265,10 +1265,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(), diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 76bd2d7431..00e45e6a9d 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -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(naga::Module), } /// Descriptor for use with [`Device::create_shader_module`].