mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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]]
|
||||
name = "d3d12"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"libloading 0.8.3",
|
||||
"libloading 0.7.4",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -1410,7 +1409,7 @@ dependencies = [
|
|||
"egui",
|
||||
"instant",
|
||||
"log",
|
||||
"raw-window-handle",
|
||||
"raw-window-handle 0.5.2",
|
||||
"smithay-clipboard",
|
||||
"winit",
|
||||
]
|
||||
|
@ -3845,10 +3844,10 @@ checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0"
|
|||
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae585df4b6514cf8842ac0f1ab4992edc975892704835b549cf818dc0191249e"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-set",
|
||||
"bitflags 2.5.0",
|
||||
"codespan-reporting",
|
||||
|
@ -3874,7 +3873,7 @@ dependencies = [
|
|||
"jni-sys",
|
||||
"ndk-sys",
|
||||
"num_enum",
|
||||
"raw-window-handle",
|
||||
"raw-window-handle 0.5.2",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
@ -4722,6 +4721,12 @@ version = "0.5.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544"
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.10.0"
|
||||
|
@ -5557,7 +5562,7 @@ dependencies = [
|
|||
"libc",
|
||||
"libservo",
|
||||
"log",
|
||||
"raw-window-handle",
|
||||
"raw-window-handle 0.5.2",
|
||||
"servo-media",
|
||||
"servo_allocator",
|
||||
"shellwords",
|
||||
|
@ -5763,12 +5768,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
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"
|
||||
checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830"
|
||||
checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"num-traits",
|
||||
"bitflags 2.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -5963,7 +5967,7 @@ dependencies = [
|
|||
"mach2",
|
||||
"metal 0.24.0",
|
||||
"objc",
|
||||
"raw-window-handle",
|
||||
"raw-window-handle 0.5.2",
|
||||
"servo-display-link",
|
||||
"sparkle",
|
||||
"wayland-sys 0.30.1",
|
||||
|
@ -7080,16 +7084,18 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
|
|||
|
||||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef91c1d62d1e9e81c79e600131a258edf75c9531cbdbde09c44a011a47312726"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-vec",
|
||||
"bitflags 2.5.0",
|
||||
"cfg_aliases",
|
||||
"codespan-reporting",
|
||||
"indexmap 2.2.6",
|
||||
"log",
|
||||
"naga",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"ron",
|
||||
|
@ -7104,9 +7110,8 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wgpu-hal"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b84ecc802da3eb67b4cf3dd9ea6fe45bbb47ef13e6c49c5c3240868a9cc6cdd9"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"arrayvec",
|
||||
|
@ -7114,6 +7119,7 @@ dependencies = [
|
|||
"bit-set",
|
||||
"bitflags 2.5.0",
|
||||
"block",
|
||||
"cfg_aliases",
|
||||
"core-graphics-types",
|
||||
"d3d12",
|
||||
"gpu-alloc",
|
||||
|
@ -7121,7 +7127,7 @@ dependencies = [
|
|||
"js-sys",
|
||||
"khronos-egl",
|
||||
"libc",
|
||||
"libloading 0.8.3",
|
||||
"libloading 0.7.4",
|
||||
"log",
|
||||
"metal 0.27.0",
|
||||
"naga",
|
||||
|
@ -7130,7 +7136,7 @@ dependencies = [
|
|||
"parking_lot",
|
||||
"profiling",
|
||||
"range-alloc",
|
||||
"raw-window-handle",
|
||||
"raw-window-handle 0.6.0",
|
||||
"rustc-hash",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
|
@ -7142,9 +7148,8 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d5ed5f0edf0de351fe311c53304986315ce866f394a2e6df0c4b3c70774bcdd"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=32e70bc1635905c508d408eb1cf22b2aa062ffe1#32e70bc1635905c508d408eb1cf22b2aa062ffe1"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"js-sys",
|
||||
|
@ -7439,7 +7444,7 @@ dependencies = [
|
|||
"once_cell",
|
||||
"orbclient",
|
||||
"percent-encoding",
|
||||
"raw-window-handle",
|
||||
"raw-window-handle 0.5.2",
|
||||
"redox_syscall 0.3.5",
|
||||
"sctk-adwaita",
|
||||
"smithay-client-toolkit",
|
||||
|
|
|
@ -126,8 +126,8 @@ webpki-roots = "0.25"
|
|||
webrender = { git = "https://github.com/servo/webrender", branch = "0.64", features = ["capture"] }
|
||||
webrender_api = { git = "https://github.com/servo/webrender", branch = "0.64" }
|
||||
webrender_traits = { path = "components/shared/webrender" }
|
||||
wgpu-core = "0.18"
|
||||
wgpu-types = "0.18"
|
||||
wgpu-core = { git = "https://github.com/gfx-rs/wgpu", rev = "32e70bc1635905c508d408eb1cf22b2aa062ffe1" }
|
||||
wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "32e70bc1635905c508d408eb1cf22b2aa062ffe1" }
|
||||
winapi = "0.3"
|
||||
xi-unicode = "0.1.0"
|
||||
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 {
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuadapter-requestdevice>
|
||||
fn RequestDevice(&self, descriptor: &GPUDeviceDescriptor, comp: InRealm) -> Rc<Promise> {
|
||||
|
@ -106,69 +121,83 @@ impl GPUAdapterMethods for GPUAdapter {
|
|||
}
|
||||
|
||||
let mut desc = wgt::DeviceDescriptor {
|
||||
features,
|
||||
limits: wgt::Limits::default(),
|
||||
required_features: features,
|
||||
required_limits: wgt::Limits::default(),
|
||||
label: None,
|
||||
};
|
||||
if let Some(limits) = &descriptor.requiredLimits {
|
||||
for (limit, value) in (*limits).iter() {
|
||||
let v = u32::try_from(*value).unwrap_or(u32::MAX);
|
||||
match limit.as_ref() {
|
||||
"maxTextureDimension1D" => desc.limits.max_texture_dimension_1d = v,
|
||||
"maxTextureDimension2D" => desc.limits.max_texture_dimension_2d = v,
|
||||
"maxTextureDimension3D" => desc.limits.max_texture_dimension_3d = v,
|
||||
"maxTextureArrayLayers" => desc.limits.max_texture_array_layers = v,
|
||||
"maxBindGroups" => desc.limits.max_bind_groups = v,
|
||||
"maxBindingsPerBindGroup" => desc.limits.max_bindings_per_bind_group = v,
|
||||
"maxTextureDimension1D" => desc.required_limits.max_texture_dimension_1d = v,
|
||||
"maxTextureDimension2D" => desc.required_limits.max_texture_dimension_2d = v,
|
||||
"maxTextureDimension3D" => desc.required_limits.max_texture_dimension_3d = v,
|
||||
"maxTextureArrayLayers" => desc.required_limits.max_texture_array_layers = v,
|
||||
"maxBindGroups" => desc.required_limits.max_bind_groups = v,
|
||||
"maxBindingsPerBindGroup" => {
|
||||
desc.required_limits.max_bindings_per_bind_group = v
|
||||
},
|
||||
"maxDynamicUniformBuffersPerPipelineLayout" => {
|
||||
desc.limits.max_dynamic_uniform_buffers_per_pipeline_layout = v
|
||||
desc.required_limits
|
||||
.max_dynamic_uniform_buffers_per_pipeline_layout = v
|
||||
},
|
||||
"maxDynamicStorageBuffersPerPipelineLayout" => {
|
||||
desc.limits.max_dynamic_storage_buffers_per_pipeline_layout = v
|
||||
desc.required_limits
|
||||
.max_dynamic_storage_buffers_per_pipeline_layout = v
|
||||
},
|
||||
"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" => {
|
||||
desc.limits.max_storage_buffers_per_shader_stage = v
|
||||
desc.required_limits.max_storage_buffers_per_shader_stage = v
|
||||
},
|
||||
"maxStorageTexturesPerShaderStage" => {
|
||||
desc.limits.max_storage_textures_per_shader_stage = v
|
||||
desc.required_limits.max_storage_textures_per_shader_stage = v
|
||||
},
|
||||
"maxUniformBuffersPerShaderStage" => {
|
||||
desc.limits.max_uniform_buffers_per_shader_stage = v
|
||||
desc.required_limits.max_uniform_buffers_per_shader_stage = v
|
||||
},
|
||||
"maxUniformBufferBindingSize" => {
|
||||
desc.limits.max_uniform_buffer_binding_size = v
|
||||
desc.required_limits.max_uniform_buffer_binding_size = v
|
||||
},
|
||||
"maxStorageBufferBindingSize" => {
|
||||
desc.limits.max_storage_buffer_binding_size = v
|
||||
desc.required_limits.max_storage_buffer_binding_size = v
|
||||
},
|
||||
"minUniformBufferOffsetAlignment" => {
|
||||
desc.limits.min_uniform_buffer_offset_alignment = v
|
||||
desc.required_limits.min_uniform_buffer_offset_alignment = v
|
||||
},
|
||||
"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" => {
|
||||
desc.limits.max_inter_stage_shader_components = v
|
||||
desc.required_limits.max_inter_stage_shader_components = v
|
||||
},
|
||||
"maxComputeWorkgroupStorageSize" => {
|
||||
desc.limits.max_compute_workgroup_storage_size = v
|
||||
desc.required_limits.max_compute_workgroup_storage_size = v
|
||||
},
|
||||
"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" => {
|
||||
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}");
|
||||
|
@ -251,8 +280,8 @@ impl AsyncWGPUListener for GPUAdapter {
|
|||
self.channel.clone(),
|
||||
self,
|
||||
Heap::default(),
|
||||
descriptor.features,
|
||||
descriptor.limits,
|
||||
descriptor.required_features,
|
||||
descriptor.required_limits,
|
||||
device_id,
|
||||
queue_id,
|
||||
descriptor.label.unwrap_or_default(),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
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::codegen::Bindings::WebGPUBinding::GPUBindGroupMethods;
|
||||
|
@ -16,6 +16,9 @@ use crate::dom::gpubindgrouplayout::GPUBindGroupLayout;
|
|||
#[dom_struct]
|
||||
pub struct GPUBindGroup {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "channels are hard"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
bind_group: WebGPUBindGroup,
|
||||
|
@ -26,6 +29,7 @@ pub struct GPUBindGroup {
|
|||
|
||||
impl GPUBindGroup {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
bind_group: WebGPUBindGroup,
|
||||
device: WebGPUDevice,
|
||||
layout: &GPUBindGroupLayout,
|
||||
|
@ -33,6 +37,7 @@ impl GPUBindGroup {
|
|||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
bind_group,
|
||||
device,
|
||||
|
@ -42,6 +47,7 @@ impl GPUBindGroup {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
bind_group: WebGPUBindGroup,
|
||||
device: WebGPUDevice,
|
||||
layout: &GPUBindGroupLayout,
|
||||
|
@ -49,7 +55,7 @@ impl GPUBindGroup {
|
|||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUBindGroup::new_inherited(
|
||||
bind_group, device, layout, label,
|
||||
channel, bind_group, device, layout, label,
|
||||
)),
|
||||
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 {
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label>
|
||||
fn Label(&self) -> USVString {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::WebGPUBindGroupLayout;
|
||||
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBindGroupLayoutMethods;
|
||||
|
@ -15,15 +15,23 @@ use crate::dom::globalscope::GlobalScope;
|
|||
#[dom_struct]
|
||||
pub struct GPUBindGroupLayout {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "channels are hard"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
bind_group_layout: WebGPUBindGroupLayout,
|
||||
}
|
||||
|
||||
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 {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
bind_group_layout,
|
||||
}
|
||||
|
@ -31,11 +39,16 @@ impl GPUBindGroupLayout {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
bind_group_layout: WebGPUBindGroupLayout,
|
||||
label: USVString,
|
||||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUBindGroupLayout::new_inherited(bind_group_layout, label)),
|
||||
Box::new(GPUBindGroupLayout::new_inherited(
|
||||
channel,
|
||||
bind_group_layout,
|
||||
label,
|
||||
)),
|
||||
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 {
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label>
|
||||
fn Label(&self) -> USVString {
|
||||
|
|
|
@ -130,8 +130,18 @@ impl GPUBuffer {
|
|||
|
||||
impl Drop for GPUBuffer {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self.Destroy() {
|
||||
error!("GPUBuffer destruction failed with {e:?}!"); // TODO: should we allow panic here?
|
||||
if matches!(self.state(), GPUBufferState::Destroyed) {
|
||||
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");
|
||||
|
||||
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()));
|
||||
}
|
||||
|
|
|
@ -74,10 +74,10 @@ impl Drop for GPUCommandBuffer {
|
|||
fn drop(&mut self) {
|
||||
if let Err(e) = self.channel.0.send((
|
||||
None,
|
||||
WebGPURequest::FreeCommandBuffer(self.command_buffer.0),
|
||||
WebGPURequest::DropCommandBuffer(self.command_buffer.0),
|
||||
)) {
|
||||
warn!(
|
||||
"Failed to send FreeCommandBuffer({:?}) ({})",
|
||||
"Failed to send DropCommandBuffer({:?}) ({})",
|
||||
self.command_buffer.0, e
|
||||
);
|
||||
}
|
||||
|
|
|
@ -393,7 +393,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
.expect("Failed to send Finish");
|
||||
|
||||
*self.state.borrow_mut() = GPUCommandEncoderState::Closed;
|
||||
let buffer = webgpu::WebGPUCommandBuffer(self.encoder.0);
|
||||
let buffer = webgpu::WebGPUCommandBuffer(self.encoder.0.transmute());
|
||||
GPUCommandBuffer::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use std::string::String;
|
||||
|
||||
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::codegen::Bindings::WebGPUBinding::GPUComputePipelineMethods;
|
||||
|
@ -20,6 +20,9 @@ use crate::dom::gpudevice::GPUDevice;
|
|||
#[dom_struct]
|
||||
pub struct GPUComputePipeline {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "channels are hard"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
compute_pipeline: WebGPUComputePipeline,
|
||||
|
@ -30,6 +33,7 @@ pub struct GPUComputePipeline {
|
|||
|
||||
impl GPUComputePipeline {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
compute_pipeline: WebGPUComputePipeline,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
|
@ -37,6 +41,7 @@ impl GPUComputePipeline {
|
|||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
compute_pipeline,
|
||||
bind_group_layouts: bgls,
|
||||
|
@ -46,6 +51,7 @@ impl GPUComputePipeline {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
compute_pipeline: WebGPUComputePipeline,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
|
@ -53,6 +59,7 @@ impl GPUComputePipeline {
|
|||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUComputePipeline::new_inherited(
|
||||
channel,
|
||||
compute_pipeline,
|
||||
label,
|
||||
bgls,
|
||||
|
@ -87,8 +94,23 @@ impl GPUComputePipelineMethods for GPUComputePipeline {
|
|||
}
|
||||
Ok(GPUBindGroupLayout::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
self.bind_group_layouts[index as usize],
|
||||
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
|
||||
}
|
||||
|
||||
pub fn channel(&self) -> WebGPU {
|
||||
self.channel.clone()
|
||||
}
|
||||
|
||||
pub fn handle_server_msg(&self, scope: Option<ErrorScopeId>, result: WebGPUOpResult) {
|
||||
let result = match result {
|
||||
WebGPUOpResult::Success => Ok(()),
|
||||
|
@ -542,6 +546,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
GPUBindGroupLayout::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
bgl,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
)
|
||||
|
@ -591,6 +596,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let pipeline_layout = webgpu::WebGPUPipelineLayout(pipeline_layout_id);
|
||||
GPUPipelineLayout::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
pipeline_layout,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
bgls,
|
||||
|
@ -651,6 +657,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
GPUBindGroup::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
bind_group,
|
||||
self.device,
|
||||
&descriptor.layout,
|
||||
|
@ -686,6 +693,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let shader_module = webgpu::WebGPUShaderModule(program_id);
|
||||
GPUShaderModule::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
shader_module,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
)
|
||||
|
@ -730,6 +738,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let compute_pipeline = webgpu::WebGPUComputePipeline(compute_pipeline_id);
|
||||
GPUComputePipeline::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
compute_pipeline,
|
||||
descriptor.parent.parent.label.clone().unwrap_or_default(),
|
||||
bgls,
|
||||
|
@ -783,7 +792,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
}
|
||||
|
||||
/// <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 desc = wgt::TextureUsages::from_bits(descriptor.usage).map(|usg| {
|
||||
wgpu_res::TextureDescriptor {
|
||||
|
@ -814,10 +823,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
let scope_id = self.use_current_scope();
|
||||
if desc.is_none() {
|
||||
self.handle_server_msg(
|
||||
scope_id,
|
||||
WebGPUOpResult::ValidationError(String::from("Invalid GPUTextureUsage")),
|
||||
);
|
||||
return Err(Error::Type(String::from("Invalid GPUTextureUsage")));
|
||||
}
|
||||
self.channel
|
||||
.0
|
||||
|
@ -833,7 +839,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
let texture = webgpu::WebGPUTexture(texture_id);
|
||||
|
||||
GPUTexture::new(
|
||||
Ok(GPUTexture::new(
|
||||
&self.global(),
|
||||
texture,
|
||||
self,
|
||||
|
@ -845,7 +851,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
descriptor.format,
|
||||
descriptor.usage,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createsampler>
|
||||
|
@ -890,6 +896,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
GPUSampler::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
self.device,
|
||||
compare_enable,
|
||||
sampler,
|
||||
|
@ -1173,8 +1180,20 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
}
|
||||
|
||||
impl Drop for GPUDevice {
|
||||
// not sure about this but this is non failable version of destroy
|
||||
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/. */
|
||||
|
||||
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::codegen::Bindings::WebGPUBinding::GPUPipelineLayoutMethods;
|
||||
|
@ -15,6 +15,9 @@ use crate::dom::globalscope::GlobalScope;
|
|||
#[dom_struct]
|
||||
pub struct GPUPipelineLayout {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
pipeline_layout: WebGPUPipelineLayout,
|
||||
|
@ -24,12 +27,14 @@ pub struct GPUPipelineLayout {
|
|||
|
||||
impl GPUPipelineLayout {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
pipeline_layout: WebGPUPipelineLayout,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
pipeline_layout,
|
||||
bind_group_layouts: bgls,
|
||||
|
@ -38,12 +43,14 @@ impl GPUPipelineLayout {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
pipeline_layout: WebGPUPipelineLayout,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUPipelineLayout::new_inherited(
|
||||
channel,
|
||||
pipeline_layout,
|
||||
label,
|
||||
bgls,
|
||||
|
@ -74,3 +81,17 @@ impl GPUPipelineLayoutMethods for GPUPipelineLayout {
|
|||
*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/. */
|
||||
|
||||
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::codegen::Bindings::WebGPUBinding::GPURenderBundleMethods;
|
||||
|
@ -77,3 +77,18 @@ impl GPURenderBundleMethods for GPURenderBundle {
|
|||
*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 dom_struct::dom_struct;
|
||||
use webgpu::{WebGPUBindGroupLayout, WebGPURenderPipeline};
|
||||
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPURenderPipeline, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderPipelineMethods;
|
||||
|
@ -20,6 +20,9 @@ use crate::dom::gpudevice::GPUDevice;
|
|||
#[dom_struct]
|
||||
pub struct GPURenderPipeline {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "channels are hard"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
render_pipeline: WebGPURenderPipeline,
|
||||
|
@ -37,6 +40,7 @@ impl GPURenderPipeline {
|
|||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel: device.channel(),
|
||||
label: DomRefCell::new(label),
|
||||
render_pipeline,
|
||||
bind_group_layouts: bgls,
|
||||
|
@ -87,8 +91,23 @@ impl GPURenderPipelineMethods for GPURenderPipeline {
|
|||
}
|
||||
Ok(GPUBindGroupLayout::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
self.bind_group_layouts[index as usize],
|
||||
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/. */
|
||||
|
||||
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::codegen::Bindings::WebGPUBinding::GPUSamplerMethods;
|
||||
|
@ -15,6 +15,9 @@ use crate::dom::globalscope::GlobalScope;
|
|||
#[dom_struct]
|
||||
pub struct GPUSampler {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
device: WebGPUDevice,
|
||||
|
@ -25,6 +28,7 @@ pub struct GPUSampler {
|
|||
|
||||
impl GPUSampler {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
device: WebGPUDevice,
|
||||
compare_enable: bool,
|
||||
sampler: WebGPUSampler,
|
||||
|
@ -32,6 +36,7 @@ impl GPUSampler {
|
|||
) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
device,
|
||||
sampler,
|
||||
|
@ -41,6 +46,7 @@ impl GPUSampler {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
device: WebGPUDevice,
|
||||
compare_enable: bool,
|
||||
sampler: WebGPUSampler,
|
||||
|
@ -48,6 +54,7 @@ impl GPUSampler {
|
|||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUSampler::new_inherited(
|
||||
channel,
|
||||
device,
|
||||
compare_enable,
|
||||
sampler,
|
||||
|
@ -75,3 +82,15 @@ impl GPUSamplerMethods for GPUSampler {
|
|||
*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 dom_struct::dom_struct;
|
||||
use webgpu::WebGPUShaderModule;
|
||||
use webgpu::{WebGPU, WebGPURequest, WebGPUShaderModule};
|
||||
|
||||
use super::bindings::error::Fallible;
|
||||
use super::promise::Promise;
|
||||
|
@ -19,15 +19,19 @@ use crate::dom::globalscope::GlobalScope;
|
|||
#[dom_struct]
|
||||
pub struct GPUShaderModule {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
shader_module: WebGPUShaderModule,
|
||||
}
|
||||
|
||||
impl GPUShaderModule {
|
||||
fn new_inherited(shader_module: WebGPUShaderModule, label: USVString) -> Self {
|
||||
fn new_inherited(channel: WebGPU, shader_module: WebGPUShaderModule, label: USVString) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
label: DomRefCell::new(label),
|
||||
shader_module,
|
||||
}
|
||||
|
@ -35,11 +39,16 @@ impl GPUShaderModule {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
shader_module: WebGPUShaderModule,
|
||||
label: USVString,
|
||||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUShaderModule::new_inherited(shader_module, label)),
|
||||
Box::new(GPUShaderModule::new_inherited(
|
||||
channel,
|
||||
shader_module,
|
||||
label,
|
||||
)),
|
||||
global,
|
||||
)
|
||||
}
|
||||
|
@ -67,3 +76,18 @@ impl GPUShaderModuleMethods for GPUShaderModule {
|
|||
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 {
|
||||
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(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
texture_view,
|
||||
self,
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
|
@ -197,11 +210,13 @@ impl GPUTextureMethods for GPUTexture {
|
|||
if self.destroyed.get() {
|
||||
return;
|
||||
}
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send((None, WebGPURequest::DestroyTexture(self.texture.0)))
|
||||
{
|
||||
if let Err(e) = self.channel.0.send((
|
||||
None,
|
||||
WebGPURequest::DestroyTexture {
|
||||
device_id: self.device.id().0,
|
||||
texture_id: self.texture.0,
|
||||
},
|
||||
)) {
|
||||
warn!(
|
||||
"Failed to send WebGPURequest::DestroyTexture({:?}) ({})",
|
||||
self.texture.0, e
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::WebGPUTextureView;
|
||||
use webgpu::{WebGPU, WebGPURequest, WebGPUTextureView};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUTextureViewMethods;
|
||||
|
@ -16,6 +16,9 @@ use crate::dom::gputexture::GPUTexture;
|
|||
#[dom_struct]
|
||||
pub struct GPUTextureView {
|
||||
reflector_: Reflector,
|
||||
#[ignore_malloc_size_of = "defined in webgpu"]
|
||||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
texture_view: WebGPUTextureView,
|
||||
|
@ -24,12 +27,14 @@ pub struct GPUTextureView {
|
|||
|
||||
impl GPUTextureView {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
texture_view: WebGPUTextureView,
|
||||
texture: &GPUTexture,
|
||||
label: USVString,
|
||||
) -> GPUTextureView {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
channel,
|
||||
texture: Dom::from_ref(texture),
|
||||
label: DomRefCell::new(label),
|
||||
texture_view,
|
||||
|
@ -38,12 +43,18 @@ impl GPUTextureView {
|
|||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
texture_view: WebGPUTextureView,
|
||||
texture: &GPUTexture,
|
||||
label: USVString,
|
||||
) -> DomRoot<GPUTextureView> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUTextureView::new_inherited(texture_view, texture, label)),
|
||||
Box::new(GPUTextureView::new_inherited(
|
||||
channel,
|
||||
texture_view,
|
||||
texture,
|
||||
label,
|
||||
)),
|
||||
global,
|
||||
)
|
||||
}
|
||||
|
@ -66,3 +77,18 @@ impl GPUTextureViewMethods for GPUTextureView {
|
|||
*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/. */
|
||||
|
||||
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::{
|
||||
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandEncoderId, ComputePipelineId,
|
||||
DeviceId, PipelineLayoutId, RenderBundleId, RenderPipelineId, SamplerId, ShaderModuleId,
|
||||
|
@ -11,47 +15,75 @@ use webgpu::wgpu::id::{
|
|||
use webgpu::wgpu::identity::IdentityManager;
|
||||
use webgpu::wgt::Backend;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct IdentityHub {
|
||||
adapters: IdentityManager,
|
||||
devices: IdentityManager,
|
||||
buffers: IdentityManager,
|
||||
bind_groups: IdentityManager,
|
||||
bind_group_layouts: IdentityManager,
|
||||
compute_pipelines: IdentityManager,
|
||||
pipeline_layouts: IdentityManager,
|
||||
shader_modules: IdentityManager,
|
||||
command_encoders: IdentityManager,
|
||||
textures: IdentityManager,
|
||||
texture_views: IdentityManager,
|
||||
samplers: IdentityManager,
|
||||
render_pipelines: IdentityManager,
|
||||
render_bundles: IdentityManager,
|
||||
adapters: IdentityManager<Adapter>,
|
||||
devices: IdentityManager<Device>,
|
||||
buffers: IdentityManager<Buffer>,
|
||||
bind_groups: IdentityManager<BindGroup>,
|
||||
bind_group_layouts: IdentityManager<BindGroupLayout>,
|
||||
compute_pipelines: IdentityManager<ComputePipeline>,
|
||||
pipeline_layouts: IdentityManager<PipelineLayout>,
|
||||
shader_modules: IdentityManager<ShaderModule>,
|
||||
command_encoders: IdentityManager<CommandEncoder>,
|
||||
textures: IdentityManager<Texture>,
|
||||
texture_views: IdentityManager<TextureView>,
|
||||
samplers: IdentityManager<Sampler>,
|
||||
render_pipelines: IdentityManager<RenderPipeline>,
|
||||
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 {
|
||||
_surface: IdentityManager,
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
vk_hub: IdentityHub,
|
||||
#[cfg(target_os = "windows")]
|
||||
dx12_hub: IdentityHub,
|
||||
#[cfg(target_os = "windows")]
|
||||
dx11_hub: IdentityHub,
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
metal_hub: IdentityHub,
|
||||
dummy_hub: IdentityHub,
|
||||
}
|
||||
|
||||
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 {
|
||||
match backend {
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
Backend::Vulkan => &mut self.vk_hub,
|
||||
#[cfg(target_os = "windows")]
|
||||
Backend::Dx12 => &mut self.dx12_hub,
|
||||
#[cfg(target_os = "windows")]
|
||||
Backend::Dx11 => &mut self.dx11_hub,
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
Backend::Metal => &mut self.metal_hub,
|
||||
_ => &mut self.dummy_hub,
|
||||
|
@ -64,8 +96,6 @@ impl Identities {
|
|||
(&mut self.vk_hub, Backend::Vulkan),
|
||||
#[cfg(target_os = "windows")]
|
||||
(&mut self.dx12_hub, Backend::Dx12),
|
||||
#[cfg(target_os = "windows")]
|
||||
(&mut self.dx11_hub, Backend::Dx11),
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
(&mut self.metal_hub, Backend::Metal),
|
||||
(&mut self.dummy_hub, Backend::Empty),
|
||||
|
@ -73,7 +103,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -83,7 +113,7 @@ impl Identities {
|
|||
pub fn create_adapter_ids(&mut self) -> SmallVec<[AdapterId; 4]> {
|
||||
let mut ids = SmallVec::new();
|
||||
for hubs in self.hubs() {
|
||||
ids.push(hubs.0.adapters.alloc(hubs.1));
|
||||
ids.push(hubs.0.adapters.process(hubs.1));
|
||||
}
|
||||
ids
|
||||
}
|
||||
|
@ -93,7 +123,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -101,7 +131,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -109,7 +139,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -117,7 +147,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -125,7 +155,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -133,7 +163,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -141,7 +171,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -149,7 +179,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -157,7 +187,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -165,7 +195,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -173,7 +203,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -181,7 +211,7 @@ impl Identities {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -242,7 +242,7 @@ impl ServiceWorkerGlobalScope {
|
|||
runtime,
|
||||
from_devtools_receiver,
|
||||
closing,
|
||||
Arc::new(Mutex::new(Identities::default())),
|
||||
Arc::new(Mutex::new(Identities::new())),
|
||||
),
|
||||
task_queue: TaskQueue::new(receiver, own_sender.clone()),
|
||||
own_sender,
|
||||
|
|
|
@ -129,7 +129,7 @@ interface GPUDevice: EventTarget {
|
|||
|
||||
[NewObject, Throws]
|
||||
GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
|
||||
[NewObject]
|
||||
[NewObject, Throws]
|
||||
GPUTexture createTexture(GPUTextureDescriptor descriptor);
|
||||
[NewObject]
|
||||
GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
|
||||
|
|
|
@ -1430,7 +1430,7 @@ impl ScriptThread {
|
|||
|
||||
node_ids: Default::default(),
|
||||
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),
|
||||
inherited_secure_context: state.inherited_secure_context,
|
||||
layouts: Default::default(),
|
||||
|
@ -2122,7 +2122,10 @@ impl ScriptThread {
|
|||
WebGPUMsg::FreeBindGroupLayout(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::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),
|
||||
|
|
|
@ -23,17 +23,20 @@ smallvec = { workspace = true, features = ["serde"] }
|
|||
webrender = { workspace = true }
|
||||
webrender_api = { 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 }
|
||||
|
||||
# We want the wgpu-core Metal backend on macOS and iOS.
|
||||
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies.wgpu-core]
|
||||
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
|
||||
features = ["replay", "trace", "serial-pass", "vulkan"]
|
||||
features = ["vulkan"]
|
||||
|
||||
# We want the wgpu-core Direct3D backends on Windows.
|
||||
[target.'cfg(windows)'.dependencies.wgpu-core]
|
||||
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
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::wgpu::id::{
|
||||
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, ComputePipelineId,
|
||||
DeviceId, PipelineLayoutId, QuerySetId, RenderBundleId, RenderPipelineId, SamplerId,
|
||||
ShaderModuleId, StagingBufferId, SurfaceId, TextureId, TextureViewId, TypedId,
|
||||
ShaderModuleId, StagingBufferId, SurfaceId, TextureId, TextureViewId,
|
||||
};
|
||||
use crate::wgpu::identity::{
|
||||
GlobalIdentityHandlerFactory, IdentityHandler, IdentityHandlerFactory,
|
||||
};
|
||||
use crate::wgt::Backend;
|
||||
use crate::{ErrorScopeId, WebGPUDevice, WebGPURequest};
|
||||
use crate::{ErrorScopeId, WebGPUDevice};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub enum WebGPUOpResult {
|
||||
|
@ -55,117 +50,3 @@ pub enum WebGPUMsg {
|
|||
},
|
||||
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 euclid::default::Size2D;
|
||||
use identity::{IdentityRecyclerFactory, WebGPUMsg, WebGPUOpResult};
|
||||
use identity::{WebGPUMsg, WebGPUOpResult};
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender, IpcSharedMemory};
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
|
@ -48,7 +48,7 @@ use wgpu::resource::{
|
|||
BufferDescriptor, BufferMapAsyncStatus, BufferMapCallback, BufferMapCallbackC,
|
||||
BufferMapOperation, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
|
||||
};
|
||||
use wgt::{Dx12Compiler, InstanceDescriptor};
|
||||
use wgt::InstanceDescriptor;
|
||||
|
||||
pub type ErrorScopeId = NonZeroU64;
|
||||
const DEVICE_POLL_INTERVAL: u64 = 100;
|
||||
|
@ -190,14 +190,30 @@ pub enum WebGPURequest {
|
|||
},
|
||||
DestroyBuffer(id::BufferId),
|
||||
DestroyDevice(id::DeviceId),
|
||||
DestroyTexture {
|
||||
device_id: id::DeviceId,
|
||||
texture_id: id::TextureId,
|
||||
},
|
||||
DestroySwapChain {
|
||||
external_id: u64,
|
||||
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<()>),
|
||||
FreeCommandBuffer(id::CommandBufferId),
|
||||
FreeDevice(id::DeviceId),
|
||||
RenderBundleEncoderFinish {
|
||||
render_bundle_encoder: RenderBundleEncoder,
|
||||
descriptor: RenderBundleDescriptor<'static>,
|
||||
|
@ -268,7 +284,7 @@ pub enum WebGPURequest {
|
|||
struct BufferMapInfo<'a, T> {
|
||||
buffer_id: id::BufferId,
|
||||
sender: IpcSender<T>,
|
||||
global: &'a wgpu::global::Global<IdentityRecyclerFactory>,
|
||||
global: &'a wgpu::global::Global,
|
||||
size: usize,
|
||||
external_id: Option<u64>,
|
||||
}
|
||||
|
@ -347,7 +363,7 @@ struct WGPU<'a> {
|
|||
receiver: IpcReceiver<(Option<ErrorScopeId>, WebGPURequest)>,
|
||||
sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
|
||||
script_sender: IpcSender<WebGPUMsg>,
|
||||
global: wgpu::global::Global<IdentityRecyclerFactory>,
|
||||
global: wgpu::global::Global,
|
||||
adapters: Vec<WebGPUAdapter>,
|
||||
devices: HashMap<WebGPUDevice, PipelineId>,
|
||||
// Track invalid adapters https://gpuweb.github.io/gpuweb/#invalid
|
||||
|
@ -375,20 +391,14 @@ impl<'a> WGPU<'a> {
|
|||
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
|
||||
wgpu_image_map: Arc<Mutex<HashMap<u64, PresentationData>>>,
|
||||
) -> Self {
|
||||
let factory = IdentityRecyclerFactory {
|
||||
sender: script_sender.clone(),
|
||||
self_sender: sender.clone(),
|
||||
};
|
||||
WGPU {
|
||||
receiver,
|
||||
sender,
|
||||
script_sender,
|
||||
global: wgpu::global::Global::new(
|
||||
"wgpu-core",
|
||||
factory,
|
||||
InstanceDescriptor {
|
||||
backends: wgt::Backends::PRIMARY,
|
||||
dx12_shader_compiler: Dx12Compiler::default(),
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
|
@ -462,12 +472,12 @@ impl<'a> WGPU<'a> {
|
|||
let operation = BufferMapOperation {
|
||||
host: host_map,
|
||||
callback: unsafe {
|
||||
BufferMapCallback::from_c(BufferMapCallbackC {
|
||||
Some(BufferMapCallback::from_c(BufferMapCallbackC {
|
||||
callback,
|
||||
user_data: convert_to_pointer(
|
||||
self.buffer_maps.get(&buffer_id).unwrap().clone(),
|
||||
),
|
||||
})
|
||||
}))
|
||||
},
|
||||
};
|
||||
let global = &self.global;
|
||||
|
@ -579,7 +589,7 @@ impl<'a> WGPU<'a> {
|
|||
} => {
|
||||
let global = &self.global;
|
||||
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);
|
||||
},
|
||||
WebGPURequest::CreateBindGroupLayout {
|
||||
|
@ -590,7 +600,7 @@ impl<'a> WGPU<'a> {
|
|||
let global = &self.global;
|
||||
if let Some(desc) = descriptor {
|
||||
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);
|
||||
}
|
||||
|
@ -603,7 +613,7 @@ impl<'a> WGPU<'a> {
|
|||
let global = &self.global;
|
||||
if let Some(desc) = descriptor {
|
||||
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);
|
||||
}
|
||||
|
@ -616,7 +626,7 @@ impl<'a> WGPU<'a> {
|
|||
let global = &self.global;
|
||||
let desc = wgt::CommandEncoderDescriptor { label };
|
||||
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);
|
||||
},
|
||||
|
@ -629,19 +639,21 @@ impl<'a> WGPU<'a> {
|
|||
let global = &self.global;
|
||||
let bgls = implicit_ids
|
||||
.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 =
|
||||
implicit_ids
|
||||
.as_ref()
|
||||
.map(|(layout, _)| ImplicitPipelineIds {
|
||||
root_id: *layout,
|
||||
root_id: Some(*layout),
|
||||
group_ids: bgls.as_slice(),
|
||||
});
|
||||
let result = tuple_to_result(
|
||||
gfx_select!(compute_pipeline_id => global.device_create_compute_pipeline(
|
||||
device_id,
|
||||
&descriptor,
|
||||
compute_pipeline_id,
|
||||
Some(compute_pipeline_id),
|
||||
implicit
|
||||
)),
|
||||
);
|
||||
|
@ -664,7 +676,7 @@ impl<'a> WGPU<'a> {
|
|||
} => {
|
||||
let global = &self.global;
|
||||
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);
|
||||
},
|
||||
WebGPURequest::CreateRenderPipeline {
|
||||
|
@ -676,17 +688,24 @@ impl<'a> WGPU<'a> {
|
|||
let global = &self.global;
|
||||
let bgls = implicit_ids
|
||||
.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 =
|
||||
implicit_ids
|
||||
.as_ref()
|
||||
.map(|(layout, _)| ImplicitPipelineIds {
|
||||
root_id: *layout,
|
||||
root_id: Some(*layout),
|
||||
group_ids: bgls.as_slice(),
|
||||
});
|
||||
if let Some(desc) = descriptor {
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
@ -700,7 +719,7 @@ impl<'a> WGPU<'a> {
|
|||
gfx_select!(sampler_id => global.device_create_sampler(
|
||||
device_id,
|
||||
&descriptor,
|
||||
sampler_id
|
||||
Some(sampler_id)
|
||||
)),
|
||||
);
|
||||
self.send_result(device_id, scope_id, result);
|
||||
|
@ -720,7 +739,7 @@ impl<'a> WGPU<'a> {
|
|||
shader_bound_checks: wgt::ShaderBoundChecks::default(),
|
||||
};
|
||||
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);
|
||||
},
|
||||
WebGPURequest::CreateSwapChain {
|
||||
|
@ -743,7 +762,7 @@ impl<'a> WGPU<'a> {
|
|||
external_id,
|
||||
PresentationData {
|
||||
device_id,
|
||||
queue_id: device_id,
|
||||
queue_id: device_id.transmute(),
|
||||
data: vec![255; (buffer_stride * height as u32) as usize],
|
||||
size: Size2D::new(width, height),
|
||||
unassigned_buffer_ids: buffer_ids,
|
||||
|
@ -778,7 +797,7 @@ impl<'a> WGPU<'a> {
|
|||
gfx_select!(texture_id => global.device_create_texture(
|
||||
device_id,
|
||||
&desc,
|
||||
texture_id
|
||||
Some(texture_id)
|
||||
)),
|
||||
);
|
||||
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(
|
||||
texture_id,
|
||||
&desc,
|
||||
texture_view_id
|
||||
Some(texture_view_id)
|
||||
)),
|
||||
);
|
||||
|
||||
|
@ -805,11 +824,11 @@ impl<'a> WGPU<'a> {
|
|||
},
|
||||
WebGPURequest::DestroyBuffer(buffer) => {
|
||||
let global = &self.global;
|
||||
gfx_select!(buffer => global.buffer_drop(buffer, false));
|
||||
let _result = gfx_select!(buffer => global.buffer_destroy(buffer));
|
||||
},
|
||||
WebGPURequest::DestroyDevice(device) => {
|
||||
let global = &self.global;
|
||||
gfx_select!(device => global.device_drop(device));
|
||||
gfx_select!(device => global.device_destroy(device));
|
||||
},
|
||||
WebGPURequest::DestroySwapChain {
|
||||
external_id,
|
||||
|
@ -838,9 +857,13 @@ impl<'a> WGPU<'a> {
|
|||
self.webrender_api
|
||||
.send_transaction(self.webrender_document, txn);
|
||||
},
|
||||
WebGPURequest::DestroyTexture(texture) => {
|
||||
WebGPURequest::DestroyTexture {
|
||||
device_id,
|
||||
texture_id,
|
||||
} => {
|
||||
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) => {
|
||||
if let Err(e) = sender.send(()) {
|
||||
|
@ -848,12 +871,17 @@ impl<'a> WGPU<'a> {
|
|||
}
|
||||
break;
|
||||
},
|
||||
WebGPURequest::FreeCommandBuffer(command_buffer_id) => {
|
||||
WebGPURequest::DropCommandBuffer(id) => {
|
||||
self.error_command_encoders
|
||||
.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 pipeline_id = self.devices.remove(&device).unwrap();
|
||||
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);
|
||||
}
|
||||
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 {
|
||||
render_bundle_encoder,
|
||||
|
@ -874,7 +907,7 @@ impl<'a> WGPU<'a> {
|
|||
gfx_select!(render_bundle_id => global.render_bundle_encoder_finish(
|
||||
render_bundle_encoder,
|
||||
&descriptor,
|
||||
render_bundle_id
|
||||
Some(render_bundle_id)
|
||||
)),
|
||||
);
|
||||
|
||||
|
@ -885,10 +918,10 @@ impl<'a> WGPU<'a> {
|
|||
options,
|
||||
ids,
|
||||
} => {
|
||||
let adapter_id = match self.global.request_adapter(
|
||||
&options,
|
||||
wgpu::instance::AdapterInputs::IdSet(&ids, |id| id.backend()),
|
||||
) {
|
||||
let adapter_id = match self
|
||||
.global
|
||||
.request_adapter(&options, wgpu::instance::AdapterInputs::IdSet(&ids))
|
||||
{
|
||||
Ok(id) => id,
|
||||
Err(w) => {
|
||||
if let Err(e) = sender.send(Some(Err(format!("{:?}", w)))) {
|
||||
|
@ -932,20 +965,18 @@ impl<'a> WGPU<'a> {
|
|||
} => {
|
||||
let desc = DeviceDescriptor {
|
||||
label: descriptor.label.as_ref().map(crate::Cow::from),
|
||||
features: descriptor.features,
|
||||
limits: descriptor.limits.clone(),
|
||||
required_features: descriptor.required_features,
|
||||
required_limits: descriptor.required_limits.clone(),
|
||||
};
|
||||
let global = &self.global;
|
||||
let id = match tuple_to_result(
|
||||
gfx_select!(device_id => global.adapter_request_device(
|
||||
adapter_id.0,
|
||||
&desc,
|
||||
None,
|
||||
device_id
|
||||
)),
|
||||
) {
|
||||
Ok(id) => id,
|
||||
Err(e) => {
|
||||
let (device_id, queue_id) = match gfx_select!(device_id => global.adapter_request_device(
|
||||
adapter_id.0,
|
||||
&desc,
|
||||
None,
|
||||
Some(device_id),
|
||||
Some(device_id.transmute()),
|
||||
)) {
|
||||
(_, _, Some(e)) => {
|
||||
if let Err(w) = sender.send(Some(Err(format!("{:?}", e)))) {
|
||||
warn!(
|
||||
"Failed to send response to WebGPURequest::RequestDevice ({})",
|
||||
|
@ -954,11 +985,10 @@ impl<'a> WGPU<'a> {
|
|||
}
|
||||
break;
|
||||
},
|
||||
(device_id, queue_id, None) => (device_id, queue_id),
|
||||
};
|
||||
let device = WebGPUDevice(id);
|
||||
// Note: (zakorgy) Note sure if sending the queue is needed at all,
|
||||
// since wgpu-core uses the same id for the device and the queue
|
||||
let queue = WebGPUQueue(id);
|
||||
let device = WebGPUDevice(device_id);
|
||||
let queue = WebGPUQueue(queue_id);
|
||||
self.devices.insert(device, pipeline_id);
|
||||
if let Err(e) = sender.send(Some(Ok(WebGPUResponse::RequestDevice {
|
||||
device_id: device,
|
||||
|
@ -1006,16 +1036,18 @@ impl<'a> WGPU<'a> {
|
|||
command_buffers,
|
||||
} => {
|
||||
let global = &self.global;
|
||||
let cmd_id = command_buffers
|
||||
.iter()
|
||||
.find(|id| self.error_command_encoders.borrow().contains_key(id));
|
||||
let cmd_id = command_buffers.iter().find(|id| {
|
||||
self.error_command_encoders
|
||||
.borrow()
|
||||
.contains_key(&id.transmute())
|
||||
});
|
||||
let result = if cmd_id.is_some() {
|
||||
Err(String::from("Invalid command buffer submitted"))
|
||||
} else {
|
||||
gfx_select!(queue_id => global.queue_submit(queue_id, &command_buffers))
|
||||
.map_err(|e| format!("{:?}", e))
|
||||
};
|
||||
self.send_result(queue_id, scope_id, result);
|
||||
self.send_result(queue_id.transmute(), scope_id, result);
|
||||
},
|
||||
WebGPURequest::SwapChainPresent {
|
||||
external_id,
|
||||
|
@ -1054,7 +1086,7 @@ impl<'a> WGPU<'a> {
|
|||
let _ = gfx_select!(b_id => global.device_create_buffer(
|
||||
device_id,
|
||||
&buffer_desc,
|
||||
b_id
|
||||
Some(b_id)
|
||||
));
|
||||
b_id
|
||||
} else {
|
||||
|
@ -1077,7 +1109,7 @@ impl<'a> WGPU<'a> {
|
|||
let _ = gfx_select!(encoder_id => global.device_create_command_encoder(
|
||||
device_id,
|
||||
&comm_desc,
|
||||
encoder_id
|
||||
Some(encoder_id)
|
||||
));
|
||||
|
||||
let buffer_cv = ImageCopyBuffer {
|
||||
|
@ -1111,7 +1143,7 @@ impl<'a> WGPU<'a> {
|
|||
));
|
||||
let _ = gfx_select!(queue_id => global.queue_submit(
|
||||
queue_id,
|
||||
&[encoder_id]
|
||||
&[encoder_id.transmute()]
|
||||
));
|
||||
|
||||
let map_info = BufferMapInfo {
|
||||
|
@ -1151,12 +1183,12 @@ impl<'a> WGPU<'a> {
|
|||
let map_op = BufferMapOperation {
|
||||
host: HostMap::Read,
|
||||
callback: unsafe {
|
||||
BufferMapCallback::from_c(BufferMapCallbackC {
|
||||
Some(BufferMapCallback::from_c(BufferMapCallbackC {
|
||||
callback,
|
||||
user_data: convert_to_pointer(
|
||||
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));
|
||||
|
@ -1235,7 +1267,7 @@ impl<'a> WGPU<'a> {
|
|||
buffer_offset as wgt::BufferAddress,
|
||||
&data
|
||||
));
|
||||
self.send_result(queue_id, scope_id, result);
|
||||
self.send_result(queue_id.transmute(), scope_id, result);
|
||||
},
|
||||
WebGPURequest::WriteTexture {
|
||||
queue_id,
|
||||
|
@ -1253,7 +1285,7 @@ impl<'a> WGPU<'a> {
|
|||
&data_layout,
|
||||
&size
|
||||
));
|
||||
self.send_result(queue_id, scope_id, result);
|
||||
self.send_result(queue_id.transmute(), scope_id, result);
|
||||
},
|
||||
WebGPURequest::QueueOnSubmittedWorkDone { sender, queue_id } => {
|
||||
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));
|
||||
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-shared",
|
||||
"metal",
|
||||
"raw-window-handle",
|
||||
|
||||
# Duplicated by indexmap.
|
||||
"hashbrown",
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,3 @@
|
|||
[canvas_composite_alpha_bgra8unorm_opaque_copy.https.html]
|
||||
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