Expose CreateWin32SurfaceKHR and device extensions

This commit is contained in:
msiglreith 2018-04-17 19:29:10 +02:00
parent d446cc15ca
commit 1d299a4949
2 changed files with 48 additions and 4 deletions

View file

@ -343,6 +343,8 @@ pub extern "C" fn gfxGetInstanceProcAddr(
vkGetPhysicalDeviceSurfaceCapabilitiesKHR, PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR => gfxGetPhysicalDeviceSurfaceCapabilitiesKHR,
vkGetPhysicalDeviceSurfaceFormatsKHR, PFN_vkGetPhysicalDeviceSurfaceFormatsKHR => gfxGetPhysicalDeviceSurfaceFormatsKHR,
vkGetPhysicalDeviceSurfacePresentModesKHR, PFN_vkGetPhysicalDeviceSurfacePresentModesKHR => gfxGetPhysicalDeviceSurfacePresentModesKHR,
vkCreateWin32SurfaceKHR, PFN_vkCreateWin32SurfaceKHR => gfxCreateWin32SurfaceKHR,
}
}
@ -566,6 +568,7 @@ pub extern "C" fn gfxDestroyDevice(gpu: VkDevice, _pAllocator: *const VkAllocati
}
lazy_static! {
// TODO: Request from backend
static ref INSTANCE_EXTENSIONS: Vec<VkExtensionProperties> = {
let mut extensions = [
VkExtensionProperties {
@ -593,6 +596,23 @@ lazy_static! {
extensions.to_vec()
};
static ref DEVICE_EXTENSIONS: Vec<VkExtensionProperties> = {
let mut extensions = [
VkExtensionProperties {
extensionName: [0; 256], // VK_KHR_SWAPCHAIN_EXTENSION_NAME
specVersion: VK_KHR_SWAPCHAIN_SPEC_VERSION,
},
];
extensions[0]
.extensionName[..VK_KHR_SWAPCHAIN_EXTENSION_NAME.len()]
.copy_from_slice(unsafe {
mem::transmute(VK_KHR_SWAPCHAIN_EXTENSION_NAME as &[u8])
});
extensions.to_vec()
};
}
#[inline]
@ -629,10 +649,27 @@ pub extern "C" fn gfxEnumerateDeviceExtensionProperties(
_physicalDevice: VkPhysicalDevice,
_pLayerName: *const ::std::os::raw::c_char,
pPropertyCount: *mut u32,
_pProperties: *mut VkExtensionProperties,
pProperties: *mut VkExtensionProperties,
) -> VkResult {
// TODO: dummy implementation
unsafe { *pPropertyCount = 0; }
let property_count = unsafe { &mut *pPropertyCount };
let num_extensions = DEVICE_EXTENSIONS.len() as u32;
if pProperties.is_null() {
*property_count = num_extensions;
} else {
if *property_count > num_extensions {
*property_count = num_extensions;
}
let properties =
unsafe { slice::from_raw_parts_mut(pProperties, *property_count as usize) };
for i in 0..*property_count as usize {
properties[i] = DEVICE_EXTENSIONS[i];
}
if *property_count < num_extensions {
return VkResult::VK_INCOMPLETE;
}
}
VkResult::VK_SUCCESS
}

View file

@ -6828,3 +6828,10 @@ pub type PFN_vkDestroyInstance = ::std::option::Option<unsafe extern "C" fn(
instance: VkInstance,
pAllocator: *const VkAllocationCallbacks,
)>;
pub type PFN_vkCreateWin32SurfaceKHR = ::std::option::Option<unsafe extern "C" fn(
instance: VkInstance,
pCreateInfo: *const VkWin32SurfaceCreateInfoKHR,
pAllocator: *const VkAllocationCallbacks,
pSurface: *mut VkSurfaceKHR,
) -> VkResult>;