raw-window-handle 0.6
This commit is contained in:
parent
befb84aea8
commit
b577b326a8
321
Cargo.lock
generated
321
Cargo.lock
generated
|
@ -467,12 +467,43 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "com-rs"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "combine"
|
||||
version = "4.6.6"
|
||||
|
@ -661,6 +692,17 @@ dependencies = [
|
|||
"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]]
|
||||
name = "darling"
|
||||
version = "0.13.4"
|
||||
|
@ -769,7 +811,7 @@ dependencies = [
|
|||
"log",
|
||||
"thiserror",
|
||||
"type-map",
|
||||
"wgpu",
|
||||
"wgpu 0.17.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1263,6 +1305,17 @@ dependencies = [
|
|||
"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]]
|
||||
name = "glib"
|
||||
version = "0.16.9"
|
||||
|
@ -1322,6 +1375,27 @@ dependencies = [
|
|||
"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]]
|
||||
name = "gobject-sys"
|
||||
version = "0.16.3"
|
||||
|
@ -1365,6 +1439,19 @@ dependencies = [
|
|||
"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]]
|
||||
name = "gpu-descriptor"
|
||||
version = "0.2.4"
|
||||
|
@ -1471,6 +1558,21 @@ dependencies = [
|
|||
"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]]
|
||||
name = "heck"
|
||||
version = "0.3.3"
|
||||
|
@ -1582,7 +1684,7 @@ dependencies = [
|
|||
"imgui",
|
||||
"log",
|
||||
"smallvec",
|
||||
"wgpu",
|
||||
"wgpu 0.17.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1771,6 +1873,23 @@ dependencies = [
|
|||
"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]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
@ -1935,6 +2054,21 @@ dependencies = [
|
|||
"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]]
|
||||
name = "minimal-egui"
|
||||
version = "0.1.0"
|
||||
|
@ -2055,7 +2189,27 @@ dependencies = [
|
|||
"log",
|
||||
"num-traits",
|
||||
"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",
|
||||
"thiserror",
|
||||
"unicode-xid",
|
||||
|
@ -2386,10 +2540,10 @@ dependencies = [
|
|||
"bytemuck",
|
||||
"pixels-mocks",
|
||||
"pollster",
|
||||
"raw-window-handle 0.5.2",
|
||||
"raw-window-handle 0.6.0",
|
||||
"thiserror",
|
||||
"ultraviolet",
|
||||
"wgpu",
|
||||
"wgpu 0.19.1",
|
||||
"winit 0.28.7",
|
||||
]
|
||||
|
||||
|
@ -2425,6 +2579,12 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
|
||||
|
||||
[[package]]
|
||||
name = "presser"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.3.1"
|
||||
|
@ -2536,6 +2696,12 @@ version = "0.5.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.3.5"
|
||||
|
@ -2843,6 +3009,15 @@ dependencies = [
|
|||
"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]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
|
@ -3589,7 +3764,7 @@ dependencies = [
|
|||
"cfg-if",
|
||||
"js-sys",
|
||||
"log",
|
||||
"naga",
|
||||
"naga 0.13.0",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"raw-window-handle 0.5.2",
|
||||
|
@ -3598,9 +3773,34 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"wgpu-core",
|
||||
"wgpu-hal",
|
||||
"wgpu-types",
|
||||
"wgpu-core 0.17.1",
|
||||
"wgpu-hal 0.17.2",
|
||||
"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]]
|
||||
|
@ -3614,7 +3814,7 @@ dependencies = [
|
|||
"bitflags 2.4.2",
|
||||
"codespan-reporting",
|
||||
"log",
|
||||
"naga",
|
||||
"naga 0.13.0",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"raw-window-handle 0.5.2",
|
||||
|
@ -3622,8 +3822,34 @@ dependencies = [
|
|||
"smallvec",
|
||||
"thiserror",
|
||||
"web-sys",
|
||||
"wgpu-hal",
|
||||
"wgpu-types",
|
||||
"wgpu-hal 0.17.2",
|
||||
"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]]
|
||||
|
@ -3639,19 +3865,19 @@ dependencies = [
|
|||
"bitflags 2.4.2",
|
||||
"block",
|
||||
"core-graphics-types",
|
||||
"d3d12",
|
||||
"glow",
|
||||
"d3d12 0.7.0",
|
||||
"glow 0.12.3",
|
||||
"gpu-alloc",
|
||||
"gpu-allocator",
|
||||
"gpu-allocator 0.22.0",
|
||||
"gpu-descriptor",
|
||||
"hassle-rs",
|
||||
"hassle-rs 0.10.0",
|
||||
"js-sys",
|
||||
"khronos-egl",
|
||||
"khronos-egl 4.1.0",
|
||||
"libc",
|
||||
"libloading 0.8.1",
|
||||
"log",
|
||||
"metal",
|
||||
"naga",
|
||||
"metal 0.26.0",
|
||||
"naga 0.13.0",
|
||||
"objc",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
|
@ -3663,7 +3889,51 @@ dependencies = [
|
|||
"thiserror",
|
||||
"wasm-bindgen",
|
||||
"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",
|
||||
]
|
||||
|
||||
|
@ -3678,6 +3948,17 @@ dependencies = [
|
|||
"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]]
|
||||
name = "wide"
|
||||
version = "0.7.13"
|
||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -21,13 +21,13 @@ include = [
|
|||
|
||||
[dependencies]
|
||||
bytemuck = "1.12"
|
||||
raw-window-handle = "0.5"
|
||||
raw-window-handle = "0.6"
|
||||
thiserror = "1.0"
|
||||
ultraviolet = "0.9"
|
||||
wgpu = "0.17"
|
||||
wgpu = "0.19"
|
||||
|
||||
[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]
|
||||
pollster = "0.3"
|
||||
|
@ -37,8 +37,4 @@ pixels-mocks = { path = "internals/pixels-mocks" }
|
|||
winit = "0.28"
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"examples/*",
|
||||
"internals/*",
|
||||
"run-wasm",
|
||||
]
|
||||
members = ["examples/*", "internals/*", "run-wasm"]
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
use crate::renderers::{ScalingMatrix, ScalingRenderer};
|
||||
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.
|
||||
pub struct PixelsBuilder<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle> {
|
||||
request_adapter_options: Option<wgpu::RequestAdapterOptions<'req>>,
|
||||
pub struct PixelsBuilder<
|
||||
'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>>,
|
||||
backend: wgpu::Backends,
|
||||
width: u32,
|
||||
|
@ -19,8 +28,13 @@ pub struct PixelsBuilder<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplay
|
|||
blend_state: wgpu::BlendState,
|
||||
}
|
||||
|
||||
impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>
|
||||
PixelsBuilder<'req, 'dev, 'win, W>
|
||||
impl<
|
||||
'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.
|
||||
///
|
||||
|
@ -70,7 +84,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>
|
|||
/// Add options for requesting a [`wgpu::Adapter`].
|
||||
pub fn request_adapter_options(
|
||||
mut self,
|
||||
request_adapter_options: wgpu::RequestAdapterOptions<'req>,
|
||||
request_adapter_options: wgpu::RequestAdapterOptions<'req, 'sur>,
|
||||
) -> Self {
|
||||
self.request_adapter_options = Some(request_adapter_options);
|
||||
self
|
||||
|
@ -250,7 +264,12 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>
|
|||
});
|
||||
|
||||
// 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 request_adapter_options = &self.request_adapter_options;
|
||||
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
|
||||
.device_descriptor
|
||||
.unwrap_or_else(|| wgpu::DeviceDescriptor {
|
||||
limits: adapter.limits(),
|
||||
required_limits: adapter.limits(),
|
||||
..wgpu::DeviceDescriptor::default()
|
||||
});
|
||||
|
||||
|
@ -624,6 +643,9 @@ const fn texture_format_size(texture_format: wgpu::TextureFormat) -> f32 {
|
|||
Astc { block: B12x10, channel: _ } => 7.5, // 12.0 * 10.0 / 16.0
|
||||
|
||||
// 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!(),
|
||||
}
|
||||
}
|
||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -34,16 +34,17 @@
|
|||
pub use crate::builder::{check_texture_size, PixelsBuilder};
|
||||
pub use crate::renderers::ScalingRenderer;
|
||||
pub use raw_window_handle;
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||
use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
|
||||
use thiserror::Error;
|
||||
pub use wgpu;
|
||||
use wgpu::WasmNotSendSync;
|
||||
|
||||
mod builder;
|
||||
mod renderers;
|
||||
|
||||
/// A logical texture for a window surface.
|
||||
#[derive(Debug)]
|
||||
pub struct SurfaceTexture<'win, W: HasRawWindowHandle + HasRawDisplayHandle> {
|
||||
pub struct SurfaceTexture<'win, W: HasWindowHandle + HasDisplayHandle + WasmNotSendSync> {
|
||||
window: &'win W,
|
||||
size: SurfaceSize,
|
||||
}
|
||||
|
@ -67,7 +68,7 @@ pub struct PixelsContext {
|
|||
/// The `Queue` provides access to the GPU command 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
|
||||
/// [`Pixels::render_with`].
|
||||
|
@ -147,7 +148,7 @@ pub enum TextureError {
|
|||
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.
|
||||
///
|
||||
/// 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.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(
|
||||
pub fn new<W: HasWindowHandle + HasDisplayHandle + WasmNotSendSync>(
|
||||
width: u32,
|
||||
height: u32,
|
||||
surface_texture: SurfaceTexture<'_, W>,
|
||||
|
@ -244,7 +245,7 @@ impl Pixels {
|
|||
/// # Panics
|
||||
///
|
||||
/// 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,
|
||||
height: u32,
|
||||
surface_texture: SurfaceTexture<'_, W>,
|
||||
|
@ -558,6 +559,7 @@ impl Pixels {
|
|||
present_mode: self.present_mode,
|
||||
alpha_mode: self.alpha_mode,
|
||||
view_formats: vec![],
|
||||
desired_maximum_frame_latency: 1,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -184,10 +184,11 @@ impl ScalingRenderer {
|
|||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(self.clear_color),
|
||||
store: true,
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
..Default::default()
|
||||
});
|
||||
rpass.set_pipeline(&self.render_pipeline);
|
||||
rpass.set_bind_group(0, &self.bind_group, &[]);
|
||||
|
|
Loading…
Reference in a new issue