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

@ -21,13 +21,16 @@ use webgpu::{
wgt, WebGPU, WebGPURequest,
};
use super::bindings::codegen::Bindings::GPURenderPipelineBinding::GPUIndexFormat;
use super::bindings::error::Fallible;
#[dom_struct]
pub struct GPURenderPassEncoder {
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]
render_pass: DomRefCell<Option<RenderPass>>,
@ -39,7 +42,7 @@ impl GPURenderPassEncoder {
channel: WebGPU,
render_pass: Option<RenderPass>,
parent: &GPUCommandEncoder,
label: Option<USVString>,
label: USVString,
) -> Self {
Self {
channel,
@ -55,7 +58,7 @@ impl GPURenderPassEncoder {
channel: WebGPU,
render_pass: Option<RenderPass>,
parent: &GPUCommandEncoder,
label: Option<USVString>,
label: USVString,
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPURenderPassEncoder::new_inherited(
@ -71,12 +74,12 @@ impl GPURenderPassEncoder {
impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
/// 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;
}
@ -127,7 +130,7 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
}
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-setblendcolor
fn SetBlendColor(&self, color: GPUColor) {
fn SetBlendConstant(&self, color: GPUColor) {
if let Some(render_pass) = self.render_pass.borrow_mut().as_mut() {
let colors = match color {
GPUColor::GPUColorDict(d) => wgt::Color {
@ -149,7 +152,7 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
}
},
};
wgpu_render::wgpu_render_pass_set_blend_color(render_pass, &colors);
wgpu_render::wgpu_render_pass_set_blend_constant(render_pass, &colors);
}
}
@ -160,8 +163,8 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
}
}
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-endpass
fn EndPass(&self) {
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-end
fn End(&self) -> Fallible<()> {
let render_pass = self.render_pass.borrow_mut().take();
self.channel
.0
@ -178,6 +181,7 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
GPUCommandEncoderState::Open,
GPUCommandEncoderState::EncodingRenderPass,
);
Ok(())
}
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderencoderbase-setpipeline
@ -187,12 +191,22 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
}
}
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderencoderbase-setindexbuffer
fn SetIndexBuffer(&self, buffer: &GPUBuffer, offset: u64, size: u64) {
/// https://gpuweb.github.io/gpuweb/#dom-gpurendercommandsmixin-setindexbuffer
fn SetIndexBuffer(
&self,
buffer: &GPUBuffer,
index_format: GPUIndexFormat,
offset: u64,
size: u64,
) {
if let Some(render_pass) = self.render_pass.borrow_mut().as_mut() {
wgpu_render::wgpu_render_pass_set_index_buffer(
render_pass,
buffer.id().0,
match index_format {
GPUIndexFormat::Uint16 => wgt::IndexFormat::Uint16,
GPUIndexFormat::Uint32 => wgt::IndexFormat::Uint32,
},
offset,
wgt::BufferSize::new(size),
);