Merge pull request #191 from linebender/version_bump

Update dependencies
This commit is contained in:
Raph Levien 2022-10-18 07:30:59 -07:00 committed by GitHub
commit 12fe2c10bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 601 additions and 310 deletions

750
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -7,12 +7,12 @@ license = "MIT/Apache-2.0"
edition = "2018"
[dependencies]
ash = "0.33"
ash-window = "0.7"
raw-window-handle = "0.3"
bitflags = "1.2.1"
smallvec = "1.6.1"
bytemuck = "1.7.2"
ash = { version = "0.37", features = ["loaded"] }
ash-window = "0.12"
raw-window-handle = "0.5"
bitflags = "1.3.2"
smallvec = "1.9"
bytemuck = "1.12.1"
[target.'cfg(target_os="windows")'.dependencies]
winapi = { version = "0.3.9", features = [
@ -24,8 +24,10 @@ winapi = { version = "0.3.9", features = [
wio = "0.2.2"
[target.'cfg(target_os="macos")'.dependencies]
metal = "0.22"
objc = "0.2.5"
metal = "0.24"
objc = "0.2.7"
block = "0.1.6"
cocoa-foundation = "0.1"
# Note: foreign-types is up to 0.5 but metal hasn't upgraded to it
foreign-types = "0.3.2"
core-graphics-types = "0.1.1"

View file

@ -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 {

View file

@ -29,9 +29,10 @@ use objc::rc::autoreleasepool;
use objc::runtime::{Object, BOOL, YES};
use objc::{class, msg_send, sel, sel_impl};
use metal::{CGFloat, 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,
@ -139,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::MacOS(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())

View file

@ -16,7 +16,7 @@
//! Utilities and types for Metal integration
use metal::{CGFloat, CGSize};
use core_graphics_types::{base::CGFloat, geometry::CGSize};
#[link(name = "QuartzCore", kind = "framework")]
extern "C" {

View file

@ -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),
}
}

View file

@ -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));
}
}

View file

@ -28,11 +28,12 @@ path = "../piet-gpu-types"
[dependencies]
piet = "0.2.0"
png = "0.16.2"
rand = "0.7.3"
png = "0.17.6"
rand = "0.8.5"
roxmltree = "0.13"
winit = "0.26.1"
clap = "2.33"
winit = {version = "0.27.3", default-features = false, features = ["x11", "wayland", "wayland-dlopen"]}
raw-window-handle = "0.5"
clap = "3.2.22"
swash = "0.1.4"
bytemuck = { version = "1.7.2", features = ["derive"] }

View file

