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