mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
Fix ash and raw_window_handle breakage
Follow API changes introduced by ash, ash_window, and raw_window_handle. Also updates ash_window to 0.12. Note: this doesn't fix the android client.
This commit is contained in:
parent
8e3df2573c
commit
69d16ac209
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -46,12 +46,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ash-window"
|
name = "ash-window"
|
||||||
version = "0.11.0"
|
version = "0.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7f0573d0bfb0da1260b38f4bfd33fae0c71466e78d070a0f72a490bc09ab6a57"
|
checksum = "b912285a7c29f3a8f87ca6f55afc48768624e5e33ec17dbd2f2075903f5e35ab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ash",
|
"ash",
|
||||||
"raw-window-handle 0.4.3",
|
"raw-window-handle 0.5.0",
|
||||||
"raw-window-metal",
|
"raw-window-metal",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1034,6 +1034,7 @@ dependencies = [
|
||||||
"png",
|
"png",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"raw-window-handle 0.3.4",
|
"raw-window-handle 0.3.4",
|
||||||
|
"raw-window-handle 0.5.0",
|
||||||
"roxmltree",
|
"roxmltree",
|
||||||
"swash",
|
"swash",
|
||||||
"winit",
|
"winit",
|
||||||
|
@ -1267,14 +1268,14 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raw-window-metal"
|
name = "raw-window-metal"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7dd1dc19cf6fa2c1b7be107990884912d012c09d0d7b1631f76df7b01c07374b"
|
checksum = "5d18241d631f19847a5f4cc0a3f81d978202c375573ab7d90ab14dcf0a9262ec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"core-graphics",
|
"core-graphics",
|
||||||
"objc",
|
"objc",
|
||||||
"raw-window-handle 0.4.3",
|
"raw-window-handle 0.5.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -7,8 +7,8 @@ license = "MIT/Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ash = "0.37"
|
ash = { version = "0.37", features = ["loaded"] }
|
||||||
ash-window = "0.11"
|
ash-window = "0.12"
|
||||||
raw-window-handle = "0.5"
|
raw-window-handle = "0.5"
|
||||||
bitflags = "1.3.2"
|
bitflags = "1.3.2"
|
||||||
smallvec = "1.9"
|
smallvec = "1.9"
|
||||||
|
|
|
@ -17,7 +17,7 @@ use winapi::shared::minwindef::TRUE;
|
||||||
use winapi::shared::{dxgi, dxgi1_2, dxgitype};
|
use winapi::shared::{dxgi, dxgi1_2, dxgitype};
|
||||||
use winapi::um::d3d12;
|
use winapi::um::d3d12;
|
||||||
|
|
||||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
|
||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
|
@ -153,9 +153,10 @@ impl Dx12Instance {
|
||||||
/// Create a surface for the specified window handle.
|
/// Create a surface for the specified window handle.
|
||||||
pub fn surface(
|
pub fn surface(
|
||||||
&self,
|
&self,
|
||||||
window_handle: &dyn HasRawWindowHandle,
|
_display_handle: RawDisplayHandle,
|
||||||
|
window_handle: RawWindowHandle,
|
||||||
) -> Result<Dx12Surface, Error> {
|
) -> Result<Dx12Surface, Error> {
|
||||||
if let RawWindowHandle::Windows(w) = window_handle.raw_window_handle() {
|
if let RawWindowHandle::Win32(w) = window_handle {
|
||||||
let hwnd = w.hwnd as *mut _;
|
let hwnd = w.hwnd as *mut _;
|
||||||
Ok(Dx12Surface { hwnd })
|
Ok(Dx12Surface { hwnd })
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,10 +29,10 @@ use objc::rc::autoreleasepool;
|
||||||
use objc::runtime::{Object, BOOL, YES};
|
use objc::runtime::{Object, BOOL, YES};
|
||||||
use objc::{class, msg_send, sel, sel_impl};
|
use objc::{class, msg_send, sel, sel_impl};
|
||||||
|
|
||||||
use metal::{CommandBufferRef, MTLFeatureSet};
|
|
||||||
use core_graphics_types::base::CGFloat;
|
use core_graphics_types::base::CGFloat;
|
||||||
|
use metal::{CommandBufferRef, MTLFeatureSet};
|
||||||
|
|
||||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
BufferUsage, ComputePassDescriptor, Error, GpuInfo, ImageFormat, MapMode, WorkgroupLimits,
|
BufferUsage, ComputePassDescriptor, Error, GpuInfo, ImageFormat, MapMode, WorkgroupLimits,
|
||||||
|
@ -140,9 +140,10 @@ impl MtlInstance {
|
||||||
|
|
||||||
pub unsafe fn surface(
|
pub unsafe fn surface(
|
||||||
&self,
|
&self,
|
||||||
window_handle: &dyn HasRawWindowHandle,
|
_display_handle: RawDisplayHandle,
|
||||||
|
window_handle: RawWindowHandle,
|
||||||
) -> Result<MtlSurface, Error> {
|
) -> Result<MtlSurface, Error> {
|
||||||
if let RawWindowHandle::AppKit(handle) = window_handle.raw_window_handle() {
|
if let RawWindowHandle::AppKit(handle) = window_handle {
|
||||||
Ok(Self::make_surface(handle.ns_view as id, handle.ns_window as id).unwrap())
|
Ok(Self::make_surface(handle.ns_view as id, handle.ns_window as id).unwrap())
|
||||||
} else {
|
} else {
|
||||||
Err("can't create surface for window handle".into())
|
Err("can't create surface for window handle".into())
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
//! A multiplexer module that selects a back-end at runtime.
|
//! A multiplexer module that selects a back-end at runtime.
|
||||||
|
|
||||||
|
use raw_window_handle::RawDisplayHandle;
|
||||||
|
use raw_window_handle::RawWindowHandle;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
mux_cfg! {
|
mux_cfg! {
|
||||||
|
@ -163,12 +165,13 @@ impl Instance {
|
||||||
/// Create a surface from the specified window handle.
|
/// Create a surface from the specified window handle.
|
||||||
pub unsafe fn surface(
|
pub unsafe fn surface(
|
||||||
&self,
|
&self,
|
||||||
window_handle: &dyn raw_window_handle::HasRawWindowHandle,
|
display_handle: RawDisplayHandle,
|
||||||
|
window_handle: RawWindowHandle,
|
||||||
) -> Result<Surface, Error> {
|
) -> Result<Surface, Error> {
|
||||||
mux_match! { self;
|
mux_match! { self;
|
||||||
Instance::Vk(i) => i.surface(window_handle).map(Surface::Vk),
|
Instance::Vk(i) => i.surface(display_handle, window_handle).map(Surface::Vk),
|
||||||
Instance::Dx12(i) => i.surface(window_handle).map(Surface::Dx12),
|
Instance::Dx12(i) => i.surface(display_handle, window_handle).map(Surface::Dx12),
|
||||||
Instance::Mtl(i) => i.surface(window_handle).map(Surface::Mtl),
|
Instance::Mtl(i) => i.surface(display_handle, window_handle).map(Surface::Mtl),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ use ash::extensions::{ext::DebugUtils, khr};
|
||||||
use ash::vk::DebugUtilsLabelEXT;
|
use ash::vk::DebugUtilsLabelEXT;
|
||||||
use ash::{vk, Device, Entry, Instance};
|
use ash::{vk, Device, Entry, Instance};
|
||||||
|
|
||||||
|
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use crate::backend::Device as DeviceTrait;
|
use crate::backend::Device as DeviceTrait;
|
||||||
|
@ -157,7 +158,7 @@ impl VkInstance {
|
||||||
pub fn new() -> Result<VkInstance, Error> {
|
pub fn new() -> Result<VkInstance, Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let app_name = CString::new("VkToy").unwrap();
|
let app_name = CString::new("VkToy").unwrap();
|
||||||
let entry = Entry::new()?;
|
let entry = Entry::load()?;
|
||||||
|
|
||||||
let mut layers = Layers::new(entry.enumerate_instance_layer_properties()?);
|
let mut layers = Layers::new(entry.enumerate_instance_layer_properties()?);
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
|
@ -165,7 +166,7 @@ impl VkInstance {
|
||||||
.try_add(CStr::from_bytes_with_nul(b"VK_LAYER_KHRONOS_validation\0").unwrap());
|
.try_add(CStr::from_bytes_with_nul(b"VK_LAYER_KHRONOS_validation\0").unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut exts = Extensions::new(entry.enumerate_instance_extension_properties()?);
|
let mut exts = Extensions::new(entry.enumerate_instance_extension_properties(None)?);
|
||||||
let mut has_debug_ext = false;
|
let mut has_debug_ext = false;
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
has_debug_ext = exts.try_add(DebugUtils::name());
|
has_debug_ext = exts.try_add(DebugUtils::name());
|
||||||
|
@ -221,12 +222,15 @@ impl VkInstance {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (dbg_loader, _dbg_callbk) = if has_debug_ext {
|
let (dbg_loader, _dbg_callbk) = if has_debug_ext {
|
||||||
|
let flags = vk::DebugUtilsMessageTypeFlagsEXT::GENERAL
|
||||||
|
| vk::DebugUtilsMessageTypeFlagsEXT::PERFORMANCE
|
||||||
|
| vk::DebugUtilsMessageTypeFlagsEXT::VALIDATION;
|
||||||
let dbg_info = vk::DebugUtilsMessengerCreateInfoEXT::builder()
|
let dbg_info = vk::DebugUtilsMessengerCreateInfoEXT::builder()
|
||||||
.message_severity(
|
.message_severity(
|
||||||
vk::DebugUtilsMessageSeverityFlagsEXT::ERROR
|
vk::DebugUtilsMessageSeverityFlagsEXT::ERROR
|
||||||
| vk::DebugUtilsMessageSeverityFlagsEXT::WARNING,
|
| vk::DebugUtilsMessageSeverityFlagsEXT::WARNING,
|
||||||
)
|
)
|
||||||
.message_type(vk::DebugUtilsMessageTypeFlagsEXT::all())
|
.message_type(flags)
|
||||||
.pfn_user_callback(Some(vulkan_debug_callback));
|
.pfn_user_callback(Some(vulkan_debug_callback));
|
||||||
let dbg_loader = DebugUtils::new(&entry, &instance);
|
let dbg_loader = DebugUtils::new(&entry, &instance);
|
||||||
let dbg_callbk = dbg_loader
|
let dbg_callbk = dbg_loader
|
||||||
|
@ -256,10 +260,17 @@ impl VkInstance {
|
||||||
/// The caller is responsible for making sure that the instance outlives the surface.
|
/// The caller is responsible for making sure that the instance outlives the surface.
|
||||||
pub unsafe fn surface(
|
pub unsafe fn surface(
|
||||||
&self,
|
&self,
|
||||||
window_handle: &dyn raw_window_handle::HasRawWindowHandle,
|
display_handle: RawDisplayHandle,
|
||||||
|
window_handle: RawWindowHandle,
|
||||||
) -> Result<VkSurface, Error> {
|
) -> Result<VkSurface, Error> {
|
||||||
Ok(VkSurface {
|
Ok(VkSurface {
|
||||||
surface: ash_window::create_surface(&self.entry, &self.instance, window_handle, None)?,
|
surface: ash_window::create_surface(
|
||||||
|
&self.entry,
|
||||||
|
&self.instance,
|
||||||
|
display_handle,
|
||||||
|
window_handle,
|
||||||
|
None,
|
||||||
|
)?,
|
||||||
surface_fn: khr::Surface::new(&self.entry, &self.instance),
|
surface_fn: khr::Surface::new(&self.entry, &self.instance),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -273,8 +284,7 @@ impl VkInstance {
|
||||||
/// but for now keep things simple.
|
/// but for now keep things simple.
|
||||||
pub unsafe fn device(&self) -> Result<VkDevice, Error> {
|
pub unsafe fn device(&self) -> Result<VkDevice, Error> {
|
||||||
let devices = self.instance.enumerate_physical_devices()?;
|
let devices = self.instance.enumerate_physical_devices()?;
|
||||||
let (pdevice, qfi) =
|
let (pdevice, qfi) = choose_device(&self.instance, &devices).ok_or("no suitable device")?;
|
||||||
choose_device(&self.instance, &devices).ok_or("no suitable device")?;
|
|
||||||
|
|
||||||
let mut has_descriptor_indexing = false;
|
let mut has_descriptor_indexing = false;
|
||||||
let vk1_1 = self.vk_version >= vk::make_api_version(0, 1, 1, 0);
|
let vk1_1 = self.vk_version >= vk::make_api_version(0, 1, 1, 0);
|
||||||
|
@ -1456,7 +1466,10 @@ unsafe fn choose_device(
|
||||||
// both Metal and DX12 which do not require such validation. It might be worth
|
// both Metal and DX12 which do not require such validation. It might be worth
|
||||||
// exposing this to the user in a future device enumeration API, which would
|
// exposing this to the user in a future device enumeration API, which would
|
||||||
// also allow selection between discrete and integrated devices.
|
// also allow selection between discrete and integrated devices.
|
||||||
if info.queue_flags.contains(vk::QueueFlags::COMPUTE | vk::QueueFlags::GRAPHICS) {
|
if info
|
||||||
|
.queue_flags
|
||||||
|
.contains(vk::QueueFlags::COMPUTE | vk::QueueFlags::GRAPHICS)
|
||||||
|
{
|
||||||
return Some((*pdevice, ix as u32));
|
return Some((*pdevice, ix as u32));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ png = "0.17.6"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
roxmltree = "0.13"
|
roxmltree = "0.13"
|
||||||
winit = "0.27.3"
|
winit = "0.27.3"
|
||||||
|
raw-window-handle = "0.5"
|
||||||
clap = "3.2.22"
|
clap = "3.2.22"
|
||||||
swash = "0.1.4"
|
swash = "0.1.4"
|
||||||
bytemuck = { version = "1.7.2", features = ["derive"] }
|
bytemuck = { version = "1.7.2", features = ["derive"] }
|
||||||
|
|
|
@ -6,6 +6,8 @@ use piet_gpu::{test_scenes, PicoSvg, PietGpuRenderContext, RenderDriver, Rendere
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
|
||||||
|
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||||
|
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
|
@ -60,7 +62,9 @@ fn main() -> Result<(), Error> {
|
||||||
let instance = Instance::new(InstanceFlags::default())?;
|
let instance = Instance::new(InstanceFlags::default())?;
|
||||||
let mut info_string = "info".to_string();
|
let mut info_string = "info".to_string();
|
||||||
unsafe {
|
unsafe {
|
||||||
let surface = instance.surface(&window)?;
|
let display_handle = window.raw_display_handle();
|
||||||
|
let window_handle = window.raw_window_handle();
|
||||||
|
let surface = instance.surface(display_handle, window_handle)?;
|
||||||
let device = instance.device()?;
|
let device = instance.device()?;
|
||||||
let mut swapchain = instance.swapchain(WIDTH / 2, HEIGHT / 2, &device, &surface)?;
|
let mut swapchain = instance.swapchain(WIDTH / 2, HEIGHT / 2, &device, &surface)?;
|
||||||
let session = Session::new(device);
|
let session = Session::new(device);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
//! Tests for the piet-gpu draw object stage.
|
//! Tests for the piet-gpu draw object stage.
|
||||||
|
|
||||||
use piet_gpu_hal::{BufWrite, BufferUsage};
|
use piet_gpu_hal::{BufWrite, BufferUsage};
|
||||||
use rand::{seq::SliceRandom};
|
use rand::seq::SliceRandom;
|
||||||
|
|
||||||
use crate::{Config, Runner, TestResult};
|
use crate::{Config, Runner, TestResult};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue