raw-window-handle 0.6

This commit is contained in:
Alex Janka 2024-02-08 15:05:59 +11:00
parent befb84aea8
commit b577b326a8
5 changed files with 346 additions and 44 deletions

321
Cargo.lock generated
View file

@ -467,12 +467,43 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "com"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e17887fd17353b65b1b2ef1c526c83e26cd72e74f598a8dc1bee13a48f3d9f6"
dependencies = [
"com_macros",
]
[[package]] [[package]]
name = "com-rs" name = "com-rs"
version = "0.2.1" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf43edc576402991846b093a7ca18a3477e0ef9c588cde84964b5d3e43016642" checksum = "bf43edc576402991846b093a7ca18a3477e0ef9c588cde84964b5d3e43016642"
[[package]]
name = "com_macros"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d375883580a668c7481ea6631fc1a8863e33cc335bf56bfad8d7e6d4b04b13a5"
dependencies = [
"com_macros_support",
"proc-macro2",
"syn 1.0.109",
]
[[package]]
name = "com_macros_support"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad899a1087a9296d5644792d7cb72b8e34c1bec8e7d4fbc002230169a6e8710c"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "combine" name = "combine"
version = "4.6.6" version = "4.6.6"
@ -661,6 +692,17 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "d3d12"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e3d747f100290a1ca24b752186f61f6637e1deffe3bf6320de6fcb29510a307"
dependencies = [
"bitflags 2.4.2",
"libloading 0.8.1",
"winapi",
]
[[package]] [[package]]
name = "darling" name = "darling"
version = "0.13.4" version = "0.13.4"
@ -769,7 +811,7 @@ dependencies = [
"log", "log",
"thiserror", "thiserror",
"type-map", "type-map",
"wgpu", "wgpu 0.17.2",
] ]
[[package]] [[package]]
@ -1263,6 +1305,17 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "gl_generator"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
dependencies = [
"khronos_api",
"log",
"xml-rs",
]
[[package]] [[package]]
name = "glib" name = "glib"
version = "0.16.9" version = "0.16.9"
@ -1322,6 +1375,27 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "glow"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd348e04c43b32574f2de31c8bb397d96c9fcfa1371bd4ca6d8bdc464ab121b1"
dependencies = [
"js-sys",
"slotmap",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "glutin_wgl_sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead"
dependencies = [
"gl_generator",
]
[[package]] [[package]]
name = "gobject-sys" name = "gobject-sys"
version = "0.16.3" version = "0.16.3"
@ -1365,6 +1439,19 @@ dependencies = [
"windows 0.44.0", "windows 0.44.0",
] ]
[[package]]
name = "gpu-allocator"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884"
dependencies = [
"log",
"presser",
"thiserror",
"winapi",
"windows 0.52.0",
]
[[package]] [[package]]
name = "gpu-descriptor" name = "gpu-descriptor"
version = "0.2.4" version = "0.2.4"
@ -1471,6 +1558,21 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "hassle-rs"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890"
dependencies = [
"bitflags 2.4.2",
"com",
"libc",
"libloading 0.8.1",
"thiserror",
"widestring",
"winapi",
]
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.3.3" version = "0.3.3"
@ -1582,7 +1684,7 @@ dependencies = [
"imgui", "imgui",
"log", "log",
"smallvec", "smallvec",
"wgpu", "wgpu 0.17.2",
] ]
[[package]] [[package]]
@ -1771,6 +1873,23 @@ dependencies = [
"pkg-config", "pkg-config",
] ]
[[package]]
name = "khronos-egl"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
dependencies = [
"libc",
"libloading 0.8.1",
"pkg-config",
]
[[package]]
name = "khronos_api"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@ -1935,6 +2054,21 @@ dependencies = [
"paste", "paste",
] ]
[[package]]
name = "metal"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25"
dependencies = [
"bitflags 2.4.2",
"block",
"core-graphics-types",
"foreign-types 0.5.0",
"log",
"objc",
"paste",
]
[[package]] [[package]]
name = "minimal-egui" name = "minimal-egui"
version = "0.1.0" version = "0.1.0"
@ -2055,7 +2189,27 @@ dependencies = [
"log", "log",
"num-traits", "num-traits",
"rustc-hash", "rustc-hash",
"spirv", "spirv 0.2.0+1.5.4",
"termcolor",
"thiserror",
"unicode-xid",
]
[[package]]
name = "naga"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8878eb410fc90853da3908aebfe61d73d26d4437ef850b70050461f939509899"
dependencies = [
"bit-set",
"bitflags 2.4.2",
"codespan-reporting",
"hexf-parse",
"indexmap 2.1.0",
"log",
"num-traits",
"rustc-hash",
"spirv 0.3.0+sdk-1.3.268.0",
"termcolor", "termcolor",
"thiserror", "thiserror",
"unicode-xid", "unicode-xid",
@ -2386,10 +2540,10 @@ dependencies = [
"bytemuck", "bytemuck",
"pixels-mocks", "pixels-mocks",
"pollster", "pollster",
"raw-window-handle 0.5.2", "raw-window-handle 0.6.0",
"thiserror", "thiserror",
"ultraviolet", "ultraviolet",
"wgpu", "wgpu 0.19.1",
"winit 0.28.7", "winit 0.28.7",
] ]
@ -2425,6 +2579,12 @@ 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 = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
[[package]]
name = "presser"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "1.3.1" version = "1.3.1"
@ -2536,6 +2696,12 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
[[package]]
name = "raw-window-handle"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544"
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.3.5" version = "0.3.5"
@ -2843,6 +3009,15 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "spirv"
version = "0.3.0+sdk-1.3.268.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844"
dependencies = [
"bitflags 2.4.2",
]
[[package]] [[package]]
name = "stable_deref_trait" name = "stable_deref_trait"
version = "1.2.0" version = "1.2.0"
@ -3589,7 +3764,7 @@ dependencies = [
"cfg-if", "cfg-if",
"js-sys", "js-sys",
"log", "log",
"naga", "naga 0.13.0",
"parking_lot", "parking_lot",
"profiling", "profiling",
"raw-window-handle 0.5.2", "raw-window-handle 0.5.2",
@ -3598,9 +3773,34 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
"wgpu-core", "wgpu-core 0.17.1",
"wgpu-hal", "wgpu-hal 0.17.2",
"wgpu-types", "wgpu-types 0.17.0",
]
[[package]]
name = "wgpu"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bfe9a310dcf2e6b85f00c46059aaeaf4184caa8e29a1ecd4b7a704c3482332d"
dependencies = [
"arrayvec 0.7.4",
"cfg-if",
"cfg_aliases",
"js-sys",
"log",
"naga 0.19.0",
"parking_lot",
"profiling",
"raw-window-handle 0.6.0",
"smallvec",
"static_assertions",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"wgpu-core 0.19.0",
"wgpu-hal 0.19.1",
"wgpu-types 0.19.0",
] ]
[[package]] [[package]]
@ -3614,7 +3814,7 @@ dependencies = [
"bitflags 2.4.2", "bitflags 2.4.2",
"codespan-reporting", "codespan-reporting",
"log", "log",
"naga", "naga 0.13.0",
"parking_lot", "parking_lot",
"profiling", "profiling",
"raw-window-handle 0.5.2", "raw-window-handle 0.5.2",
@ -3622,8 +3822,34 @@ dependencies = [
"smallvec", "smallvec",
"thiserror", "thiserror",
"web-sys", "web-sys",
"wgpu-hal", "wgpu-hal 0.17.2",
"wgpu-types", "wgpu-types 0.17.0",
]
[[package]]
name = "wgpu-core"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b15e451d4060ada0d99a64df44e4d590213496da7c4f245572d51071e8e30ed"
dependencies = [
"arrayvec 0.7.4",
"bit-vec",
"bitflags 2.4.2",
"cfg_aliases",
"codespan-reporting",
"indexmap 2.1.0",
"log",
"naga 0.19.0",
"once_cell",
"parking_lot",
"profiling",
"raw-window-handle 0.6.0",
"rustc-hash",
"smallvec",
"thiserror",
"web-sys",
"wgpu-hal 0.19.1",
"wgpu-types 0.19.0",
] ]
[[package]] [[package]]
@ -3639,19 +3865,19 @@ dependencies = [
"bitflags 2.4.2", "bitflags 2.4.2",
"block", "block",
"core-graphics-types", "core-graphics-types",
"d3d12", "d3d12 0.7.0",
"glow", "glow 0.12.3",
"gpu-alloc", "gpu-alloc",
"gpu-allocator", "gpu-allocator 0.22.0",
"gpu-descriptor", "gpu-descriptor",
"hassle-rs", "hassle-rs 0.10.0",
"js-sys", "js-sys",
"khronos-egl", "khronos-egl 4.1.0",
"libc", "libc",
"libloading 0.8.1", "libloading 0.8.1",
"log", "log",
"metal", "metal 0.26.0",
"naga", "naga 0.13.0",
"objc", "objc",
"parking_lot", "parking_lot",
"profiling", "profiling",
@ -3663,7 +3889,51 @@ dependencies = [
"thiserror", "thiserror",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
"wgpu-types", "wgpu-types 0.17.0",
"winapi",
]
[[package]]
name = "wgpu-hal"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bb47856236bfafc0bc591a925eb036ac19cd987624a447ff353e7a7e7e6f72"
dependencies = [
"android_system_properties",
"arrayvec 0.7.4",
"ash",
"bit-set",
"bitflags 2.4.2",
"block",
"cfg_aliases",
"core-graphics-types",
"d3d12 0.19.0",
"glow 0.13.1",
"glutin_wgl_sys",
"gpu-alloc",
"gpu-allocator 0.25.0",
"gpu-descriptor",
"hassle-rs 0.11.0",
"js-sys",
"khronos-egl 6.0.0",
"libc",
"libloading 0.8.1",
"log",
"metal 0.27.0",
"naga 0.19.0",
"objc",
"once_cell",
"parking_lot",
"profiling",
"range-alloc",
"raw-window-handle 0.6.0",
"renderdoc-sys",
"rustc-hash",
"smallvec",
"thiserror",
"wasm-bindgen",
"web-sys",
"wgpu-types 0.19.0",
"winapi", "winapi",
] ]
@ -3678,6 +3948,17 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "wgpu-types"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "895fcbeb772bfb049eb80b2d6e47f6c9af235284e9703c96fc0218a42ffd5af2"
dependencies = [
"bitflags 2.4.2",
"js-sys",
"web-sys",
]
[[package]] [[package]]
name = "wide" name = "wide"
version = "0.7.13" version = "0.7.13"

