mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
webgpu: Update wgpu to 0.19 (#31995)
* Update wgpu to 32e70bc163
(0.19)
* Update expect only good
* reexpect
* remove dbg stuff
* Remove all occurrences of dx11_hub
This commit is contained in:
parent
81c4f2ae7a
commit
4af413cd04
28 changed files with 3422 additions and 9526 deletions
59
Cargo.lock
generated
59
Cargo.lock
generated
|
@ -1112,12 +1112,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "d3d12"
|
name = "d3d12"
|
||||||
version = "0.7.0"
|
version = "0.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||||
checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"libloading 0.8.3",
|
"libloading 0.7.4",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1410,7 +1409,7 @@ dependencies = [
|
||||||
"egui",
|
"egui",
|
||||||
"instant",
|
"instant",
|
||||||
"log",
|
"log",
|
||||||
"raw-window-handle",
|
"raw-window-handle 0.5.2",
|
||||||
"smithay-clipboard",
|
"smithay-clipboard",
|
||||||
"winit",
|
"winit",
|
||||||
]
|
]
|
||||||
|
@ -3845,10 +3844,10 @@ checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "naga"
|
name = "naga"
|
||||||
version = "0.14.2"
|
version = "0.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||||
checksum = "ae585df4b6514cf8842ac0f1ab4992edc975892704835b549cf818dc0191249e"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
"bit-set",
|
"bit-set",
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
|
@ -3874,7 +3873,7 @@ dependencies = [
|
||||||
"jni-sys",
|
"jni-sys",
|
||||||
"ndk-sys",
|
"ndk-sys",
|
||||||
"num_enum",
|
"num_enum",
|
||||||
"raw-window-handle",
|
"raw-window-handle 0.5.2",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4722,6 +4721,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 = "rayon"
|
name = "rayon"
|
||||||
version = "1.10.0"
|
version = "1.10.0"
|
||||||
|
@ -5557,7 +5562,7 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"libservo",
|
"libservo",
|
||||||
"log",
|
"log",
|
||||||
"raw-window-handle",
|
"raw-window-handle 0.5.2",
|
||||||
"servo-media",
|
"servo-media",
|
||||||
"servo_allocator",
|
"servo_allocator",
|
||||||
"shellwords",
|
"shellwords",
|
||||||
|
@ -5763,12 +5768,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spirv"
|
name = "spirv"
|
||||||
version = "0.2.0+1.5.4"
|
version = "0.3.0+sdk-1.3.268.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830"
|
checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 2.5.0",
|
||||||
"num-traits",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -5963,7 +5967,7 @@ dependencies = [
|
||||||
"mach2",
|
"mach2",
|
||||||
"metal 0.24.0",
|
"metal 0.24.0",
|
||||||
"objc",
|
"objc",
|
||||||
"raw-window-handle",
|
"raw-window-handle 0.5.2",
|
||||||
"servo-display-link",
|
"servo-display-link",
|
||||||
"sparkle",
|
"sparkle",
|
||||||
"wayland-sys 0.30.1",
|
"wayland-sys 0.30.1",
|
||||||
|
@ -7080,16 +7084,18 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-core"
|
name = "wgpu-core"
|
||||||
version = "0.18.1"
|
version = "0.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||||
checksum = "ef91c1d62d1e9e81c79e600131a258edf75c9531cbdbde09c44a011a47312726"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"bit-vec",
|
"bit-vec",
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
|
"cfg_aliases",
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
|
"indexmap 2.2.6",
|
||||||
"log",
|
"log",
|
||||||
"naga",
|
"naga",
|
||||||
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"profiling",
|
"profiling",
|
||||||
"ron",
|
"ron",
|
||||||
|
@ -7104,9 +7110,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-hal"
|
name = "wgpu-hal"
|
||||||
version = "0.18.1"
|
version = "0.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||||
checksum = "b84ecc802da3eb67b4cf3dd9ea6fe45bbb47ef13e6c49c5c3240868a9cc6cdd9"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_system_properties",
|
"android_system_properties",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
|
@ -7114,6 +7119,7 @@ dependencies = [
|
||||||
"bit-set",
|
"bit-set",
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"block",
|
"block",
|
||||||
|
"cfg_aliases",
|
||||||
"core-graphics-types",
|
"core-graphics-types",
|
||||||
"d3d12",
|
"d3d12",
|
||||||
"gpu-alloc",
|
"gpu-alloc",
|
||||||
|
@ -7121,7 +7127,7 @@ dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"khronos-egl",
|
"khronos-egl",
|
||||||
"libc",
|
"libc",
|
||||||
"libloading 0.8.3",
|
"libloading 0.7.4",
|
||||||
"log",
|
"log",
|
||||||
"metal 0.27.0",
|
"metal 0.27.0",
|
||||||
"naga",
|
"naga",
|
||||||
|
@ -7130,7 +7136,7 @@ dependencies = [
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"profiling",
|
"profiling",
|
||||||
"range-alloc",
|
"range-alloc",
|
||||||
"raw-window-handle",
|
"raw-window-handle 0.6.0",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@ -7142,9 +7148,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-types"
|
name = "wgpu-types"
|
||||||
version = "0.18.0"
|
version = "0.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||||
checksum = "0d5ed5f0edf0de351fe311c53304986315ce866f394a2e6df0c4b3c70774bcdd"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
@ -7439,7 +7444,7 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"orbclient",
|
"orbclient",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"raw-window-handle",
|
"raw-window-handle 0.5.2",
|
||||||
"redox_syscall 0.3.5",
|
"redox_syscall 0.3.5",
|
||||||
"sctk-adwaita",
|
"sctk-adwaita",
|
||||||
"smithay-client-toolkit",
|
"smithay-client-toolkit",
|
||||||
|
|
|
@ -126,8 +126,8 @@ webpki-roots = "0.25"
|
||||||
webrender = { git = "https://github.com/servo/webrender", branch = "0.64", features = ["capture"] }
|
webrender = { git = "https://github.com/servo/webrender", branch = "0.64", features = ["capture"] }
|
||||||
webrender_api = { git = "https://github.com/servo/webrender", branch = "0.64" }
|
webrender_api = { git = "https://github.com/servo/webrender", branch = "0.64" }
|
||||||
webrender_traits = { path = "components/shared/webrender" }
|
webrender_traits = { path = "components/shared/webrender" }
|
||||||
wgpu-core = "0.18"
|
wgpu-core = { git = "https://github.com/gfx-rs/wgpu", rev = "32e70bc1635905c508d408eb1cf22b2aa062ffe1" }
|
||||||
wgpu-types = "0.18"
|
wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "32e70bc1635905c508d408eb1cf22b2aa062ffe1" }
|
||||||
winapi = "0.3"
|
winapi = "0.3"
|
||||||
xi-unicode = "0.1.0"
|
xi-unicode = "0.1.0"
|
||||||
xml5ever = "0.17"
|
xml5ever = "0.17"
|
||||||
|
|
|
@ -86,6 +86,21 @@ impl GPUAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPUAdapter {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DropAdapter(self.adapter.0)))
|
||||||
|
{
|
||||||
|
warn!(
|
||||||
|
"Failed to send WebGPURequest::DropAdapter({:?}) ({})",
|
||||||
|
self.adapter.0, e
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl GPUAdapterMethods for GPUAdapter {
|
impl GPUAdapterMethods for GPUAdapter {
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuadapter-requestdevice>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpuadapter-requestdevice>
|
||||||
fn RequestDevice(&self, descriptor: &GPUDeviceDescriptor, comp: InRealm) -> Rc<Promise> {
|
fn RequestDevice(&self, descriptor: &GPUDeviceDescriptor, comp: InRealm) -> Rc<Promise> {
|
||||||
|
@ -106,69 +121,83 @@ impl GPUAdapterMethods for GPUAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut desc = wgt::DeviceDescriptor {
|
let mut desc = wgt::DeviceDescriptor {
|
||||||
features,
|
required_features: features,
|
||||||
limits: wgt::Limits::default(),
|
required_limits: wgt::Limits::default(),
|
||||||
label: None,
|
label: None,
|
||||||
};
|
};
|
||||||
if let Some(limits) = &descriptor.requiredLimits {
|
if let Some(limits) = &descriptor.requiredLimits {
|
||||||
for (limit, value) in (*limits).iter() {
|
for (limit, value) in (*limits).iter() {
|
||||||
let v = u32::try_from(*value).unwrap_or(u32::MAX);
|
let v = u32::try_from(*value).unwrap_or(u32::MAX);
|
||||||
match limit.as_ref() {
|
match limit.as_ref() {
|
||||||
"maxTextureDimension1D" => desc.limits.max_texture_dimension_1d = v,
|
"maxTextureDimension1D" => desc.required_limits.max_texture_dimension_1d = v,
|
||||||
"maxTextureDimension2D" => desc.limits.max_texture_dimension_2d = v,
|
"maxTextureDimension2D" => desc.required_limits.max_texture_dimension_2d = v,
|
||||||
"maxTextureDimension3D" => desc.limits.max_texture_dimension_3d = v,
|
"maxTextureDimension3D" => desc.required_limits.max_texture_dimension_3d = v,
|
||||||
"maxTextureArrayLayers" => desc.limits.max_texture_array_layers = v,
|
"maxTextureArrayLayers" => desc.required_limits.max_texture_array_layers = v,
|
||||||
"maxBindGroups" => desc.limits.max_bind_groups = v,
|
"maxBindGroups" => desc.required_limits.max_bind_groups = v,
|
||||||
"maxBindingsPerBindGroup" => desc.limits.max_bindings_per_bind_group = v,
|
"maxBindingsPerBindGroup" => {
|
||||||
|
desc.required_limits.max_bindings_per_bind_group = v
|
||||||
|
},
|
||||||
"maxDynamicUniformBuffersPerPipelineLayout" => {
|
"maxDynamicUniformBuffersPerPipelineLayout" => {
|
||||||
desc.limits.max_dynamic_uniform_buffers_per_pipeline_layout = v
|
desc.required_limits
|
||||||
|
.max_dynamic_uniform_buffers_per_pipeline_layout = v
|
||||||
},
|
},
|
||||||
"maxDynamicStorageBuffersPerPipelineLayout" => {
|
"maxDynamicStorageBuffersPerPipelineLayout" => {
|
||||||
desc.limits.max_dynamic_storage_buffers_per_pipeline_layout = v
|
desc.required_limits
|
||||||
|
.max_dynamic_storage_buffers_per_pipeline_layout = v
|
||||||
},
|
},
|
||||||
"maxSampledTexturesPerShaderStage" => {
|
"maxSampledTexturesPerShaderStage" => {
|
||||||
desc.limits.max_sampled_textures_per_shader_stage = v
|
desc.required_limits.max_sampled_textures_per_shader_stage = v
|
||||||
|
},
|
||||||
|
"maxSamplersPerShaderStage" => {
|
||||||
|
desc.required_limits.max_samplers_per_shader_stage = v
|
||||||
},
|
},
|
||||||
"maxSamplersPerShaderStage" => desc.limits.max_samplers_per_shader_stage = v,
|
|
||||||
"maxStorageBuffersPerShaderStage" => {
|
"maxStorageBuffersPerShaderStage" => {
|
||||||
desc.limits.max_storage_buffers_per_shader_stage = v
|
desc.required_limits.max_storage_buffers_per_shader_stage = v
|
||||||
},
|
},
|
||||||
"maxStorageTexturesPerShaderStage" => {
|
"maxStorageTexturesPerShaderStage" => {
|
||||||
desc.limits.max_storage_textures_per_shader_stage = v
|
desc.required_limits.max_storage_textures_per_shader_stage = v
|
||||||
},
|
},
|
||||||
"maxUniformBuffersPerShaderStage" => {
|
"maxUniformBuffersPerShaderStage" => {
|
||||||
desc.limits.max_uniform_buffers_per_shader_stage = v
|
desc.required_limits.max_uniform_buffers_per_shader_stage = v
|
||||||
},
|
},
|
||||||
"maxUniformBufferBindingSize" => {
|
"maxUniformBufferBindingSize" => {
|
||||||
desc.limits.max_uniform_buffer_binding_size = v
|
desc.required_limits.max_uniform_buffer_binding_size = v
|
||||||
},
|
},
|
||||||
"maxStorageBufferBindingSize" => {
|
"maxStorageBufferBindingSize" => {
|
||||||
desc.limits.max_storage_buffer_binding_size = v
|
desc.required_limits.max_storage_buffer_binding_size = v
|
||||||
},
|
},
|
||||||
"minUniformBufferOffsetAlignment" => {
|
"minUniformBufferOffsetAlignment" => {
|
||||||
desc.limits.min_uniform_buffer_offset_alignment = v
|
desc.required_limits.min_uniform_buffer_offset_alignment = v
|
||||||
},
|
},
|
||||||
"minStorageBufferOffsetAlignment" => {
|
"minStorageBufferOffsetAlignment" => {
|
||||||
desc.limits.min_storage_buffer_offset_alignment = v
|
desc.required_limits.min_storage_buffer_offset_alignment = v
|
||||||
|
},
|
||||||
|
"maxVertexBuffers" => desc.required_limits.max_vertex_buffers = v,
|
||||||
|
"maxBufferSize" => desc.required_limits.max_buffer_size = *value,
|
||||||
|
"maxVertexAttributes" => desc.required_limits.max_vertex_attributes = v,
|
||||||
|
"maxVertexBufferArrayStride" => {
|
||||||
|
desc.required_limits.max_vertex_buffer_array_stride = v
|
||||||
},
|
},
|
||||||
"maxVertexBuffers" => desc.limits.max_vertex_buffers = v,
|
|
||||||
"maxBufferSize" => desc.limits.max_buffer_size = *value,
|
|
||||||
"maxVertexAttributes" => desc.limits.max_vertex_attributes = v,
|
|
||||||
"maxVertexBufferArrayStride" => desc.limits.max_vertex_buffer_array_stride = v,
|
|
||||||
"maxInterStageShaderComponents" => {
|
"maxInterStageShaderComponents" => {
|
||||||
desc.limits.max_inter_stage_shader_components = v
|
desc.required_limits.max_inter_stage_shader_components = v
|
||||||
},
|
},
|
||||||
"maxComputeWorkgroupStorageSize" => {
|
"maxComputeWorkgroupStorageSize" => {
|
||||||
desc.limits.max_compute_workgroup_storage_size = v
|
desc.required_limits.max_compute_workgroup_storage_size = v
|
||||||
},
|
},
|
||||||
"maxComputeInvocationsPerWorkgroup" => {
|
"maxComputeInvocationsPerWorkgroup" => {
|
||||||
desc.limits.max_compute_invocations_per_workgroup = v
|
desc.required_limits.max_compute_invocations_per_workgroup = v
|
||||||
|
},
|
||||||
|
"maxComputeWorkgroupSizeX" => {
|
||||||
|
desc.required_limits.max_compute_workgroup_size_x = v
|
||||||
|
},
|
||||||
|
"maxComputeWorkgroupSizeY" => {
|
||||||
|
desc.required_limits.max_compute_workgroup_size_y = v
|
||||||
|
},
|
||||||
|
"maxComputeWorkgroupSizeZ" => {
|
||||||
|
desc.required_limits.max_compute_workgroup_size_z = v
|
||||||
},
|
},
|
||||||
"maxComputeWorkgroupSizeX" => desc.limits.max_compute_workgroup_size_x = v,
|
|
||||||
"maxComputeWorkgroupSizeY" => desc.limits.max_compute_workgroup_size_y = v,
|
|
||||||
"maxComputeWorkgroupSizeZ" => desc.limits.max_compute_workgroup_size_z = v,
|
|
||||||
"maxComputeWorkgroupsPerDimension" => {
|
"maxComputeWorkgroupsPerDimension" => {
|
||||||
desc.limits.max_compute_workgroups_per_dimension = v
|
desc.required_limits.max_compute_workgroups_per_dimension = v
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
error!("Unknown required limit: {limit} with value {value}");
|
error!("Unknown required limit: {limit} with value {value}");
|
||||||
|
@ -251,8 +280,8 @@ impl AsyncWGPUListener for GPUAdapter {
|
||||||
self.channel.clone(),
|
self.channel.clone(),
|
||||||
self,
|
self,
|
||||||
Heap::default(),
|
Heap::default(),
|
||||||
descriptor.features,
|
descriptor.required_features,
|
||||||
descriptor.limits,
|
descriptor.required_limits,
|
||||||
device_id,
|
device_id,
|
||||||
queue_id,
|
queue_id,
|
||||||
descriptor.label.unwrap_or_default(),
|
descriptor.label.unwrap_or_default(),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::{WebGPUBindGroup, WebGPUDevice};
|
use webgpu::{WebGPU, WebGPUBindGroup, WebGPUDevice, WebGPURequest};
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBindGroupMethods;
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBindGroupMethods;
|
||||||
|
@ -16,6 +16,9 @@ use crate::dom::gpubindgrouplayout::GPUBindGroupLayout;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUBindGroup {
|
pub struct GPUBindGroup {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
#[ignore_malloc_size_of = "channels are hard"]
|
||||||
|
#[no_trace]
|
||||||
|
channel: WebGPU,
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
bind_group: WebGPUBindGroup,
|
bind_group: WebGPUBindGroup,
|
||||||
|
@ -26,6 +29,7 @@ pub struct GPUBindGroup {
|
||||||
|
|
||||||
impl GPUBindGroup {
|
impl GPUBindGroup {
|
||||||
fn new_inherited(
|
fn new_inherited(
|
||||||
|
channel: WebGPU,
|
||||||
bind_group: WebGPUBindGroup,
|
bind_group: WebGPUBindGroup,
|
||||||
device: WebGPUDevice,
|
device: WebGPUDevice,
|
||||||
layout: &GPUBindGroupLayout,
|
layout: &GPUBindGroupLayout,
|
||||||
|
@ -33,6 +37,7 @@ impl GPUBindGroup {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
channel,
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
bind_group,
|
bind_group,
|
||||||
device,
|
device,
|
||||||
|
@ -42,6 +47,7 @@ impl GPUBindGroup {
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
|
channel: WebGPU,
|
||||||
bind_group: WebGPUBindGroup,
|
bind_group: WebGPUBindGroup,
|
||||||
device: WebGPUDevice,
|
device: WebGPUDevice,
|
||||||
layout: &GPUBindGroupLayout,
|
layout: &GPUBindGroupLayout,
|
||||||
|
@ -49,7 +55,7 @@ impl GPUBindGroup {
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUBindGroup::new_inherited(
|
Box::new(GPUBindGroup::new_inherited(
|
||||||
bind_group, device, layout, label,
|
channel, bind_group, device, layout, label,
|
||||||
)),
|
)),
|
||||||
global,
|
global,
|
||||||
)
|
)
|
||||||
|
@ -62,6 +68,21 @@ impl GPUBindGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPUBindGroup {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DropBindGroup(self.bind_group.0)))
|
||||||
|
{
|
||||||
|
warn!(
|
||||||
|
"Failed to send WebGPURequest::DropBindGroup({:?}) ({})",
|
||||||
|
self.bind_group.0, e
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl GPUBindGroupMethods for GPUBindGroup {
|
impl GPUBindGroupMethods for GPUBindGroup {
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label>
|
||||||
fn Label(&self) -> USVString {
|
fn Label(&self) -> USVString {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::WebGPUBindGroupLayout;
|
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPURequest};
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBindGroupLayoutMethods;
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBindGroupLayoutMethods;
|
||||||
|
@ -15,15 +15,23 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUBindGroupLayout {
|
pub struct GPUBindGroupLayout {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
#[ignore_malloc_size_of = "channels are hard"]
|
||||||
|
#[no_trace]
|
||||||
|
channel: WebGPU,
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
bind_group_layout: WebGPUBindGroupLayout,
|
bind_group_layout: WebGPUBindGroupLayout,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GPUBindGroupLayout {
|
impl GPUBindGroupLayout {
|
||||||
fn new_inherited(bind_group_layout: WebGPUBindGroupLayout, label: USVString) -> Self {
|
fn new_inherited(
|
||||||
|
channel: WebGPU,
|
||||||
|
bind_group_layout: WebGPUBindGroupLayout,
|
||||||
|
label: USVString,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
channel,
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
bind_group_layout,
|
bind_group_layout,
|
||||||
}
|
}
|
||||||
|
@ -31,11 +39,16 @@ impl GPUBindGroupLayout {
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
|
channel: WebGPU,
|
||||||
bind_group_layout: WebGPUBindGroupLayout,
|
bind_group_layout: WebGPUBindGroupLayout,
|
||||||
label: USVString,
|
label: USVString,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUBindGroupLayout::new_inherited(bind_group_layout, label)),
|
Box::new(GPUBindGroupLayout::new_inherited(
|
||||||
|
channel,
|
||||||
|
bind_group_layout,
|
||||||
|
label,
|
||||||
|
)),
|
||||||
global,
|
global,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -47,6 +60,20 @@ impl GPUBindGroupLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPUBindGroupLayout {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self.channel.0.send((
|
||||||
|
None,
|
||||||
|
WebGPURequest::DropBindGroupLayout(self.bind_group_layout.0),
|
||||||
|
)) {
|
||||||
|
warn!(
|
||||||
|
"Failed to send WebGPURequest::DropBindGroupLayout({:?}) ({})",
|
||||||
|
self.bind_group_layout.0, e
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl GPUBindGroupLayoutMethods for GPUBindGroupLayout {
|
impl GPUBindGroupLayoutMethods for GPUBindGroupLayout {
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label>
|
||||||
fn Label(&self) -> USVString {
|
fn Label(&self) -> USVString {
|
||||||
|
|
|
@ -130,8 +130,18 @@ impl GPUBuffer {
|
||||||
|
|
||||||
impl Drop for GPUBuffer {
|
impl Drop for GPUBuffer {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if let Err(e) = self.Destroy() {
|
if matches!(self.state(), GPUBufferState::Destroyed) {
|
||||||
error!("GPUBuffer destruction failed with {e:?}!"); // TODO: should we allow panic here?
|
return;
|
||||||
|
}
|
||||||
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DropBuffer(self.buffer.0)))
|
||||||
|
{
|
||||||
|
warn!(
|
||||||
|
"Failed to send WebGPURequest::DropBuffer({:?}) ({})",
|
||||||
|
self.buffer.0, e
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ impl GPUCanvasContextMethods for GPUCanvasContext {
|
||||||
.expect("Failed to create WebGPU SwapChain");
|
.expect("Failed to create WebGPU SwapChain");
|
||||||
|
|
||||||
self.texture
|
self.texture
|
||||||
.set(Some(&descriptor.device.CreateTexture(&text_desc)));
|
.set(Some(&descriptor.device.CreateTexture(&text_desc).unwrap()));
|
||||||
|
|
||||||
self.webrender_image.set(Some(receiver.recv().unwrap()));
|
self.webrender_image.set(Some(receiver.recv().unwrap()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,10 +74,10 @@ impl Drop for GPUCommandBuffer {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if let Err(e) = self.channel.0.send((
|
if let Err(e) = self.channel.0.send((
|
||||||
None,
|
None,
|
||||||
WebGPURequest::FreeCommandBuffer(self.command_buffer.0),
|
WebGPURequest::DropCommandBuffer(self.command_buffer.0),
|
||||||
)) {
|
)) {
|
||||||
warn!(
|
warn!(
|
||||||
"Failed to send FreeCommandBuffer({:?}) ({})",
|
"Failed to send DropCommandBuffer({:?}) ({})",
|
||||||
self.command_buffer.0, e
|
self.command_buffer.0, e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,7 +393,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
.expect("Failed to send Finish");
|
.expect("Failed to send Finish");
|
||||||
|
|
||||||
*self.state.borrow_mut() = GPUCommandEncoderState::Closed;
|
*self.state.borrow_mut() = GPUCommandEncoderState::Closed;
|
||||||
let buffer = webgpu::WebGPUCommandBuffer(self.encoder.0);
|
let buffer = webgpu::WebGPUCommandBuffer(self.encoder.0.transmute());
|
||||||
GPUCommandBuffer::new(
|
GPUCommandBuffer::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
self.channel.clone(),
|
self.channel.clone(),
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::{WebGPUBindGroupLayout, WebGPUComputePipeline};
|
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPUComputePipeline, WebGPURequest};
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUComputePipelineMethods;
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUComputePipelineMethods;
|
||||||
|
@ -20,6 +20,9 @@ use crate::dom::gpudevice::GPUDevice;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUComputePipeline {
|
pub struct GPUComputePipeline {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
#[ignore_malloc_size_of = "channels are hard"]
|
||||||
|
#[no_trace]
|
||||||
|
channel: WebGPU,
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
compute_pipeline: WebGPUComputePipeline,
|
compute_pipeline: WebGPUComputePipeline,
|
||||||
|
@ -30,6 +33,7 @@ pub struct GPUComputePipeline {
|
||||||
|
|
||||||
impl GPUComputePipeline {
|
impl GPUComputePipeline {
|
||||||
fn new_inherited(
|
fn new_inherited(
|
||||||
|
channel: WebGPU,
|
||||||
compute_pipeline: WebGPUComputePipeline,
|
compute_pipeline: WebGPUComputePipeline,
|
||||||
label: USVString,
|
label: USVString,
|
||||||
bgls: Vec<WebGPUBindGroupLayout>,
|
bgls: Vec<WebGPUBindGroupLayout>,
|
||||||
|
@ -37,6 +41,7 @@ impl GPUComputePipeline {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
channel,
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
compute_pipeline,
|
compute_pipeline,
|
||||||
bind_group_layouts: bgls,
|
bind_group_layouts: bgls,
|
||||||
|
@ -46,6 +51,7 @@ impl GPUComputePipeline {
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
|
channel: WebGPU,
|
||||||
compute_pipeline: WebGPUComputePipeline,
|
compute_pipeline: WebGPUComputePipeline,
|
||||||
label: USVString,
|
label: USVString,
|
||||||
bgls: Vec<WebGPUBindGroupLayout>,
|
bgls: Vec<WebGPUBindGroupLayout>,
|
||||||
|
@ -53,6 +59,7 @@ impl GPUComputePipeline {
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUComputePipeline::new_inherited(
|
Box::new(GPUComputePipeline::new_inherited(
|
||||||
|
channel,
|
||||||
compute_pipeline,
|
compute_pipeline,
|
||||||
label,
|
label,
|
||||||
bgls,
|
bgls,
|
||||||
|
@ -87,8 +94,23 @@ impl GPUComputePipelineMethods for GPUComputePipeline {
|
||||||
}
|
}
|
||||||
Ok(GPUBindGroupLayout::new(
|
Ok(GPUBindGroupLayout::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
self.channel.clone(),
|
||||||
self.bind_group_layouts[index as usize],
|
self.bind_group_layouts[index as usize],
|
||||||
USVString::default(),
|
USVString::default(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPUComputePipeline {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self.channel.0.send((
|
||||||
|
None,
|
||||||
|
WebGPURequest::DropComputePipeline(self.compute_pipeline.0),
|
||||||
|
)) {
|
||||||
|
warn!(
|
||||||
|
"Failed to send WebGPURequest::DropComputePipeline({:?}) ({})",
|
||||||
|
self.compute_pipeline.0, e
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -176,6 +176,10 @@ impl GPUDevice {
|
||||||
self.device
|
self.device
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn channel(&self) -> WebGPU {
|
||||||
|
self.channel.clone()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn handle_server_msg(&self, scope: Option<ErrorScopeId>, result: WebGPUOpResult) {
|
pub fn handle_server_msg(&self, scope: Option<ErrorScopeId>, result: WebGPUOpResult) {
|
||||||
let result = match result {
|
let result = match result {
|
||||||
WebGPUOpResult::Success => Ok(()),
|
WebGPUOpResult::Success => Ok(()),
|
||||||
|
@ -542,6 +546,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
|
|
||||||
GPUBindGroupLayout::new(
|
GPUBindGroupLayout::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
self.channel.clone(),
|
||||||
bgl,
|
bgl,
|
||||||
descriptor.parent.label.clone().unwrap_or_default(),
|
descriptor.parent.label.clone().unwrap_or_default(),
|
||||||
)
|
)
|
||||||
|
@ -591,6 +596,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
let pipeline_layout = webgpu::WebGPUPipelineLayout(pipeline_layout_id);
|
let pipeline_layout = webgpu::WebGPUPipelineLayout(pipeline_layout_id);
|
||||||
GPUPipelineLayout::new(
|
GPUPipelineLayout::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
self.channel.clone(),
|
||||||
pipeline_layout,
|
pipeline_layout,
|
||||||
descriptor.parent.label.clone().unwrap_or_default(),
|
descriptor.parent.label.clone().unwrap_or_default(),
|
||||||
bgls,
|
bgls,
|
||||||
|
@ -651,6 +657,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
|
|
||||||
GPUBindGroup::new(
|
GPUBindGroup::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
self.channel.clone(),
|
||||||
bind_group,
|
bind_group,
|
||||||
self.device,
|
self.device,
|
||||||
&descriptor.layout,
|
&descriptor.layout,
|
||||||
|
@ -686,6 +693,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
let shader_module = webgpu::WebGPUShaderModule(program_id);
|
let shader_module = webgpu::WebGPUShaderModule(program_id);
|
||||||
GPUShaderModule::new(
|
GPUShaderModule::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
self.channel.clone(),
|
||||||
shader_module,
|
shader_module,
|
||||||
descriptor.parent.label.clone().unwrap_or_default(),
|
descriptor.parent.label.clone().unwrap_or_default(),
|
||||||
)
|
)
|
||||||
|
@ -730,6 +738,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
let compute_pipeline = webgpu::WebGPUComputePipeline(compute_pipeline_id);
|
let compute_pipeline = webgpu::WebGPUComputePipeline(compute_pipeline_id);
|
||||||
GPUComputePipeline::new(
|
GPUComputePipeline::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
self.channel.clone(),
|
||||||
compute_pipeline,
|
compute_pipeline,
|
||||||
descriptor.parent.parent.label.clone().unwrap_or_default(),
|
descriptor.parent.parent.label.clone().unwrap_or_default(),
|
||||||
bgls,
|
bgls,
|
||||||
|
@ -783,7 +792,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createtexture>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createtexture>
|
||||||
fn CreateTexture(&self, descriptor: &GPUTextureDescriptor) -> DomRoot<GPUTexture> {
|
fn CreateTexture(&self, descriptor: &GPUTextureDescriptor) -> Fallible<DomRoot<GPUTexture>> {
|
||||||
let size = convert_texture_size_to_dict(&descriptor.size);
|
let size = convert_texture_size_to_dict(&descriptor.size);
|
||||||
let desc = wgt::TextureUsages::from_bits(descriptor.usage).map(|usg| {
|
let desc = wgt::TextureUsages::from_bits(descriptor.usage).map(|usg| {
|
||||||
wgpu_res::TextureDescriptor {
|
wgpu_res::TextureDescriptor {
|
||||||
|
@ -814,10 +823,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
|
|
||||||
let scope_id = self.use_current_scope();
|
let scope_id = self.use_current_scope();
|
||||||
if desc.is_none() {
|
if desc.is_none() {
|
||||||
self.handle_server_msg(
|
return Err(Error::Type(String::from("Invalid GPUTextureUsage")));
|
||||||
scope_id,
|
|
||||||
WebGPUOpResult::ValidationError(String::from("Invalid GPUTextureUsage")),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
|
@ -833,7 +839,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
|
|
||||||
let texture = webgpu::WebGPUTexture(texture_id);
|
let texture = webgpu::WebGPUTexture(texture_id);
|
||||||
|
|
||||||
GPUTexture::new(
|
Ok(GPUTexture::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
texture,
|
texture,
|
||||||
self,
|
self,
|
||||||
|
@ -845,7 +851,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
descriptor.format,
|
descriptor.format,
|
||||||
descriptor.usage,
|
descriptor.usage,
|
||||||
descriptor.parent.label.clone().unwrap_or_default(),
|
descriptor.parent.label.clone().unwrap_or_default(),
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createsampler>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createsampler>
|
||||||
|
@ -890,6 +896,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
|
|
||||||
GPUSampler::new(
|
GPUSampler::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
self.channel.clone(),
|
||||||
self.device,
|
self.device,
|
||||||
compare_enable,
|
compare_enable,
|
||||||
sampler,
|
sampler,
|
||||||
|
@ -1173,8 +1180,20 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for GPUDevice {
|
impl Drop for GPUDevice {
|
||||||
// not sure about this but this is non failable version of destroy
|
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.Destroy()
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DestroyDevice(self.device.0)))
|
||||||
|
{
|
||||||
|
warn!("Failed to send DestroyDevice ({:?}) ({})", self.device.0, e);
|
||||||
|
}
|
||||||
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DropDevice(self.device.0)))
|
||||||
|
{
|
||||||
|
warn!("Failed to send DropDevice ({:?}) ({})", self.device.0, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::{WebGPUBindGroupLayout, WebGPUPipelineLayout};
|
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPUPipelineLayout, WebGPURequest};
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUPipelineLayoutMethods;
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUPipelineLayoutMethods;
|
||||||
|
@ -15,6 +15,9 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUPipelineLayout {
|
pub struct GPUPipelineLayout {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||||
|
#[no_trace]
|
||||||
|
channel: WebGPU,
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
pipeline_layout: WebGPUPipelineLayout,
|
pipeline_layout: WebGPUPipelineLayout,
|
||||||
|
@ -24,12 +27,14 @@ pub struct GPUPipelineLayout {
|
||||||
|
|
||||||
impl GPUPipelineLayout {
|
impl GPUPipelineLayout {
|
||||||
fn new_inherited(
|
fn new_inherited(
|
||||||
|
channel: WebGPU,
|
||||||
pipeline_layout: WebGPUPipelineLayout,
|
pipeline_layout: WebGPUPipelineLayout,
|
||||||
label: USVString,
|
label: USVString,
|
||||||
bgls: Vec<WebGPUBindGroupLayout>,
|
bgls: Vec<WebGPUBindGroupLayout>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
channel,
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
pipeline_layout,
|
pipeline_layout,
|
||||||
bind_group_layouts: bgls,
|
bind_group_layouts: bgls,
|
||||||
|
@ -38,12 +43,14 @@ impl GPUPipelineLayout {
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
|
channel: WebGPU,
|
||||||
pipeline_layout: WebGPUPipelineLayout,
|
pipeline_layout: WebGPUPipelineLayout,
|
||||||
label: USVString,
|
label: USVString,
|
||||||
bgls: Vec<WebGPUBindGroupLayout>,
|
bgls: Vec<WebGPUBindGroupLayout>,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUPipelineLayout::new_inherited(
|
Box::new(GPUPipelineLayout::new_inherited(
|
||||||
|
channel,
|
||||||
pipeline_layout,
|
pipeline_layout,
|
||||||
label,
|
label,
|
||||||
bgls,
|
bgls,
|
||||||
|
@ -74,3 +81,17 @@ impl GPUPipelineLayoutMethods for GPUPipelineLayout {
|
||||||
*self.label.borrow_mut() = value;
|
*self.label.borrow_mut() = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPUPipelineLayout {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self.channel.0.send((
|
||||||
|
None,
|
||||||
|
WebGPURequest::DropPipelineLayout(self.pipeline_layout.0),
|
||||||
|
)) {
|
||||||
|
warn!(
|
||||||
|
"Failed to send DropPipelineLayout ({:?}) ({})",
|
||||||
|
self.pipeline_layout.0, e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::{WebGPU, WebGPUDevice, WebGPURenderBundle};
|
use webgpu::{WebGPU, WebGPUDevice, WebGPURenderBundle, WebGPURequest};
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderBundleMethods;
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderBundleMethods;
|
||||||
|
@ -77,3 +77,18 @@ impl GPURenderBundleMethods for GPURenderBundle {
|
||||||
*self.label.borrow_mut() = value;
|
*self.label.borrow_mut() = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPURenderBundle {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DropRenderBundle(self.render_bundle.0)))
|
||||||
|
{
|
||||||
|
warn!(
|
||||||
|
"Failed to send DropRenderBundle ({:?}) ({})",
|
||||||
|
self.render_bundle.0, e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::{WebGPUBindGroupLayout, WebGPURenderPipeline};
|
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPURenderPipeline, WebGPURequest};
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderPipelineMethods;
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderPipelineMethods;
|
||||||
|
@ -20,6 +20,9 @@ use crate::dom::gpudevice::GPUDevice;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPURenderPipeline {
|
pub struct GPURenderPipeline {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
#[ignore_malloc_size_of = "channels are hard"]
|
||||||
|
#[no_trace]
|
||||||
|
channel: WebGPU,
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
render_pipeline: WebGPURenderPipeline,
|
render_pipeline: WebGPURenderPipeline,
|
||||||
|
@ -37,6 +40,7 @@ impl GPURenderPipeline {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
channel: device.channel(),
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
render_pipeline,
|
render_pipeline,
|
||||||
bind_group_layouts: bgls,
|
bind_group_layouts: bgls,
|
||||||
|
@ -87,8 +91,23 @@ impl GPURenderPipelineMethods for GPURenderPipeline {
|
||||||
}
|
}
|
||||||
Ok(GPUBindGroupLayout::new(
|
Ok(GPUBindGroupLayout::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
self.channel.clone(),
|
||||||
self.bind_group_layouts[index as usize],
|
self.bind_group_layouts[index as usize],
|
||||||
USVString::default(),
|
USVString::default(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPURenderPipeline {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self.channel.0.send((
|
||||||
|
None,
|
||||||
|
WebGPURequest::DropRenderPipeline(self.render_pipeline.0),
|
||||||
|
)) {
|
||||||
|
warn!(
|
||||||
|
"Failed to send WebGPURequest::DropRenderPipeline({:?}) ({})",
|
||||||
|
self.render_pipeline.0, e
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::{WebGPUDevice, WebGPUSampler};
|
use webgpu::{WebGPU, WebGPUDevice, WebGPURequest, WebGPUSampler};
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUSamplerMethods;
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUSamplerMethods;
|
||||||
|
@ -15,6 +15,9 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUSampler {
|
pub struct GPUSampler {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||||
|
#[no_trace]
|
||||||
|
channel: WebGPU,
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
device: WebGPUDevice,
|
device: WebGPUDevice,
|
||||||
|
@ -25,6 +28,7 @@ pub struct GPUSampler {
|
||||||
|
|
||||||
impl GPUSampler {
|
impl GPUSampler {
|
||||||
fn new_inherited(
|
fn new_inherited(
|
||||||
|
channel: WebGPU,
|
||||||
device: WebGPUDevice,
|
device: WebGPUDevice,
|
||||||
compare_enable: bool,
|
compare_enable: bool,
|
||||||
sampler: WebGPUSampler,
|
sampler: WebGPUSampler,
|
||||||
|
@ -32,6 +36,7 @@ impl GPUSampler {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
channel,
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
device,
|
device,
|
||||||
sampler,
|
sampler,
|
||||||
|
@ -41,6 +46,7 @@ impl GPUSampler {
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
|
channel: WebGPU,
|
||||||
device: WebGPUDevice,
|
device: WebGPUDevice,
|
||||||
compare_enable: bool,
|
compare_enable: bool,
|
||||||
sampler: WebGPUSampler,
|
sampler: WebGPUSampler,
|
||||||
|
@ -48,6 +54,7 @@ impl GPUSampler {
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUSampler::new_inherited(
|
Box::new(GPUSampler::new_inherited(
|
||||||
|
channel,
|
||||||
device,
|
device,
|
||||||
compare_enable,
|
compare_enable,
|
||||||
sampler,
|
sampler,
|
||||||
|
@ -75,3 +82,15 @@ impl GPUSamplerMethods for GPUSampler {
|
||||||
*self.label.borrow_mut() = value;
|
*self.label.borrow_mut() = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPUSampler {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DropSampler(self.sampler.0)))
|
||||||
|
{
|
||||||
|
warn!("Failed to send DropSampler ({:?}) ({})", self.sampler.0, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::WebGPUShaderModule;
|
use webgpu::{WebGPU, WebGPURequest, WebGPUShaderModule};
|
||||||
|
|
||||||
use super::bindings::error::Fallible;
|
use super::bindings::error::Fallible;
|
||||||
use super::promise::Promise;
|
use super::promise::Promise;
|
||||||
|
@ -19,15 +19,19 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUShaderModule {
|
pub struct GPUShaderModule {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||||
|
#[no_trace]
|
||||||
|
channel: WebGPU,
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
shader_module: WebGPUShaderModule,
|
shader_module: WebGPUShaderModule,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GPUShaderModule {
|
impl GPUShaderModule {
|
||||||
fn new_inherited(shader_module: WebGPUShaderModule, label: USVString) -> Self {
|
fn new_inherited(channel: WebGPU, shader_module: WebGPUShaderModule, label: USVString) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
channel,
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
shader_module,
|
shader_module,
|
||||||
}
|
}
|
||||||
|
@ -35,11 +39,16 @@ impl GPUShaderModule {
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
|
channel: WebGPU,
|
||||||
shader_module: WebGPUShaderModule,
|
shader_module: WebGPUShaderModule,
|
||||||
label: USVString,
|
label: USVString,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUShaderModule::new_inherited(shader_module, label)),
|
Box::new(GPUShaderModule::new_inherited(
|
||||||
|
channel,
|
||||||
|
shader_module,
|
||||||
|
label,
|
||||||
|
)),
|
||||||
global,
|
global,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -67,3 +76,18 @@ impl GPUShaderModuleMethods for GPUShaderModule {
|
||||||
todo!("Missing in wgpu: https://github.com/gfx-rs/wgpu/issues/2170")
|
todo!("Missing in wgpu: https://github.com/gfx-rs/wgpu/issues/2170")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPUShaderModule {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DropShaderModule(self.shader_module.0)))
|
||||||
|
{
|
||||||
|
warn!(
|
||||||
|
"Failed to send DropShaderModule ({:?}) ({})",
|
||||||
|
self.shader_module.0, e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -109,7 +109,19 @@ impl GPUTexture {
|
||||||
|
|
||||||
impl Drop for GPUTexture {
|
impl Drop for GPUTexture {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.Destroy()
|
if self.destroyed.get() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DropTexture(self.texture.0)))
|
||||||
|
{
|
||||||
|
warn!(
|
||||||
|
"Failed to send WebGPURequest::DropTexture({:?}) ({})",
|
||||||
|
self.texture.0, e
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +198,7 @@ impl GPUTextureMethods for GPUTexture {
|
||||||
|
|
||||||
GPUTextureView::new(
|
GPUTextureView::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
self.channel.clone(),
|
||||||
texture_view,
|
texture_view,
|
||||||
self,
|
self,
|
||||||
descriptor.parent.label.clone().unwrap_or_default(),
|
descriptor.parent.label.clone().unwrap_or_default(),
|
||||||
|
@ -197,11 +210,13 @@ impl GPUTextureMethods for GPUTexture {
|
||||||
if self.destroyed.get() {
|
if self.destroyed.get() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Err(e) = self
|
if let Err(e) = self.channel.0.send((
|
||||||
.channel
|
None,
|
||||||
.0
|
WebGPURequest::DestroyTexture {
|
||||||
.send((None, WebGPURequest::DestroyTexture(self.texture.0)))
|
device_id: self.device.id().0,
|
||||||
{
|
texture_id: self.texture.0,
|
||||||
|
},
|
||||||
|
)) {
|
||||||
warn!(
|
warn!(
|
||||||
"Failed to send WebGPURequest::DestroyTexture({:?}) ({})",
|
"Failed to send WebGPURequest::DestroyTexture({:?}) ({})",
|
||||||
self.texture.0, e
|
self.texture.0, e
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use webgpu::WebGPUTextureView;
|
use webgpu::{WebGPU, WebGPURequest, WebGPUTextureView};
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUTextureViewMethods;
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUTextureViewMethods;
|
||||||
|
@ -16,6 +16,9 @@ use crate::dom::gputexture::GPUTexture;
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GPUTextureView {
|
pub struct GPUTextureView {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||||
|
#[no_trace]
|
||||||
|
channel: WebGPU,
|
||||||
label: DomRefCell<USVString>,
|
label: DomRefCell<USVString>,
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
texture_view: WebGPUTextureView,
|
texture_view: WebGPUTextureView,
|
||||||
|
@ -24,12 +27,14 @@ pub struct GPUTextureView {
|
||||||
|
|
||||||
impl GPUTextureView {
|
impl GPUTextureView {
|
||||||
fn new_inherited(
|
fn new_inherited(
|
||||||
|
channel: WebGPU,
|
||||||
texture_view: WebGPUTextureView,
|
texture_view: WebGPUTextureView,
|
||||||
texture: &GPUTexture,
|
texture: &GPUTexture,
|
||||||
label: USVString,
|
label: USVString,
|
||||||
) -> GPUTextureView {
|
) -> GPUTextureView {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
channel,
|
||||||
texture: Dom::from_ref(texture),
|
texture: Dom::from_ref(texture),
|
||||||
label: DomRefCell::new(label),
|
label: DomRefCell::new(label),
|
||||||
texture_view,
|
texture_view,
|
||||||
|
@ -38,12 +43,18 @@ impl GPUTextureView {
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
|
channel: WebGPU,
|
||||||
texture_view: WebGPUTextureView,
|
texture_view: WebGPUTextureView,
|
||||||
texture: &GPUTexture,
|
texture: &GPUTexture,
|
||||||
label: USVString,
|
label: USVString,
|
||||||
) -> DomRoot<GPUTextureView> {
|
) -> DomRoot<GPUTextureView> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUTextureView::new_inherited(texture_view, texture, label)),
|
Box::new(GPUTextureView::new_inherited(
|
||||||
|
channel,
|
||||||
|
texture_view,
|
||||||
|
texture,
|
||||||
|
label,
|
||||||
|
)),
|
||||||
global,
|
global,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -66,3 +77,18 @@ impl GPUTextureViewMethods for GPUTextureView {
|
||||||
*self.label.borrow_mut() = value;
|
*self.label.borrow_mut() = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for GPUTextureView {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Err(e) = self
|
||||||
|
.channel
|
||||||
|
.0
|
||||||
|
.send((None, WebGPURequest::DropTextureView(self.texture_view.0)))
|
||||||
|
{
|
||||||
|
warn!(
|
||||||
|
"Failed to send DropTextureView ({:?}) ({})",
|
||||||
|
self.texture_view.0, e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
use webgpu::wgpu::id::markers::{
|
||||||
|
Adapter, BindGroup, BindGroupLayout, Buffer, CommandEncoder, ComputePipeline, Device,
|
||||||
|
PipelineLayout, RenderBundle, RenderPipeline, Sampler, ShaderModule, Texture, TextureView,
|
||||||
|
};
|
||||||
use webgpu::wgpu::id::{
|
use webgpu::wgpu::id::{
|
||||||
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandEncoderId, ComputePipelineId,
|
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandEncoderId, ComputePipelineId,
|
||||||
DeviceId, PipelineLayoutId, RenderBundleId, RenderPipelineId, SamplerId, ShaderModuleId,
|
DeviceId, PipelineLayoutId, RenderBundleId, RenderPipelineId, SamplerId, ShaderModuleId,
|
||||||
|
@ -11,47 +15,75 @@ use webgpu::wgpu::id::{
|
||||||
use webgpu::wgpu::identity::IdentityManager;
|
use webgpu::wgpu::identity::IdentityManager;
|
||||||
use webgpu::wgt::Backend;
|
use webgpu::wgt::Backend;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug)]
|
||||||
pub struct IdentityHub {
|
pub struct IdentityHub {
|
||||||
adapters: IdentityManager,
|
adapters: IdentityManager<Adapter>,
|
||||||
devices: IdentityManager,
|
devices: IdentityManager<Device>,
|
||||||
buffers: IdentityManager,
|
buffers: IdentityManager<Buffer>,
|
||||||
bind_groups: IdentityManager,
|
bind_groups: IdentityManager<BindGroup>,
|
||||||
bind_group_layouts: IdentityManager,
|
bind_group_layouts: IdentityManager<BindGroupLayout>,
|
||||||
compute_pipelines: IdentityManager,
|
compute_pipelines: IdentityManager<ComputePipeline>,
|
||||||
pipeline_layouts: IdentityManager,
|
pipeline_layouts: IdentityManager<PipelineLayout>,
|
||||||
shader_modules: IdentityManager,
|
shader_modules: IdentityManager<ShaderModule>,
|
||||||
command_encoders: IdentityManager,
|
command_encoders: IdentityManager<CommandEncoder>,
|
||||||
textures: IdentityManager,
|
textures: IdentityManager<Texture>,
|
||||||
texture_views: IdentityManager,
|
texture_views: IdentityManager<TextureView>,
|
||||||
samplers: IdentityManager,
|
samplers: IdentityManager<Sampler>,
|
||||||
render_pipelines: IdentityManager,
|
render_pipelines: IdentityManager<RenderPipeline>,
|
||||||
render_bundles: IdentityManager,
|
render_bundles: IdentityManager<RenderBundle>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
impl IdentityHub {
|
||||||
|
fn new() -> Self {
|
||||||
|
IdentityHub {
|
||||||
|
adapters: IdentityManager::new(),
|
||||||
|
devices: IdentityManager::new(),
|
||||||
|
buffers: IdentityManager::new(),
|
||||||
|
bind_groups: IdentityManager::new(),
|
||||||
|
bind_group_layouts: IdentityManager::new(),
|
||||||
|
compute_pipelines: IdentityManager::new(),
|
||||||
|
pipeline_layouts: IdentityManager::new(),
|
||||||
|
shader_modules: IdentityManager::new(),
|
||||||
|
command_encoders: IdentityManager::new(),
|
||||||
|
textures: IdentityManager::new(),
|
||||||
|
texture_views: IdentityManager::new(),
|
||||||
|
samplers: IdentityManager::new(),
|
||||||
|
render_pipelines: IdentityManager::new(),
|
||||||
|
render_bundles: IdentityManager::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Identities {
|
pub struct Identities {
|
||||||
_surface: IdentityManager,
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||||
vk_hub: IdentityHub,
|
vk_hub: IdentityHub,
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
dx12_hub: IdentityHub,
|
dx12_hub: IdentityHub,
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
dx11_hub: IdentityHub,
|
|
||||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||||
metal_hub: IdentityHub,
|
metal_hub: IdentityHub,
|
||||||
dummy_hub: IdentityHub,
|
dummy_hub: IdentityHub,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Identities {
|
impl Identities {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Identities {
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||||
|
vk_hub: IdentityHub::new(),
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
dx12_hub: IdentityHub::new(),
|
||||||
|
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||||
|
metal_hub: IdentityHub::new(),
|
||||||
|
dummy_hub: IdentityHub::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn select(&mut self, backend: Backend) -> &mut IdentityHub {
|
fn select(&mut self, backend: Backend) -> &mut IdentityHub {
|
||||||
match backend {
|
match backend {
|
||||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||||
Backend::Vulkan => &mut self.vk_hub,
|
Backend::Vulkan => &mut self.vk_hub,
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
Backend::Dx12 => &mut self.dx12_hub,
|
Backend::Dx12 => &mut self.dx12_hub,
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
Backend::Dx11 => &mut self.dx11_hub,
|
|
||||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||||
Backend::Metal => &mut self.metal_hub,
|
Backend::Metal => &mut self.metal_hub,
|
||||||
_ => &mut self.dummy_hub,
|
_ => &mut self.dummy_hub,
|
||||||
|
@ -64,8 +96,6 @@ impl Identities {
|
||||||
(&mut self.vk_hub, Backend::Vulkan),
|
(&mut self.vk_hub, Backend::Vulkan),
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
(&mut self.dx12_hub, Backend::Dx12),
|
(&mut self.dx12_hub, Backend::Dx12),
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
(&mut self.dx11_hub, Backend::Dx11),
|
|
||||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||||
(&mut self.metal_hub, Backend::Metal),
|
(&mut self.metal_hub, Backend::Metal),
|
||||||
(&mut self.dummy_hub, Backend::Empty),
|
(&mut self.dummy_hub, Backend::Empty),
|
||||||
|
@ -73,7 +103,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_device_id(&mut self, backend: Backend) -> DeviceId {
|
pub fn create_device_id(&mut self, backend: Backend) -> DeviceId {
|
||||||
self.select(backend).devices.alloc(backend)
|
self.select(backend).devices.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_device_id(&mut self, id: DeviceId) {
|
pub fn kill_device_id(&mut self, id: DeviceId) {
|
||||||
|
@ -83,7 +113,7 @@ impl Identities {
|
||||||
pub fn create_adapter_ids(&mut self) -> SmallVec<[AdapterId; 4]> {
|
pub fn create_adapter_ids(&mut self) -> SmallVec<[AdapterId; 4]> {
|
||||||
let mut ids = SmallVec::new();
|
let mut ids = SmallVec::new();
|
||||||
for hubs in self.hubs() {
|
for hubs in self.hubs() {
|
||||||
ids.push(hubs.0.adapters.alloc(hubs.1));
|
ids.push(hubs.0.adapters.process(hubs.1));
|
||||||
}
|
}
|
||||||
ids
|
ids
|
||||||
}
|
}
|
||||||
|
@ -93,7 +123,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_buffer_id(&mut self, backend: Backend) -> BufferId {
|
pub fn create_buffer_id(&mut self, backend: Backend) -> BufferId {
|
||||||
self.select(backend).buffers.alloc(backend)
|
self.select(backend).buffers.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_buffer_id(&mut self, id: BufferId) {
|
pub fn kill_buffer_id(&mut self, id: BufferId) {
|
||||||
|
@ -101,7 +131,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_bind_group_id(&mut self, backend: Backend) -> BindGroupId {
|
pub fn create_bind_group_id(&mut self, backend: Backend) -> BindGroupId {
|
||||||
self.select(backend).bind_groups.alloc(backend)
|
self.select(backend).bind_groups.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_bind_group_id(&mut self, id: BindGroupId) {
|
pub fn kill_bind_group_id(&mut self, id: BindGroupId) {
|
||||||
|
@ -109,7 +139,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_bind_group_layout_id(&mut self, backend: Backend) -> BindGroupLayoutId {
|
pub fn create_bind_group_layout_id(&mut self, backend: Backend) -> BindGroupLayoutId {
|
||||||
self.select(backend).bind_group_layouts.alloc(backend)
|
self.select(backend).bind_group_layouts.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_bind_group_layout_id(&mut self, id: BindGroupLayoutId) {
|
pub fn kill_bind_group_layout_id(&mut self, id: BindGroupLayoutId) {
|
||||||
|
@ -117,7 +147,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_compute_pipeline_id(&mut self, backend: Backend) -> ComputePipelineId {
|
pub fn create_compute_pipeline_id(&mut self, backend: Backend) -> ComputePipelineId {
|
||||||
self.select(backend).compute_pipelines.alloc(backend)
|
self.select(backend).compute_pipelines.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_compute_pipeline_id(&mut self, id: ComputePipelineId) {
|
pub fn kill_compute_pipeline_id(&mut self, id: ComputePipelineId) {
|
||||||
|
@ -125,7 +155,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_pipeline_layout_id(&mut self, backend: Backend) -> PipelineLayoutId {
|
pub fn create_pipeline_layout_id(&mut self, backend: Backend) -> PipelineLayoutId {
|
||||||
self.select(backend).pipeline_layouts.alloc(backend)
|
self.select(backend).pipeline_layouts.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_pipeline_layout_id(&mut self, id: PipelineLayoutId) {
|
pub fn kill_pipeline_layout_id(&mut self, id: PipelineLayoutId) {
|
||||||
|
@ -133,7 +163,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_shader_module_id(&mut self, backend: Backend) -> ShaderModuleId {
|
pub fn create_shader_module_id(&mut self, backend: Backend) -> ShaderModuleId {
|
||||||
self.select(backend).shader_modules.alloc(backend)
|
self.select(backend).shader_modules.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_shader_module_id(&mut self, id: ShaderModuleId) {
|
pub fn kill_shader_module_id(&mut self, id: ShaderModuleId) {
|
||||||
|
@ -141,7 +171,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_command_encoder_id(&mut self, backend: Backend) -> CommandEncoderId {
|
pub fn create_command_encoder_id(&mut self, backend: Backend) -> CommandEncoderId {
|
||||||
self.select(backend).command_encoders.alloc(backend)
|
self.select(backend).command_encoders.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_command_buffer_id(&mut self, id: CommandEncoderId) {
|
pub fn kill_command_buffer_id(&mut self, id: CommandEncoderId) {
|
||||||
|
@ -149,7 +179,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_sampler_id(&mut self, backend: Backend) -> SamplerId {
|
pub fn create_sampler_id(&mut self, backend: Backend) -> SamplerId {
|
||||||
self.select(backend).samplers.alloc(backend)
|
self.select(backend).samplers.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_sampler_id(&mut self, id: SamplerId) {
|
pub fn kill_sampler_id(&mut self, id: SamplerId) {
|
||||||
|
@ -157,7 +187,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_render_pipeline_id(&mut self, backend: Backend) -> RenderPipelineId {
|
pub fn create_render_pipeline_id(&mut self, backend: Backend) -> RenderPipelineId {
|
||||||
self.select(backend).render_pipelines.alloc(backend)
|
self.select(backend).render_pipelines.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_render_pipeline_id(&mut self, id: RenderPipelineId) {
|
pub fn kill_render_pipeline_id(&mut self, id: RenderPipelineId) {
|
||||||
|
@ -165,7 +195,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_texture_id(&mut self, backend: Backend) -> TextureId {
|
pub fn create_texture_id(&mut self, backend: Backend) -> TextureId {
|
||||||
self.select(backend).textures.alloc(backend)
|
self.select(backend).textures.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_texture_id(&mut self, id: TextureId) {
|
pub fn kill_texture_id(&mut self, id: TextureId) {
|
||||||
|
@ -173,7 +203,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_texture_view_id(&mut self, backend: Backend) -> TextureViewId {
|
pub fn create_texture_view_id(&mut self, backend: Backend) -> TextureViewId {
|
||||||
self.select(backend).texture_views.alloc(backend)
|
self.select(backend).texture_views.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_texture_view_id(&mut self, id: TextureViewId) {
|
pub fn kill_texture_view_id(&mut self, id: TextureViewId) {
|
||||||
|
@ -181,7 +211,7 @@ impl Identities {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_render_bundle_id(&mut self, backend: Backend) -> RenderBundleId {
|
pub fn create_render_bundle_id(&mut self, backend: Backend) -> RenderBundleId {
|
||||||
self.select(backend).render_bundles.alloc(backend)
|
self.select(backend).render_bundles.process(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kill_render_bundle_id(&mut self, id: RenderBundleId) {
|
pub fn kill_render_bundle_id(&mut self, id: RenderBundleId) {
|
||||||
|
|
|
@ -242,7 +242,7 @@ impl ServiceWorkerGlobalScope {
|
||||||
runtime,
|
runtime,
|
||||||
from_devtools_receiver,
|
from_devtools_receiver,
|
||||||
closing,
|
closing,
|
||||||
Arc::new(Mutex::new(Identities::default())),
|
Arc::new(Mutex::new(Identities::new())),
|
||||||
),
|
),
|
||||||
task_queue: TaskQueue::new(receiver, own_sender.clone()),
|
task_queue: TaskQueue::new(receiver, own_sender.clone()),
|
||||||
own_sender,
|
own_sender,
|
||||||
|
|
|
@ -129,7 +129,7 @@ interface GPUDevice: EventTarget {
|
||||||
|
|
||||||
[NewObject, Throws]
|
[NewObject, Throws]
|
||||||
GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
|
GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
|
||||||
[NewObject]
|
[NewObject, Throws]
|
||||||
GPUTexture createTexture(GPUTextureDescriptor descriptor);
|
GPUTexture createTexture(GPUTextureDescriptor descriptor);
|
||||||
[NewObject]
|
[NewObject]
|
||||||
GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
|
GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
|
||||||
|
|
|
@ -1430,7 +1430,7 @@ impl ScriptThread {
|
||||||
|
|
||||||
node_ids: Default::default(),
|
node_ids: Default::default(),
|
||||||
is_user_interacting: Cell::new(false),
|
is_user_interacting: Cell::new(false),
|
||||||
gpu_id_hub: Arc::new(Mutex::new(Identities::default())),
|
gpu_id_hub: Arc::new(Mutex::new(Identities::new())),
|
||||||
webgpu_port: RefCell::new(None),
|
webgpu_port: RefCell::new(None),
|
||||||
inherited_secure_context: state.inherited_secure_context,
|
inherited_secure_context: state.inherited_secure_context,
|
||||||
layouts: Default::default(),
|
layouts: Default::default(),
|
||||||
|
@ -2122,7 +2122,10 @@ impl ScriptThread {
|
||||||
WebGPUMsg::FreeBindGroupLayout(id) => {
|
WebGPUMsg::FreeBindGroupLayout(id) => {
|
||||||
self.gpu_id_hub.lock().kill_bind_group_layout_id(id)
|
self.gpu_id_hub.lock().kill_bind_group_layout_id(id)
|
||||||
},
|
},
|
||||||
WebGPUMsg::FreeCommandBuffer(id) => self.gpu_id_hub.lock().kill_command_buffer_id(id),
|
WebGPUMsg::FreeCommandBuffer(id) => self
|
||||||
|
.gpu_id_hub
|
||||||
|
.lock()
|
||||||
|
.kill_command_buffer_id(id.transmute()),
|
||||||
WebGPUMsg::FreeSampler(id) => self.gpu_id_hub.lock().kill_sampler_id(id),
|
WebGPUMsg::FreeSampler(id) => self.gpu_id_hub.lock().kill_sampler_id(id),
|
||||||
WebGPUMsg::FreeShaderModule(id) => self.gpu_id_hub.lock().kill_shader_module_id(id),
|
WebGPUMsg::FreeShaderModule(id) => self.gpu_id_hub.lock().kill_shader_module_id(id),
|
||||||
WebGPUMsg::FreeRenderBundle(id) => self.gpu_id_hub.lock().kill_render_bundle_id(id),
|
WebGPUMsg::FreeRenderBundle(id) => self.gpu_id_hub.lock().kill_render_bundle_id(id),
|
||||||
|
|
|
@ -23,17 +23,20 @@ smallvec = { workspace = true, features = ["serde"] }
|
||||||
webrender = { workspace = true }
|
webrender = { workspace = true }
|
||||||
webrender_api = { workspace = true }
|
webrender_api = { workspace = true }
|
||||||
webrender_traits = { workspace = true }
|
webrender_traits = { workspace = true }
|
||||||
wgpu-core = { workspace = true, features = ["replay", "trace", "serial-pass", "wgsl"] }
|
wgpu-core = { workspace = true, features = ["replay", "trace", "wgsl"] }
|
||||||
wgpu-types = { workspace = true }
|
wgpu-types = { workspace = true }
|
||||||
|
|
||||||
|
# We want the wgpu-core Metal backend on macOS and iOS.
|
||||||
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies.wgpu-core]
|
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies.wgpu-core]
|
||||||
workspace = true
|
workspace = true
|
||||||
features = ["replay", "trace", "serial-pass", "metal"]
|
features = ["metal"]
|
||||||
|
|
||||||
[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies.wgpu-core]
|
# We want the wgpu-core Vulkan backend on Linux and Windows.
|
||||||
|
[target.'cfg(any(windows, all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies.wgpu-core]
|
||||||
workspace = true
|
workspace = true
|
||||||
features = ["replay", "trace", "serial-pass", "vulkan"]
|
features = ["vulkan"]
|
||||||
|
|
||||||
|
# We want the wgpu-core Direct3D backends on Windows.
|
||||||
[target.'cfg(windows)'.dependencies.wgpu-core]
|
[target.'cfg(windows)'.dependencies.wgpu-core]
|
||||||
workspace = true
|
workspace = true
|
||||||
features = ["replay", "trace", "serial-pass", "dx11", "dx12", "vulkan"]
|
features = ["dx12", "vulkan"]
|
||||||
|
|
|
@ -2,20 +2,15 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use ipc_channel::ipc::IpcSender;
|
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::wgpu::id::{
|
use crate::wgpu::id::{
|
||||||
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, ComputePipelineId,
|
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, ComputePipelineId,
|
||||||
DeviceId, PipelineLayoutId, QuerySetId, RenderBundleId, RenderPipelineId, SamplerId,
|
DeviceId, PipelineLayoutId, QuerySetId, RenderBundleId, RenderPipelineId, SamplerId,
|
||||||
ShaderModuleId, StagingBufferId, SurfaceId, TextureId, TextureViewId, TypedId,
|
ShaderModuleId, StagingBufferId, SurfaceId, TextureId, TextureViewId,
|
||||||
};
|
};
|
||||||
use crate::wgpu::identity::{
|
use crate::{ErrorScopeId, WebGPUDevice};
|
||||||
GlobalIdentityHandlerFactory, IdentityHandler, IdentityHandlerFactory,
|
|
||||||
};
|
|
||||||
use crate::wgt::Backend;
|
|
||||||
use crate::{ErrorScopeId, WebGPUDevice, WebGPURequest};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub enum WebGPUOpResult {
|
pub enum WebGPUOpResult {
|
||||||
|
@ -55,117 +50,3 @@ pub enum WebGPUMsg {
|
||||||
},
|
},
|
||||||
Exit,
|
Exit,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct IdentityRecycler {
|
|
||||||
sender: IpcSender<WebGPUMsg>,
|
|
||||||
self_sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct IdentityRecyclerFactory {
|
|
||||||
pub sender: IpcSender<WebGPUMsg>,
|
|
||||||
pub self_sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! impl_identity_handler {
|
|
||||||
($id:ty, $st:tt, $($var:tt)*) => {
|
|
||||||
impl IdentityHandler<$id> for IdentityRecycler {
|
|
||||||
type Input = $id;
|
|
||||||
fn process(&self, id: $id, _backend: Backend) -> Self::Input {
|
|
||||||
log::debug!("process {} {:?}", $st, id);
|
|
||||||
//debug_assert_eq!(id.unzip().2, backend);
|
|
||||||
id
|
|
||||||
}
|
|
||||||
fn free(&self, id: $id) {
|
|
||||||
log::debug!("free {} {:?}", $st, id);
|
|
||||||
let msg = $($var)*(id);
|
|
||||||
if self.sender.send(msg.clone()).is_err() {
|
|
||||||
log::error!("Failed to send {:?}", msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_identity_handler!(AdapterId, "adapter", WebGPUMsg::FreeAdapter);
|
|
||||||
impl_identity_handler!(SurfaceId, "surface", WebGPUMsg::FreeSurface);
|
|
||||||
impl_identity_handler!(SamplerId, "sampler", WebGPUMsg::FreeSampler);
|
|
||||||
impl_identity_handler!(TextureId, "texture", WebGPUMsg::FreeTexture);
|
|
||||||
impl_identity_handler!(TextureViewId, "texture_view", WebGPUMsg::FreeTextureView);
|
|
||||||
impl_identity_handler!(BufferId, "buffer", WebGPUMsg::FreeBuffer);
|
|
||||||
impl_identity_handler!(BindGroupId, "bind_group", WebGPUMsg::FreeBindGroup);
|
|
||||||
impl_identity_handler!(ShaderModuleId, "shader_module", WebGPUMsg::FreeShaderModule);
|
|
||||||
impl_identity_handler!(RenderBundleId, "render_bundle", WebGPUMsg::FreeRenderBundle);
|
|
||||||
impl_identity_handler!(
|
|
||||||
StagingBufferId,
|
|
||||||
"staging_buffer",
|
|
||||||
WebGPUMsg::FreeStagingBuffer
|
|
||||||
);
|
|
||||||
impl_identity_handler!(QuerySetId, "quary_set", WebGPUMsg::FreeQuerySet);
|
|
||||||
impl_identity_handler!(
|
|
||||||
RenderPipelineId,
|
|
||||||
"render_pipeline",
|
|
||||||
WebGPUMsg::FreeRenderPipeline
|
|
||||||
);
|
|
||||||
impl_identity_handler!(
|
|
||||||
ComputePipelineId,
|
|
||||||
"compute_pipeline",
|
|
||||||
WebGPUMsg::FreeComputePipeline
|
|
||||||
);
|
|
||||||
impl_identity_handler!(
|
|
||||||
CommandBufferId,
|
|
||||||
"command_buffer",
|
|
||||||
WebGPUMsg::FreeCommandBuffer
|
|
||||||
);
|
|
||||||
impl_identity_handler!(
|
|
||||||
BindGroupLayoutId,
|
|
||||||
"bind_group_layout",
|
|
||||||
WebGPUMsg::FreeBindGroupLayout
|
|
||||||
);
|
|
||||||
impl_identity_handler!(
|
|
||||||
PipelineLayoutId,
|
|
||||||
"pipeline_layout",
|
|
||||||
WebGPUMsg::FreePipelineLayout
|
|
||||||
);
|
|
||||||
|
|
||||||
impl IdentityHandler<DeviceId> for IdentityRecycler {
|
|
||||||
type Input = DeviceId;
|
|
||||||
fn process(&self, id: DeviceId, _backend: Backend) -> Self::Input {
|
|
||||||
log::debug!("process device {:?}", id);
|
|
||||||
//debug_assert_eq!(id.unzip().2, backend);
|
|
||||||
id
|
|
||||||
}
|
|
||||||
fn free(&self, id: DeviceId) {
|
|
||||||
log::debug!("free device {:?}", id);
|
|
||||||
if self.sender.send(WebGPUMsg::FreeDevice(id)).is_err() {
|
|
||||||
log::error!("Failed to send FreeDevice({:?}) to script", id);
|
|
||||||
}
|
|
||||||
if self
|
|
||||||
.self_sender
|
|
||||||
.send((None, WebGPURequest::FreeDevice(id)))
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
log::error!("Failed to send FreeDevice({:?}) to server", id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I: TypedId + Clone + std::fmt::Debug> IdentityHandlerFactory<I> for IdentityRecyclerFactory
|
|
||||||
where
|
|
||||||
I: TypedId + Clone + std::fmt::Debug,
|
|
||||||
IdentityRecycler: IdentityHandler<I>,
|
|
||||||
{
|
|
||||||
type Filter = IdentityRecycler;
|
|
||||||
fn spawn(&self) -> Self::Filter {
|
|
||||||
IdentityRecycler {
|
|
||||||
sender: self.sender.clone(),
|
|
||||||
self_sender: self.self_sender.clone(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GlobalIdentityHandlerFactory for IdentityRecyclerFactory {
|
|
||||||
fn ids_are_generated_in_wgpu() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
use euclid::default::Size2D;
|
use euclid::default::Size2D;
|
||||||
use identity::{IdentityRecyclerFactory, WebGPUMsg, WebGPUOpResult};
|
use identity::{WebGPUMsg, WebGPUOpResult};
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender, IpcSharedMemory};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender, IpcSharedMemory};
|
||||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
|
@ -48,7 +48,7 @@ use wgpu::resource::{
|
||||||
BufferDescriptor, BufferMapAsyncStatus, BufferMapCallback, BufferMapCallbackC,
|
BufferDescriptor, BufferMapAsyncStatus, BufferMapCallback, BufferMapCallbackC,
|
||||||
BufferMapOperation, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
|
BufferMapOperation, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
|
||||||
};
|
};
|
||||||
use wgt::{Dx12Compiler, InstanceDescriptor};
|
use wgt::InstanceDescriptor;
|
||||||
|
|
||||||
pub type ErrorScopeId = NonZeroU64;
|
pub type ErrorScopeId = NonZeroU64;
|
||||||
const DEVICE_POLL_INTERVAL: u64 = 100;
|
const DEVICE_POLL_INTERVAL: u64 = 100;
|
||||||
|
@ -190,14 +190,30 @@ pub enum WebGPURequest {
|
||||||
},
|
},
|
||||||
DestroyBuffer(id::BufferId),
|
DestroyBuffer(id::BufferId),
|
||||||
DestroyDevice(id::DeviceId),
|
DestroyDevice(id::DeviceId),
|
||||||
|
DestroyTexture {
|
||||||
|
device_id: id::DeviceId,
|
||||||
|
texture_id: id::TextureId,
|
||||||
|
},
|
||||||
DestroySwapChain {
|
DestroySwapChain {
|
||||||
external_id: u64,
|
external_id: u64,
|
||||||
image_key: ImageKey,
|
image_key: ImageKey,
|
||||||
},
|
},
|
||||||
DestroyTexture(id::TextureId),
|
DropTexture(id::TextureId),
|
||||||
|
DropAdapter(id::AdapterId),
|
||||||
|
DropDevice(id::DeviceId),
|
||||||
|
DropBuffer(id::BufferId),
|
||||||
|
DropPipelineLayout(id::PipelineLayoutId),
|
||||||
|
DropComputePipeline(id::ComputePipelineId),
|
||||||
|
DropRenderPipeline(id::RenderPipelineId),
|
||||||
|
DropBindGroup(id::BindGroupId),
|
||||||
|
DropBindGroupLayout(id::BindGroupLayoutId),
|
||||||
|
DropCommandBuffer(id::CommandBufferId),
|
||||||
|
DropTextureView(id::TextureViewId),
|
||||||
|
DropSampler(id::SamplerId),
|
||||||
|
DropShaderModule(id::ShaderModuleId),
|
||||||
|
DropRenderBundle(id::RenderBundleId),
|
||||||
|
DropQuerySet(id::QuerySetId),
|
||||||
Exit(IpcSender<()>),
|
Exit(IpcSender<()>),
|
||||||
FreeCommandBuffer(id::CommandBufferId),
|
|
||||||
FreeDevice(id::DeviceId),
|
|
||||||
RenderBundleEncoderFinish {
|
RenderBundleEncoderFinish {
|
||||||
render_bundle_encoder: RenderBundleEncoder,
|
render_bundle_encoder: RenderBundleEncoder,
|
||||||
descriptor: RenderBundleDescriptor<'static>,
|
descriptor: RenderBundleDescriptor<'static>,
|
||||||
|
@ -268,7 +284,7 @@ pub enum WebGPURequest {
|
||||||
struct BufferMapInfo<'a, T> {
|
struct BufferMapInfo<'a, T> {
|
||||||
buffer_id: id::BufferId,
|
buffer_id: id::BufferId,
|
||||||
sender: IpcSender<T>,
|
sender: IpcSender<T>,
|
||||||
global: &'a wgpu::global::Global<IdentityRecyclerFactory>,
|
global: &'a wgpu::global::Global,
|
||||||
size: usize,
|
size: usize,
|
||||||
external_id: Option<u64>,
|
external_id: Option<u64>,
|
||||||
}
|
}
|
||||||
|
@ -347,7 +363,7 @@ struct WGPU<'a> {
|
||||||
receiver: IpcReceiver<(Option<ErrorScopeId>, WebGPURequest)>,
|
receiver: IpcReceiver<(Option<ErrorScopeId>, WebGPURequest)>,
|
||||||
sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
|
sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
|
||||||
script_sender: IpcSender<WebGPUMsg>,
|
script_sender: IpcSender<WebGPUMsg>,
|
||||||
global: wgpu::global::Global<IdentityRecyclerFactory>,
|
global: wgpu::global::Global,
|
||||||
adapters: Vec<WebGPUAdapter>,
|
adapters: Vec<WebGPUAdapter>,
|
||||||
devices: HashMap<WebGPUDevice, PipelineId>,
|
devices: HashMap<WebGPUDevice, PipelineId>,
|
||||||
// Track invalid adapters https://gpuweb.github.io/gpuweb/#invalid
|
// Track invalid adapters https://gpuweb.github.io/gpuweb/#invalid
|
||||||
|
@ -375,20 +391,14 @@ impl<'a> WGPU<'a> {
|
||||||
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
|
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
|
||||||
wgpu_image_map: Arc<Mutex<HashMap<u64, PresentationData>>>,
|
wgpu_image_map: Arc<Mutex<HashMap<u64, PresentationData>>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let factory = IdentityRecyclerFactory {
|
|
||||||
sender: script_sender.clone(),
|
|
||||||
self_sender: sender.clone(),
|
|
||||||
};
|
|
||||||
WGPU {
|
WGPU {
|
||||||
receiver,
|
receiver,
|
||||||
sender,
|
sender,
|
||||||
script_sender,
|
script_sender,
|
||||||
global: wgpu::global::Global::new(
|
global: wgpu::global::Global::new(
|
||||||
"wgpu-core",
|
"wgpu-core",
|
||||||
factory,
|
|
||||||
InstanceDescriptor {
|
InstanceDescriptor {
|
||||||
backends: wgt::Backends::PRIMARY,
|
backends: wgt::Backends::PRIMARY,
|
||||||
dx12_shader_compiler: Dx12Compiler::default(),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -462,12 +472,12 @@ impl<'a> WGPU<'a> {
|
||||||
let operation = BufferMapOperation {
|
let operation = BufferMapOperation {
|
||||||
host: host_map,
|
host: host_map,
|
||||||
callback: unsafe {
|
callback: unsafe {
|
||||||
BufferMapCallback::from_c(BufferMapCallbackC {
|
Some(BufferMapCallback::from_c(BufferMapCallbackC {
|
||||||
callback,
|
callback,
|
||||||
user_data: convert_to_pointer(
|
user_data: convert_to_pointer(
|
||||||
self.buffer_maps.get(&buffer_id).unwrap().clone(),
|
self.buffer_maps.get(&buffer_id).unwrap().clone(),
|
||||||
),
|
),
|
||||||
})
|
}))
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
|
@ -579,7 +589,7 @@ impl<'a> WGPU<'a> {
|
||||||
} => {
|
} => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let result = tuple_to_result(gfx_select!(bind_group_id =>
|
let result = tuple_to_result(gfx_select!(bind_group_id =>
|
||||||
global.device_create_bind_group(device_id, &descriptor, bind_group_id)));
|
global.device_create_bind_group(device_id, &descriptor, Some(bind_group_id))));
|
||||||
self.send_result(device_id, scope_id, result);
|
self.send_result(device_id, scope_id, result);
|
||||||
},
|
},
|
||||||
WebGPURequest::CreateBindGroupLayout {
|
WebGPURequest::CreateBindGroupLayout {
|
||||||
|
@ -590,7 +600,7 @@ impl<'a> WGPU<'a> {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
if let Some(desc) = descriptor {
|
if let Some(desc) = descriptor {
|
||||||
let result = tuple_to_result(gfx_select!(bind_group_layout_id =>
|
let result = tuple_to_result(gfx_select!(bind_group_layout_id =>
|
||||||
global.device_create_bind_group_layout(device_id, &desc, bind_group_layout_id)));
|
global.device_create_bind_group_layout(device_id, &desc, Some(bind_group_layout_id))));
|
||||||
|
|
||||||
self.send_result(device_id, scope_id, result);
|
self.send_result(device_id, scope_id, result);
|
||||||
}
|
}
|
||||||
|
@ -603,7 +613,7 @@ impl<'a> WGPU<'a> {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
if let Some(desc) = descriptor {
|
if let Some(desc) = descriptor {
|
||||||
let result = tuple_to_result(gfx_select!(buffer_id =>
|
let result = tuple_to_result(gfx_select!(buffer_id =>
|
||||||
global.device_create_buffer(device_id, &desc, buffer_id)));
|
global.device_create_buffer(device_id, &desc, Some(buffer_id))));
|
||||||
|
|
||||||
self.send_result(device_id, scope_id, result);
|
self.send_result(device_id, scope_id, result);
|
||||||
}
|
}
|
||||||
|
@ -616,7 +626,7 @@ impl<'a> WGPU<'a> {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let desc = wgt::CommandEncoderDescriptor { label };
|
let desc = wgt::CommandEncoderDescriptor { label };
|
||||||
let result = tuple_to_result(gfx_select!(command_encoder_id =>
|
let result = tuple_to_result(gfx_select!(command_encoder_id =>
|
||||||
global.device_create_command_encoder(device_id, &desc, command_encoder_id)));
|
global.device_create_command_encoder(device_id, &desc, Some(command_encoder_id))));
|
||||||
|
|
||||||
self.send_result(device_id, scope_id, result);
|
self.send_result(device_id, scope_id, result);
|
||||||
},
|
},
|
||||||
|
@ -629,19 +639,21 @@ impl<'a> WGPU<'a> {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let bgls = implicit_ids
|
let bgls = implicit_ids
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(Vec::with_capacity(0), |(_, bgls)| bgls.clone());
|
.map_or(Vec::with_capacity(0), |(_, bgls)| {
|
||||||
|
bgls.iter().map(|x| Some(x.to_owned())).collect()
|
||||||
|
});
|
||||||
let implicit =
|
let implicit =
|
||||||
implicit_ids
|
implicit_ids
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|(layout, _)| ImplicitPipelineIds {
|
.map(|(layout, _)| ImplicitPipelineIds {
|
||||||
root_id: *layout,
|
root_id: Some(*layout),
|
||||||
group_ids: bgls.as_slice(),
|
group_ids: bgls.as_slice(),
|
||||||
});
|
});
|
||||||
let result = tuple_to_result(
|
let result = tuple_to_result(
|
||||||
gfx_select!(compute_pipeline_id => global.device_create_compute_pipeline(
|
gfx_select!(compute_pipeline_id => global.device_create_compute_pipeline(
|
||||||
device_id,
|
device_id,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
compute_pipeline_id,
|
Some(compute_pipeline_id),
|
||||||
implicit
|
implicit
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
@ -664,7 +676,7 @@ impl<'a> WGPU<'a> {
|
||||||
} => {
|
} => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let result = tuple_to_result(gfx_select!(pipeline_layout_id =>
|
let result = tuple_to_result(gfx_select!(pipeline_layout_id =>
|
||||||
global.device_create_pipeline_layout(device_id, &descriptor, pipeline_layout_id)));
|
global.device_create_pipeline_layout(device_id, &descriptor, Some(pipeline_layout_id))));
|
||||||
self.send_result(device_id, scope_id, result);
|
self.send_result(device_id, scope_id, result);
|
||||||
},
|
},
|
||||||
WebGPURequest::CreateRenderPipeline {
|
WebGPURequest::CreateRenderPipeline {
|
||||||
|
@ -676,17 +688,24 @@ impl<'a> WGPU<'a> {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let bgls = implicit_ids
|
let bgls = implicit_ids
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(Vec::with_capacity(0), |(_, bgls)| bgls.clone());
|
.map_or(Vec::with_capacity(0), |(_, bgls)| {
|
||||||
|
bgls.iter().map(|x| Some(x.to_owned())).collect()
|
||||||
|
});
|
||||||
let implicit =
|
let implicit =
|
||||||
implicit_ids
|
implicit_ids
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|(layout, _)| ImplicitPipelineIds {
|
.map(|(layout, _)| ImplicitPipelineIds {
|
||||||
root_id: *layout,
|
root_id: Some(*layout),
|
||||||
group_ids: bgls.as_slice(),
|
group_ids: bgls.as_slice(),
|
||||||
});
|
});
|
||||||
if let Some(desc) = descriptor {
|
if let Some(desc) = descriptor {
|
||||||
let result = tuple_to_result(gfx_select!(render_pipeline_id =>
|
let result = tuple_to_result(gfx_select!(render_pipeline_id =>
|
||||||
global.device_create_render_pipeline(device_id, &desc, render_pipeline_id, implicit)));
|
global.device_create_render_pipeline(
|
||||||
|
device_id,
|
||||||
|
&desc,
|
||||||
|
Some(render_pipeline_id),
|
||||||
|
implicit)
|
||||||
|
));
|
||||||
self.send_result(device_id, scope_id, result);
|
self.send_result(device_id, scope_id, result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -700,7 +719,7 @@ impl<'a> WGPU<'a> {
|
||||||
gfx_select!(sampler_id => global.device_create_sampler(
|
gfx_select!(sampler_id => global.device_create_sampler(
|
||||||
device_id,
|
device_id,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
sampler_id
|
Some(sampler_id)
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
self.send_result(device_id, scope_id, result);
|
self.send_result(device_id, scope_id, result);
|
||||||
|
@ -720,7 +739,7 @@ impl<'a> WGPU<'a> {
|
||||||
shader_bound_checks: wgt::ShaderBoundChecks::default(),
|
shader_bound_checks: wgt::ShaderBoundChecks::default(),
|
||||||
};
|
};
|
||||||
let result = tuple_to_result(gfx_select!(program_id =>
|
let result = tuple_to_result(gfx_select!(program_id =>
|
||||||
global.device_create_shader_module(device_id, &desc, source, program_id)));
|
global.device_create_shader_module(device_id, &desc, source, Some(program_id))));
|
||||||
self.send_result(device_id, scope_id, result);
|
self.send_result(device_id, scope_id, result);
|
||||||
},
|
},
|
||||||
WebGPURequest::CreateSwapChain {
|
WebGPURequest::CreateSwapChain {
|
||||||
|
@ -743,7 +762,7 @@ impl<'a> WGPU<'a> {
|
||||||
external_id,
|
external_id,
|
||||||
PresentationData {
|
PresentationData {
|
||||||
device_id,
|
device_id,
|
||||||
queue_id: device_id,
|
queue_id: device_id.transmute(),
|
||||||
data: vec![255; (buffer_stride * height as u32) as usize],
|
data: vec![255; (buffer_stride * height as u32) as usize],
|
||||||
size: Size2D::new(width, height),
|
size: Size2D::new(width, height),
|
||||||
unassigned_buffer_ids: buffer_ids,
|
unassigned_buffer_ids: buffer_ids,
|
||||||
|
@ -778,7 +797,7 @@ impl<'a> WGPU<'a> {
|
||||||
gfx_select!(texture_id => global.device_create_texture(
|
gfx_select!(texture_id => global.device_create_texture(
|
||||||
device_id,
|
device_id,
|
||||||
&desc,
|
&desc,
|
||||||
texture_id
|
Some(texture_id)
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
self.send_result(device_id, scope_id, result);
|
self.send_result(device_id, scope_id, result);
|
||||||
|
@ -796,7 +815,7 @@ impl<'a> WGPU<'a> {
|
||||||
gfx_select!(texture_view_id => global.texture_create_view(
|
gfx_select!(texture_view_id => global.texture_create_view(
|
||||||
texture_id,
|
texture_id,
|
||||||
&desc,
|
&desc,
|
||||||
texture_view_id
|
Some(texture_view_id)
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -805,11 +824,11 @@ impl<'a> WGPU<'a> {
|
||||||
},
|
},
|
||||||
WebGPURequest::DestroyBuffer(buffer) => {
|
WebGPURequest::DestroyBuffer(buffer) => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
gfx_select!(buffer => global.buffer_drop(buffer, false));
|
let _result = gfx_select!(buffer => global.buffer_destroy(buffer));
|
||||||
},
|
},
|
||||||
WebGPURequest::DestroyDevice(device) => {
|
WebGPURequest::DestroyDevice(device) => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
gfx_select!(device => global.device_drop(device));
|
gfx_select!(device => global.device_destroy(device));
|
||||||
},
|
},
|
||||||
WebGPURequest::DestroySwapChain {
|
WebGPURequest::DestroySwapChain {
|
||||||
external_id,
|
external_id,
|
||||||
|
@ -838,9 +857,13 @@ impl<'a> WGPU<'a> {
|
||||||
self.webrender_api
|
self.webrender_api
|
||||||
.send_transaction(self.webrender_document, txn);
|
.send_transaction(self.webrender_document, txn);
|
||||||
},
|
},
|
||||||
WebGPURequest::DestroyTexture(texture) => {
|
WebGPURequest::DestroyTexture {
|
||||||
|
device_id,
|
||||||
|
texture_id,
|
||||||
|
} => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
gfx_select!(texture => global.texture_drop(texture, true));
|
let result = gfx_select!(texture_id => global.texture_destroy(texture_id));
|
||||||
|
self.send_result(device_id, scope_id, result);
|
||||||
},
|
},
|
||||||
WebGPURequest::Exit(sender) => {
|
WebGPURequest::Exit(sender) => {
|
||||||
if let Err(e) = sender.send(()) {
|
if let Err(e) = sender.send(()) {
|
||||||
|
@ -848,12 +871,17 @@ impl<'a> WGPU<'a> {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
},
|
},
|
||||||
WebGPURequest::FreeCommandBuffer(command_buffer_id) => {
|
WebGPURequest::DropCommandBuffer(id) => {
|
||||||
self.error_command_encoders
|
self.error_command_encoders
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.remove(&command_buffer_id);
|
.remove(&id.transmute());
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.command_buffer_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeCommandBuffer(id)) {
|
||||||
|
warn!("Unable to send FreeCommandBuffer({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
},
|
},
|
||||||
WebGPURequest::FreeDevice(device_id) => {
|
WebGPURequest::DropDevice(device_id) => {
|
||||||
let device = WebGPUDevice(device_id);
|
let device = WebGPUDevice(device_id);
|
||||||
let pipeline_id = self.devices.remove(&device).unwrap();
|
let pipeline_id = self.devices.remove(&device).unwrap();
|
||||||
if let Err(e) = self.script_sender.send(WebGPUMsg::CleanDevice {
|
if let Err(e) = self.script_sender.send(WebGPUMsg::CleanDevice {
|
||||||
|
@ -862,6 +890,11 @@ impl<'a> WGPU<'a> {
|
||||||
}) {
|
}) {
|
||||||
warn!("Unable to send CleanDevice({:?}) ({:?})", device_id, e);
|
warn!("Unable to send CleanDevice({:?}) ({:?})", device_id, e);
|
||||||
}
|
}
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(device_id => global.device_drop(device_id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeDevice(device_id)) {
|
||||||
|
warn!("Unable to send FreeDevice({:?}) ({:?})", device_id, e);
|
||||||
|
};
|
||||||
},
|
},
|
||||||
WebGPURequest::RenderBundleEncoderFinish {
|
WebGPURequest::RenderBundleEncoderFinish {
|
||||||
render_bundle_encoder,
|
render_bundle_encoder,
|
||||||
|
@ -874,7 +907,7 @@ impl<'a> WGPU<'a> {
|
||||||
gfx_select!(render_bundle_id => global.render_bundle_encoder_finish(
|
gfx_select!(render_bundle_id => global.render_bundle_encoder_finish(
|
||||||
render_bundle_encoder,
|
render_bundle_encoder,
|
||||||
&descriptor,
|
&descriptor,
|
||||||
render_bundle_id
|
Some(render_bundle_id)
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -885,10 +918,10 @@ impl<'a> WGPU<'a> {
|
||||||
options,
|
options,
|
||||||
ids,
|
ids,
|
||||||
} => {
|
} => {
|
||||||
let adapter_id = match self.global.request_adapter(
|
let adapter_id = match self
|
||||||
&options,
|
.global
|
||||||
wgpu::instance::AdapterInputs::IdSet(&ids, |id| id.backend()),
|
.request_adapter(&options, wgpu::instance::AdapterInputs::IdSet(&ids))
|
||||||
) {
|
{
|
||||||
Ok(id) => id,
|
Ok(id) => id,
|
||||||
Err(w) => {
|
Err(w) => {
|
||||||
if let Err(e) = sender.send(Some(Err(format!("{:?}", w)))) {
|
if let Err(e) = sender.send(Some(Err(format!("{:?}", w)))) {
|
||||||
|
@ -932,20 +965,18 @@ impl<'a> WGPU<'a> {
|
||||||
} => {
|
} => {
|
||||||
let desc = DeviceDescriptor {
|
let desc = DeviceDescriptor {
|
||||||
label: descriptor.label.as_ref().map(crate::Cow::from),
|
label: descriptor.label.as_ref().map(crate::Cow::from),
|
||||||
features: descriptor.features,
|
required_features: descriptor.required_features,
|
||||||
limits: descriptor.limits.clone(),
|
required_limits: descriptor.required_limits.clone(),
|
||||||
};
|
};
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let id = match tuple_to_result(
|
let (device_id, queue_id) = match gfx_select!(device_id => global.adapter_request_device(
|
||||||
gfx_select!(device_id => global.adapter_request_device(
|
|
||||||
adapter_id.0,
|
adapter_id.0,
|
||||||
&desc,
|
&desc,
|
||||||
None,
|
None,
|
||||||
device_id
|
Some(device_id),
|
||||||
)),
|
Some(device_id.transmute()),
|
||||||
) {
|
)) {
|
||||||
Ok(id) => id,
|
(_, _, Some(e)) => {
|
||||||
Err(e) => {
|
|
||||||
if let Err(w) = sender.send(Some(Err(format!("{:?}", e)))) {
|
if let Err(w) = sender.send(Some(Err(format!("{:?}", e)))) {
|
||||||
warn!(
|
warn!(
|
||||||
"Failed to send response to WebGPURequest::RequestDevice ({})",
|
"Failed to send response to WebGPURequest::RequestDevice ({})",
|
||||||
|
@ -954,11 +985,10 @@ impl<'a> WGPU<'a> {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
},
|
},
|
||||||
|
(device_id, queue_id, None) => (device_id, queue_id),
|
||||||
};
|
};
|
||||||
let device = WebGPUDevice(id);
|
let device = WebGPUDevice(device_id);
|
||||||
// Note: (zakorgy) Note sure if sending the queue is needed at all,
|
let queue = WebGPUQueue(queue_id);
|
||||||
// since wgpu-core uses the same id for the device and the queue
|
|
||||||
let queue = WebGPUQueue(id);
|
|
||||||
self.devices.insert(device, pipeline_id);
|
self.devices.insert(device, pipeline_id);
|
||||||
if let Err(e) = sender.send(Some(Ok(WebGPUResponse::RequestDevice {
|
if let Err(e) = sender.send(Some(Ok(WebGPUResponse::RequestDevice {
|
||||||
device_id: device,
|
device_id: device,
|
||||||
|
@ -1006,16 +1036,18 @@ impl<'a> WGPU<'a> {
|
||||||
command_buffers,
|
command_buffers,
|
||||||
} => {
|
} => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let cmd_id = command_buffers
|
let cmd_id = command_buffers.iter().find(|id| {
|
||||||
.iter()
|
self.error_command_encoders
|
||||||
.find(|id| self.error_command_encoders.borrow().contains_key(id));
|
.borrow()
|
||||||
|
.contains_key(&id.transmute())
|
||||||
|
});
|
||||||
let result = if cmd_id.is_some() {
|
let result = if cmd_id.is_some() {
|
||||||
Err(String::from("Invalid command buffer submitted"))
|
Err(String::from("Invalid command buffer submitted"))
|
||||||
} else {
|
} else {
|
||||||
gfx_select!(queue_id => global.queue_submit(queue_id, &command_buffers))
|
gfx_select!(queue_id => global.queue_submit(queue_id, &command_buffers))
|
||||||
.map_err(|e| format!("{:?}", e))
|
.map_err(|e| format!("{:?}", e))
|
||||||
};
|
};
|
||||||
self.send_result(queue_id, scope_id, result);
|
self.send_result(queue_id.transmute(), scope_id, result);
|
||||||
},
|
},
|
||||||
WebGPURequest::SwapChainPresent {
|
WebGPURequest::SwapChainPresent {
|
||||||
external_id,
|
external_id,
|
||||||
|
@ -1054,7 +1086,7 @@ impl<'a> WGPU<'a> {
|
||||||
let _ = gfx_select!(b_id => global.device_create_buffer(
|
let _ = gfx_select!(b_id => global.device_create_buffer(
|
||||||
device_id,
|
device_id,
|
||||||
&buffer_desc,
|
&buffer_desc,
|
||||||
b_id
|
Some(b_id)
|
||||||
));
|
));
|
||||||
b_id
|
b_id
|
||||||
} else {
|
} else {
|
||||||
|
@ -1077,7 +1109,7 @@ impl<'a> WGPU<'a> {
|
||||||
let _ = gfx_select!(encoder_id => global.device_create_command_encoder(
|
let _ = gfx_select!(encoder_id => global.device_create_command_encoder(
|
||||||
device_id,
|
device_id,
|
||||||
&comm_desc,
|
&comm_desc,
|
||||||
encoder_id
|
Some(encoder_id)
|
||||||
));
|
));
|
||||||
|
|
||||||
let buffer_cv = ImageCopyBuffer {
|
let buffer_cv = ImageCopyBuffer {
|
||||||
|
@ -1111,7 +1143,7 @@ impl<'a> WGPU<'a> {
|
||||||
));
|
));
|
||||||
let _ = gfx_select!(queue_id => global.queue_submit(
|
let _ = gfx_select!(queue_id => global.queue_submit(
|
||||||
queue_id,
|
queue_id,
|
||||||
&[encoder_id]
|
&[encoder_id.transmute()]
|
||||||
));
|
));
|
||||||
|
|
||||||
let map_info = BufferMapInfo {
|
let map_info = BufferMapInfo {
|
||||||
|
@ -1151,12 +1183,12 @@ impl<'a> WGPU<'a> {
|
||||||
let map_op = BufferMapOperation {
|
let map_op = BufferMapOperation {
|
||||||
host: HostMap::Read,
|
host: HostMap::Read,
|
||||||
callback: unsafe {
|
callback: unsafe {
|
||||||
BufferMapCallback::from_c(BufferMapCallbackC {
|
Some(BufferMapCallback::from_c(BufferMapCallbackC {
|
||||||
callback,
|
callback,
|
||||||
user_data: convert_to_pointer(
|
user_data: convert_to_pointer(
|
||||||
self.present_buffer_maps.get(&buffer_id).unwrap().clone(),
|
self.present_buffer_maps.get(&buffer_id).unwrap().clone(),
|
||||||
),
|
),
|
||||||
})
|
}))
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let _ = gfx_select!(buffer_id => global.buffer_map_async(buffer_id, 0..buffer_size, map_op));
|
let _ = gfx_select!(buffer_id => global.buffer_map_async(buffer_id, 0..buffer_size, map_op));
|
||||||
|
@ -1235,7 +1267,7 @@ impl<'a> WGPU<'a> {
|
||||||
buffer_offset as wgt::BufferAddress,
|
buffer_offset as wgt::BufferAddress,
|
||||||
&data
|
&data
|
||||||
));
|
));
|
||||||
self.send_result(queue_id, scope_id, result);
|
self.send_result(queue_id.transmute(), scope_id, result);
|
||||||
},
|
},
|
||||||
WebGPURequest::WriteTexture {
|
WebGPURequest::WriteTexture {
|
||||||
queue_id,
|
queue_id,
|
||||||
|
@ -1253,7 +1285,7 @@ impl<'a> WGPU<'a> {
|
||||||
&data_layout,
|
&data_layout,
|
||||||
&size
|
&size
|
||||||
));
|
));
|
||||||
self.send_result(queue_id, scope_id, result);
|
self.send_result(queue_id.transmute(), scope_id, result);
|
||||||
},
|
},
|
||||||
WebGPURequest::QueueOnSubmittedWorkDone { sender, queue_id } => {
|
WebGPURequest::QueueOnSubmittedWorkDone { sender, queue_id } => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
|
@ -1265,7 +1297,100 @@ impl<'a> WGPU<'a> {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
let result = gfx_select!(queue_id => global.queue_on_submitted_work_done(queue_id, callback));
|
let result = gfx_select!(queue_id => global.queue_on_submitted_work_done(queue_id, callback));
|
||||||
self.send_result(queue_id, scope_id, result);
|
self.send_result(queue_id.transmute(), scope_id, result);
|
||||||
|
},
|
||||||
|
WebGPURequest::DropTexture(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.texture_drop(id, true));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeTexture(id)) {
|
||||||
|
warn!("Unable to send FreeTexture({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropAdapter(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.adapter_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeAdapter(id)) {
|
||||||
|
warn!("Unable to send FreeAdapter({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropBuffer(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.buffer_drop(id, true));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBuffer(id)) {
|
||||||
|
warn!("Unable to send FreeBuffer({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropPipelineLayout(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.pipeline_layout_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreePipelineLayout(id)) {
|
||||||
|
warn!("Unable to send FreePipelineLayout({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropComputePipeline(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.compute_pipeline_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeComputePipeline(id))
|
||||||
|
{
|
||||||
|
warn!("Unable to send FreeComputePipeline({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropRenderPipeline(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.render_pipeline_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeRenderPipeline(id)) {
|
||||||
|
warn!("Unable to send FreeRenderPipeline({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropBindGroup(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.bind_group_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBindGroup(id)) {
|
||||||
|
warn!("Unable to send FreeBindGroup({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropBindGroupLayout(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.bind_group_layout_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBindGroupLayout(id))
|
||||||
|
{
|
||||||
|
warn!("Unable to send FreeBindGroupLayout({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropTextureView(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
let _result = gfx_select!(id => global.texture_view_drop(id, true));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeTextureView(id)) {
|
||||||
|
warn!("Unable to send FreeTextureView({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropSampler(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.sampler_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeSampler(id)) {
|
||||||
|
warn!("Unable to send FreeSampler({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropShaderModule(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.shader_module_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeShaderModule(id)) {
|
||||||
|
warn!("Unable to send FreeShaderModule({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropRenderBundle(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.render_bundle_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeRenderBundle(id)) {
|
||||||
|
warn!("Unable to send FreeRenderBundle({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
WebGPURequest::DropQuerySet(id) => {
|
||||||
|
let global = &self.global;
|
||||||
|
gfx_select!(id => global.query_set_drop(id));
|
||||||
|
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeQuerySet(id)) {
|
||||||
|
warn!("Unable to send FreeQuerySet({:?}) ({:?})", id, e);
|
||||||
|
};
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ packages = [
|
||||||
"foreign-types",
|
"foreign-types",
|
||||||
"foreign-types-shared",
|
"foreign-types-shared",
|
||||||
"metal",
|
"metal",
|
||||||
|
"raw-window-handle",
|
||||||
|
|
||||||
# Duplicated by indexmap.
|
# Duplicated by indexmap.
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,3 @@
|
||||||
[canvas_composite_alpha_bgra8unorm_opaque_copy.https.html]
|
[canvas_composite_alpha_bgra8unorm_opaque_copy.https.html]
|
||||||
expected:
|
expected:
|
||||||
if os == "linux" and not debug: [CRASH, PASS]
|
if os == "linux" and not debug: [CRASH, PASS, FAIL]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue