From a656eaa1b6ef933cef054a590f1d86928a5ce9e5 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 23 Mar 2019 22:30:08 -0400 Subject: [PATCH] gfx update and support for acquire fences --- Cargo.lock | 12 ++++++------ libportability-gfx/src/conv.rs | 4 ++++ libportability-gfx/src/impls.rs | 9 ++------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e26a4a5..2fe7242 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -310,7 +310,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gfx-backend-dx11" version = "0.1.1" -source = "git+https://github.com/gfx-rs/gfx#3afab46c73a5cf711cd398deda8acb9a009a5b2a" +source = "git+https://github.com/gfx-rs/gfx#c8e7aeb2ec8cb39bd95292a5a95d7fffb46ece89" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -328,7 +328,7 @@ dependencies = [ [[package]] name = "gfx-backend-dx12" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#3afab46c73a5cf711cd398deda8acb9a009a5b2a" +source = "git+https://github.com/gfx-rs/gfx#c8e7aeb2ec8cb39bd95292a5a95d7fffb46ece89" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "d3d12 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -345,7 +345,7 @@ dependencies = [ [[package]] name = "gfx-backend-metal" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#3afab46c73a5cf711cd398deda8acb9a009a5b2a" +source = "git+https://github.com/gfx-rs/gfx#c8e7aeb2ec8cb39bd95292a5a95d7fffb46ece89" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -369,7 +369,7 @@ dependencies = [ [[package]] name = "gfx-backend-vulkan" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#3afab46c73a5cf711cd398deda8acb9a009a5b2a" +source = "git+https://github.com/gfx-rs/gfx#c8e7aeb2ec8cb39bd95292a5a95d7fffb46ece89" dependencies = [ "ash 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -386,7 +386,7 @@ dependencies = [ [[package]] name = "gfx-hal" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#3afab46c73a5cf711cd398deda8acb9a009a5b2a" +source = "git+https://github.com/gfx-rs/gfx#c8e7aeb2ec8cb39bd95292a5a95d7fffb46ece89" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -865,7 +865,7 @@ dependencies = [ [[package]] name = "range-alloc" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#3afab46c73a5cf711cd398deda8acb9a009a5b2a" +source = "git+https://github.com/gfx-rs/gfx#c8e7aeb2ec8cb39bd95292a5a95d7fffb46ece89" [[package]] name = "rdrand" diff --git a/libportability-gfx/src/conv.rs b/libportability-gfx/src/conv.rs index 17ea574..b487cf3 100644 --- a/libportability-gfx/src/conv.rs +++ b/libportability-gfx/src/conv.rs @@ -7,6 +7,7 @@ use super::*; pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits { + let viewport_size = limits.max_viewport_dimensions[0].max(limits.max_viewport_dimensions[1]); VkPhysicalDeviceLimits { maxImageDimension1D: limits.max_image_1d_size, maxImageDimension2D: limits.max_image_2d_size, @@ -19,6 +20,9 @@ pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits { maxPushConstantsSize: limits.max_push_constants_size as _, maxViewports: limits.max_viewports as _, maxViewportDimensions: limits.max_viewport_dimensions, + // Warning: spec violation + // "The x/y rectangle of the viewport must lie entirely within the current attachment size." + viewportBoundsRange: [0.0, viewport_size as f32], maxVertexInputAttributes: limits.max_vertex_input_attributes as _, maxVertexInputBindings: limits.max_vertex_input_bindings as _, maxVertexInputAttributeOffset: limits.max_vertex_input_attribute_offset as _, diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 23dccf7..a4d2d45 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -1,7 +1,7 @@ use hal::{command as com, memory, pass, pso, queue}; use hal::{ DescriptorPool, Device, Features, Instance, PhysicalDevice, QueueFamily, - Surface, Swapchain as HalSwapchain, FrameSync, + Surface, Swapchain as _, }; use hal::buffer::IndexBufferView; use hal::command::RawCommandBuffer; @@ -4577,18 +4577,13 @@ pub extern "C" fn gfxAcquireNextImageKHR( fence: VkFence, pImageIndex: *mut u32, ) -> VkResult { - let sync = match semaphore.as_ref() { - Some(sem) => FrameSync::Semaphore(sem), - None => FrameSync::Fence(&*fence), - }; - let raw = match swapchain.raw { Some(ref mut raw) => raw, None => return VkResult::VK_ERROR_OUT_OF_DATE_KHR, }; match unsafe { - raw.acquire_image(timeout, sync) + raw.acquire_image(timeout, semaphore.as_ref(), fence.as_ref()) } { Ok(frame) => { unsafe { *pImageIndex = frame; }