View file

@ -21,13 +21,13 @@ include = [
[dependencies] [dependencies]
bytemuck = "1.12" bytemuck = "1.12"
raw-window-handle = "0.5" raw-window-handle = "0.6"
thiserror = "1.0" thiserror = "1.0"
ultraviolet = "0.9" ultraviolet = "0.9"
wgpu = "0.17" wgpu = "0.19"
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
wgpu = { version = "0.17", features = ["webgl"] } wgpu = { version = "0.19", features = ["webgl"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
pollster = "0.3" pollster = "0.3"
@ -37,8 +37,4 @@ pixels-mocks = { path = "internals/pixels-mocks" }
winit = "0.28" winit = "0.28"
[workspace] [workspace]
members = [ members = ["examples/*", "internals/*", "run-wasm"]
"examples/*",
"internals/*",
"run-wasm",
]

View file

@ -1,10 +1,19 @@
use crate::renderers::{ScalingMatrix, ScalingRenderer}; use crate::renderers::{ScalingMatrix, ScalingRenderer};
use crate::{Error, Pixels, PixelsContext, SurfaceSize, SurfaceTexture, TextureError}; use crate::{Error, Pixels, PixelsContext, SurfaceSize, SurfaceTexture, TextureError};
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; use raw_window_handle::{
HasDisplayHandle, HasRawDisplayHandle, HasRawWindowHandle, HasWindowHandle,
};
use wgpu::WasmNotSendSync;
/// A builder to help create customized pixel buffers. /// A builder to help create customized pixel buffers.
pub struct PixelsBuilder<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle> { pub struct PixelsBuilder<
request_adapter_options: Option<wgpu::RequestAdapterOptions<'req>>, 'req,
'sur,
'dev,
'win,
W: HasWindowHandle + HasDisplayHandle + WasmNotSendSync + Into<wgpu::SurfaceTarget<'win>>,
> {
request_adapter_options: Option<wgpu::RequestAdapterOptions<'req, 'sur>>,
device_descriptor: Option<wgpu::DeviceDescriptor<'dev>>, device_descriptor: Option<wgpu::DeviceDescriptor<'dev>>,
backend: wgpu::Backends, backend: wgpu::Backends,
width: u32, width: u32,
@ -19,8 +28,13 @@ pub struct PixelsBuilder<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplay
blend_state: wgpu::BlendState, blend_state: wgpu::BlendState,
} }
impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle> impl<
PixelsBuilder<'req, 'dev, 'win, W> 'req,
'sur,
'dev,
'win,
W: HasWindowHandle + HasDisplayHandle + WasmNotSendSync + Into<wgpu::SurfaceTarget<'win>>,
> PixelsBuilder<'req, 'sur, 'dev, 'win, W>
{ {
/// Create a builder that can be finalized into a [`Pixels`] pixel buffer. /// Create a builder that can be finalized into a [`Pixels`] pixel buffer.
/// ///
@ -70,7 +84,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>
/// Add options for requesting a [`wgpu::Adapter`]. /// Add options for requesting a [`wgpu::Adapter`].
pub fn request_adapter_options( pub fn request_adapter_options(
mut self, mut self,
request_adapter_options: wgpu::RequestAdapterOptions<'req>, request_adapter_options: wgpu::RequestAdapterOptions<'req, 'sur>,
) -> Self { ) -> Self {
self.request_adapter_options = Some(request_adapter_options); self.request_adapter_options = Some(request_adapter_options);
self self
@ -250,7 +264,12 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>
}); });
// TODO: Use `options.pixel_aspect_ratio` to stretch the scaled texture // TODO: Use `options.pixel_aspect_ratio` to stretch the scaled texture
let surface = unsafe { instance.create_surface(self.surface_texture.window) }?; let surface = unsafe {
instance.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::RawHandle {
raw_display_handle: self.surface_texture.window.raw_display_handle().unwrap(),
raw_window_handle: self.surface_texture.window.raw_window_handle().unwrap(),
})?
};
let compatible_surface = Some(&surface); let compatible_surface = Some(&surface);
let request_adapter_options = &self.request_adapter_options; let request_adapter_options = &self.request_adapter_options;
let adapter = match wgpu::util::initialize_adapter_from_env(&instance, compatible_surface) { let adapter = match wgpu::util::initialize_adapter_from_env(&instance, compatible_surface) {
@ -279,7 +298,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>
let device_descriptor = self let device_descriptor = self
.device_descriptor .device_descriptor
.unwrap_or_else(|| wgpu::DeviceDescriptor { .unwrap_or_else(|| wgpu::DeviceDescriptor {
limits: adapter.limits(), required_limits: adapter.limits(),
..wgpu::DeviceDescriptor::default() ..wgpu::DeviceDescriptor::default()
}); });
@ -625,5 +644,8 @@ const fn texture_format_size(texture_format: wgpu::TextureFormat) -> f32 {
// 12x12 blocks, 16 bytes per block // 12x12 blocks, 16 bytes per block
Astc { block: B12x12, channel: _ } => 9.0,// 12.0 * 12.0 / 16.0 Astc { block: B12x12, channel: _ } => 9.0,// 12.0 * 12.0 / 16.0
Rgb10a2Uint => todo!(),
NV12 => todo!(),
} }
} }

View file

@ -34,16 +34,17 @@
pub use crate::builder::{check_texture_size, PixelsBuilder}; pub use crate::builder::{check_texture_size, PixelsBuilder};
pub use crate::renderers::ScalingRenderer; pub use crate::renderers::ScalingRenderer;
pub use raw_window_handle; pub use raw_window_handle;
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
use thiserror::Error; use thiserror::Error;
pub use wgpu; pub use wgpu;
use wgpu::WasmNotSendSync;
mod builder; mod builder;
mod renderers; mod renderers;
/// A logical texture for a window surface. /// A logical texture for a window surface.
#[derive(Debug)] #[derive(Debug)]
pub struct SurfaceTexture<'win, W: HasRawWindowHandle + HasRawDisplayHandle> { pub struct SurfaceTexture<'win, W: HasWindowHandle + HasDisplayHandle + WasmNotSendSync> {
window: &'win W, window: &'win W,
size: SurfaceSize, size: SurfaceSize,
} }
@ -67,7 +68,7 @@ pub struct PixelsContext {
/// The `Queue` provides access to the GPU command queue. /// The `Queue` provides access to the GPU command queue.
pub queue: wgpu::Queue, pub queue: wgpu::Queue,
surface: wgpu::Surface, surface: wgpu::Surface<'static>,
/// This is the texture that your raw data is copied to by [`Pixels::render`] or /// This is the texture that your raw data is copied to by [`Pixels::render`] or
/// [`Pixels::render_with`]. /// [`Pixels::render_with`].
@ -147,7 +148,7 @@ pub enum TextureError {
TextureHeight(u32), TextureHeight(u32),
} }
impl<'win, W: HasRawWindowHandle + HasRawDisplayHandle> SurfaceTexture<'win, W> { impl<'win, W: HasWindowHandle + HasDisplayHandle + WasmNotSendSync> SurfaceTexture<'win, W> {
/// Create a logical texture for a window surface. /// Create a logical texture for a window surface.
/// ///
/// It is recommended (but not required) that the `width` and `height` are equivalent to the /// It is recommended (but not required) that the `width` and `height` are equivalent to the
@ -213,7 +214,7 @@ impl Pixels {
/// ///
/// Panics when `width` or `height` are 0. /// Panics when `width` or `height` are 0.
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub fn new<W: HasRawWindowHandle + HasRawDisplayHandle>( pub fn new<W: HasWindowHandle + HasDisplayHandle + WasmNotSendSync>(
width: u32, width: u32,
height: u32, height: u32,
surface_texture: SurfaceTexture<'_, W>, surface_texture: SurfaceTexture<'_, W>,
@ -244,7 +245,7 @@ impl Pixels {
/// # Panics /// # Panics
/// ///
/// Panics when `width` or `height` are 0. /// Panics when `width` or `height` are 0.
pub async fn new_async<W: HasRawWindowHandle + HasRawDisplayHandle>( pub async fn new_async<W: HasWindowHandle + HasDisplayHandle + WasmNotSendSync>(
width: u32, width: u32,
height: u32, height: u32,
surface_texture: SurfaceTexture<'_, W>, surface_texture: SurfaceTexture<'_, W>,
@ -558,6 +559,7 @@ impl Pixels {
present_mode: self.present_mode, present_mode: self.present_mode,
alpha_mode: self.alpha_mode, alpha_mode: self.alpha_mode,
view_formats: vec![], view_formats: vec![],
desired_maximum_frame_latency: 1,
}, },
); );
} }

View file

@ -184,10 +184,11 @@ impl ScalingRenderer {
resolve_target: None, resolve_target: None,
ops: wgpu::Operations { ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(self.clear_color), load: wgpu::LoadOp::Clear(self.clear_color),
store: true, store: wgpu::StoreOp::Store,
}, },
})], })],
depth_stencil_attachment: None, depth_stencil_attachment: None,
..Default::default()
}); });
rpass.set_pipeline(&self.render_pipeline); rpass.set_pipeline(&self.render_pipeline);
rpass.set_bind_group(0, &self.bind_group, &[]); rpass.set_bind_group(0, &self.bind_group, &[]);