mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 04:31:30 +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]]
|
||||
name = "ash-window"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f0573d0bfb0da1260b38f4bfd33fae0c71466e78d070a0f72a490bc09ab6a57"
|
||||
checksum = "b912285a7c29f3a8f87ca6f55afc48768624e5e33ec17dbd2f2075903f5e35ab"
|
||||
dependencies = [
|
||||
"ash",
|
||||
"raw-window-handle 0.4.3",
|
||||
"raw-window-handle 0.5.0",
|
||||
"raw-window-metal",
|
||||
]
|
||||
|
||||
|
@ -1034,6 +1034,7 @@ dependencies = [
|
|||
"png",
|
||||
"rand 0.8.5",
|
||||
"raw-window-handle 0.3.4",
|
||||
"raw-window-handle 0.5.0",
|
||||
"roxmltree",
|
||||
"swash",
|
||||
"winit",
|
||||
|
@ -1267,14 +1268,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "raw-window-metal"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd1dc19cf6fa2c1b7be107990884912d012c09d0d7b1631f76df7b01c07374b"
|
||||
checksum = "5d18241d631f19847a5f4cc0a3f81d978202c375573ab7d90ab14dcf0a9262ec"
|
||||
dependencies = [
|
||||
"cocoa",
|
||||
"core-graphics",
|
||||
"objc",
|
||||
"raw-window-handle 0.4.3",
|
||||
"raw-window-handle 0.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -7,8 +7,8 @@ license = "MIT/Apache-2.0"
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
ash = "0.37"
|
||||
ash-window = "0.11"
|
||||
ash = { version = "0.37", features = ["loaded"] }
|
||||
ash-window = "0.12"
|
||||
raw-window-handle = "0.5"
|
||||
bitflags = "1.3.2"
|
||||
smallvec = "1.9"
|
||||
|
|
|
@ -17,7 +17,7 @@ use winapi::shared::minwindef::TRUE;
|
|||
use winapi::shared::{dxgi, dxgi1_2, dxgitype};
|
||||
use winapi::um::d3d12;
|
||||
|
||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
||||
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
|
||||
|
||||
use smallvec::SmallVec;
|
||||
|
||||
|
@ -153,9 +153,10 @@ impl Dx12Instance {
|
|||
/// Create a surface for the specified window handle.
|
||||
pub fn surface(
|
||||
&self,
|
||||
window_handle: &dyn HasRawWindowHandle,
|
||||
_display_handle: RawDisplayHandle,
|
||||
window_handle: RawWindowHandle,
|
||||
) -> 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 _;
|
||||
Ok(Dx12Surface { hwnd })
|
||||
} else {
|
||||
|
|
|
@ -29,10 +29,10 @@ use objc::rc::autoreleasepool;
|
|||
use objc::runtime::{Object, BOOL, YES};
|
||||
use objc::{class, msg_send, sel, sel_impl};
|
||||
|
||||
use metal::{CommandBufferRef, MTLFeatureSet};
|
||||
use core_graphics_types::base::CGFloat;
|
||||
use metal::{CommandBufferRef, MTLFeatureSet};
|
||||
|
||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
||||
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
|
||||
|
||||
use crate::{
|
||||
BufferUsage, ComputePassDescriptor, Error, GpuInfo, ImageFormat, MapMode, WorkgroupLimits,
|
||||
|
@ -140,9 +140,10 @@ impl MtlInstance {
|
|||
|
||||
pub unsafe fn surface(
|
||||
&self,
|
||||
window_handle: &dyn HasRawWindowHandle,
|
||||
_display_handle: RawDisplayHandle,
|
||||
window_handle: RawWindowHandle,
|
||||
) -> 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())
|
||||
} else {
|
||||
Err("can't create surface for window handle".into())
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
//! A multiplexer module that selects a back-end at runtime.
|
||||
|
||||
use raw_window_handle::RawDisplayHandle;
|
||||
use raw_window_handle::RawWindowHandle;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
mux_cfg! {
|
||||
|
@ -163,12 +165,13 @@ impl Instance {
|
|||
/// Create a surface from the specified window handle.
|
||||
pub unsafe fn surface(
|
||||
&self,
|
||||
window_handle: &dyn raw_window_handle::HasRawWindowHandle,
|
||||
display_handle: RawDisplayHandle,
|
||||
window_handle: RawWindowHandle,
|
||||
) -> Result<Surface, Error> {
|
||||
mux_match! { self;
|
||||
Instance::Vk(i) => i.surface(window_handle).map(Surface::Vk),
|
||||
Instance::Dx12(i) => i.surface(window_handle).map(Surface::Dx12),
|
||||
Instance::Mtl(i) => i.surface(window_handle).map(Surface::Mtl),
|
||||
Instance::Vk(i) => i.surface(display_handle, window_handle).map(Surface::Vk),
|
||||
Instance::Dx12(i) => i.surface(display_handle, window_handle).map(Surface::Dx12),
|
||||
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, Device, Entry, Instance};
|
||||
|
||||
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::backend::Device as DeviceTrait;
|
||||
|
@ -157,7 +158,7 @@ impl VkInstance {
|
|||
pub fn new() -> Result<VkInstance, Error> {
|
||||
unsafe {
|
||||
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()?);
|
||||
if cfg!(debug_assertions) {
|
||||
|
@ -165,7 +166,7 @@ impl VkInstance {
|
|||
.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;
|
||||
if cfg!(debug_assertions) {
|
||||
has_debug_ext = exts.try_add(DebugUtils::name());
|
||||
|
@ -221,12 +222,15 @@ impl VkInstance {
|
|||
)?;
|
||||
|
||||
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()
|
||||
.message_severity(
|
||||
vk::DebugUtilsMessageSeverityFlagsEXT::ERROR
|
||||
| vk::DebugUtilsMessageSeverityFlagsEXT::WARNING,
|
||||
)
|
||||
.message_type(vk::DebugUtilsMessageTypeFlagsEXT::all())
|
||||
.message_type(flags)
|
||||
.pfn_user_callback(Some(vulkan_debug_callback));
|
||||
let dbg_loader = DebugUtils::new(&entry, &instance);
|
||||
let dbg_callbk = dbg_loader
|
||||
|
@ -256,10 +260,17 @@ impl VkInstance {
|
|||
/// The caller is responsible for making sure that the instance outlives the surface.
|
||||
pub unsafe fn surface(
|
||||
&self,
|
||||
window_handle: &dyn raw_window_handle::HasRawWindowHandle,
|
||||
display_handle: RawDisplayHandle,
|
||||
window_handle: RawWindowHandle,
|
||||
) -> Result<VkSurface, Error> {
|
||||
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),
|
||||
})
|
||||
}
|
||||
|
@ -273,8 +284,7 @@ impl VkInstance {
|
|||
/// but for now keep things simple.
|
||||
pub unsafe fn device(&self) -> Result<VkDevice, Error> {
|
||||
let devices = self.instance.enumerate_physical_devices()?;
|
||||
let (pdevice, qfi) =
|
||||
choose_device(&self.instance, &devices).ok_or("no suitable device")?;
|
||||
let (pdevice, qfi) = choose_device(&self.instance, &devices).ok_or("no suitable device")?;
|
||||
|
||||
let mut has_descriptor_indexing = false;
|
||||
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
|
||||
// exposing this to the user in a future device enumeration API, which would
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ png = "0.17.6"
|
|||
rand = "0.8.5"
|
||||
roxmltree = "0.13"
|
||||
winit = "0.27.3"
|
||||
raw-window-handle = "0.5"
|
||||
clap = "3.2.22"
|
||||
swash = "0.1.4"
|
||||
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 raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||
|
||||
use winit::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
|
@ -60,7 +62,9 @@ fn main() -> Result<(), Error> {
|
|||
let instance = Instance::new(InstanceFlags::default())?;
|
||||
let mut info_string = "info".to_string();
|
||||
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 mut swapchain = instance.swapchain(WIDTH / 2, HEIGHT / 2, &device, &surface)?;
|
||||
let session = Session::new(device);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
//! Tests for the piet-gpu draw object stage.
|
||||
|
||||
use piet_gpu_hal::{BufWrite, BufferUsage};
|
||||
use rand::{seq::SliceRandom};
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
use crate::{Config, Runner, TestResult};
|
||||
|
||||
|
|
Loading…
Reference in a new issue