From 1f69948ef147368f17291bcdbb716f558e8d28d9 Mon Sep 17 00:00:00 2001 From: msiglreith Date: Mon, 29 Jan 2018 23:25:15 +0100 Subject: [PATCH] Update to latest master --- libportability-gfx/src/conv.rs | 12 +++++++++--- libportability-gfx/src/impls.rs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/libportability-gfx/src/conv.rs b/libportability-gfx/src/conv.rs index c10dacb..3de0c87 100644 --- a/libportability-gfx/src/conv.rs +++ b/libportability-gfx/src/conv.rs @@ -1,4 +1,4 @@ -use hal::{adapter, buffer, command, format, image, memory, pass, pso, window}; +use hal::{buffer, command, error, format, image, memory, pass, pso, window}; use hal::{PatchSize, Primitive}; use std::mem; @@ -355,8 +355,8 @@ pub fn map_pipeline_stage_flags(stages: VkPipelineStageFlags) -> pso::PipelineSt } } -pub fn map_err_device_creation(err: adapter::DeviceCreationError) -> VkResult { - use hal::adapter::DeviceCreationError::*; +pub fn map_err_device_creation(err: error::DeviceCreationError) -> VkResult { + use hal::error::DeviceCreationError::*; match err { OutOfHostMemory => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY, @@ -523,3 +523,9 @@ pub fn map_blend_op( ) -> pso::BlendOp { unimplemented!() } + +#[inline] +pub fn map_cmd_buffer_usage(flags: VkCommandBufferUsageFlags) -> command::CommandBufferFlags { + // Vulkan and HAL flags are equal + unsafe { mem::transmute(flags as u16) } +} diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index feb4dee..5d77e9c 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -5,7 +5,7 @@ use hal::{ }; use hal::device::WaitFor; use hal::pool::RawCommandPool; -use hal::command::{ClearValueRaw, RawCommandBuffer, Rect, Viewport}; +use hal::command::{ClearValueRaw, RawCommandBuffer, RawLevel, Rect, Viewport}; use hal::queue::RawCommandQueue; use std::ffi::{CStr, CString}; @@ -1934,13 +1934,15 @@ pub extern "C" fn gfxAllocateCommandBuffers( pCommandBuffers: *mut VkCommandBuffer, ) -> VkResult { let info = unsafe { &mut *(pAllocateInfo as *mut VkCommandBufferAllocateInfo) }; - assert_eq!( - info.level, - VkCommandBufferLevel::VK_COMMAND_BUFFER_LEVEL_PRIMARY - ); //TODO + let level = match info.level { + VkCommandBufferLevel::VK_COMMAND_BUFFER_LEVEL_PRIMARY => RawLevel::Primary, + VkCommandBufferLevel::VK_COMMAND_BUFFER_LEVEL_SECONDARY => RawLevel::Secondary, + level => panic!("Unexpected command buffer lvel: {:?}", level), + }; + let count = info.commandBufferCount as usize; - let cmd_bufs = info.commandPool.allocate(count); + let cmd_bufs = info.commandPool.allocate(count, level); let output = unsafe { slice::from_raw_parts_mut(pCommandBuffers, count) }; for (out, cmd_buf) in output.iter_mut().zip(cmd_bufs) { @@ -1968,9 +1970,7 @@ pub extern "C" fn gfxBeginCommandBuffer( mut commandBuffer: VkCommandBuffer, pBeginInfo: *const VkCommandBufferBeginInfo, ) -> VkResult { - assert_eq!(unsafe { (*pBeginInfo).flags }, 0); // TODO - - commandBuffer.begin(); + commandBuffer.begin(conv::map_cmd_buffer_usage(unsafe { (*pBeginInfo).flags })); VkResult::VK_SUCCESS }