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
This commit is contained in:
Samson 2023-08-21 01:16:46 +02:00 committed by GitHub
parent fed3491f23
commit 71e0372ac1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 15612 additions and 4023 deletions

View file

@ -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