mirror of
https://github.com/italicsjenga/portability.git
synced 2025-02-23 17:47:43 +11:00
commit
a7806c4b10
4 changed files with 75 additions and 24 deletions
|
@ -155,7 +155,7 @@ pub fn map_image_kind(
|
||||||
assert!(!is_cube || array_layers % 6 == 0);
|
assert!(!is_cube || array_layers % 6 == 0);
|
||||||
|
|
||||||
match ty {
|
match ty {
|
||||||
VkImageType::VK_IMAGE_TYPE_1D => image::Kind::D1(extent.width as _),
|
VkImageType::VK_IMAGE_TYPE_1D if array_layers == 1 => image::Kind::D1(extent.width as _),
|
||||||
VkImageType::VK_IMAGE_TYPE_1D => image::Kind::D1Array(extent.width as _, array_layers as _),
|
VkImageType::VK_IMAGE_TYPE_1D => image::Kind::D1Array(extent.width as _, array_layers as _),
|
||||||
VkImageType::VK_IMAGE_TYPE_2D if array_layers == 1 => {
|
VkImageType::VK_IMAGE_TYPE_2D if array_layers == 1 => {
|
||||||
image::Kind::D2(extent.width as _, extent.height as _, map_aa_mode(samples))
|
image::Kind::D2(extent.width as _, extent.height as _, map_aa_mode(samples))
|
||||||
|
|
|
@ -695,19 +695,19 @@ pub extern "C" fn gfxWaitForFences(
|
||||||
waitAll: VkBool32,
|
waitAll: VkBool32,
|
||||||
timeout: u64,
|
timeout: u64,
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
let fences = unsafe {
|
let fence_slice = unsafe {
|
||||||
slice::from_raw_parts(pFences, fenceCount as _)
|
slice::from_raw_parts(pFences, fenceCount as _)
|
||||||
.into_iter()
|
|
||||||
.map(|fence| &**fence)
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
};
|
};
|
||||||
|
let fences = fence_slice
|
||||||
|
.into_iter()
|
||||||
|
.map(|fence| &**fence);
|
||||||
|
|
||||||
let wait_for = match waitAll {
|
let wait_for = match waitAll {
|
||||||
VK_FALSE => WaitFor::Any,
|
VK_FALSE => WaitFor::Any,
|
||||||
_ => WaitFor::All,
|
_ => WaitFor::All,
|
||||||
};
|
};
|
||||||
|
|
||||||
if gpu.device.wait_for_fences(&fences, wait_for, timeout as _) {
|
if gpu.device.wait_for_fences(fences, wait_for, timeout as _) {
|
||||||
VkResult::VK_SUCCESS
|
VkResult::VK_SUCCESS
|
||||||
} else {
|
} else {
|
||||||
VkResult::VK_TIMEOUT
|
VkResult::VK_TIMEOUT
|
||||||
|
@ -1388,8 +1388,7 @@ pub extern "C" fn gfxCreatePipelineLayout(
|
||||||
|
|
||||||
let layouts = set_layouts
|
let layouts = set_layouts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|layout| &**layout)
|
.map(|layout| &**layout);
|
||||||
.collect::<Vec<&<B as Backend>::DescriptorSetLayout>>();
|
|
||||||
|
|
||||||
let ranges = push_constants
|
let ranges = push_constants
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -1399,11 +1398,10 @@ pub extern "C" fn gfxCreatePipelineLayout(
|
||||||
let size = constant.size / 4;
|
let size = constant.size / 4;
|
||||||
|
|
||||||
(stages, start .. start+size)
|
(stages, start .. start+size)
|
||||||
})
|
});
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
let pipeline_layout = gpu.device
|
let pipeline_layout = gpu.device
|
||||||
.create_pipeline_layout(&layouts, &ranges);
|
.create_pipeline_layout(layouts, ranges);
|
||||||
|
|
||||||
unsafe { *pPipelineLayout = Handle::new(pipeline_layout); }
|
unsafe { *pPipelineLayout = Handle::new(pipeline_layout); }
|
||||||
VkResult::VK_SUCCESS
|
VkResult::VK_SUCCESS
|
||||||
|
@ -1534,10 +1532,9 @@ pub extern "C" fn gfxAllocateDescriptorSets(
|
||||||
};
|
};
|
||||||
let layouts = set_layouts
|
let layouts = set_layouts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|layout| &**layout)
|
.map(|layout| &**layout);
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
let descriptor_sets = pool.allocate_sets(&layouts);
|
let descriptor_sets = pool.allocate_sets(layouts);
|
||||||
let sets = unsafe {
|
let sets = unsafe {
|
||||||
slice::from_raw_parts_mut(pDescriptorSets, info.descriptorSetCount as _)
|
slice::from_raw_parts_mut(pDescriptorSets, info.descriptorSetCount as _)
|
||||||
};
|
};
|
||||||
|
@ -1645,6 +1642,16 @@ pub extern "C" fn gfxUpdateDescriptorSets(
|
||||||
.map(|image| (&*image.imageView, conv::map_image_layout(image.imageLayout)))
|
.map(|image| (&*image.imageView, conv::map_image_layout(image.imageLayout)))
|
||||||
.collect()
|
.collect()
|
||||||
),
|
),
|
||||||
|
pso::DescriptorType::CombinedImageSampler => pso::DescriptorWrite::CombinedImageSampler(
|
||||||
|
image_info
|
||||||
|
.into_iter()
|
||||||
|
.map(|image| (
|
||||||
|
&*image.sampler,
|
||||||
|
&*image.imageView,
|
||||||
|
conv::map_image_layout(image.imageLayout),
|
||||||
|
))
|
||||||
|
.collect()
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
pso::DescriptorSetWrite {
|
pso::DescriptorSetWrite {
|
||||||
|
@ -1667,13 +1674,12 @@ pub extern "C" fn gfxCreateFramebuffer(
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
let info = unsafe { &*pCreateInfo };
|
let info = unsafe { &*pCreateInfo };
|
||||||
|
|
||||||
let attachments = unsafe {
|
let attachments_slice = unsafe {
|
||||||
slice::from_raw_parts(info.pAttachments, info.attachmentCount as _)
|
slice::from_raw_parts(info.pAttachments, info.attachmentCount as _)
|
||||||
};
|
};
|
||||||
let attachments = attachments
|
let attachments = attachments_slice
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|attachment| &**attachment)
|
.map(|attachment| &**attachment);
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
let extent = hal::device::Extent {
|
let extent = hal::device::Extent {
|
||||||
width: info.width,
|
width: info.width,
|
||||||
|
@ -1683,7 +1689,7 @@ pub extern "C" fn gfxCreateFramebuffer(
|
||||||
|
|
||||||
let framebuffer = gpu
|
let framebuffer = gpu
|
||||||
.device
|
.device
|
||||||
.create_framebuffer(&*info.renderPass, &attachments, extent)
|
.create_framebuffer(&*info.renderPass, attachments, extent)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -2856,17 +2862,18 @@ pub extern "C" fn gfxCmdSetDiscardRectangleEXT(
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCreateWin32SurfaceKHR(
|
pub extern "C" fn gfxCreateWin32SurfaceKHR(
|
||||||
instance: VkInstance,
|
instance: VkInstance,
|
||||||
pCreateInfos: *const VkWin32SurfaceCreateInfoKHR,
|
pCreateInfo: *const VkWin32SurfaceCreateInfoKHR,
|
||||||
pAllocator: *const VkAllocationCallbacks,
|
pAllocator: *const VkAllocationCallbacks,
|
||||||
pSurface: *mut VkSurfaceKHR,
|
pSurface: *mut VkSurfaceKHR,
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
|
let info = unsafe { &*pCreateInfo };
|
||||||
#[cfg(all(feature = "vulkan", target_os = "windows"))]
|
#[cfg(all(feature = "vulkan", target_os = "windows"))]
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
assert_eq!((*pCreateInfos).flags, 0);
|
assert_eq!(info.flags, 0);
|
||||||
assert!(pAllocator.is_null());
|
assert!(pAllocator.is_null());
|
||||||
*pSurface = Handle::new(
|
*pSurface = Handle::new(
|
||||||
instance.create_surface_from_hwnd((*pCreateInfos).hinstance, (*pCreateInfos).hwnd),
|
instance.create_surface_from_hwnd(info.hinstance, info.hwnd),
|
||||||
);
|
);
|
||||||
VkResult::VK_SUCCESS
|
VkResult::VK_SUCCESS
|
||||||
}
|
}
|
||||||
|
@ -2874,15 +2881,36 @@ pub extern "C" fn gfxCreateWin32SurfaceKHR(
|
||||||
#[cfg(feature = "dx12")]
|
#[cfg(feature = "dx12")]
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
assert_eq!((*pCreateInfos).flags, 0);
|
assert_eq!(info.flags, 0);
|
||||||
assert!(pAllocator.is_null());
|
assert!(pAllocator.is_null());
|
||||||
*pSurface = Handle::new(instance.create_surface_from_hwnd((*pCreateInfos).hwnd));
|
*pSurface = Handle::new(instance.create_surface_from_hwnd(info.hwnd));
|
||||||
VkResult::VK_SUCCESS
|
VkResult::VK_SUCCESS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
pub extern "C" fn gfxCreateXcbSurfaceKHR(
|
||||||
|
instance: VkInstance,
|
||||||
|
pCreateInfo: *const VkXcbSurfaceCreateInfoKHR,
|
||||||
|
pAllocator: *const VkAllocationCallbacks,
|
||||||
|
pSurface: *mut VkSurfaceKHR,
|
||||||
|
) -> VkResult {
|
||||||
|
let info = unsafe { &*pCreateInfo };
|
||||||
|
#[cfg(feature = "vulkan")]
|
||||||
|
{
|
||||||
|
unsafe {
|
||||||
|
assert_eq!(info.flags, 0);
|
||||||
|
assert!(pAllocator.is_null());
|
||||||
|
*pSurface = Handle::new(
|
||||||
|
instance.create_surface_from_xcb(info.connection as _, info.window),
|
||||||
|
);
|
||||||
|
VkResult::VK_SUCCESS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "vulkan"))]
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxAcquireNextImageKHR(
|
pub extern "C" fn gfxAcquireNextImageKHR(
|
||||||
_device: VkDevice,
|
_device: VkDevice,
|
||||||
|
|
|
@ -4753,6 +4753,19 @@ pub struct VkWin32SurfaceCreateInfoKHR {
|
||||||
impl Clone for VkWin32SurfaceCreateInfoKHR {
|
impl Clone for VkWin32SurfaceCreateInfoKHR {
|
||||||
fn clone(&self) -> Self { *self }
|
fn clone(&self) -> Self { *self }
|
||||||
}
|
}
|
||||||
|
pub type VkXcbSurfaceCreateFlagsKHR = VkFlags;
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Debug, Copy)]
|
||||||
|
pub struct VkXcbSurfaceCreateInfoKHR {
|
||||||
|
pub sType: VkStructureType,
|
||||||
|
pub pNext: *mut ::std::os::raw::c_void,
|
||||||
|
pub flags: VkXcbSurfaceCreateFlagsKHR,
|
||||||
|
pub connection: *mut ::std::os::raw::c_void,
|
||||||
|
pub window: u32,
|
||||||
|
}
|
||||||
|
impl Clone for VkXcbSurfaceCreateInfoKHR {
|
||||||
|
fn clone(&self) -> Self { *self }
|
||||||
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy)]
|
#[derive(Debug, Copy)]
|
||||||
pub struct VkPhysicalDeviceFeatures2KHR {
|
pub struct VkPhysicalDeviceFeatures2KHR {
|
||||||
|
|
|
@ -276,6 +276,16 @@ pub extern "C" fn vkCreateWin32SurfaceKHR(
|
||||||
gfxCreateWin32SurfaceKHR(instance, pCreateInfos, pAllocator, pSurface)
|
gfxCreateWin32SurfaceKHR(instance, pCreateInfos, pAllocator, pSurface)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn vkCreateXcbSurfaceKHR(
|
||||||
|
instance: VkInstance,
|
||||||
|
pCreateInfos: *const VkXcbSurfaceCreateInfoKHR,
|
||||||
|
pAllocator: *const VkAllocationCallbacks,
|
||||||
|
pSurface: *mut VkSurfaceKHR,
|
||||||
|
) -> VkResult {
|
||||||
|
gfxCreateXcbSurfaceKHR(instance, pCreateInfos, pAllocator, pSurface)
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn vkMapMemory(
|
pub extern "C" fn vkMapMemory(
|
||||||
device: VkDevice,
|
device: VkDevice,
|
||||||
|
|
Loading…
Add table
Reference in a new issue