@ -6,15 +6,14 @@
//! Requires the [cargo-apk] tool.
//! [cargo-apk]: https://crates.io/crates/cargo-apk
use raw_window_handle::android::AndroidHandle;
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use raw_window_handle::{
AndroidDisplayHandle, AndroidNdkWindowHandle, RawDisplayHandle, RawWindowHandle,
};
use ndk::native_window::NativeWindow;
use ndk_glue::Event;
use piet_gpu_hal::{
CmdBuf, Error, ImageLayout, Instance, InstanceFlags, QueryPool, Semaphore, Session,
SubmittedCmdBuf, Surface, Swapchain,
Error, ImageLayout, Instance, InstanceFlags, Semaphore, Session, Surface, Swapchain,
};
use piet::kurbo::Point;
@ -27,10 +26,6 @@ fn main() {
my_main().unwrap();
}
struct MyHandle {
handle: AndroidHandle,
}
// State required to render and present the contents
struct GfxState {
session: Session,
@ -53,9 +48,13 @@ fn my_main() -> Result<(), Error> {
if let Some(window) = &*window {
let width = window.width() as usize;
let height = window.height() as usize;
let handle = get_handle(window);
let instance = Instance::new(InstanceFlags::default())?;
let surface = unsafe { instance.surface(&handle)? };
let mut android_handle = AndroidNdkWindowHandle::empty();
android_handle.a_native_window = window.ptr().as_ptr() as *mut _;
let window_handle = RawWindowHandle::AndroidNdk(android_handle);
let display_handle =
RawDisplayHandle::Android(AndroidDisplayHandle::empty());
let surface = unsafe { instance.surface(display_handle, window_handle)? };
gfx_state = Some(GfxState::new(&instance, Some(&surface), width, height)?);
} else {
println!("native window is sadly none");
@ -74,24 +73,6 @@ fn my_main() -> Result<(), Error> {
}
}
fn get_handle(window: &NativeWindow) -> MyHandle {
println!(
"window = {:?}, {}x{}",
window.ptr(),
window.width(),
window.height()
);
let mut handle = AndroidHandle::empty();
handle.a_native_window = window.ptr().as_ptr() as *mut std::ffi::c_void;
MyHandle { handle }
}
unsafe impl HasRawWindowHandle for MyHandle {
fn raw_window_handle(&self) -> RawWindowHandle {
RawWindowHandle::Android(self.handle)
}
}
impl GfxState {
fn new(
instance: &Instance,

View file

@ -218,10 +218,10 @@ fn trace_ptcl(buf: &[u32]) {
fn main() -> Result<(), Error> {
let matches = App::new("piet-gpu test")
.arg(Arg::with_name("INPUT").index(1))
.arg(Arg::with_name("flip").short("f").long("flip"))
.arg(Arg::with_name("flip").short('f').long("flip"))
.arg(
Arg::with_name("scale")
.short("s")
.short('s')
.long("scale")
.takes_value(true),
)
@ -278,7 +278,7 @@ fn main() -> Result<(), Error> {
let ref mut w = BufWriter::new(file);
let mut encoder = png::Encoder::new(w, WIDTH as u32, HEIGHT as u32);
encoder.set_color(png::ColorType::RGBA);
encoder.set_color(png::ColorType::Rgba);
encoder.set_depth(png::BitDepth::Eight);
let mut writer = encoder.write_header().unwrap();

View file

@ -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},
@ -20,10 +22,10 @@ const HEIGHT: usize = 1536;
fn main() -> Result<(), Error> {
let matches = App::new("piet-gpu test")
.arg(Arg::with_name("INPUT").index(1))
.arg(Arg::with_name("flip").short("f").long("flip"))
.arg(Arg::with_name("flip").short('f').long("flip"))
.arg(
Arg::with_name("scale")
.short("s")
.short('s')
.long("scale")
.takes_value(true),
)
@ -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);

View file

@ -2,7 +2,7 @@
use rand::{Rng, RngCore};
use crate::{Blend, BlendMode, Colrv1RadialGradient, CompositionMode, PietGpuRenderContext};
use crate::{Blend, BlendMode, Colrv1RadialGradient, PietGpuRenderContext};
use piet::kurbo::{Affine, BezPath, Circle, Line, Point, Rect, Shape};
use piet::{
Color, GradientStop, LinearGradient, Text, TextAttribute, TextLayoutBuilder, UnitPoint,
@ -34,10 +34,10 @@ pub fn render_scene(rc: &mut PietGpuRenderContext) {
for _ in 0..N_CIRCLES {
let color = Color::from_rgba32_u32(rng.next_u32());
let center = Point::new(
rng.gen_range(0.0, WIDTH as f64),
rng.gen_range(0.0, HEIGHT as f64),
rng.gen_range(0.0..WIDTH as f64),
rng.gen_range(0.0..HEIGHT as f64),
);
let radius = rng.gen_range(0.0, 50.0);
let radius = rng.gen_range(0.0..50.0);
let circle = Circle::new(center, radius);
rc.fill(circle, &color);
}

View file

@ -10,7 +10,7 @@ edition = "2021"
default = ["piet-gpu"]
[dependencies]
clap = "2.33"
clap = "3.2.22"
bytemuck = "1.7.2"
kurbo = "0.7.1"
rand = "0.7.3"

View file

@ -17,7 +17,7 @@
//! Tests for the piet-gpu draw object stage.
use piet_gpu_hal::{BufWrite, BufferUsage};
use rand::{seq::SliceRandom, Rng};
use rand::seq::SliceRandom;
use crate::{Config, Runner, TestResult};

View file

@ -42,27 +42,27 @@ fn main() {
let matches = App::new("piet-gpu-tests")
.arg(
Arg::with_name("verbose")
.short("v")
.short('v')
.long("verbose")
.help("Verbose reporting of results"),
)
.arg(
Arg::with_name("groups")
.short("g")
.short('g')
.long("groups")
.help("Groups to run")
.takes_value(true),
)
.arg(
Arg::with_name("size")
.short("s")
.short('s')
.long("size")
.help("Size of tests")
.takes_value(true),
)
.arg(
Arg::with_name("n_iter")
.short("n")
.short('n')
.long("n_iter")
.help("Number of iterations")
.takes_value(true),