From 6e0ce965bf20885db805be1a08d2e51800cc46bc Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Tue, 5 Jun 2018 12:57:17 -0400 Subject: [PATCH] Cleaner destruction of events and query pools --- Cargo.lock | 8 ++++---- Makefile | 2 +- libportability-gfx/src/conv.rs | 2 ++ libportability-gfx/src/impls.rs | 24 ++++++++++++++---------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a1abd3..c4a569c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -252,7 +252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gfx-backend-dx12" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#91ec6303fded63498b01e4a55e8ebe6768d3c2cc" +source = "git+https://github.com/gfx-rs/gfx#505e8057803d8cc0302b5fdcfe7ae807b8f3b8cf" dependencies = [ "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)", @@ -268,7 +268,7 @@ dependencies = [ [[package]] name = "gfx-backend-metal" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#91ec6303fded63498b01e4a55e8ebe6768d3c2cc" +source = "git+https://github.com/gfx-rs/gfx#505e8057803d8cc0302b5fdcfe7ae807b8f3b8cf" dependencies = [ "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)", @@ -290,7 +290,7 @@ dependencies = [ [[package]] name = "gfx-backend-vulkan" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#91ec6303fded63498b01e4a55e8ebe6768d3c2cc" +source = "git+https://github.com/gfx-rs/gfx#505e8057803d8cc0302b5fdcfe7ae807b8f3b8cf" dependencies = [ "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)", @@ -308,7 +308,7 @@ dependencies = [ [[package]] name = "gfx-hal" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#91ec6303fded63498b01e4a55e8ebe6768d3c2cc" +source = "git+https://github.com/gfx-rs/gfx#505e8057803d8cc0302b5fdcfe7ae807b8f3b8cf" dependencies = [ "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)", diff --git a/Makefile b/Makefile index ab576ea..4352ab9 100644 --- a/Makefile +++ b/Makefile @@ -104,4 +104,4 @@ clean: cargo clean 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 diff --git a/libportability-gfx/src/conv.rs b/libportability-gfx/src/conv.rs index d7b3b2a..b47a3b0 100644 --- a/libportability-gfx/src/conv.rs +++ b/libportability-gfx/src/conv.rs @@ -12,6 +12,8 @@ pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits { maxImageDimension2D: limits.max_texture_size as _, maxImageDimension3D: 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 maxTessellationPatchSize: limits.max_patch_size as _, maxViewports: limits.max_viewports as _, diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 3787a23..754f87b 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -10,9 +10,7 @@ use hal::command::RawCommandBuffer; use hal::queue::RawCommandQueue; use std::ffi::{CStr, CString}; -use std::mem; -#[cfg(feature = "renderdoc")] -use std::ptr; +use std::{mem, ptr}; #[cfg(feature = "renderdoc")] use std::os::raw::c_void; @@ -596,11 +594,12 @@ 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(mut d) = gpu.unbox() { + if let Some(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()); } @@ -1142,10 +1141,12 @@ pub extern "C" fn gfxCreateEvent( #[inline] pub extern "C" fn gfxDestroyEvent( _gpu: VkDevice, - _event: VkEvent, + event: VkEvent, _pAllocator: *const VkAllocationCallbacks, ) { - unimplemented!() + if event != ptr::null_mut() { + unimplemented!() + } } #[inline] pub extern "C" fn gfxGetEventStatus(_gpu: VkDevice, _event: VkEvent) -> VkResult { @@ -1172,10 +1173,12 @@ pub extern "C" fn gfxCreateQueryPool( #[inline] pub extern "C" fn gfxDestroyQueryPool( _gpu: VkDevice, - _queryPool: VkQueryPool, + queryPool: VkQueryPool, _pAllocator: *const VkAllocationCallbacks, ) { - unimplemented!() + if queryPool != ptr::null_mut() { + unimplemented!() + } } #[inline] pub extern "C" fn gfxGetQueryPoolResults( @@ -2540,9 +2543,10 @@ pub extern "C" fn gfxDestroyRenderPass( pub extern "C" fn gfxGetRenderAreaGranularity( _gpu: VkDevice, _renderPass: VkRenderPass, - _pGranularity: *mut VkExtent2D, + pGranularity: *mut VkExtent2D, ) { - unimplemented!() + let granularity = VkExtent2D { width: 1, height: 1 }; //TODO? + unsafe { *pGranularity = granularity }; } #[inline]