mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-27 01:11:32 +11:00
Compute PSO creation refactor
This commit is contained in:
parent
6e0ce965bf
commit
f89c417b89
|
@ -594,16 +594,15 @@ pub extern "C" fn gfxCreateDevice(
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxDestroyDevice(gpu: VkDevice, _pAllocator: *const VkAllocationCallbacks) {
|
pub extern "C" fn gfxDestroyDevice(gpu: VkDevice, _pAllocator: *const VkAllocationCallbacks) {
|
||||||
// release all the owned command queues
|
// release all the owned command queues
|
||||||
if let Some(d) = gpu.unbox() {
|
if let Some(mut d) = gpu.unbox() {
|
||||||
#[cfg(feature = "renderdoc")]
|
#[cfg(feature = "renderdoc")]
|
||||||
{
|
{
|
||||||
use renderdoc::api::RenderDocV100;
|
use renderdoc::api::RenderDocV100;
|
||||||
let device = gpu.capturing as *mut c_void;
|
let device = gpu.capturing as *mut c_void;
|
||||||
let mut d = d;
|
|
||||||
d.renderdoc.end_frame_capture(device as *mut _, ptr::null());
|
d.renderdoc.end_frame_capture(device as *mut _, ptr::null());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (_, family) in d.queues {
|
for (_, family) in d.queues.drain() {
|
||||||
for queue in family {
|
for queue in family {
|
||||||
let _ = queue.unbox();
|
let _ = queue.unbox();
|
||||||
}
|
}
|
||||||
|
@ -1487,7 +1486,7 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
|
||||||
.pSpecializationInfo
|
.pSpecializationInfo
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(conv::map_specialization_info)
|
.map(conv::map_specialization_info)
|
||||||
.unwrap_or(vec![])
|
.unwrap_or_default()
|
||||||
};
|
};
|
||||||
|
|
||||||
shader_stages.push((
|
shader_stages.push((
|
||||||
|
@ -1866,27 +1865,31 @@ pub extern "C" fn gfxCreateComputePipelines(
|
||||||
slice::from_raw_parts(pCreateInfos, createInfoCount as _)
|
slice::from_raw_parts(pCreateInfos, createInfoCount as _)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut shader_stages = Vec::with_capacity(infos.len());
|
|
||||||
|
|
||||||
// Collect all information which we will borrow later. Need to work around
|
// Collect all information which we will borrow later. Need to work around
|
||||||
// the borrow checker here.
|
// the borrow checker here.
|
||||||
// TODO: try to refactor it once we have a more generic API
|
// TODO: try to refactor it once we have a more generic API
|
||||||
for info in infos {
|
let shader_stages = infos
|
||||||
|
.iter()
|
||||||
|
.map(|info| {
|
||||||
let name = unsafe { CStr::from_ptr(info.stage.pName).to_owned() };
|
let name = unsafe { CStr::from_ptr(info.stage.pName).to_owned() };
|
||||||
let specialization = unsafe { info.stage
|
let specialization = unsafe { info.stage
|
||||||
.pSpecializationInfo
|
.pSpecializationInfo
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(conv::map_specialization_info)
|
.map(conv::map_specialization_info)
|
||||||
.unwrap_or(vec![])
|
.unwrap_or_default()
|
||||||
};
|
};
|
||||||
|
|
||||||
shader_stages.push((
|
(
|
||||||
name.into_string().unwrap(),
|
name.into_string().unwrap(),
|
||||||
specialization,
|
specialization,
|
||||||
));
|
)
|
||||||
}
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let descs = infos.into_iter().zip(&shader_stages).map(|(info, &(ref entry, ref specialization))| {
|
let descs = infos
|
||||||
|
.into_iter()
|
||||||
|
.zip(&shader_stages)
|
||||||
|
.map(|(info, &(ref entry, ref specialization))| {
|
||||||
let shader = pso::EntryPoint {
|
let shader = pso::EntryPoint {
|
||||||
entry,
|
entry,
|
||||||
module: &*info.stage.module,
|
module: &*info.stage.module,
|
||||||
|
@ -1928,7 +1931,8 @@ pub extern "C" fn gfxCreateComputePipelines(
|
||||||
flags,
|
flags,
|
||||||
parent,
|
parent,
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>();
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let pipelines = gpu.device.create_compute_pipelines(&descs);
|
let pipelines = gpu.device.create_compute_pipelines(&descs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue