mirror of
https://github.com/italicsjenga/portability.git
synced 2025-02-23 17:47:43 +11:00
Merge #44
44: Fix dispatchable handles r=kvark a=msiglreith Temporarily disables command buffer freeing. Allows to run first CTS tests on dx12 with the ICD layer.
This commit is contained in:
commit
1df436d581
5 changed files with 24 additions and 16 deletions
|
@ -4,7 +4,7 @@ publish = false
|
|||
version = "0.1.0"
|
||||
authors = [
|
||||
"Dzmitry Malyshau <kvark@mozilla.com>",
|
||||
"Markus Siglreightmaier <m.siglreith@gmail.com>",
|
||||
"Markus Siglreithmaier <m.siglreith@gmail.com>",
|
||||
]
|
||||
|
||||
[lib]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use VK_NULL_HANDLE;
|
||||
use std::{borrow, fmt, ops};
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
pub struct Handle<T>(*mut T);
|
||||
|
||||
|
@ -59,28 +60,32 @@ pub type DispatchHandle<T> = Handle<T>;
|
|||
|
||||
#[cfg(feature = "dispatch")]
|
||||
mod dispatch {
|
||||
const ICD_LOADER_MAGIC: u32 = 0x01CDC0DE;
|
||||
use VK_NULL_HANDLE;
|
||||
use std::{borrow, fmt, ops};
|
||||
|
||||
const ICD_LOADER_MAGIC: u64 = 0x01CDC0DE;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct DispatchHandle<T>(u32, super::Handle<T>);
|
||||
pub struct DispatchHandle<T>(*mut (u64, T));
|
||||
|
||||
impl<T> DispatchHandle<T> {
|
||||
pub fn new(value: T) -> Self {
|
||||
DispatchHandle(ICD_LOADER_MAGIC, super::Handle::new(value))
|
||||
let ptr = Box::into_raw(Box::new((ICD_LOADER_MAGIC, value)));
|
||||
DispatchHandle(ptr)
|
||||
}
|
||||
|
||||
pub fn unwrap(self) -> Box<T> {
|
||||
self.1.unwrap()
|
||||
pub fn unwrap(self) -> Box<(u64, T)> {
|
||||
unsafe { Box::from_raw(self.0) }
|
||||
}
|
||||
|
||||
pub fn is_null(&self) -> bool {
|
||||
self.1.is_null()
|
||||
self.0 == VK_NULL_HANDLE as *mut _
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Clone for DispatchHandle<T> {
|
||||
fn clone(&self) -> Self {
|
||||
DispatchHandle(self.0, self.1)
|
||||
DispatchHandle(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,25 +94,25 @@ mod dispatch {
|
|||
impl<T> ops::Deref for DispatchHandle<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &T {
|
||||
self.1.deref()
|
||||
unsafe { &(*self.0).1 }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ops::DerefMut for DispatchHandle<T> {
|
||||
fn deref_mut(&mut self) -> &mut T {
|
||||
self.1.deref_mut()
|
||||
unsafe { &mut (*self.0).1 }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> borrow::Borrow<T> for DispatchHandle<T> {
|
||||
fn borrow(&self) -> &T {
|
||||
self.1.borrow()
|
||||
unsafe { &(*self.0).1 }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for DispatchHandle<T> {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(formatter, "DispatchHandle({:p})", (self.1).0)
|
||||
write!(formatter, "DispatchHandle({:p})", self.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ pub extern "C" fn gfxCreateInstance(
|
|||
env_logger::init();
|
||||
}
|
||||
let instance = back::Instance::create("portability", 1);
|
||||
unsafe { *pInstance = DispatchHandle::new(instance) };
|
||||
unsafe { *pInstance = Handle::new(instance) };
|
||||
VkResult::VK_SUCCESS
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ pub extern "C" fn gfxGetDeviceProcAddr(
|
|||
vkAllocateDescriptorSets, PFN_vkAllocateDescriptorSets => gfxAllocateDescriptorSets,
|
||||
vkFreeDescriptorSets, PFN_vkFreeDescriptorSets => gfxFreeDescriptorSets,
|
||||
vkUpdateDescriptorSets, PFN_vkUpdateDescriptorSets => gfxUpdateDescriptorSets,
|
||||
|
||||
|
||||
vkCreateFence, PFN_vkCreateFence => gfxCreateFence,
|
||||
vkDestroyFence, PFN_vkDestroyFence => gfxDestroyFence,
|
||||
vkWaitForFences, PFN_vkWaitForFences => gfxWaitForFences,
|
||||
|
@ -2168,10 +2168,13 @@ pub extern "C" fn gfxFreeCommandBuffers(
|
|||
commandBufferCount: u32,
|
||||
pCommandBuffers: *const VkCommandBuffer,
|
||||
) {
|
||||
// TODO:
|
||||
/*
|
||||
let buffer_slice = unsafe { slice::from_raw_parts(pCommandBuffers, commandBufferCount as _) };
|
||||
let buffers = buffer_slice.iter().map(|buffer| *buffer.unwrap()).collect();
|
||||
|
||||
unsafe { commandPool.free(buffers) };
|
||||
*/
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -4,7 +4,7 @@ publish = false
|
|||
version = "0.1.0"
|
||||
authors = [
|
||||
"Dzmitry Malyshau <kvark@mozilla.com>",
|
||||
"Markus Siglreightmaier <m.siglreith@gmail.com>",
|
||||
"Markus Siglreithmaier <m.siglreith@gmail.com>",
|
||||
]
|
||||
|
||||
[lib]
|
||||
|
|
|
@ -4,7 +4,7 @@ publish = false
|
|||
version = "0.1.0"
|
||||
authors = [
|
||||
"Dzmitry Malyshau <kvark@mozilla.com>",
|
||||
"Markus Siglreightmaier <m.siglreith@gmail.com>",
|
||||
"Markus Siglreithmaier <m.siglreith@gmail.com>",
|
||||
]
|
||||
|
||||
[lib]
|
||||
|
|
Loading…
Add table
Reference in a new issue