Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade crates and fix standard+synchronization validation errors #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,414 changes: 778 additions & 636 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@ x11 = ["egui-winit/x11"]

[dependencies]
anyhow = "1.0.75"
ash = { version = "0.37.3", default-features = false }
ash-window = "0.12.0"
ash = { version = "0.38.0", default-features = false }
ash-window = "0.13.0"
bytemuck = "1.14.0"
directories-next = { version = "2.0.0", optional = true }
egui = "0.25.0"
egui-winit = "0.25.0"
gpu-allocator = { version = "0.25.0", default-features = false, features = ["vulkan"], optional = true }
egui = "0.28.1"
egui-winit = "0.28.1"
gpu-allocator = { version = "0.27.0", default-features = false, features = ["vulkan"], optional = true }
log = "0.4.20"
raw-window-handle = "0.5"
raw-window-handle = "0.6.2"
ron = { version = "0.8.1", optional = true }
serde = { version = "1.0.193", optional = true }

[dev-dependencies]
ash = { version = "0.37.3", default-features = false, features = ["linked", "debug"] }
egui_extras = { version = "0.25.0", features = ["all_loaders"] }
ash = { version = "0.38.0", default-features = false, features = ["linked", "debug"] }
egui_extras = { version = "0.28.1", features = ["all_loaders"] }
egui-ash = { path = ".", features = ["gpu-allocator", "persistence"] }
egui_tiles = "0.6.0"
glam = "0.25.0"
image = { version = "0.24.7", default-features = false, features = ["png", "jpeg", "bmp"] }
egui_tiles = "0.9.0"
glam = "0.28.0"
image = { version = "0.25.1", default-features = false, features = ["png", "jpeg", "bmp"] }
log = "0.4.20"
tobj = "4.0.0"
71 changes: 38 additions & 33 deletions examples/egui_ash_simple/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
use ash::{
extensions::{
ext::DebugUtils,
khr::{Surface, Swapchain},
},
vk, Device, Entry, Instance,
};
use ash::{vk, Device, Entry, Instance};
use egui::FontData;
use egui_ash::{
raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle},
raw_window_handle::{HasDisplayHandle as _, HasWindowHandle as _},
winit, App, AppCreator, AshRenderState, CreationContext, ExitSignal, RunOption, Theme,
};
use gpu_allocator::vulkan::*;
Expand All @@ -23,9 +17,9 @@ struct MyApp {
entry: Entry,
instance: Instance,
device: Device,
debug_utils_loader: DebugUtils,
debug_utils_loader: ash::ext::debug_utils::Instance,
debug_messenger: vk::DebugUtilsMessengerEXT,
surface_loader: Surface,
surface_loader: ash::khr::surface::Instance,
surface: vk::SurfaceKHR,
command_pool: vk::CommandPool,
allocator: ManuallyDrop<Arc<Mutex<Allocator>>>,
Expand Down Expand Up @@ -73,7 +67,7 @@ impl App for MyApp {
egui::Window::new("My Window")
.id(egui::Id::new("my_window"))
.resizable(true)
.scroll2([true, true])
.scroll([true, true])
.show(&ctx, |ui| {
ui.heading("Hello");
ui.label("Hello egui!");
Expand Down Expand Up @@ -158,14 +152,18 @@ impl MyAppCreator {
}

fn create_entry() -> Entry {
Entry::linked()
ash::Entry::linked()
}

fn create_instance(
required_instance_extensions: &[CString],
entry: &Entry,
) -> (Instance, DebugUtils, vk::DebugUtilsMessengerEXT) {
let mut debug_utils_messenger_create_info = vk::DebugUtilsMessengerCreateInfoEXT::builder()
) -> (
Instance,
ash::ext::debug_utils::Instance,
vk::DebugUtilsMessengerEXT,
) {
let mut debug_utils_messenger_create_info = vk::DebugUtilsMessengerCreateInfoEXT::default()
.flags(vk::DebugUtilsMessengerCreateFlagsEXT::empty())
.message_severity(
vk::DebugUtilsMessageSeverityFlagsEXT::WARNING
Expand All @@ -178,15 +176,14 @@ impl MyAppCreator {
| vk::DebugUtilsMessageTypeFlagsEXT::PERFORMANCE
| vk::DebugUtilsMessageTypeFlagsEXT::VALIDATION,
)
.pfn_user_callback(Some(Self::vulkan_debug_utils_callback))
.build();
.pfn_user_callback(Some(Self::vulkan_debug_utils_callback));

let app_name = std::ffi::CString::new("egui-ash example simple").unwrap();
let app_info = vk::ApplicationInfo::builder()
let app_info = vk::ApplicationInfo::default()
.application_name(&app_name)
.application_version(vk::make_api_version(1, 0, 0, 0))
.api_version(vk::API_VERSION_1_0);
let mut extension_names = vec![DebugUtils::name().as_ptr()];
let mut extension_names = vec![ash::ext::debug_utils::NAME.as_ptr()];
for ext in required_instance_extensions {
let name = ext.as_ptr();
extension_names.push(name);
Expand All @@ -199,7 +196,7 @@ impl MyAppCreator {
.iter()
.map(|l| l.as_ptr())
.collect::<Vec<*const i8>>();
let instance_create_info = vk::InstanceCreateInfo::builder()
let instance_create_info = vk::InstanceCreateInfo::default()
.push_next(&mut debug_utils_messenger_create_info)
.application_info(&app_info)
.enabled_extension_names(&extension_names);
Expand All @@ -215,7 +212,7 @@ impl MyAppCreator {
};

// setup debug utils
let debug_utils_loader = DebugUtils::new(&entry, &instance);
let debug_utils_loader = ash::ext::debug_utils::Instance::new(&entry, &instance);
let debug_messenger = if Self::ENABLE_VALIDATION_LAYERS {
unsafe {
debug_utils_loader
Expand All @@ -229,12 +226,15 @@ impl MyAppCreator {
(instance, debug_utils_loader, debug_messenger)
}

fn create_surface_loader(entry: &Entry, instance: &Instance) -> Surface {
Surface::new(&entry, &instance)
fn create_surface_loader(entry: &Entry, instance: &Instance) -> ash::khr::surface::Instance {
ash::khr::surface::Instance::new(entry, instance)
}

fn create_swapchain_loader(instance: &Instance, device: &Device) -> Swapchain {
Swapchain::new(&instance, &device)
fn create_swapchain_loader(
instance: &Instance,
device: &Device,
) -> ash::khr::swapchain::Device {
ash::khr::swapchain::Device::new(instance, device)
}

fn create_surface(
Expand All @@ -246,8 +246,14 @@ impl MyAppCreator {
ash_window::create_surface(
entry,
instance,
window.raw_display_handle(),
window.raw_window_handle(),
window
.display_handle()
.expect("Unable to get display handle")
.as_raw(),
window
.window_handle()
.expect("Unable to get display handle")
.as_raw(),
None,
)
.expect("Failed to create surface")
Expand All @@ -256,7 +262,7 @@ impl MyAppCreator {

fn create_physical_device(
instance: &Instance,
surface_loader: &Surface,
surface_loader: &ash::khr::surface::Instance,
surface: vk::SurfaceKHR,
required_device_extensions: &[CString],
) -> (vk::PhysicalDevice, vk::PhysicalDeviceMemoryProperties, u32) {
Expand Down Expand Up @@ -358,21 +364,20 @@ impl MyAppCreator {
) -> (Device, vk::Queue) {
let queue_priorities = [1.0_f32];
let mut queue_create_infos = vec![];
let queue_create_info = vk::DeviceQueueCreateInfo::builder()
let queue_create_info = vk::DeviceQueueCreateInfo::default()
.queue_family_index(queue_family_index)
.queue_priorities(&queue_priorities)
.build();
.queue_priorities(&queue_priorities);
queue_create_infos.push(queue_create_info);

let physical_device_features = vk::PhysicalDeviceFeatures::builder().build();
let physical_device_features = vk::PhysicalDeviceFeatures::default();

let enable_extension_names = required_device_extensions
.iter()
.map(|s| s.as_ptr())
.collect::<Vec<_>>();

// device create info
let device_create_info = vk::DeviceCreateInfo::builder()
let device_create_info = vk::DeviceCreateInfo::default()
.queue_create_infos(&queue_create_infos)
.enabled_features(&physical_device_features)
.enabled_extension_names(&enable_extension_names);
Expand All @@ -391,7 +396,7 @@ impl MyAppCreator {
}

fn create_command_pool(device: &Device, queue_family_index: u32) -> vk::CommandPool {
let command_pool_create_info = vk::CommandPoolCreateInfo::builder()
let command_pool_create_info = vk::CommandPoolCreateInfo::default()
.flags(vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER)
.queue_family_index(queue_family_index);
unsafe {
Expand Down
69 changes: 35 additions & 34 deletions examples/egui_ash_vulkan/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
use ash::{
extensions::{
ext::DebugUtils,
khr::{Surface, Swapchain},
},
vk, Device, Entry, Instance,
};
use ash::{ext::debug_utils, vk, Device, Entry, Instance};
use egui_ash::{
raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle},
raw_window_handle::{HasDisplayHandle as _, HasWindowHandle as _},
winit, App, AppCreator, AshRenderState, CreationContext, HandleRedraw, RunOption, Theme,
};
use gpu_allocator::vulkan::*;
Expand All @@ -24,11 +18,11 @@ struct MyApp {
entry: Entry,
instance: Instance,
device: Device,
debug_utils_loader: DebugUtils,
debug_utils_loader: debug_utils::Instance,
debug_messenger: vk::DebugUtilsMessengerEXT,
physical_device: vk::PhysicalDevice,
surface_loader: Surface,
swapchain_loader: Swapchain,
surface_loader: ash::khr::surface::Instance,
swapchain_loader: ash::khr::swapchain::Device,
surface: vk::SurfaceKHR,
queue: vk::Queue,
command_pool: vk::CommandPool,
Expand Down Expand Up @@ -70,7 +64,7 @@ impl App for MyApp {
egui::Window::new("My Window")
.id(egui::Id::new("my_window"))
.resizable(true)
.scroll2([true, true])
.scroll([true, true])
.show(&ctx, |ui| {
ui.heading("Hello");
ui.label("Hello egui!");
Expand Down Expand Up @@ -162,14 +156,14 @@ impl MyAppCreator {
}

fn create_entry() -> Entry {
Entry::linked()
ash::Entry::linked()
}

fn create_instance(
required_instance_extensions: &[CString],
entry: &Entry,
) -> (Instance, DebugUtils, vk::DebugUtilsMessengerEXT) {
let mut debug_utils_messenger_create_info = vk::DebugUtilsMessengerCreateInfoEXT::builder()
) -> (Instance, debug_utils::Instance, vk::DebugUtilsMessengerEXT) {
let mut debug_utils_messenger_create_info = vk::DebugUtilsMessengerCreateInfoEXT::default()
.flags(vk::DebugUtilsMessengerCreateFlagsEXT::empty())
.message_severity(
vk::DebugUtilsMessageSeverityFlagsEXT::WARNING
Expand All @@ -182,15 +176,14 @@ impl MyAppCreator {
| vk::DebugUtilsMessageTypeFlagsEXT::PERFORMANCE
| vk::DebugUtilsMessageTypeFlagsEXT::VALIDATION,
)
.pfn_user_callback(Some(Self::vulkan_debug_utils_callback))
.build();
.pfn_user_callback(Some(Self::vulkan_debug_utils_callback));

let app_name = std::ffi::CString::new("egui-winit-ash example simple").unwrap();
let app_info = vk::ApplicationInfo::builder()
let app_info = vk::ApplicationInfo::default()
.application_name(&app_name)
.application_version(vk::make_api_version(1, 0, 0, 0))
.api_version(vk::API_VERSION_1_0);
let mut extension_names = vec![DebugUtils::name().as_ptr()];
let mut extension_names = vec![debug_utils::NAME.as_ptr()];
for ext in required_instance_extensions {
let name = ext.as_ptr();
extension_names.push(name);
Expand All @@ -203,7 +196,7 @@ impl MyAppCreator {
.iter()
.map(|l| l.as_ptr())
.collect::<Vec<*const i8>>();
let instance_create_info = vk::InstanceCreateInfo::builder()
let instance_create_info = vk::InstanceCreateInfo::default()
.push_next(&mut debug_utils_messenger_create_info)
.application_info(&app_info)
.enabled_extension_names(&extension_names);
Expand All @@ -219,7 +212,7 @@ impl MyAppCreator {
};

// setup debug utils
let debug_utils_loader = DebugUtils::new(&entry, &instance);
let debug_utils_loader = debug_utils::Instance::new(&entry, &instance);
let debug_messenger = if Self::ENABLE_VALIDATION_LAYERS {
unsafe {
debug_utils_loader
Expand All @@ -233,12 +226,15 @@ impl MyAppCreator {
(instance, debug_utils_loader, debug_messenger)
}

fn create_surface_loader(entry: &Entry, instance: &Instance) -> Surface {
Surface::new(&entry, &instance)
fn create_surface_loader(entry: &Entry, instance: &Instance) -> ash::khr::surface::Instance {
ash::khr::surface::Instance::new(&entry, &instance)
}

fn create_swapchain_loader(instance: &Instance, device: &Device) -> Swapchain {
Swapchain::new(&instance, &device)
fn create_swapchain_loader(
instance: &Instance,
device: &Device,
) -> ash::khr::swapchain::Device {
ash::khr::swapchain::Device::new(&instance, &device)
}

fn create_surface(
Expand All @@ -250,8 +246,14 @@ impl MyAppCreator {
ash_window::create_surface(
entry,
instance,
window.raw_display_handle(),
window.raw_window_handle(),
window
.display_handle()
.expect("Failed to get display handle")
.as_raw(),
window
.window_handle()
.expect("Failed to get window handle")
.as_raw(),
None,
)
.expect("Failed to create surface")
Expand All @@ -260,7 +262,7 @@ impl MyAppCreator {

fn create_physical_device(
instance: &Instance,
surface_loader: &Surface,
surface_loader: &ash::khr::surface::Instance,
surface: vk::SurfaceKHR,
required_device_extensions: &[CString],
) -> (vk::PhysicalDevice, vk::PhysicalDeviceMemoryProperties, u32) {
Expand Down Expand Up @@ -362,21 +364,20 @@ impl MyAppCreator {
) -> (Device, vk::Queue) {
let queue_priorities = [1.0_f32];
let mut queue_create_infos = vec![];
let queue_create_info = vk::DeviceQueueCreateInfo::builder()
let queue_create_info = vk::DeviceQueueCreateInfo::default()
.queue_family_index(queue_family_index)
.queue_priorities(&queue_priorities)
.build();
.queue_priorities(&queue_priorities);
queue_create_infos.push(queue_create_info);

let physical_device_features = vk::PhysicalDeviceFeatures::builder().build();
let physical_device_features = vk::PhysicalDeviceFeatures::default();

let enable_extension_names = required_device_extensions
.iter()
.map(|s| s.as_ptr())
.collect::<Vec<_>>();

// device create info
let device_create_info = vk::DeviceCreateInfo::builder()
let device_create_info = vk::DeviceCreateInfo::default()
.queue_create_infos(&queue_create_infos)
.enabled_features(&physical_device_features)
.enabled_extension_names(&enable_extension_names);
Expand All @@ -395,7 +396,7 @@ impl MyAppCreator {
}

fn create_command_pool(device: &Device, queue_family_index: u32) -> vk::CommandPool {
let command_pool_create_info = vk::CommandPoolCreateInfo::builder()
let command_pool_create_info = vk::CommandPoolCreateInfo::default()
.flags(vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER)
.queue_family_index(queue_family_index);
unsafe {
Expand Down
Loading