mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
webgpu: Update wgpu and revamp computepass (#32575)
* Do not wait on drop, but rather wake poller thread * Update wgpu and render stuff * Set some good expectations * Update wgpu again * handle IPC error as warning * More good expectations * Some more expectations CTS does not match the spec: https://github.com/gpuweb/cts/issues/3806 * This expectations are due to other changes in servo also happening on main * Explain error_command_encoders and remove RefCell around it * fixup * store validness of passes * More good expectations * More docs * this assert is wrong * This is even more right per CTS/spec Only Command encoder state errors are allowed here, but wgpu does not exposes them. * More good expectations * One bad expectation * Fix my english
This commit is contained in:
parent
fced0b4940
commit
e9cf4d4971
16 changed files with 372 additions and 1870 deletions
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -214,11 +214,11 @@ checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b"
|
|||
|
||||
[[package]]
|
||||
name = "ash"
|
||||
version = "0.37.3+1.3.251"
|
||||
version = "0.38.0+1.3.281"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a"
|
||||
checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
|
||||
dependencies = [
|
||||
"libloading 0.7.4",
|
||||
"libloading 0.8.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1176,10 +1176,10 @@ checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
|
|||
[[package]]
|
||||
name = "d3d12"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=d0a5e48aa7e84683114c3870051cc414ae92ac03#d0a5e48aa7e84683114c3870051cc414ae92ac03"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=1e784c9c0af7a785b62e3b6840ed012a7477520f#1e784c9c0af7a785b62e3b6840ed012a7477520f"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"libloading 0.8.4",
|
||||
"libloading 0.7.4",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -2261,9 +2261,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glutin_wgl_sys"
|
||||
version = "0.5.0"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead"
|
||||
checksum = "0a4e1951bbd9434a81aa496fe59ccc2235af3820d27b85f9314e279609211e2c"
|
||||
dependencies = [
|
||||
"gl_generator",
|
||||
]
|
||||
|
@ -4003,7 +4003,7 @@ checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0"
|
|||
[[package]]
|
||||
name = "naga"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=d0a5e48aa7e84683114c3870051cc414ae92ac03#d0a5e48aa7e84683114c3870051cc414ae92ac03"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=1e784c9c0af7a785b62e3b6840ed012a7477520f#1e784c9c0af7a785b62e3b6840ed012a7477520f"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-set",
|
||||
|
@ -4012,7 +4012,6 @@ dependencies = [
|
|||
"hexf-parse",
|
||||
"indexmap",
|
||||
"log",
|
||||
"num-traits",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"spirv",
|
||||
|
@ -7295,7 +7294,7 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
|
|||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=d0a5e48aa7e84683114c3870051cc414ae92ac03#d0a5e48aa7e84683114c3870051cc414ae92ac03"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=1e784c9c0af7a785b62e3b6840ed012a7477520f#1e784c9c0af7a785b62e3b6840ed012a7477520f"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-vec",
|
||||
|
@ -7313,7 +7312,6 @@ dependencies = [
|
|||
"serde",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"web-sys",
|
||||
"wgpu-hal",
|
||||
"wgpu-types",
|
||||
]
|
||||
|
@ -7321,7 +7319,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-hal"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=d0a5e48aa7e84683114c3870051cc414ae92ac03#d0a5e48aa7e84683114c3870051cc414ae92ac03"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=1e784c9c0af7a785b62e3b6840ed012a7477520f#1e784c9c0af7a785b62e3b6840ed012a7477520f"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"arrayvec",
|
||||
|
@ -7339,7 +7337,7 @@ dependencies = [
|
|||
"js-sys",
|
||||
"khronos-egl",
|
||||
"libc",
|
||||
"libloading 0.8.4",
|
||||
"libloading 0.7.4",
|
||||
"log",
|
||||
"metal 0.28.0",
|
||||
"naga",
|
||||
|
@ -7362,7 +7360,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=d0a5e48aa7e84683114c3870051cc414ae92ac03#d0a5e48aa7e84683114c3870051cc414ae92ac03"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=1e784c9c0af7a785b62e3b6840ed012a7477520f#1e784c9c0af7a785b62e3b6840ed012a7477520f"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"js-sys",
|
||||
|
|
|
@ -136,8 +136,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 = { git = "https://github.com/gfx-rs/wgpu", rev = "d0a5e48aa7e84683114c3870051cc414ae92ac03" }
|
||||
wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "d0a5e48aa7e84683114c3870051cc414ae92ac03" }
|
||||
wgpu-core = { git = "https://github.com/gfx-rs/wgpu", rev = "1e784c9c0af7a785b62e3b6840ed012a7477520f" }
|
||||
wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "1e784c9c0af7a785b62e3b6840ed012a7477520f" }
|
||||
windows-sys = "0.52"
|
||||
xi-unicode = "0.1.0"
|
||||
xml5ever = "0.18"
|
||||
|
|
|
@ -64,7 +64,6 @@ use crate::dom::bindings::str::{DOMString, USVString};
|
|||
use crate::dom::bindings::utils::WindowProxyHandler;
|
||||
use crate::dom::gpubuffer::GPUBufferState;
|
||||
use crate::dom::gpucanvascontext::WebGPUContextId;
|
||||
use crate::dom::gpucommandencoder::GPUCommandEncoderState;
|
||||
use crate::dom::htmlimageelement::SourceSet;
|
||||
use crate::dom::htmlmediaelement::HTMLMediaElementFetchContext;
|
||||
use crate::script_runtime::{ContextForRequestInterrupt, StreamConsumer};
|
||||
|
@ -371,7 +370,6 @@ unsafe_no_jsmanaged_fields!(DOMString);
|
|||
unsafe_no_jsmanaged_fields!(USVString);
|
||||
unsafe_no_jsmanaged_fields!(WebGPUContextId);
|
||||
unsafe_no_jsmanaged_fields!(GPUBufferState);
|
||||
unsafe_no_jsmanaged_fields!(GPUCommandEncoderState);
|
||||
unsafe_no_jsmanaged_fields!(SourceSet);
|
||||
unsafe_no_jsmanaged_fields!(HTMLMediaElementFetchContext);
|
||||
unsafe_no_jsmanaged_fields!(StreamConsumer);
|
||||
|
|
|
@ -8,8 +8,9 @@ use std::collections::HashSet;
|
|||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::wgc::command as wgpu_com;
|
||||
use webgpu::{self, wgt, WebGPU, WebGPURequest};
|
||||
use webgpu::{self, wgt, WebGPU, WebGPUComputePass, WebGPURequest};
|
||||
|
||||
use super::gpuconvert::convert_label;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
||||
GPUCommandBufferDescriptor, GPUCommandEncoderMethods, GPUComputePassDescriptor, GPUExtent3D,
|
||||
|
@ -31,16 +32,6 @@ use crate::dom::gpuconvert::{
|
|||
use crate::dom::gpudevice::GPUDevice;
|
||||
use crate::dom::gpurenderpassencoder::GPURenderPassEncoder;
|
||||
|
||||
// TODO(sagudev): this is different now
|
||||
// https://gpuweb.github.io/gpuweb/#enumdef-encoder-state
|
||||
#[derive(MallocSizeOf, PartialEq)]
|
||||
pub enum GPUCommandEncoderState {
|
||||
Open,
|
||||
EncodingRenderPass,
|
||||
EncodingComputePass,
|
||||
Closed,
|
||||
}
|
||||
|
||||
#[dom_struct]
|
||||
pub struct GPUCommandEncoder {
|
||||
reflector_: Reflector,
|
||||
|
@ -51,7 +42,6 @@ pub struct GPUCommandEncoder {
|
|||
#[no_trace]
|
||||
encoder: webgpu::WebGPUCommandEncoder,
|
||||
buffers: DomRefCell<HashSet<DomRoot<GPUBuffer>>>,
|
||||
state: DomRefCell<GPUCommandEncoderState>,
|
||||
device: Dom<GPUDevice>,
|
||||
valid: Cell<bool>,
|
||||
}
|
||||
|
@ -70,7 +60,6 @@ impl GPUCommandEncoder {
|
|||
device: Dom::from_ref(device),
|
||||
encoder,
|
||||
buffers: DomRefCell::new(HashSet::new()),
|
||||
state: DomRefCell::new(GPUCommandEncoderState::Open),
|
||||
valid: Cell::new(true),
|
||||
}
|
||||
}
|
||||
|
@ -96,13 +85,8 @@ impl GPUCommandEncoder {
|
|||
self.encoder
|
||||
}
|
||||
|
||||
pub fn set_state(&self, set: GPUCommandEncoderState, expect: GPUCommandEncoderState) {
|
||||
if *self.state.borrow() == expect {
|
||||
*self.state.borrow_mut() = set;
|
||||
} else {
|
||||
self.valid.set(false);
|
||||
*self.state.borrow_mut() = GPUCommandEncoderState::Closed;
|
||||
}
|
||||
pub fn device_id(&self) -> webgpu::WebGPUDevice {
|
||||
self.device.id()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,32 +106,26 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
&self,
|
||||
descriptor: &GPUComputePassDescriptor,
|
||||
) -> DomRoot<GPUComputePassEncoder> {
|
||||
self.set_state(
|
||||
GPUCommandEncoderState::EncodingComputePass,
|
||||
GPUCommandEncoderState::Open,
|
||||
);
|
||||
let compute_pass_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_compute_pass_id(self.device.id().0.backend());
|
||||
|
||||
let compute_pass = if !self.valid.get() {
|
||||
None
|
||||
} else {
|
||||
Some(wgpu_com::ComputePass::new(
|
||||
self.encoder.0,
|
||||
&wgpu_com::ComputePassDescriptor {
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|l| Cow::Borrowed(&**l)),
|
||||
timestamp_writes: None,
|
||||
},
|
||||
))
|
||||
};
|
||||
if let Err(e) = self.channel.0.send(WebGPURequest::BeginComputePass {
|
||||
command_encoder_id: self.id().0,
|
||||
compute_pass_id,
|
||||
label: convert_label(&descriptor.parent),
|
||||
device_id: self.device.id().0,
|
||||
}) {
|
||||
warn!("Failed to send WebGPURequest::BeginComputePass {e:?}");
|
||||
}
|
||||
|
||||
GPUComputePassEncoder::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
self,
|
||||
compute_pass,
|
||||
WebGPUComputePass(compute_pass_id),
|
||||
descriptor.parent.label.clone().unwrap_or_default(),
|
||||
)
|
||||
}
|
||||
|
@ -157,11 +135,6 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
&self,
|
||||
descriptor: &GPURenderPassDescriptor,
|
||||
) -> DomRoot<GPURenderPassEncoder> {
|
||||
self.set_state(
|
||||
GPUCommandEncoderState::EncodingRenderPass,
|
||||
GPUCommandEncoderState::Open,
|
||||
);
|
||||
|
||||
let render_pass = if !self.valid.get() {
|
||||
None
|
||||
} else {
|
||||
|
@ -259,11 +232,6 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
destination_offset: GPUSize64,
|
||||
size: GPUSize64,
|
||||
) {
|
||||
if !(*self.state.borrow() == GPUCommandEncoderState::Open) {
|
||||
self.valid.set(false);
|
||||
return;
|
||||
}
|
||||
|
||||
self.buffers.borrow_mut().insert(DomRoot::from_ref(source));
|
||||
self.buffers
|
||||
.borrow_mut()
|
||||
|
@ -288,11 +256,6 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
destination: &GPUImageCopyTexture,
|
||||
copy_size: GPUExtent3D,
|
||||
) {
|
||||
if !(*self.state.borrow() == GPUCommandEncoderState::Open) {
|
||||
self.valid.set(false);
|
||||
return;
|
||||
}
|
||||
|
||||
self.buffers
|
||||
.borrow_mut()
|
||||
.insert(DomRoot::from_ref(&*source.buffer));
|
||||
|
@ -315,11 +278,6 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
destination: &GPUImageCopyBuffer,
|
||||
copy_size: GPUExtent3D,
|
||||
) {
|
||||
if !(*self.state.borrow() == GPUCommandEncoderState::Open) {
|
||||
self.valid.set(false);
|
||||
return;
|
||||
}
|
||||
|
||||
self.buffers
|
||||
.borrow_mut()
|
||||
.insert(DomRoot::from_ref(&*destination.buffer));
|
||||
|
@ -342,11 +300,6 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
destination: &GPUImageCopyTexture,
|
||||
copy_size: GPUExtent3D,
|
||||
) {
|
||||
if !(*self.state.borrow() == GPUCommandEncoderState::Open) {
|
||||
self.valid.set(false);
|
||||
return;
|
||||
}
|
||||
|
||||
self.channel
|
||||
.0
|
||||
.send(WebGPURequest::CopyTextureToTexture {
|
||||
|
@ -371,7 +324,6 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
})
|
||||
.expect("Failed to send Finish");
|
||||
|
||||
*self.state.borrow_mut() = GPUCommandEncoderState::Closed;
|
||||
let buffer = webgpu::WebGPUCommandBuffer(self.encoder.0.into_command_buffer_id());
|
||||
GPUCommandBuffer::new(
|
||||
&self.global(),
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::wgc::command::{compute_commands as wgpu_comp, ComputePass};
|
||||
use webgpu::{WebGPU, WebGPURequest};
|
||||
use webgpu::{WebGPU, WebGPUComputePass, WebGPURequest};
|
||||
|
||||
use super::bindings::error::Fallible;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
|
@ -15,7 +14,7 @@ use crate::dom::bindings::str::USVString;
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::gpubindgroup::GPUBindGroup;
|
||||
use crate::dom::gpubuffer::GPUBuffer;
|
||||
use crate::dom::gpucommandencoder::{GPUCommandEncoder, GPUCommandEncoderState};
|
||||
use crate::dom::gpucommandencoder::GPUCommandEncoder;
|
||||
use crate::dom::gpucomputepipeline::GPUComputePipeline;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -25,9 +24,8 @@ pub struct GPUComputePassEncoder {
|
|||
#[no_trace]
|
||||
channel: WebGPU,
|
||||
label: DomRefCell<USVString>,
|
||||
#[ignore_malloc_size_of = "defined in wgpu-core"]
|
||||
#[no_trace]
|
||||
compute_pass: DomRefCell<Option<ComputePass>>,
|
||||
compute_pass: WebGPUComputePass,
|
||||
command_encoder: Dom<GPUCommandEncoder>,
|
||||
}
|
||||
|
||||
|
@ -35,14 +33,14 @@ impl GPUComputePassEncoder {
|
|||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
parent: &GPUCommandEncoder,
|
||||
compute_pass: Option<ComputePass>,
|
||||
compute_pass: WebGPUComputePass,
|
||||
label: USVString,
|
||||
) -> Self {
|
||||
Self {
|
||||
channel,
|
||||
reflector_: Reflector::new(),
|
||||
label: DomRefCell::new(label),
|
||||
compute_pass: DomRefCell::new(compute_pass),
|
||||
compute_pass,
|
||||
command_encoder: Dom::from_ref(parent),
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +49,7 @@ impl GPUComputePassEncoder {
|
|||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
parent: &GPUCommandEncoder,
|
||||
compute_pass: Option<ComputePass>,
|
||||
compute_pass: WebGPUComputePass,
|
||||
label: USVString,
|
||||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
|
@ -79,57 +77,83 @@ impl GPUComputePassEncoderMethods for GPUComputePassEncoder {
|
|||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpucomputepassencoder-dispatchworkgroups>
|
||||
fn DispatchWorkgroups(&self, x: u32, y: u32, z: u32) {
|
||||
if let Some(compute_pass) = self.compute_pass.borrow_mut().as_mut() {
|
||||
wgpu_comp::wgpu_compute_pass_dispatch_workgroups(compute_pass, x, y, z);
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send(WebGPURequest::ComputePassDispatchWorkgroups {
|
||||
compute_pass_id: self.compute_pass.0,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
device_id: self.command_encoder.device_id().0,
|
||||
})
|
||||
{
|
||||
warn!("Error sending WebGPURequest::ComputePassDispatchWorkgroups: {e:?}")
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpucomputepassencoder-dispatchworkgroupsindirect>
|
||||
fn DispatchWorkgroupsIndirect(&self, indirect_buffer: &GPUBuffer, indirect_offset: u64) {
|
||||
if let Some(compute_pass) = self.compute_pass.borrow_mut().as_mut() {
|
||||
wgpu_comp::wgpu_compute_pass_dispatch_workgroups_indirect(
|
||||
compute_pass,
|
||||
indirect_buffer.id().0,
|
||||
indirect_offset,
|
||||
);
|
||||
fn DispatchWorkgroupsIndirect(&self, buffer: &GPUBuffer, offset: u64) {
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send(WebGPURequest::ComputePassDispatchWorkgroupsIndirect {
|
||||
compute_pass_id: self.compute_pass.0,
|
||||
buffer_id: buffer.id().0,
|
||||
offset,
|
||||
device_id: self.command_encoder.device_id().0,
|
||||
})
|
||||
{
|
||||
warn!("Error sending WebGPURequest::ComputePassDispatchWorkgroupsIndirect: {e:?}")
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-endpass>
|
||||
fn End(&self) -> Fallible<()> {
|
||||
let compute_pass = self.compute_pass.borrow_mut().take();
|
||||
self.channel
|
||||
.0
|
||||
.send(WebGPURequest::RunComputePass {
|
||||
command_encoder_id: self.command_encoder.id().0,
|
||||
compute_pass,
|
||||
})
|
||||
.expect("Failed to send RunComputePass"); //TODO: handle error
|
||||
|
||||
self.command_encoder.set_state(
|
||||
GPUCommandEncoderState::Open,
|
||||
GPUCommandEncoderState::EncodingComputePass,
|
||||
);
|
||||
if let Err(e) = self.channel.0.send(WebGPURequest::EndComputePass {
|
||||
compute_pass_id: self.compute_pass.0,
|
||||
device_id: self.command_encoder.device_id().0,
|
||||
command_encoder_id: self.command_encoder.id().0,
|
||||
}) {
|
||||
warn!("Failed to send WebGPURequest::EndComputePass: {e:?}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpuprogrammablepassencoder-setbindgroup>
|
||||
#[allow(unsafe_code)]
|
||||
fn SetBindGroup(&self, index: u32, bind_group: &GPUBindGroup, dynamic_offsets: Vec<u32>) {
|
||||
if let Some(compute_pass) = self.compute_pass.borrow_mut().as_mut() {
|
||||
wgpu_comp::wgpu_compute_pass_set_bind_group(
|
||||
compute_pass,
|
||||
index,
|
||||
bind_group.id().0,
|
||||
&dynamic_offsets,
|
||||
)
|
||||
fn SetBindGroup(&self, index: u32, bind_group: &GPUBindGroup, offsets: Vec<u32>) {
|
||||
if let Err(e) = self.channel.0.send(WebGPURequest::ComputePassSetBindGroup {
|
||||
compute_pass_id: self.compute_pass.0,
|
||||
index,
|
||||
bind_group_id: bind_group.id().0,
|
||||
offsets,
|
||||
device_id: self.command_encoder.device_id().0,
|
||||
}) {
|
||||
warn!("Error sending WebGPURequest::ComputePassSetBindGroup: {e:?}")
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpucomputepassencoder-setpipeline>
|
||||
fn SetPipeline(&self, pipeline: &GPUComputePipeline) {
|
||||
if let Some(compute_pass) = self.compute_pass.borrow_mut().as_mut() {
|
||||
wgpu_comp::wgpu_compute_pass_set_pipeline(compute_pass, pipeline.id().0);
|
||||
if let Err(e) = self.channel.0.send(WebGPURequest::ComputePassSetPipeline {
|
||||
compute_pass_id: self.compute_pass.0,
|
||||
pipeline_id: pipeline.id().0,
|
||||
device_id: self.command_encoder.device_id().0,
|
||||
}) {
|
||||
warn!("Error sending WebGPURequest::ComputePassSetPipeline: {e:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GPUComputePassEncoder {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send(WebGPURequest::DropComputePass(self.compute_pass.0))
|
||||
{
|
||||
warn!("Failed to send WebGPURequest::DropComputePass with {e:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -586,7 +586,9 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
entry_point: Some(Cow::Owned(descriptor.compute.entryPoint.to_string())),
|
||||
constants: Cow::Owned(HashMap::new()),
|
||||
zero_initialize_workgroup_memory: true,
|
||||
vertex_pulling_transform: false,
|
||||
},
|
||||
cache: None,
|
||||
};
|
||||
|
||||
self.channel
|
||||
|
@ -769,6 +771,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
Some(wgpu_pipe::RenderPipelineDescriptor {
|
||||
label: convert_label(&descriptor.parent.parent),
|
||||
layout,
|
||||
cache: None,
|
||||
vertex: wgpu_pipe::VertexState {
|
||||
stage: wgpu_pipe::ProgrammableStageDescriptor {
|
||||
module: descriptor.vertex.parent.module.id().0,
|
||||
|
@ -777,6 +780,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
)),
|
||||
constants: Cow::Owned(HashMap::new()),
|
||||
zero_initialize_workgroup_memory: true,
|
||||
vertex_pulling_transform: false,
|
||||
},
|
||||
buffers: Cow::Owned(
|
||||
descriptor
|
||||
|
@ -813,6 +817,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
entry_point: Some(Cow::Owned(stage.parent.entryPoint.to_string())),
|
||||
constants: Cow::Owned(HashMap::new()),
|
||||
zero_initialize_workgroup_memory: true,
|
||||
vertex_pulling_transform: false,
|
||||
},
|
||||
targets: Cow::Owned(
|
||||
stage
|
||||
|
|
|
@ -19,7 +19,7 @@ use crate::dom::bindings::str::USVString;
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::gpubindgroup::GPUBindGroup;
|
||||
use crate::dom::gpubuffer::GPUBuffer;
|
||||
use crate::dom::gpucommandencoder::{GPUCommandEncoder, GPUCommandEncoderState};
|
||||
use crate::dom::gpucommandencoder::GPUCommandEncoder;
|
||||
use crate::dom::gpurenderbundle::GPURenderBundle;
|
||||
use crate::dom::gpurenderpipeline::GPURenderPipeline;
|
||||
|
||||
|
@ -164,16 +164,12 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
|
|||
let render_pass = self.render_pass.borrow_mut().take();
|
||||
self.channel
|
||||
.0
|
||||
.send(WebGPURequest::RunRenderPass {
|
||||
command_encoder_id: self.command_encoder.id().0,
|
||||
.send(WebGPURequest::EndRenderPass {
|
||||
render_pass,
|
||||
device_id: self.command_encoder.device_id().0,
|
||||
})
|
||||
.expect("Failed to send RunRenderPass");
|
||||
|
||||
self.command_encoder.set_state(
|
||||
GPUCommandEncoderState::Open,
|
||||
GPUCommandEncoderState::EncodingRenderPass,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use smallvec::SmallVec;
|
||||
use webgpu::identity::{ComputePass, ComputePassId};
|
||||
use webgpu::wgc::id::markers::{
|
||||
Adapter, BindGroup, BindGroupLayout, Buffer, CommandEncoder, ComputePipeline, Device,
|
||||
PipelineLayout, RenderBundle, RenderPipeline, Sampler, ShaderModule, Texture, TextureView,
|
||||
|
@ -31,6 +32,7 @@ pub struct IdentityHub {
|
|||
samplers: IdentityManager<Sampler>,
|
||||
render_pipelines: IdentityManager<RenderPipeline>,
|
||||
render_bundles: IdentityManager<RenderBundle>,
|
||||
compute_passes: IdentityManager<ComputePass>,
|
||||
}
|
||||
|
||||
impl IdentityHub {
|
||||
|
@ -50,6 +52,7 @@ impl IdentityHub {
|
|||
samplers: IdentityManager::new(),
|
||||
render_pipelines: IdentityManager::new(),
|
||||
render_bundles: IdentityManager::new(),
|
||||
compute_passes: IdentityManager::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,6 +228,14 @@ impl Identities {
|
|||
pub fn kill_render_bundle_id(&mut self, id: RenderBundleId) {
|
||||
self.select(id.backend()).render_bundles.free(id);
|
||||
}
|
||||
|
||||
pub fn create_compute_pass_id(&mut self, backend: Backend) -> ComputePassId {
|
||||
self.select(backend).compute_passes.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_compute_pass_id(&mut self, id: ComputePassId) {
|
||||
self.select(id.backend()).compute_passes.free(id);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Identities {
|
||||
|
|
|
@ -2450,6 +2450,7 @@ impl ScriptThread {
|
|||
WebGPUMsg::FreeRenderPipeline(id) => self.gpu_id_hub.lock().kill_render_pipeline_id(id),
|
||||
WebGPUMsg::FreeTexture(id) => self.gpu_id_hub.lock().kill_texture_id(id),
|
||||
WebGPUMsg::FreeTextureView(id) => self.gpu_id_hub.lock().kill_texture_view_id(id),
|
||||
WebGPUMsg::FreeComputePass(id) => self.gpu_id_hub.lock().kill_compute_pass_id(id),
|
||||
WebGPUMsg::Exit => *self.webgpu_port.borrow_mut() = None,
|
||||
WebGPUMsg::DeviceLost {
|
||||
pipeline_id,
|
||||
|
|
|
@ -16,8 +16,7 @@ use wgc::binding_model::{
|
|||
BindGroupDescriptor, BindGroupLayoutDescriptor, PipelineLayoutDescriptor,
|
||||
};
|
||||
use wgc::command::{
|
||||
ComputePass, ImageCopyBuffer, ImageCopyTexture, RenderBundleDescriptor, RenderBundleEncoder,
|
||||
RenderPass,
|
||||
ImageCopyBuffer, ImageCopyTexture, RenderBundleDescriptor, RenderBundleEncoder, RenderPass,
|
||||
};
|
||||
use wgc::device::HostMap;
|
||||
use wgc::id;
|
||||
|
@ -191,6 +190,7 @@ pub enum WebGPURequest {
|
|||
DropShaderModule(id::ShaderModuleId),
|
||||
DropRenderBundle(id::RenderBundleId),
|
||||
DropQuerySet(id::QuerySetId),
|
||||
DropComputePass(id::ComputePassEncoderId),
|
||||
Exit(IpcSender<()>),
|
||||
RenderBundleEncoderFinish {
|
||||
render_bundle_encoder: RenderBundleEncoder,
|
||||
|
@ -210,13 +210,45 @@ pub enum WebGPURequest {
|
|||
device_id: id::DeviceId,
|
||||
pipeline_id: PipelineId,
|
||||
},
|
||||
RunComputePass {
|
||||
BeginComputePass {
|
||||
command_encoder_id: id::CommandEncoderId,
|
||||
compute_pass: Option<ComputePass>,
|
||||
compute_pass_id: ComputePassId,
|
||||
label: Option<Cow<'static, str>>,
|
||||
device_id: id::DeviceId,
|
||||
},
|
||||
RunRenderPass {
|
||||
ComputePassSetPipeline {
|
||||
compute_pass_id: ComputePassId,
|
||||
pipeline_id: id::ComputePipelineId,
|
||||
device_id: id::DeviceId,
|
||||
},
|
||||
ComputePassSetBindGroup {
|
||||
compute_pass_id: ComputePassId,
|
||||
index: u32,
|
||||
bind_group_id: id::BindGroupId,
|
||||
offsets: Vec<u32>,
|
||||
device_id: id::DeviceId,
|
||||
},
|
||||
ComputePassDispatchWorkgroups {
|
||||
compute_pass_id: ComputePassId,
|
||||
x: u32,
|
||||
y: u32,
|
||||
z: u32,
|
||||
device_id: id::DeviceId,
|
||||
},
|
||||
ComputePassDispatchWorkgroupsIndirect {
|
||||
compute_pass_id: ComputePassId,
|
||||
buffer_id: id::BufferId,
|
||||
offset: u64,
|
||||
device_id: id::DeviceId,
|
||||
},
|
||||
EndComputePass {
|
||||
compute_pass_id: ComputePassId,
|
||||
device_id: id::DeviceId,
|
||||
command_encoder_id: id::CommandEncoderId,
|
||||
},
|
||||
EndRenderPass {
|
||||
render_pass: Option<RenderPass>,
|
||||
device_id: id::DeviceId,
|
||||
},
|
||||
Submit {
|
||||
queue_id: id::QueueId,
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub use crate::wgc::id::markers::ComputePassEncoder as ComputePass;
|
||||
pub use crate::wgc::id::ComputePassEncoderId as ComputePassId;
|
||||
use crate::wgc::id::{
|
||||
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, CommandEncoderId,
|
||||
ComputePipelineId, DeviceId, PipelineLayoutId, QueueId, RenderBundleId, RenderPipelineId,
|
||||
|
@ -43,3 +45,4 @@ webgpu_resource!(WebGPUShaderModule, ShaderModuleId);
|
|||
webgpu_resource!(WebGPUSurface, SurfaceId);
|
||||
webgpu_resource!(WebGPUTexture, TextureId);
|
||||
webgpu_resource!(WebGPUTextureView, TextureViewId);
|
||||
webgpu_resource!(WebGPUComputePass, ComputePassId);
|
||||
|
|
|
@ -10,9 +10,9 @@ use serde::{Deserialize, Serialize};
|
|||
use crate::gpu_error::Error;
|
||||
use crate::identity::WebGPUDevice;
|
||||
use crate::wgc::id::{
|
||||
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, ComputePipelineId,
|
||||
DeviceId, PipelineLayoutId, QuerySetId, RenderBundleId, RenderPipelineId, SamplerId,
|
||||
ShaderModuleId, StagingBufferId, SurfaceId, TextureId, TextureViewId,
|
||||
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, ComputePassEncoderId,
|
||||
ComputePipelineId, DeviceId, PipelineLayoutId, QuerySetId, RenderBundleId, RenderPipelineId,
|
||||
SamplerId, ShaderModuleId, StagingBufferId, SurfaceId, TextureId, TextureViewId,
|
||||
};
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#enumdef-gpudevicelostreason>
|
||||
|
@ -44,6 +44,7 @@ pub enum WebGPUMsg {
|
|||
FreeRenderBundle(RenderBundleId),
|
||||
FreeStagingBuffer(StagingBufferId),
|
||||
FreeQuerySet(QuerySetId),
|
||||
FreeComputePass(ComputePassEncoderId),
|
||||
UncapturedError {
|
||||
device: WebGPUDevice,
|
||||
pipeline_id: PipelineId,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
//! Data and main loop of WebGPU thread.
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::slice;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
@ -26,14 +25,15 @@ use wgc::instance::parse_backends_from_comma_list;
|
|||
use wgc::pipeline::ShaderModuleDescriptor;
|
||||
use wgc::resource::{BufferMapCallback, BufferMapOperation};
|
||||
use wgc::{gfx_select, id};
|
||||
use wgpu_core::command::{ComputePassDescriptor, DynComputePass};
|
||||
use wgt::InstanceDescriptor;
|
||||
pub use {wgpu_core as wgc, wgpu_types as wgt};
|
||||
|
||||
use crate::gpu_error::ErrorScope;
|
||||
use crate::poll_thread::Poller;
|
||||
use crate::{
|
||||
Error, PopError, PresentationData, Transmute, WebGPU, WebGPUAdapter, WebGPUDevice, WebGPUMsg,
|
||||
WebGPUQueue, WebGPURequest, WebGPUResponse,
|
||||
ComputePassId, Error, PopError, PresentationData, Transmute, WebGPU, WebGPUAdapter,
|
||||
WebGPUDevice, WebGPUMsg, WebGPUQueue, WebGPURequest, WebGPUResponse,
|
||||
};
|
||||
|
||||
pub const PRESENTATION_BUFFER_COUNT: usize = 10;
|
||||
|
@ -73,13 +73,20 @@ pub(crate) struct WGPU {
|
|||
devices: Arc<Mutex<HashMap<DeviceId, DeviceScope>>>,
|
||||
// Track invalid adapters https://gpuweb.github.io/gpuweb/#invalid
|
||||
_invalid_adapters: Vec<WebGPUAdapter>,
|
||||
//TODO: Remove this (https://github.com/gfx-rs/wgpu/issues/867)
|
||||
error_command_encoders: RefCell<HashMap<id::CommandEncoderId, String>>,
|
||||
// TODO: Remove this (https://github.com/gfx-rs/wgpu/issues/867)
|
||||
/// This stores first error on command encoder,
|
||||
/// because wgpu does not invalidate command encoder object
|
||||
/// (this is also reused for invalidation of command buffers)
|
||||
error_command_encoders: HashMap<id::CommandEncoderId, String>,
|
||||
webrender_api: Arc<Mutex<RenderApi>>,
|
||||
webrender_document: DocumentId,
|
||||
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
|
||||
wgpu_image_map: Arc<Mutex<HashMap<u64, PresentationData>>>,
|
||||
/// Provides access to poller thread
|
||||
poller: Poller,
|
||||
/// Store compute passes (that have not ended yet) and their validity
|
||||
compute_passes: HashMap<ComputePassId, (Box<dyn DynComputePass>, bool)>,
|
||||
//render_passes: HashMap<RenderPassId, Box<dyn DynRenderPass>>,
|
||||
}
|
||||
|
||||
impl WGPU {
|
||||
|
@ -118,11 +125,12 @@ impl WGPU {
|
|||
adapters: Vec::new(),
|
||||
devices: Arc::new(Mutex::new(HashMap::new())),
|
||||
_invalid_adapters: Vec::new(),
|
||||
error_command_encoders: RefCell::new(HashMap::new()),
|
||||
error_command_encoders: HashMap::new(),
|
||||
webrender_api: Arc::new(Mutex::new(webrender_api_sender.create_api())),
|
||||
webrender_document,
|
||||
external_images,
|
||||
wgpu_image_map,
|
||||
compute_passes: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,13 +207,11 @@ impl WGPU {
|
|||
} => {
|
||||
let global = &self.global;
|
||||
let result = if is_error {
|
||||
Err(Error::Internal(String::from("Invalid GPUCommandEncoder")))
|
||||
} else if let Some(err) = self
|
||||
.error_command_encoders
|
||||
.borrow()
|
||||
.get(&command_encoder_id)
|
||||
Err(Error::Validation(String::from("Invalid GPUCommandEncoder")))
|
||||
} else if let Some(err) =
|
||||
self.error_command_encoders.get(&command_encoder_id)
|
||||
{
|
||||
Err(Error::Internal(err.clone()))
|
||||
Err(Error::Validation(err.clone()))
|
||||
} else if let Some(error) =
|
||||
gfx_select!(command_encoder_id => global.command_encoder_finish(
|
||||
command_encoder_id,
|
||||
|
@ -218,7 +224,9 @@ impl WGPU {
|
|||
Ok(())
|
||||
};
|
||||
|
||||
// invalidate command buffer too
|
||||
self.encoder_record_error(command_encoder_id, &result);
|
||||
// dispatch validation error
|
||||
self.maybe_dispatch_error(device_id, result.err());
|
||||
},
|
||||
WebGPURequest::CopyBufferToBuffer {
|
||||
|
@ -575,7 +583,6 @@ impl WGPU {
|
|||
},
|
||||
WebGPURequest::DropCommandBuffer(id) => {
|
||||
self.error_command_encoders
|
||||
.borrow_mut()
|
||||
.remove(&id.into_command_encoder_id());
|
||||
let global = &self.global;
|
||||
gfx_select!(id => global.command_buffer_drop(id));
|
||||
|
@ -745,35 +752,129 @@ impl WGPU {
|
|||
)
|
||||
}
|
||||
},
|
||||
WebGPURequest::RunComputePass {
|
||||
WebGPURequest::BeginComputePass {
|
||||
command_encoder_id,
|
||||
compute_pass,
|
||||
compute_pass_id,
|
||||
label,
|
||||
device_id: _device_id,
|
||||
} => {
|
||||
let global = &self.global;
|
||||
let result = if let Some(pass) = compute_pass {
|
||||
gfx_select!(command_encoder_id => global.command_encoder_run_compute_pass(
|
||||
let (pass, error) = gfx_select!(
|
||||
command_encoder_id => global.command_encoder_create_compute_pass_dyn(
|
||||
command_encoder_id,
|
||||
&pass
|
||||
)).map_err(|e| format!("{:?}", e))
|
||||
} else {
|
||||
Err(String::from("Invalid ComputePass"))
|
||||
};
|
||||
self.encoder_record_error(command_encoder_id, &result);
|
||||
&ComputePassDescriptor { label, timestamp_writes: None }
|
||||
));
|
||||
assert!(
|
||||
self.compute_passes
|
||||
.insert(compute_pass_id, (pass, error.is_none()))
|
||||
.is_none(),
|
||||
"ComputePass should not exist yet."
|
||||
);
|
||||
// TODO: Command encoder state errors
|
||||
// self.maybe_dispatch_wgpu_error(device_id, error);
|
||||
},
|
||||
WebGPURequest::RunRenderPass {
|
||||
command_encoder_id,
|
||||
render_pass,
|
||||
WebGPURequest::ComputePassSetPipeline {
|
||||
compute_pass_id,
|
||||
pipeline_id,
|
||||
device_id,
|
||||
} => {
|
||||
let global = &self.global;
|
||||
let result = if let Some(pass) = render_pass {
|
||||
gfx_select!(command_encoder_id => global.command_encoder_run_render_pass(
|
||||
command_encoder_id,
|
||||
&pass
|
||||
)).map_err(|e| format!("{:?}", e))
|
||||
if let Some((pass, valid)) = self.compute_passes.get_mut(&compute_pass_id) {
|
||||
*valid &= pass.set_pipeline(&self.global, pipeline_id).is_ok();
|
||||
} else {
|
||||
Err(String::from("Invalid RenderPass"))
|
||||
self.maybe_dispatch_error(
|
||||
device_id,
|
||||
Some(Error::Validation("pass already ended".to_string())),
|
||||
);
|
||||
};
|
||||
self.encoder_record_error(command_encoder_id, &result);
|
||||
},
|
||||
WebGPURequest::ComputePassSetBindGroup {
|
||||
compute_pass_id,
|
||||
index,
|
||||
bind_group_id,
|
||||
offsets,
|
||||
device_id,
|
||||
} => {
|
||||
if let Some((pass, valid)) = self.compute_passes.get_mut(&compute_pass_id) {
|
||||
*valid &= pass
|
||||
.set_bind_group(&self.global, index, bind_group_id, &offsets)
|
||||
.is_ok();
|
||||
} else {
|
||||
self.maybe_dispatch_error(
|
||||
device_id,
|
||||
Some(Error::Validation("pass already ended".to_string())),
|
||||
);
|
||||
};
|
||||
},
|
||||
WebGPURequest::ComputePassDispatchWorkgroups {
|
||||
compute_pass_id,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
device_id,
|
||||
} => {
|
||||
if let Some((pass, valid)) = self.compute_passes.get_mut(&compute_pass_id) {
|
||||
*valid &= pass.dispatch_workgroups(&self.global, x, y, z).is_ok();
|
||||
} else {
|
||||
self.maybe_dispatch_error(
|
||||
device_id,
|
||||
Some(Error::Validation("pass already ended".to_string())),
|
||||
);
|
||||
};
|
||||
},
|
||||
WebGPURequest::ComputePassDispatchWorkgroupsIndirect {
|
||||
compute_pass_id,
|
||||
buffer_id,
|
||||
offset,
|
||||
device_id,
|
||||
} => {
|
||||
if let Some((pass, valid)) = self.compute_passes.get_mut(&compute_pass_id) {
|
||||
*valid &= pass
|
||||
.dispatch_workgroups_indirect(&self.global, buffer_id, offset)
|
||||
.is_ok();
|
||||
} else {
|
||||
self.maybe_dispatch_error(
|
||||
device_id,
|
||||
Some(Error::Validation("pass already ended".to_string())),
|
||||
);
|
||||
};
|
||||
},
|
||||
WebGPURequest::EndComputePass {
|
||||
compute_pass_id,
|
||||
device_id,
|
||||
command_encoder_id,
|
||||
} => {
|
||||
// TODO: Command encoder state error
|
||||
if let Some((mut pass, valid)) =
|
||||
self.compute_passes.remove(&compute_pass_id)
|
||||
{
|
||||
if pass.end(&self.global).is_ok() && !valid {
|
||||
self.encoder_record_error(
|
||||
command_encoder_id,
|
||||
&Err::<(), _>("Pass is invalid".to_string()),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
self.dispatch_error(
|
||||
device_id,
|
||||
Error::Validation("pass already ended".to_string()),
|
||||
);
|
||||
};
|
||||
},
|
||||
WebGPURequest::EndRenderPass {
|
||||
render_pass,
|
||||
device_id,
|
||||
} => {
|
||||
if let Some(render_pass) = render_pass {
|
||||
let command_encoder_id = render_pass.parent_id();
|
||||
let global = &self.global;
|
||||
let result = gfx_select!(command_encoder_id => global.render_pass_end(&render_pass));
|
||||
self.maybe_dispatch_wgpu_error(device_id, result.err())
|
||||
} else {
|
||||
self.dispatch_error(
|
||||
device_id,
|
||||
Error::Validation("Render pass already ended".to_string()),
|
||||
)
|
||||
}
|
||||
},
|
||||
WebGPURequest::Submit {
|
||||
queue_id,
|
||||
|
@ -782,11 +883,10 @@ impl WGPU {
|
|||
let global = &self.global;
|
||||
let cmd_id = command_buffers.iter().find(|id| {
|
||||
self.error_command_encoders
|
||||
.borrow()
|
||||
.contains_key(&id.into_command_encoder_id())
|
||||
});
|
||||
let result = if cmd_id.is_some() {
|
||||
Err(Error::Internal(String::from(
|
||||
Err(Error::Validation(String::from(
|
||||
"Invalid command buffer submitted",
|
||||
)))
|
||||
} else {
|
||||
|
@ -1026,7 +1126,8 @@ impl WGPU {
|
|||
},
|
||||
WebGPURequest::DropTexture(id) => {
|
||||
let global = &self.global;
|
||||
gfx_select!(id => global.texture_drop(id, true));
|
||||
gfx_select!(id => global.texture_drop(id, false));
|
||||
self.poller.wake();
|
||||
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeTexture(id)) {
|
||||
warn!("Unable to send FreeTexture({:?}) ({:?})", id, e);
|
||||
};
|
||||
|
@ -1040,7 +1141,8 @@ impl WGPU {
|
|||
},
|
||||
WebGPURequest::DropBuffer(id) => {
|
||||
let global = &self.global;
|
||||
gfx_select!(id => global.buffer_drop(id, true));
|
||||
gfx_select!(id => global.buffer_drop(id, false));
|
||||
self.poller.wake();
|
||||
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBuffer(id)) {
|
||||
warn!("Unable to send FreeBuffer({:?}) ({:?})", id, e);
|
||||
};
|
||||
|
@ -1060,6 +1162,13 @@ impl WGPU {
|
|||
warn!("Unable to send FreeComputePipeline({:?}) ({:?})", id, e);
|
||||
};
|
||||
},
|
||||
WebGPURequest::DropComputePass(id) => {
|
||||
// Compute pass might have already ended
|
||||
self.compute_passes.remove(&id);
|
||||
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeComputePass(id)) {
|
||||
warn!("Unable to send FreeComputePass({:?}) ({:?})", id, e);
|
||||
};
|
||||
},
|
||||
WebGPURequest::DropRenderPipeline(id) => {
|
||||
let global = &self.global;
|
||||
gfx_select!(id => global.render_pipeline_drop(id));
|
||||
|
@ -1084,7 +1193,8 @@ impl WGPU {
|
|||
},
|
||||
WebGPURequest::DropTextureView(id) => {
|
||||
let global = &self.global;
|
||||
let _result = gfx_select!(id => global.texture_view_drop(id, true));
|
||||
let _result = gfx_select!(id => global.texture_view_drop(id, false));
|
||||
self.poller.wake();
|
||||
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeTextureView(id)) {
|
||||
warn!("Unable to send FreeTextureView({:?}) ({:?})", id, e);
|
||||
};
|
||||
|
@ -1214,13 +1324,12 @@ impl WGPU {
|
|||
}
|
||||
|
||||
fn encoder_record_error<U, T: std::fmt::Debug>(
|
||||
&self,
|
||||
&mut self,
|
||||
encoder_id: id::CommandEncoderId,
|
||||
result: &Result<U, T>,
|
||||
) {
|
||||
if let Err(ref e) = result {
|
||||
self.error_command_encoders
|
||||
.borrow_mut()
|
||||
.entry(encoder_id)
|
||||
.or_insert_with(|| format!("{:?}", e));
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,2 +1,3 @@
|
|||
[canvas_complex_rgba8unorm_store.https.html]
|
||||
expected: FAIL
|
||||
expected:
|
||||
if os == "linux" and not debug: PASS
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
[canvas_image_rendering.https.html]
|
||||
expected: TIMEOUT
|
||||
expected:
|
||||
if os == "linux" and not debug: PASS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue