aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/gpucomputepassencoder.rs
diff options
context:
space:
mode:
authorSamson <16504129+sagudev@users.noreply.github.com>2023-08-21 01:16:46 +0200
committerGitHub <noreply@github.com>2023-08-20 23:16:46 +0000
commit71e0372ac18709da66e581cf4a777a7cc5d4cb92 (patch)
tree44907b543dcc822fe20025b2ac417da6e2b7c908 /components/script/dom/gpucomputepassencoder.rs
parentfed3491f23f8b7f3064ce297776deda76e485289 (diff)
downloadservo-71e0372ac18709da66e581cf4a777a7cc5d4cb92.tar.gz
servo-71e0372ac18709da66e581cf4a777a7cc5d4cb92.zip
Upgrade whole webgpu stack (#29795)
* Allow noidl files in script/dom/webidls * Upgrade wgpu to 0.16 and refresh whole webgpu implementation * Update WebGPU test expectations * misc * MutNullableDom -> DomRefCell<Option<Dom for GPUTexture * Direct use of GPUTextureDescriptor * Remove config from GPUCanvasContext * misc * finally blue color * gpubuffer "handle" error * GPU object have non-null label * gpu limits and info * use buffer_size * fix warnings * Cleanup * device destroy * fallback adapter * mach update-webgpu write webgpu commit hash in file * Mising deps in CI for webgpu tests * Updated expectations * Fixups * early reject * DomRefCell<Option<Dom -> MutNullableDom for GPUTexture
Diffstat (limited to 'components/script/dom/gpucomputepassencoder.rs')
-rw-r--r--components/script/dom/gpucomputepassencoder.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/components/script/dom/gpucomputepassencoder.rs b/components/script/dom/gpucomputepassencoder.rs
index c9b807ae6ac..e3b9383cfeb 100644
--- a/components/script/dom/gpucomputepassencoder.rs
+++ b/components/script/dom/gpucomputepassencoder.rs
@@ -18,13 +18,15 @@ use webgpu::{
WebGPU, WebGPURequest,
};
+use super::bindings::error::Fallible;
+
#[dom_struct]
pub struct GPUComputePassEncoder {
reflector_: Reflector,
#[ignore_malloc_size_of = "defined in webgpu"]
#[no_trace]
channel: WebGPU,
- label: DomRefCell<Option<USVString>>,
+ label: DomRefCell<USVString>,
#[ignore_malloc_size_of = "defined in wgpu-core"]
#[no_trace]
compute_pass: DomRefCell<Option<ComputePass>>,
@@ -36,7 +38,7 @@ impl GPUComputePassEncoder {
channel: WebGPU,
parent: &GPUCommandEncoder,
compute_pass: Option<ComputePass>,
- label: Option<USVString>,
+ label: USVString,
) -> Self {
Self {
channel,
@@ -52,7 +54,7 @@ impl GPUComputePassEncoder {
channel: WebGPU,
parent: &GPUCommandEncoder,
compute_pass: Option<ComputePass>,
- label: Option<USVString>,
+ label: USVString,
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPUComputePassEncoder::new_inherited(
@@ -68,26 +70,26 @@ impl GPUComputePassEncoder {
impl GPUComputePassEncoderMethods for GPUComputePassEncoder {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<USVString> {
+ fn Label(&self) -> USVString {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<USVString>) {
+ fn SetLabel(&self, value: USVString) {
*self.label.borrow_mut() = value;
}
- /// https://gpuweb.github.io/gpuweb/#dom-gpucomputepassencoder-dispatch
- fn Dispatch(&self, x: u32, y: u32, z: u32) {
+ /// 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(compute_pass, x, y, z);
+ wgpu_comp::wgpu_compute_pass_dispatch_workgroups(compute_pass, x, y, z);
}
}
- /// https://gpuweb.github.io/gpuweb/#dom-gpucomputepassencoder-dispatchindirect
- fn DispatchIndirect(&self, indirect_buffer: &GPUBuffer, indirect_offset: u64) {
+ /// 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_indirect(
+ wgpu_comp::wgpu_compute_pass_dispatch_workgroups_indirect(
compute_pass,
indirect_buffer.id().0,
indirect_offset,
@@ -96,7 +98,7 @@ impl GPUComputePassEncoderMethods for GPUComputePassEncoder {
}
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-endpass
- fn EndPass(&self) {
+ fn End(&self) -> Fallible<()> {
let compute_pass = self.compute_pass.borrow_mut().take();
self.channel
.0
@@ -107,12 +109,13 @@ impl GPUComputePassEncoderMethods for GPUComputePassEncoder {
compute_pass,
},
))
- .expect("Failed to send RunComputePass");
+ .expect("Failed to send RunComputePass"); //TODO: handle error
self.command_encoder.set_state(
GPUCommandEncoderState::Open,
GPUCommandEncoderState::EncodingComputePass,
);
+ Ok(())
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuprogrammablepassencoder-setbindgroup