diff --git a/native/test.c b/native/test.cpp similarity index 98% rename from native/test.c rename to native/test.cpp index fc7cf93..65095f1 100644 --- a/native/test.c +++ b/native/test.cpp @@ -4,13 +4,13 @@ #include #include -VkSurfaceKHR vkCreateSurfaceGFX(VkInstance); +extern "C" VkSurfaceKHR vkCreateSurfaceGFX(VkInstance); int main() { printf("starting the portability test\n"); VkInstance instance; - VkResult res = 0; + VkResult res = (VkResult)0; unsigned int i; VkInstanceCreateInfo inst_info = {}; diff --git a/src/conv.rs b/src/conv.rs index ac589d8..be5d8fc 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -9,19 +9,34 @@ pub fn format_from_hal(format: format::Format) -> VkFormat { use hal::format::SurfaceType::*; match format.0 { + R5_G6_B5 => match format.1 { + Unorm => VK_FORMAT_R5G6B5_UNORM_PACK16, + _ => unreachable!(), + }, + R4_G4_B4_A4 => match format.1 { + Unorm => VK_FORMAT_R4G4B4A4_UNORM_PACK16, + _ => unreachable!(), + }, R8_G8_B8_A8 => match format.1 { Unorm => VK_FORMAT_R8G8B8A8_UNORM, + Inorm => VK_FORMAT_R8G8B8A8_SNORM, Srgb => VK_FORMAT_R8G8B8A8_SRGB, - _ => unimplemented!() + _ => panic!("format {:?}", format), }, B8_G8_R8_A8 => match format.1 { Unorm => VK_FORMAT_B8G8R8A8_UNORM, + Inorm => VK_FORMAT_B8G8R8A8_SNORM, Srgb => VK_FORMAT_B8G8R8A8_SRGB, - _ => unimplemented!() + _ => panic!("format {:?}", format), + }, + R16_G16_B16_A16 => match format.1 { + Unorm => VK_FORMAT_R16G16B16A16_UNORM, + Inorm => VK_FORMAT_R16G16B16A16_SNORM, + Float => VK_FORMAT_R16G16B16A16_SFLOAT, + _ => panic!("format {:?}", format), }, _ => { - println!("\tformat {:?}", format); - unimplemented!() + panic!("format {:?}", format); } } } diff --git a/src/lib.rs b/src/lib.rs index 819e531..ac54f51 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -466,7 +466,7 @@ pub type VkInstance = Handle; pub type VkPhysicalDevice = Handle>; pub type VkDevice = Handle>; pub type VkCommandPool = Handle<::CommandPool>; -pub type VkCommandBuffer = ::CommandBuffer; +pub type VkCommandBuffer = Handle<::CommandBuffer>; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -4915,7 +4915,7 @@ pub extern fn vkAllocateCommandBuffers( slice::from_raw_parts_mut(pCommandBuffers, count) }; for (out, cmd_buf) in output.iter_mut().zip(cmd_bufs) { - *out = cmd_buf; + *out = Handle::new(cmd_buf); } VkResult::VK_SUCCESS @@ -4931,7 +4931,10 @@ pub extern fn vkFreeCommandBuffers( let buffer_slice = unsafe { slice::from_raw_parts(pCommandBuffers, commandBufferCount as _) }; - let buffers = buffer_slice.to_vec(); + let buffers = buffer_slice + .iter() + .map(|buffer| *buffer.unwrap()) + .collect(); unsafe { commandPool.free(buffers) }; }