webgpu: Sync various parts of spec (#33009)

* Sync `GPUObjectDescriptorBase` (label is not option anymore)

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Sync `GPUFeatureName`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* shader_f16 feature is not usable in wgpu so disable it

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* sync `GPUTextureFormat`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* `validate_texture_format_required_features`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Sync `GPUTexture` attributes

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Make `entryPoint` in `GPUProgrammableStage` optional

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Set good expectations

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Bad expectations because naga does not support cons declarations

Also fail on firefox, where skipped before due to missing device features

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Bad expectation, also fails on firefox

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Bad expectations, because naga does not support `let pos = positions[vertex_index];`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Set expectation

external texture does not work in firefox too (again naga)

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* set bad expectations, because naga does not support `enable`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Set bad expectations for, `Texture with '' label has been destroyed`

also fails in firefox with same reason

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* one bad expectation

also on firefox

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* expect that also matches firefox

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* more expect

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Use only 1 proc for _webgpu

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* better doc comment

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-08-19 16:06:30 +02:00 committed by GitHub
parent f45c98496e
commit 94ff89a5e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 910 additions and 4947 deletions

View file

@ -9,6 +9,7 @@ use dom_struct::dom_struct;
use webgpu::wgc::resource;
use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView};
use super::bindings::error::Fallible;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
GPUExtent3DDict, GPUTextureAspect, GPUTextureDimension, GPUTextureFormat, GPUTextureMethods,
@ -18,9 +19,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpuconvert::{
convert_label, convert_texture_format, convert_texture_view_dimension,
};
use crate::dom::gpuconvert::{convert_label, convert_texture_view_dimension};
use crate::dom::gpudevice::GPUDevice;
use crate::dom::gputextureview::GPUTextureView;
@ -142,13 +141,19 @@ impl GPUTextureMethods for GPUTexture {
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-createview>
fn CreateView(&self, descriptor: &GPUTextureViewDescriptor) -> DomRoot<GPUTextureView> {
fn CreateView(
&self,
descriptor: &GPUTextureViewDescriptor,
) -> Fallible<DomRoot<GPUTextureView>> {
let desc = if !matches!(descriptor.mipLevelCount, Some(0)) &&
!matches!(descriptor.arrayLayerCount, Some(0))
{
Some(resource::TextureViewDescriptor {
label: convert_label(&descriptor.parent),
format: descriptor.format.map(convert_texture_format),
format: descriptor
.format
.map(|f| self.device.validate_texture_format_required_features(&f))
.transpose()?,
dimension: descriptor.dimension.map(convert_texture_view_dimension),
range: wgt::ImageSubresourceRange {
aspect: match descriptor.aspect {
@ -187,13 +192,13 @@ impl GPUTextureMethods for GPUTexture {
let texture_view = WebGPUTextureView(texture_view_id);
GPUTextureView::new(
Ok(GPUTextureView::new(
&self.global(),
self.channel.clone(),
texture_view,
self,
descriptor.parent.label.clone().unwrap_or_default(),
)
descriptor.parent.label.clone(),
))
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-destroy>
@ -212,4 +217,44 @@ impl GPUTextureMethods for GPUTexture {
};
self.destroyed.set(true);
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-width>
fn Width(&self) -> u32 {
self.texture_size.width
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-height>
fn Height(&self) -> u32 {
self.texture_size.height
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-depthorarraylayers>
fn DepthOrArrayLayers(&self) -> u32 {
self.texture_size.depthOrArrayLayers
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-miplevelcount>
fn MipLevelCount(&self) -> u32 {
self.mip_level_count
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-samplecount>
fn SampleCount(&self) -> u32 {
self.sample_count
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-dimension>
fn Dimension(&self) -> GPUTextureDimension {
self.dimension
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-format>
fn Format(&self) -> GPUTextureFormat {
self.format
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-usage>
fn Usage(&self) -> u32 {
self.texture_usage
}
}