mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-26 17:01:31 +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]
|
||||
pub extern "C" fn gfxDestroyDevice(gpu: VkDevice, _pAllocator: *const VkAllocationCallbacks) {
|
||||
// release all the owned command queues
|
||||
if let Some(d) = gpu.unbox() {
|
||||
if let Some(mut d) = gpu.unbox() {
|
||||
#[cfg(feature = "renderdoc")]
|
||||
{
|
||||
use renderdoc::api::RenderDocV100;
|
||||
let device = gpu.capturing as *mut c_void;
|
||||
let mut d = d;
|
||||
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 {
|
||||
let _ = queue.unbox();
|
||||
}
|
||||
|
@ -1487,7 +1486,7 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
|
|||
.pSpecializationInfo
|
||||
.as_ref()
|
||||
.map(conv::map_specialization_info)
|
||||
.unwrap_or(vec![])
|
||||
.unwrap_or_default()
|
||||
};
|
||||
|
||||
shader_stages.push((
|
||||
|
@ -1866,27 +1865,31 @@ pub extern "C" fn gfxCreateComputePipelines(
|
|||
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
|
||||
// the borrow checker here.
|
||||
// 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 specialization = unsafe { info.stage
|
||||
.pSpecializationInfo
|
||||
.as_ref()
|
||||
.map(conv::map_specialization_info)
|
||||
.unwrap_or(vec![])
|
||||
.unwrap_or_default()
|
||||
};
|
||||
|
||||
shader_stages.push((
|
||||
(
|
||||
name.into_string().unwrap(),
|
||||
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 {
|
||||
entry,
|
||||
module: &*info.stage.module,
|
||||
|
@ -1928,7 +1931,8 @@ pub extern "C" fn gfxCreateComputePipelines(
|
|||
flags,
|
||||
parent,
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let pipelines = gpu.device.create_compute_pipelines(&descs);
|
||||
|
||||
|
|
Loading…
Reference in a new issue