93: Cleaner destruction of events and query pools r=msiglreith a=kvark



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot] 2018-06-05 20:30:15 +00:00
commit 1d55d3413c
4 changed files with 80 additions and 70 deletions

8
Cargo.lock generated
View file

@ -252,7 +252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "gfx-backend-dx12" name = "gfx-backend-dx12"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/gfx-rs/gfx#91ec6303fded63498b01e4a55e8ebe6768d3c2cc" source = "git+https://github.com/gfx-rs/gfx#505e8057803d8cc0302b5fdcfe7ae807b8f3b8cf"
dependencies = [ dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -268,7 +268,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-backend-metal" name = "gfx-backend-metal"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/gfx-rs/gfx#91ec6303fded63498b01e4a55e8ebe6768d3c2cc" source = "git+https://github.com/gfx-rs/gfx#505e8057803d8cc0302b5fdcfe7ae807b8f3b8cf"
dependencies = [ dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -290,7 +290,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-backend-vulkan" name = "gfx-backend-vulkan"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/gfx-rs/gfx#91ec6303fded63498b01e4a55e8ebe6768d3c2cc" source = "git+https://github.com/gfx-rs/gfx#505e8057803d8cc0302b5fdcfe7ae807b8f3b8cf"
dependencies = [ dependencies = [
"ash 0.24.3 (registry+https://github.com/rust-lang/crates.io-index)", "ash 0.24.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -308,7 +308,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-hal" name = "gfx-hal"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/gfx-rs/gfx#91ec6303fded63498b01e4a55e8ebe6768d3c2cc" source = "git+https://github.com/gfx-rs/gfx#505e8057803d8cc0302b5fdcfe7ae807b8f3b8cf"
dependencies = [ dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -104,4 +104,4 @@ clean:
cargo clean cargo clean
cherry: $(TARGET) cherry: $(TARGET)
cd $(CHERRY_DIR) && RUST_LOG=warn LD_LIBRARY_PATH=$(FULL_LIBRARY_PATH) go run server.go cd $(CHERRY_DIR) && rm -f Cherry.db && RUST_LOG=warn LD_LIBRARY_PATH=$(FULL_LIBRARY_PATH) go run server.go

View file

@ -12,6 +12,8 @@ pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits {
maxImageDimension2D: limits.max_texture_size as _, maxImageDimension2D: limits.max_texture_size as _,
maxImageDimension3D: limits.max_texture_size as _, maxImageDimension3D: limits.max_texture_size as _,
maxImageDimensionCube: limits.max_texture_size as _, maxImageDimensionCube: limits.max_texture_size as _,
maxFramebufferWidth: limits.max_texture_size as _, //TODO
maxFramebufferHeight: limits.max_texture_size as _, //TODO
maxTexelBufferElements: limits.max_texture_size as _, //TODO maxTexelBufferElements: limits.max_texture_size as _, //TODO
maxTessellationPatchSize: limits.max_patch_size as _, maxTessellationPatchSize: limits.max_patch_size as _,
maxViewports: limits.max_viewports as _, maxViewports: limits.max_viewports as _,

View file

@ -10,9 +10,7 @@ use hal::command::RawCommandBuffer;
use hal::queue::RawCommandQueue; use hal::queue::RawCommandQueue;
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::mem; use std::{mem, ptr};
#[cfg(feature = "renderdoc")]
use std::ptr;
#[cfg(feature = "renderdoc")] #[cfg(feature = "renderdoc")]
use std::os::raw::c_void; use std::os::raw::c_void;
@ -604,7 +602,7 @@ pub extern "C" fn gfxDestroyDevice(gpu: VkDevice, _pAllocator: *const VkAllocati
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();
} }
@ -1142,10 +1140,12 @@ pub extern "C" fn gfxCreateEvent(
#[inline] #[inline]
pub extern "C" fn gfxDestroyEvent( pub extern "C" fn gfxDestroyEvent(
_gpu: VkDevice, _gpu: VkDevice,
_event: VkEvent, event: VkEvent,
_pAllocator: *const VkAllocationCallbacks, _pAllocator: *const VkAllocationCallbacks,
) { ) {
if event != ptr::null_mut() {
unimplemented!() unimplemented!()
}
} }
#[inline] #[inline]
pub extern "C" fn gfxGetEventStatus(_gpu: VkDevice, _event: VkEvent) -> VkResult { pub extern "C" fn gfxGetEventStatus(_gpu: VkDevice, _event: VkEvent) -> VkResult {
@ -1172,10 +1172,12 @@ pub extern "C" fn gfxCreateQueryPool(
#[inline] #[inline]
pub extern "C" fn gfxDestroyQueryPool( pub extern "C" fn gfxDestroyQueryPool(
_gpu: VkDevice, _gpu: VkDevice,
_queryPool: VkQueryPool, queryPool: VkQueryPool,
_pAllocator: *const VkAllocationCallbacks, _pAllocator: *const VkAllocationCallbacks,
) { ) {
if queryPool != ptr::null_mut() {
unimplemented!() unimplemented!()
}
} }
#[inline] #[inline]
pub extern "C" fn gfxGetQueryPoolResults( pub extern "C" fn gfxGetQueryPoolResults(
@ -1484,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((
@ -1863,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,
@ -1925,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);
@ -2540,9 +2547,10 @@ pub extern "C" fn gfxDestroyRenderPass(
pub extern "C" fn gfxGetRenderAreaGranularity( pub extern "C" fn gfxGetRenderAreaGranularity(
_gpu: VkDevice, _gpu: VkDevice,
_renderPass: VkRenderPass, _renderPass: VkRenderPass,
_pGranularity: *mut VkExtent2D, pGranularity: *mut VkExtent2D,
) { ) {
unimplemented!() let granularity = VkExtent2D { width: 1, height: 1 }; //TODO?
unsafe { *pGranularity = granularity };
} }
#[inline] #[inline]