progress triangle
This commit is contained in:
parent
395c744601
commit
c6ce603f62
|
@ -32,18 +32,19 @@ fn main() {
|
||||||
window.make_current();
|
window.make_current();
|
||||||
let entry = Entry::load_vulkan().unwrap();
|
let entry = Entry::load_vulkan().unwrap();
|
||||||
let instance_ext_props = entry.enumerate_instance_extension_properties().unwrap();
|
let instance_ext_props = entry.enumerate_instance_extension_properties().unwrap();
|
||||||
println!("{:?}", instance_ext_props);
|
// println!("{:?}", instance_ext_props);
|
||||||
let app_name = CString::new("TEST").unwrap();
|
let app_name = CString::new("TEST").unwrap();
|
||||||
let raw_name = app_name.as_ptr();
|
let raw_name = app_name.as_ptr();
|
||||||
let lunarg_layer = CString::new("VK_LAYER_LUNARG_standard_validation").unwrap();
|
|
||||||
let layers = [lunarg_layer.as_ptr()];
|
let layer_names = [CString::new("VK_LAYER_LUNARG_standard_validation").unwrap()];
|
||||||
let swapchain_ext_name = CString::new("VK_KHR_swapchain").unwrap();
|
let layers_names_raw: Vec<*const i8> = layer_names.iter()
|
||||||
let surface_ext_name = CString::new("VK_KHR_surface").unwrap();
|
.map(|raw_name| raw_name.as_ptr())
|
||||||
let surface_xlib_ext_name = CString::new("VK_KHR_xlib_surface").unwrap();
|
.collect();
|
||||||
let extensions = [// swapchain_ext_name.as_ptr(),
|
let extension_names = [CString::new("VK_KHR_surface").unwrap(),
|
||||||
surface_ext_name.as_ptr(),
|
CString::new("VK_KHR_xlib_surface").unwrap()];
|
||||||
surface_xlib_ext_name.as_ptr()];
|
let extension_names_raw: Vec<*const i8> = extension_names.iter()
|
||||||
let tt = [vk::VK_KHR_SURFACE_EXTENSION_NAME];
|
.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,
|
||||||
|
@ -57,10 +58,10 @@ fn main() {
|
||||||
s_type: vk::StructureType::InstanceCreateInfo,
|
s_type: vk::StructureType::InstanceCreateInfo,
|
||||||
p_application_info: &appinfo,
|
p_application_info: &appinfo,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
pp_enabled_layer_names: layers.as_ptr(),
|
pp_enabled_layer_names: layers_names_raw.as_ptr(),
|
||||||
enabled_layer_count: layers.len() as u32,
|
enabled_layer_count: layers_names_raw.len() as u32,
|
||||||
pp_enabled_extension_names: extensions.as_ptr(),
|
pp_enabled_extension_names: extension_names_raw.as_ptr(),
|
||||||
enabled_extension_count: extensions.len() as u32,
|
enabled_extension_count: extension_names_raw.len() as u32,
|
||||||
flags: 0,
|
flags: 0,
|
||||||
};
|
};
|
||||||
let instance = entry.create_instance(create_info).expect("Instance creation error");
|
let instance = entry.create_instance(create_info).expect("Instance creation error");
|
||||||
|
@ -75,14 +76,32 @@ fn main() {
|
||||||
};
|
};
|
||||||
let surface = instance.create_xlib_surface_khr(x11_create_info).unwrap();
|
let surface = instance.create_xlib_surface_khr(x11_create_info).unwrap();
|
||||||
let pdevices = instance.enumerate_physical_devices().expect("Physical device error");
|
let pdevices = instance.enumerate_physical_devices().expect("Physical device error");
|
||||||
let pdevice = pdevices[0];
|
let (pdevice, queue_family_index) = pdevices.iter()
|
||||||
let pdevice_info = instance.get_physical_device_queue_family_properties(pdevice);
|
.map(|pdevice| {
|
||||||
let (queue_family_index, _) = pdevice_info.iter()
|
instance.get_physical_device_queue_family_properties(*pdevice)
|
||||||
.enumerate()
|
.iter()
|
||||||
.filter(|&(index, ref info)| info.queue_flags.subset(vk::QUEUE_GRAPHICS_BIT))
|
.enumerate()
|
||||||
|
.filter_map(|(index, ref info)| {
|
||||||
|
let supports_graphic_and_surface =
|
||||||
|
info.queue_flags.subset(vk::QUEUE_GRAPHICS_BIT) &&
|
||||||
|
instance.get_physical_device_surface_support_khr(*pdevice,
|
||||||
|
index as u32,
|
||||||
|
surface);
|
||||||
|
match supports_graphic_and_surface {
|
||||||
|
true => Some((*pdevice, index)),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.nth(0)
|
||||||
|
})
|
||||||
|
.filter_map(|v| v)
|
||||||
.nth(0)
|
.nth(0)
|
||||||
.expect("Could not find any suitable queue");
|
.expect("Couldn't find suitable device.");
|
||||||
println!("{:?}", pdevice_info);
|
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 features = vk::PhysicalDeviceFeatures { shader_clip_distance: 1, ..Default::default() };
|
||||||
let priorities = [1.0];
|
let priorities = [1.0];
|
||||||
let queue_info = vk::DeviceQueueCreateInfo {
|
let queue_info = vk::DeviceQueueCreateInfo {
|
||||||
s_type: vk::StructureType::DeviceQueueCreateInfo,
|
s_type: vk::StructureType::DeviceQueueCreateInfo,
|
||||||
|
@ -100,11 +119,12 @@ fn main() {
|
||||||
p_queue_create_infos: &queue_info,
|
p_queue_create_infos: &queue_info,
|
||||||
enabled_layer_count: 0,
|
enabled_layer_count: 0,
|
||||||
pp_enabled_layer_names: ptr::null(),
|
pp_enabled_layer_names: ptr::null(),
|
||||||
enabled_extension_count: 0,
|
enabled_extension_count: device_extension_names_raw.len() as u32,
|
||||||
pp_enabled_extension_names: ptr::null(),
|
pp_enabled_extension_names: device_extension_names_raw.as_ptr(),
|
||||||
p_enabled_features: ptr::null(),
|
p_enabled_features: &features,
|
||||||
};
|
};
|
||||||
let device = instance.create_device(pdevices[0], device_create_info).unwrap();
|
let device = instance.create_device(pdevice, device_create_info).unwrap();
|
||||||
|
|
||||||
|
|
||||||
device.destroy_device();
|
device.destroy_device();
|
||||||
instance.destroy_surface_khr(surface);
|
instance.destroy_surface_khr(surface);
|
||||||
|
|
Loading…
Reference in a new issue