mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
change Device.create_shader_module
to return an Arc<ShaderModule<A>
This commit is contained in:
parent
d8b1c5788a
commit
f6a3eef77e
@ -28,11 +28,7 @@ use hal::Device as _;
|
||||
|
||||
use wgt::{BufferAddress, TextureFormat};
|
||||
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
ptr::NonNull,
|
||||
sync::{atomic::Ordering, Arc},
|
||||
};
|
||||
use std::{borrow::Cow, ptr::NonNull, sync::atomic::Ordering};
|
||||
|
||||
use super::{ImplicitPipelineIds, UserClosures};
|
||||
|
||||
@ -996,7 +992,7 @@ impl Global {
|
||||
Err(e) => break 'error e,
|
||||
};
|
||||
|
||||
let id = fid.assign(Arc::new(shader));
|
||||
let id = fid.assign(shader);
|
||||
api_log!("Device::create_shader_module -> {id:?}");
|
||||
return (id, None);
|
||||
};
|
||||
@ -1050,7 +1046,7 @@ impl Global {
|
||||
Ok(shader) => shader,
|
||||
Err(e) => break 'error e,
|
||||
};
|
||||
let id = fid.assign(Arc::new(shader));
|
||||
let id = fid.assign(shader);
|
||||
api_log!("Device::create_shader_module_spirv -> {id:?}");
|
||||
return (id, None);
|
||||
};
|
||||
|
@ -1429,7 +1429,7 @@ impl<A: HalApi> Device<A> {
|
||||
self: &Arc<Self>,
|
||||
desc: &pipeline::ShaderModuleDescriptor<'a>,
|
||||
source: pipeline::ShaderModuleSource<'a>,
|
||||
) -> Result<pipeline::ShaderModule<A>, pipeline::CreateShaderModuleError> {
|
||||
) -> Result<Arc<pipeline::ShaderModule<A>>, pipeline::CreateShaderModuleError> {
|
||||
self.check_is_valid()?;
|
||||
|
||||
let (module, source) = match source {
|
||||
@ -1546,12 +1546,16 @@ impl<A: HalApi> Device<A> {
|
||||
}
|
||||
};
|
||||
|
||||
Ok(pipeline::ShaderModule {
|
||||
let module = pipeline::ShaderModule {
|
||||
raw: Some(raw),
|
||||
device: self.clone(),
|
||||
interface: Some(interface),
|
||||
label: desc.label.to_string(),
|
||||
})
|
||||
};
|
||||
|
||||
let module = Arc::new(module);
|
||||
|
||||
Ok(module)
|
||||
}
|
||||
|
||||
#[allow(unused_unsafe)]
|
||||
@ -1559,7 +1563,7 @@ impl<A: HalApi> Device<A> {
|
||||
self: &Arc<Self>,
|
||||
desc: &pipeline::ShaderModuleDescriptor<'a>,
|
||||
source: &'a [u32],
|
||||
) -> Result<pipeline::ShaderModule<A>, pipeline::CreateShaderModuleError> {
|
||||
) -> Result<Arc<pipeline::ShaderModule<A>>, pipeline::CreateShaderModuleError> {
|
||||
self.check_is_valid()?;
|
||||
|
||||
self.require_features(wgt::Features::SPIRV_SHADER_PASSTHROUGH)?;
|
||||
@ -1588,12 +1592,16 @@ impl<A: HalApi> Device<A> {
|
||||
}
|
||||
};
|
||||
|
||||
Ok(pipeline::ShaderModule {
|
||||
let module = pipeline::ShaderModule {
|
||||
raw: Some(raw),
|
||||
device: self.clone(),
|
||||
interface: None,
|
||||
label: desc.label.to_string(),
|
||||
})
|
||||
};
|
||||
|
||||
let module = Arc::new(module);
|
||||
|
||||
Ok(module)
|
||||
}
|
||||
|
||||
pub(crate) fn create_command_encoder(
|
||||
|
Loading…
Reference in New Issue
Block a user