mirror of
https://github.com/italicsjenga/portability.git
synced 2025-02-18 15:17:43 +11:00
commit
c8b4f2e7a7
3 changed files with 27 additions and 9 deletions
|
@ -4,13 +4,13 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
VkSurfaceKHR vkCreateSurfaceGFX(VkInstance);
|
extern "C" VkSurfaceKHR vkCreateSurfaceGFX(VkInstance);
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
printf("starting the portability test\n");
|
printf("starting the portability test\n");
|
||||||
|
|
||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
VkResult res = 0;
|
VkResult res = (VkResult)0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
VkInstanceCreateInfo inst_info = {};
|
VkInstanceCreateInfo inst_info = {};
|
23
src/conv.rs
23
src/conv.rs
|
@ -9,19 +9,34 @@ pub fn format_from_hal(format: format::Format) -> VkFormat {
|
||||||
use hal::format::SurfaceType::*;
|
use hal::format::SurfaceType::*;
|
||||||
|
|
||||||
match format.0 {
|
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 {
|
R8_G8_B8_A8 => match format.1 {
|
||||||
Unorm => VK_FORMAT_R8G8B8A8_UNORM,
|
Unorm => VK_FORMAT_R8G8B8A8_UNORM,
|
||||||
|
Inorm => VK_FORMAT_R8G8B8A8_SNORM,
|
||||||
Srgb => VK_FORMAT_R8G8B8A8_SRGB,
|
Srgb => VK_FORMAT_R8G8B8A8_SRGB,
|
||||||
_ => unimplemented!()
|
_ => panic!("format {:?}", format),
|
||||||
},
|
},
|
||||||
B8_G8_R8_A8 => match format.1 {
|
B8_G8_R8_A8 => match format.1 {
|
||||||
Unorm => VK_FORMAT_B8G8R8A8_UNORM,
|
Unorm => VK_FORMAT_B8G8R8A8_UNORM,
|
||||||
|
Inorm => VK_FORMAT_B8G8R8A8_SNORM,
|
||||||
Srgb => VK_FORMAT_B8G8R8A8_SRGB,
|
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);
|
panic!("format {:?}", format);
|
||||||
unimplemented!()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -466,7 +466,7 @@ pub type VkInstance = Handle<back::Instance>;
|
||||||
pub type VkPhysicalDevice = Handle<hal::Adapter<B>>;
|
pub type VkPhysicalDevice = Handle<hal::Adapter<B>>;
|
||||||
pub type VkDevice = Handle<hal::Gpu<B>>;
|
pub type VkDevice = Handle<hal::Gpu<B>>;
|
||||||
pub type VkCommandPool = Handle<<B as hal::Backend>::CommandPool>;
|
pub type VkCommandPool = Handle<<B as hal::Backend>::CommandPool>;
|
||||||
pub type VkCommandBuffer = <B as hal::Backend>::CommandBuffer;
|
pub type VkCommandBuffer = Handle<<B as hal::Backend>::CommandBuffer>;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
@ -4915,7 +4915,7 @@ pub extern fn vkAllocateCommandBuffers(
|
||||||
slice::from_raw_parts_mut(pCommandBuffers, count)
|
slice::from_raw_parts_mut(pCommandBuffers, count)
|
||||||
};
|
};
|
||||||
for (out, cmd_buf) in output.iter_mut().zip(cmd_bufs) {
|
for (out, cmd_buf) in output.iter_mut().zip(cmd_bufs) {
|
||||||
*out = cmd_buf;
|
*out = Handle::new(cmd_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult::VK_SUCCESS
|
VkResult::VK_SUCCESS
|
||||||
|
@ -4931,7 +4931,10 @@ pub extern fn vkFreeCommandBuffers(
|
||||||
let buffer_slice = unsafe {
|
let buffer_slice = unsafe {
|
||||||
slice::from_raw_parts(pCommandBuffers, commandBufferCount as _)
|
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) };
|
unsafe { commandPool.free(buffers) };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue