Update to wgpu 0.15 (#263)

This commit is contained in:
Daniel McNab 2023-01-31 16:07:03 +00:00 committed by GitHub
parent 872fc5c6de
commit f84e244fd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 19 deletions

View file

@ -1,16 +1,19 @@
[workspace] [workspace]
resolver = "2" resolver = "2"
members = ["examples/with_winit", "examples/with_bevy", "examples/run_wasm", "examples/usvg_viewer"] members = [
"examples/with_winit",
"examples/with_bevy",
"examples/run_wasm",
"examples/usvg_viewer",
]
[workspace.package] [workspace.package]
edition = "2021" edition = "2021"
version = "0.1.0" version = "0.1.0"
[patch.crates-io] [workspace.dependencies]
# Required for metal support to work on wgpu wgpu = "0.15"
# TODO: remove when wgpu is upgraded to 0.15
naga = { git = "https://github.com/gfx-rs/naga", rev = "ddcd5d3121150b2b1beee6e54e9125ff31aaa9a2" }
[package] [package]
name = "vello" name = "vello"
@ -19,7 +22,7 @@ license = "MIT/Apache-2.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
wgpu = "0.14" wgpu = { workspace = true }
raw-window-handle = "0.5" raw-window-handle = "0.5"
futures-intrusive = "0.5.0" futures-intrusive = "0.5.0"
parking_lot = "0.12" parking_lot = "0.12"

View file

@ -7,7 +7,7 @@
[![Xi Zulip](https://img.shields.io/badge/Xi%20Zulip-%23gpu-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/197075-gpu) [![Xi Zulip](https://img.shields.io/badge/Xi%20Zulip-%23gpu-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/197075-gpu)
[![dependency status](https://deps.rs/repo/github/linebender/vello/status.svg)](https://deps.rs/repo/github/linebender/vello) [![dependency status](https://deps.rs/repo/github/linebender/vello/status.svg)](https://deps.rs/repo/github/linebender/vello)
[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](#license) [![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](#license)
[![wgpu version](https://img.shields.io/badge/wgpu-v0.14-orange.svg)](https://crates.io/crates/wgpu) [![wgpu version](https://img.shields.io/badge/wgpu-v0.15-orange.svg)](https://crates.io/crates/wgpu)
<!-- [![Crates.io](https://img.shields.io/crates/v/vello.svg)](https://crates.io/crates/vello) --> <!-- [![Crates.io](https://img.shields.io/crates/v/vello.svg)](https://crates.io/crates/vello) -->
<!-- [![Docs](https://docs.rs/vello/badge.svg)](https://docs.rs/vello) --> <!-- [![Docs](https://docs.rs/vello/badge.svg)](https://docs.rs/vello) -->
<!-- [![Build status](https://github.com/linebender/vello/workflows/CI/badge.svg)](https://github.com/linebender/vello/actions) --> <!-- [![Build status](https://github.com/linebender/vello/workflows/CI/badge.svg)](https://github.com/linebender/vello/actions) -->

View file

@ -18,5 +18,5 @@ sha2 = "0.10"
ureq = "2.6" ureq = "2.6"
usvg = "0.28" usvg = "0.28"
vello = { path = "../../" } vello = { path = "../../" }
wgpu = "0.14" wgpu = { workspace = true }
winit = "0.27.5" winit = "0.27.5"

View file

@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
bevy = "0.9" bevy = { git = "https://github.com/bevyengine/bevy", rev = "5d514fb24f2459700f68d8e57d4791bdf5b1b595" }
vello = { path = "../../" } vello = { path = "../../" }

View file

@ -91,12 +91,16 @@ impl ExtractComponent for VelloScene {
type Filter = (); type Filter = ();
fn extract_component((fragment, target): bevy::ecs::query::QueryItem<'_, Self::Query>) -> Self { type Out = Self;
fn extract_component(
(fragment, target): bevy::ecs::query::QueryItem<'_, Self::Query>,
) -> Option<Self> {
let mut scene = Scene::default(); let mut scene = Scene::default();
let mut builder = SceneBuilder::for_scene(&mut scene); let mut builder = SceneBuilder::for_scene(&mut scene);
builder.append(&fragment.0, None); builder.append(&fragment.0, None);
builder.finish(); builder.finish();
Self(scene, target.0.clone()) Some(Self(scene, target.0.clone()))
} }
} }
@ -124,6 +128,7 @@ fn setup(
usage: TextureUsages::TEXTURE_BINDING usage: TextureUsages::TEXTURE_BINDING
| TextureUsages::COPY_DST | TextureUsages::COPY_DST
| TextureUsages::STORAGE_BINDING, | TextureUsages::STORAGE_BINDING,
view_formats: &[],
}, },
..default() ..default()
}; };

View file

@ -8,7 +8,7 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
wgpu = "0.14" wgpu = { workspace = true }
vello = { path = "../../", features = ["buffer_labels"] } vello = { path = "../../", features = ["buffer_labels"] }
winit = "0.27.5" winit = "0.27.5"
pollster = "0.2.5" pollster = "0.2.5"

View file

@ -280,6 +280,7 @@ impl Engine {
contents: bytes, contents: bytes,
usage: wgpu::BufferUsages::COPY_SRC, usage: wgpu::BufferUsages::COPY_SRC,
}); });
let format = image_proxy.format.to_wgpu();
let texture = device.create_texture(&wgpu::TextureDescriptor { let texture = device.create_texture(&wgpu::TextureDescriptor {
label: None, label: None,
size: wgpu::Extent3d { size: wgpu::Extent3d {
@ -291,7 +292,8 @@ impl Engine {
sample_count: 1, sample_count: 1,
dimension: wgpu::TextureDimension::D2, dimension: wgpu::TextureDimension::D2,
usage: TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST, usage: TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST,
format: image_proxy.format.to_wgpu(), format,
view_formats: &[],
}); });
let texture_view = texture.create_view(&wgpu::TextureViewDescriptor { let texture_view = texture.create_view(&wgpu::TextureViewDescriptor {
label: None, label: None,
@ -632,6 +634,7 @@ impl BindMap {
continue; continue;
} }
if let Entry::Vacant(v) = self.image_map.entry(proxy.id) { if let Entry::Vacant(v) = self.image_map.entry(proxy.id) {
let format = proxy.format.to_wgpu();
let texture = device.create_texture(&wgpu::TextureDescriptor { let texture = device.create_texture(&wgpu::TextureDescriptor {
label: None, label: None,
size: wgpu::Extent3d { size: wgpu::Extent3d {
@ -643,7 +646,8 @@ impl BindMap {
sample_count: 1, sample_count: 1,
dimension: wgpu::TextureDimension::D2, dimension: wgpu::TextureDimension::D2,
usage: TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST, usage: TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST,
format: proxy.format.to_wgpu(), format,
view_formats: &[],
}); });
let texture_view = texture.create_view(&wgpu::TextureViewDescriptor { let texture_view = texture.create_view(&wgpu::TextureViewDescriptor {
label: None, label: None,

View file

@ -286,6 +286,7 @@ impl TargetTexture {
dimension: wgpu::TextureDimension::D2, dimension: wgpu::TextureDimension::D2,
usage: wgpu::TextureUsages::STORAGE_BINDING | wgpu::TextureUsages::TEXTURE_BINDING, usage: wgpu::TextureUsages::STORAGE_BINDING | wgpu::TextureUsages::TEXTURE_BINDING,
format: wgpu::TextureFormat::Rgba8Unorm, format: wgpu::TextureFormat::Rgba8Unorm,
view_formats: &[],
}); });
let view = texture.create_view(&wgpu::TextureViewDescriptor::default()); let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
Self { Self {

View file

@ -139,10 +139,10 @@ pub fn preprocess(input: &str, defines: &HashSet<String>, imports: &HashMap<&str
} }
} }
if stack.iter().all(|item| item.active) { if stack.iter().all(|item| item.active) {
// Naga does not yet recognize `const` but web does not allow global `let`. We // wgsl-analyzer does not yet recognize `const` but naga does not allow global `let`. We
// use `let` in our canonical sources to satisfy wgsl-analyzer but replace with // use `let` in our canonical sources to satisfy wgsl-analyzer but replace with
// `const` when targeting web. // `const` when using
if cfg!(target_arch = "wasm32") && line.starts_with("let ") { if line.starts_with("let ") {
output.push_str("const"); output.push_str("const");
output.push_str(&line[3..]); output.push_str(&line[3..]);
} else { } else {

View file

@ -39,7 +39,10 @@ pub struct DeviceHandle {
impl RenderContext { impl RenderContext {
pub fn new() -> Result<Self> { pub fn new() -> Result<Self> {
let instance = Instance::new(wgpu::Backends::PRIMARY); let instance = Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::PRIMARY,
dx12_shader_compiler: wgpu::Dx12Compiler::Fxc,
});
Ok(Self { Ok(Self {
instance, instance,
devices: Vec::new(), devices: Vec::new(),
@ -51,7 +54,7 @@ impl RenderContext {
where where
W: HasRawWindowHandle + HasRawDisplayHandle, W: HasRawWindowHandle + HasRawDisplayHandle,
{ {
let surface = unsafe { self.instance.create_surface(window) }; let surface = unsafe { self.instance.create_surface(window) }.unwrap();
let format = wgpu::TextureFormat::Bgra8Unorm; let format = wgpu::TextureFormat::Bgra8Unorm;
let config = wgpu::SurfaceConfiguration { let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT, usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
@ -60,6 +63,7 @@ impl RenderContext {
height, height,
present_mode: wgpu::PresentMode::Fifo, present_mode: wgpu::PresentMode::Fifo,
alpha_mode: wgpu::CompositeAlphaMode::Auto, alpha_mode: wgpu::CompositeAlphaMode::Auto,
view_formats: vec![],
}; };
let dev_id = self.device(Some(&surface)).await.unwrap(); let dev_id = self.device(Some(&surface)).await.unwrap();
surface.configure(&self.devices[dev_id].device, &config); surface.configure(&self.devices[dev_id].device, &config);