Added extension name support
This commit is contained in:
parent
ac14f440a7
commit
28908142b4
|
@ -104,7 +104,7 @@ fn create_surface(instance: &Instance,
|
|||
-> Result<vk::SurfaceKHR, vk::Result> {
|
||||
use winit::os::windows::WindowExt;
|
||||
let hwnd = window.get_hwnd() as *mut winapi::windef::HWND__;
|
||||
let hinstance = unsafe {user32::GetWindow(hwnd, 0) as *const ()};
|
||||
let hinstance = unsafe { user32::GetWindow(hwnd, 0) as *const () };
|
||||
let win32_create_info = vk::Win32SurfaceCreateInfoKHR {
|
||||
s_type: vk::StructureType::Win32SurfaceCreateInfoKhr,
|
||||
p_next: ptr::null(),
|
||||
|
@ -118,17 +118,21 @@ fn create_surface(instance: &Instance,
|
|||
}
|
||||
|
||||
#[cfg(all(unix, not(target_os = "android")))]
|
||||
fn extension_names() -> Vec<CString> {
|
||||
vec![CString::new("VK_KHR_surface").unwrap(),
|
||||
CString::new("VK_KHR_xlib_surface").unwrap(),
|
||||
CString::new("VK_EXT_debug_report").unwrap()]
|
||||
fn extension_names() -> Vec<*const i8> {
|
||||
vec![
|
||||
Surface::name().as_ptr(),
|
||||
XlibSurface::name().as_ptr(),
|
||||
DebugReport::name().as_ptr()
|
||||
]
|
||||
}
|
||||
|
||||
#[cfg(all(windows))]
|
||||
fn extension_names() -> Vec<CString> {
|
||||
vec![CString::new("VK_KHR_surface").unwrap(),
|
||||
CString::new("VK_KHR_win32_surface").unwrap(),
|
||||
CString::new("VK_EXT_debug_report").unwrap()]
|
||||
fn extension_names() -> Vec<*const i8> {
|
||||
vec![
|
||||
Surface::name().as_ptr(),
|
||||
Win32Surface::name().as_ptr(),
|
||||
DebugReport::name().as_ptr()
|
||||
]
|
||||
}
|
||||
|
||||
unsafe extern "system" fn vulkan_debug_callback(_: vk::DebugReportFlagsEXT,
|
||||
|
@ -225,10 +229,7 @@ impl ExampleBase {
|
|||
let layers_names_raw: Vec<*const i8> = layer_names.iter()
|
||||
.map(|raw_name| raw_name.as_ptr())
|
||||
.collect();
|
||||
let extension_names = extension_names();
|
||||
let extension_names_raw: Vec<*const i8> = extension_names.iter()
|
||||
.map(|raw_name| raw_name.as_ptr())
|
||||
.collect();
|
||||
let extension_names_raw = extension_names();
|
||||
let appinfo = vk::ApplicationInfo {
|
||||
p_application_name: raw_name,
|
||||
s_type: vk::StructureType::ApplicationInfo,
|
||||
|
@ -288,10 +289,7 @@ impl ExampleBase {
|
|||
.nth(0)
|
||||
.expect("Couldn't find suitable device.");
|
||||
let queue_family_index = queue_family_index as u32;
|
||||
let device_extension_names = [CString::new("VK_KHR_swapchain").unwrap()];
|
||||
let device_extension_names_raw: Vec<*const i8> = device_extension_names.iter()
|
||||
.map(|raw_name| raw_name.as_ptr())
|
||||
.collect();
|
||||
let device_extension_names_raw = [Swapchain::name().as_ptr()];
|
||||
let features =
|
||||
vk::PhysicalDeviceFeatures { shader_clip_distance: 1, ..Default::default() };
|
||||
let priorities = [1.0];
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::mem;
|
|||
use instance::Instance;
|
||||
use entry::Entry;
|
||||
use vk;
|
||||
use std::ffi::CStr;
|
||||
|
||||
pub struct DebugReport {
|
||||
handle: vk::Instance,
|
||||
|
@ -23,6 +24,10 @@ impl DebugReport {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn name() -> &'static CStr{
|
||||
CStr::from_bytes_with_nul(b"VK_EXT_debug_report\0").expect("Wrong extension string")
|
||||
}
|
||||
|
||||
pub unsafe fn destroy_debug_report_callback_ext(&self, debug: vk::DebugReportCallbackEXT) {
|
||||
self.debug_report_fn.destroy_debug_report_callback_ext(self.handle, debug, ptr::null());
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::mem;
|
|||
use instance::Instance;
|
||||
use entry::Entry;
|
||||
use vk;
|
||||
use std::ffi::CStr;
|
||||
|
||||
pub struct Surface {
|
||||
pub handle: vk::Instance,
|
||||
|
@ -23,6 +24,10 @@ impl Surface {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn name() -> &'static CStr{
|
||||
CStr::from_bytes_with_nul(b"VK_KHR_surface\0").expect("Wrong extension string")
|
||||
}
|
||||
|
||||
pub fn get_physical_device_surface_support_khr(&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
queue_index: vk::uint32_t,
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::mem;
|
|||
use instance::Instance;
|
||||
use device::Device;
|
||||
use vk;
|
||||
use std::ffi::CStr;
|
||||
|
||||
pub struct Swapchain {
|
||||
handle: vk::Device,
|
||||
|
@ -21,6 +22,10 @@ impl Swapchain {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn name() -> &'static CStr{
|
||||
CStr::from_bytes_with_nul(b"VK_KHR_swapchain\0").expect("Wrong extension string")
|
||||
}
|
||||
|
||||
pub unsafe fn destroy_swapchain_khr(&self, swapchain: vk::SwapchainKHR) {
|
||||
self.swapchain_fn.destroy_swapchain_khr(self.handle, swapchain, ptr::null());
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::mem;
|
|||
use instance::Instance;
|
||||
use entry::Entry;
|
||||
use vk;
|
||||
use std::ffi::CStr;
|
||||
|
||||
pub struct Win32Surface {
|
||||
pub handle: vk::Instance,
|
||||
|
@ -23,6 +24,10 @@ impl Win32Surface {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn name() -> &'static CStr{
|
||||
CStr::from_bytes_with_nul(b"VK_KHR_win32_surface\0").expect("Wrong extension string")
|
||||
}
|
||||
|
||||
pub fn create_win32_surface_khr(&self,
|
||||
create_info: &vk::Win32SurfaceCreateInfoKHR)
|
||||
-> VkResult<vk::SurfaceKHR> {
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::mem;
|
|||
use instance::Instance;
|
||||
use entry::Entry;
|
||||
use vk;
|
||||
use std::ffi::CStr;
|
||||
|
||||
pub struct XlibSurface {
|
||||
pub handle: vk::Instance,
|
||||
|
@ -23,6 +24,10 @@ impl XlibSurface {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn name() -> &'static CStr{
|
||||
CStr::from_bytes_with_nul(b"VK_KHR_xlib_surface\0").expect("Wrong extension string")
|
||||
}
|
||||
|
||||
pub fn create_xlib_surface_khr(&self,
|
||||
create_info: &vk::XlibSurfaceCreateInfoKHR)
|
||||
-> VkResult<vk::SurfaceKHR> {
|
||||
|
|
Loading…
Reference in a new issue