aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2020-07-20 20:10:41 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2020-07-20 23:03:53 +0530
commitcdc0a75fe43a962caaeed5fdb15dbc3a4dc18c56 (patch)
tree8ccf16cae3f8cf3ba00dad408c8abc47807424ba /components/script/dom
parent3216209506f36b3db7dc733c2e391fb11dc6bd67 (diff)
downloadservo-cdc0a75fe43a962caaeed5fdb15dbc3a4dc18c56.tar.gz
servo-cdc0a75fe43a962caaeed5fdb15dbc3a4dc18c56.zip
Update GPUObjectBase webidl and cleanup valid flags
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/gpubindgroup.rs17
-rw-r--r--components/script/dom/gpubindgrouplayout.rs25
-rw-r--r--components/script/dom/gpubuffer.rs18
-rw-r--r--components/script/dom/gpucommandbuffer.rs8
-rw-r--r--components/script/dom/gpucommandencoder.rs12
-rw-r--r--components/script/dom/gpucomputepassencoder.rs8
-rw-r--r--components/script/dom/gpucomputepipeline.rs21
-rw-r--r--components/script/dom/gpudevice.rs97
-rw-r--r--components/script/dom/gpupipelinelayout.rs25
-rw-r--r--components/script/dom/gpuqueue.rs13
-rw-r--r--components/script/dom/gpurenderpassencoder.rs8
-rw-r--r--components/script/dom/gpurenderpipeline.rs24
-rw-r--r--components/script/dom/gpusampler.rs30
-rw-r--r--components/script/dom/gpushadermodule.rs8
-rw-r--r--components/script/dom/gpuswapchain.rs8
-rw-r--r--components/script/dom/gputexture.rs27
-rw-r--r--components/script/dom/gputextureview.rs24
-rw-r--r--components/script/dom/webidls/GPUObjectBase.webidl4
18 files changed, 146 insertions, 231 deletions
diff --git a/components/script/dom/gpubindgroup.rs b/components/script/dom/gpubindgroup.rs
index 8965952051c..458a437eed4 100644
--- a/components/script/dom/gpubindgroup.rs
+++ b/components/script/dom/gpubindgroup.rs
@@ -6,28 +6,25 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUBindGroupBinding::GPUBindGroupMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpubindgrouplayout::GPUBindGroupLayout;
use dom_struct::dom_struct;
-use std::cell::Cell;
use webgpu::{WebGPUBindGroup, WebGPUDevice};
#[dom_struct]
pub struct GPUBindGroup {
reflector_: Reflector,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
bind_group: WebGPUBindGroup,
device: WebGPUDevice,
layout: Dom<GPUBindGroupLayout>,
- valid: Cell<bool>,
}
impl GPUBindGroup {
fn new_inherited(
bind_group: WebGPUBindGroup,
device: WebGPUDevice,
- valid: bool,
layout: &GPUBindGroupLayout,
) -> Self {
Self {
@@ -35,7 +32,6 @@ impl GPUBindGroup {
label: DomRefCell::new(None),
bind_group,
device,
- valid: Cell::new(valid),
layout: Dom::from_ref(layout),
}
}
@@ -44,13 +40,10 @@ impl GPUBindGroup {
global: &GlobalScope,
bind_group: WebGPUBindGroup,
device: WebGPUDevice,
- valid: bool,
layout: &GPUBindGroupLayout,
) -> DomRoot<Self> {
reflect_dom_object(
- Box::new(GPUBindGroup::new_inherited(
- bind_group, device, valid, layout,
- )),
+ Box::new(GPUBindGroup::new_inherited(bind_group, device, layout)),
global,
)
}
@@ -64,12 +57,12 @@ impl GPUBindGroup {
impl GPUBindGroupMethods for GPUBindGroup {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/gpubindgrouplayout.rs b/components/script/dom/gpubindgrouplayout.rs
index 216058a89a0..622981ebb4d 100644
--- a/components/script/dom/gpubindgrouplayout.rs
+++ b/components/script/dom/gpubindgrouplayout.rs
@@ -6,47 +6,36 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::GPUBindGroupLayoutMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
-use std::cell::Cell;
use webgpu::WebGPUBindGroupLayout;
#[dom_struct]
pub struct GPUBindGroupLayout {
reflector_: Reflector,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
bind_group_layout: WebGPUBindGroupLayout,
- valid: Cell<bool>,
}
impl GPUBindGroupLayout {
- fn new_inherited(bind_group_layout: WebGPUBindGroupLayout, valid: bool) -> Self {
+ fn new_inherited(bind_group_layout: WebGPUBindGroupLayout) -> Self {
Self {
reflector_: Reflector::new(),
label: DomRefCell::new(None),
bind_group_layout,
- valid: Cell::new(valid),
}
}
- pub fn new(
- global: &GlobalScope,
- bind_group_layout: WebGPUBindGroupLayout,
- valid: bool,
- ) -> DomRoot<Self> {
+ pub fn new(global: &GlobalScope, bind_group_layout: WebGPUBindGroupLayout) -> DomRoot<Self> {
reflect_dom_object(
- Box::new(GPUBindGroupLayout::new_inherited(bind_group_layout, valid)),
+ Box::new(GPUBindGroupLayout::new_inherited(bind_group_layout)),
global,
)
}
}
impl GPUBindGroupLayout {
- pub fn is_valid(&self) -> bool {
- self.valid.get()
- }
-
pub fn id(&self) -> WebGPUBindGroupLayout {
self.bind_group_layout
}
@@ -54,12 +43,12 @@ impl GPUBindGroupLayout {
impl GPUBindGroupLayoutMethods for GPUBindGroupLayout {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/gpubuffer.rs b/components/script/dom/gpubuffer.rs
index c4dc472dc98..c7629852d92 100644
--- a/components/script/dom/gpubuffer.rs
+++ b/components/script/dom/gpubuffer.rs
@@ -9,7 +9,7 @@ use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpu::{response_async, AsyncWGPUListener};
use crate::dom::promise::Promise;
@@ -58,11 +58,10 @@ pub struct GPUBuffer {
reflector_: Reflector,
#[ignore_malloc_size_of = "defined in webgpu"]
channel: WebGPU,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
state: Cell<GPUBufferState>,
buffer: WebGPUBuffer,
device: WebGPUDevice,
- valid: Cell<bool>,
size: GPUSize64,
#[ignore_malloc_size_of = "promises are hard"]
map_promise: DomRefCell<Option<Rc<Promise>>>,
@@ -76,7 +75,6 @@ impl GPUBuffer {
device: WebGPUDevice,
state: GPUBufferState,
size: GPUSize64,
- valid: bool,
map_info: DomRefCell<Option<GPUBufferMapInfo>>,
) -> Self {
Self {
@@ -84,7 +82,6 @@ impl GPUBuffer {
channel,
label: DomRefCell::new(None),
state: Cell::new(state),
- valid: Cell::new(valid),
device,
buffer,
map_promise: DomRefCell::new(None),
@@ -101,12 +98,11 @@ impl GPUBuffer {
device: WebGPUDevice,
state: GPUBufferState,
size: GPUSize64,
- valid: bool,
map_info: DomRefCell<Option<GPUBufferMapInfo>>,
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPUBuffer::new_inherited(
- channel, buffer, device, state, size, valid, map_info,
+ channel, buffer, device, state, size, map_info,
)),
global,
)
@@ -121,10 +117,6 @@ impl GPUBuffer {
pub fn state(&self) -> GPUBufferState {
self.state.get()
}
-
- pub fn is_valid(&self) -> bool {
- self.valid.get()
- }
}
impl Drop for GPUBuffer {
@@ -305,12 +297,12 @@ impl GPUBufferMethods for GPUBuffer {
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/gpucommandbuffer.rs b/components/script/dom/gpucommandbuffer.rs
index 4b23a622ca3..7c7f03629d9 100644
--- a/components/script/dom/gpucommandbuffer.rs
+++ b/components/script/dom/gpucommandbuffer.rs
@@ -7,7 +7,7 @@ use crate::dom::bindings::codegen::Bindings::GPUCommandBufferBinding::GPUCommand
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::Dom;
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpubuffer::GPUBuffer;
use dom_struct::dom_struct;
@@ -27,7 +27,7 @@ pub struct GPUCommandBuffer {
reflector_: Reflector,
#[ignore_malloc_size_of = "defined in webgpu"]
channel: WebGPU,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
command_buffer: WebGPUCommandBuffer,
buffers: DomRefCell<HashSet<Dom<GPUBuffer>>>,
}
@@ -76,12 +76,12 @@ impl GPUCommandBuffer {
impl GPUCommandBufferMethods for GPUCommandBuffer {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/gpucommandencoder.rs b/components/script/dom/gpucommandencoder.rs
index 3e11e58d116..5633d16f611 100644
--- a/components/script/dom/gpucommandencoder.rs
+++ b/components/script/dom/gpucommandencoder.rs
@@ -14,7 +14,7 @@ use crate::dom::bindings::codegen::UnionTypes::{
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpubuffer::GPUBuffer;
use crate::dom::gpucommandbuffer::GPUCommandBuffer;
@@ -43,7 +43,7 @@ pub struct GPUCommandEncoder {
reflector_: Reflector,
#[ignore_malloc_size_of = "defined in webgpu"]
channel: WebGPU,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
encoder: webgpu::WebGPUCommandEncoder,
buffers: DomRefCell<HashSet<DomRoot<GPUBuffer>>>,
state: DomRefCell<GPUCommandEncoderState>,
@@ -103,12 +103,12 @@ impl GPUCommandEncoder {
impl GPUCommandEncoderMethods for GPUCommandEncoder {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
@@ -229,9 +229,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
destination_offset: GPUSize64,
size: GPUSize64,
) {
- let valid = source.is_valid() &&
- destination.is_valid() &&
- *self.state.borrow() == GPUCommandEncoderState::Open;
+ let valid = *self.state.borrow() == GPUCommandEncoderState::Open;
if !valid {
// TODO: Record an error in the current scope.
diff --git a/components/script/dom/gpucomputepassencoder.rs b/components/script/dom/gpucomputepassencoder.rs
index ac2a5b0dc90..2f4535d835e 100644
--- a/components/script/dom/gpucomputepassencoder.rs
+++ b/components/script/dom/gpucomputepassencoder.rs
@@ -6,7 +6,7 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUComputePassEncoderBinding::GPUComputePassEncoderMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpubindgroup::GPUBindGroup;
use crate::dom::gpubuffer::GPUBuffer;
@@ -23,7 +23,7 @@ pub struct GPUComputePassEncoder {
reflector_: Reflector,
#[ignore_malloc_size_of = "defined in webgpu"]
channel: WebGPU,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
#[ignore_malloc_size_of = "defined in wgpu-core"]
compute_pass: DomRefCell<Option<ComputePass>>,
command_encoder: Dom<GPUCommandEncoder>,
@@ -50,12 +50,12 @@ impl GPUComputePassEncoder {
impl GPUComputePassEncoderMethods for GPUComputePassEncoder {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
diff --git a/components/script/dom/gpucomputepipeline.rs b/components/script/dom/gpucomputepipeline.rs
index cd5fac795d7..a5b7fbc495d 100644
--- a/components/script/dom/gpucomputepipeline.rs
+++ b/components/script/dom/gpucomputepipeline.rs
@@ -7,37 +7,30 @@ use crate::dom::bindings::codegen::Bindings::GPUComputePipelineBinding::GPUCompu
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::reflector::Reflector;
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
-use std::cell::Cell;
use webgpu::WebGPUComputePipeline;
#[dom_struct]
pub struct GPUComputePipeline {
reflector_: Reflector,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
compute_pipeline: WebGPUComputePipeline,
- valid: Cell<bool>,
}
impl GPUComputePipeline {
- fn new_inherited(compute_pipeline: WebGPUComputePipeline, valid: bool) -> Self {
+ fn new_inherited(compute_pipeline: WebGPUComputePipeline) -> Self {
Self {
reflector_: Reflector::new(),
label: DomRefCell::new(None),
compute_pipeline,
- valid: Cell::new(valid),
}
}
- pub fn new(
- global: &GlobalScope,
- compute_pipeline: WebGPUComputePipeline,
- valid: bool,
- ) -> DomRoot<Self> {
+ pub fn new(global: &GlobalScope, compute_pipeline: WebGPUComputePipeline) -> DomRoot<Self> {
reflect_dom_object(
- Box::new(GPUComputePipeline::new_inherited(compute_pipeline, valid)),
+ Box::new(GPUComputePipeline::new_inherited(compute_pipeline)),
global,
)
}
@@ -51,12 +44,12 @@ impl GPUComputePipeline {
impl GPUComputePipelineMethods for GPUComputePipeline {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/gpudevice.rs b/components/script/dom/gpudevice.rs
index d438e6c23e0..2a3ffad48d9 100644
--- a/components/script/dom/gpudevice.rs
+++ b/components/script/dom/gpudevice.rs
@@ -34,11 +34,11 @@ use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureVi
use crate::dom::bindings::codegen::Bindings::GPUValidationErrorBinding::{
GPUError, GPUErrorFilter,
};
-use crate::dom::bindings::codegen::UnionTypes::Uint32ArrayOrString::{String, Uint32Array};
+use crate::dom::bindings::codegen::UnionTypes::Uint32ArrayOrString;
use crate::dom::bindings::error::Error;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
use crate::dom::bindings::root::{Dom, DomRoot};
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::bindings::trace::RootedTraceableBox;
use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
@@ -64,6 +64,7 @@ use std::cell::RefCell;
use std::collections::HashMap;
use std::ptr::NonNull;
use std::rc::Rc;
+use std::string::String;
use webgpu::wgpu::binding_model::BufferBinding;
use webgpu::{self, wgt, WebGPU, WebGPUBindings, WebGPURequest};
@@ -96,7 +97,7 @@ pub struct GPUDevice {
extensions: Heap<*mut JSObject>,
#[ignore_malloc_size_of = "mozjs"]
limits: Heap<*mut JSObject>,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
device: webgpu::WebGPUDevice,
default_queue: Dom<GPUQueue>,
scope_context: DomRefCell<ScopeContext>,
@@ -227,12 +228,12 @@ impl GPUDeviceMethods for GPUDevice {
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
@@ -246,7 +247,11 @@ impl GPUDeviceMethods for GPUDevice {
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbuffer
fn CreateBuffer(&self, descriptor: &GPUBufferDescriptor) -> DomRoot<GPUBuffer> {
let wgpu_descriptor = wgt::BufferDescriptor {
- label: Default::default(),
+ label: descriptor
+ .parent
+ .label
+ .as_ref()
+ .map(|s| String::from(s.as_ref())),
size: descriptor.size,
usage: match wgt::BufferUsage::from_bits(descriptor.usage) {
Some(u) => u,
@@ -293,7 +298,6 @@ impl GPUDeviceMethods for GPUDevice {
self.device,
state,
descriptor.size,
- true,
map_info,
)
}
@@ -409,12 +413,17 @@ impl GPUDeviceMethods for GPUDevice {
bind_group_layout_id,
entries: entries.clone(),
scope_id,
+ label: descriptor
+ .parent
+ .label
+ .as_ref()
+ .map(|s| String::from(s.as_ref())),
})
.expect("Failed to create WebGPU BindGroupLayout");
let bgl = webgpu::WebGPUBindGroupLayout(bind_group_layout_id);
- let layout = GPUBindGroupLayout::new(&self.global(), bgl, true);
+ let layout = GPUBindGroupLayout::new(&self.global(), bgl);
self.bind_group_layouts
.borrow_mut()
@@ -429,11 +438,10 @@ impl GPUDeviceMethods for GPUDevice {
descriptor: &GPUPipelineLayoutDescriptor,
) -> DomRoot<GPUPipelineLayout> {
let mut bgl_ids = Vec::new();
- descriptor.bindGroupLayouts.iter().for_each(|each| {
- if each.is_valid() {
- bgl_ids.push(each.id().0);
- }
- });
+ descriptor
+ .bindGroupLayouts
+ .iter()
+ .for_each(|each| bgl_ids.push(each.id().0));
let scope_id = self.use_current_scope();
@@ -453,12 +461,11 @@ impl GPUDeviceMethods for GPUDevice {
.expect("Failed to create WebGPU PipelineLayout");
let pipeline_layout = webgpu::WebGPUPipelineLayout(pipeline_layout_id);
- GPUPipelineLayout::new(&self.global(), pipeline_layout, true)
+ GPUPipelineLayout::new(&self.global(), pipeline_layout)
}
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbindgroup
fn CreateBindGroup(&self, descriptor: &GPUBindGroupDescriptor) -> DomRoot<GPUBindGroup> {
- let mut valid = descriptor.layout.is_valid();
let entries = descriptor
.entries
.iter()
@@ -466,16 +473,11 @@ impl GPUDeviceMethods for GPUDevice {
(
bind.binding,
match bind.resource {
- GPUBindingResource::GPUSampler(ref s) => {
- valid &= s.is_valid();
- WebGPUBindings::Sampler(s.id().0)
- },
+ GPUBindingResource::GPUSampler(ref s) => WebGPUBindings::Sampler(s.id().0),
GPUBindingResource::GPUTextureView(ref t) => {
- valid &= t.is_valid();
WebGPUBindings::TextureView(t.id().0)
},
GPUBindingResource::GPUBufferBindings(ref b) => {
- valid &= b.buffer.is_valid();
WebGPUBindings::Buffer(BufferBinding {
buffer_id: b.buffer.id().0,
offset: b.offset,
@@ -502,18 +504,17 @@ impl GPUDeviceMethods for GPUDevice {
bind_group_layout_id: descriptor.layout.id().0,
entries,
scope_id,
+ label: descriptor
+ .parent
+ .label
+ .as_ref()
+ .map(|s| String::from(s.as_ref())),
})
.expect("Failed to create WebGPU BindGroup");
let bind_group = webgpu::WebGPUBindGroup(bind_group_id);
- GPUBindGroup::new(
- &self.global(),
- bind_group,
- self.device,
- valid,
- &*descriptor.layout,
- )
+ GPUBindGroup::new(&self.global(), bind_group, self.device, &*descriptor.layout)
}
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createshadermodule
@@ -522,8 +523,10 @@ impl GPUDeviceMethods for GPUDevice {
descriptor: RootedTraceableBox<GPUShaderModuleDescriptor>,
) -> DomRoot<GPUShaderModule> {
let program: Vec<u32> = match &descriptor.code {
- Uint32Array(program) => program.to_vec(),
- String(program) => program.chars().map(|c| c as u32).collect::<Vec<u32>>(),
+ Uint32ArrayOrString::Uint32Array(program) => program.to_vec(),
+ Uint32ArrayOrString::String(program) => {
+ program.chars().map(|c| c as u32).collect::<Vec<u32>>()
+ },
};
let program_id = self
.global()
@@ -548,7 +551,6 @@ impl GPUDeviceMethods for GPUDevice {
&self,
descriptor: &GPUComputePipelineDescriptor,
) -> DomRoot<GPUComputePipeline> {
- let valid = descriptor.parent.layout.is_valid();
let pipeline = descriptor.parent.layout.id();
let program = descriptor.computeStage.module.id();
let entry_point = descriptor.computeStage.entryPoint.to_string();
@@ -573,13 +575,13 @@ impl GPUDeviceMethods for GPUDevice {
.expect("Failed to create WebGPU ComputePipeline");
let compute_pipeline = webgpu::WebGPUComputePipeline(compute_pipeline_id);
- GPUComputePipeline::new(&self.global(), compute_pipeline, valid)
+ GPUComputePipeline::new(&self.global(), compute_pipeline)
}
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createcommandencoder
fn CreateCommandEncoder(
&self,
- _descriptor: &GPUCommandEncoderDescriptor,
+ descriptor: &GPUCommandEncoderDescriptor,
) -> DomRoot<GPUCommandEncoder> {
let command_encoder_id = self
.global()
@@ -591,6 +593,11 @@ impl GPUDeviceMethods for GPUDevice {
.send(WebGPURequest::CreateCommandEncoder {
device_id: self.device.0,
command_encoder_id,
+ label: descriptor
+ .parent
+ .label
+ .as_ref()
+ .map(|s| String::from(s.as_ref())),
})
.expect("Failed to create WebGPU command encoder");
@@ -607,10 +614,13 @@ impl GPUDeviceMethods for GPUDevice {
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createtexture
fn CreateTexture(&self, descriptor: &GPUTextureDescriptor) -> DomRoot<GPUTexture> {
- let mut valid = true;
let size = convert_texture_size_to_dict(&descriptor.size);
let desc = wgt::TextureDescriptor {
- label: Default::default(),
+ label: descriptor
+ .parent
+ .label
+ .as_ref()
+ .map(|s| String::from(s.as_ref())),
size: convert_texture_size_to_wgt(&size),
mip_level_count: descriptor.mipLevelCount,
sample_count: descriptor.sampleCount,
@@ -622,10 +632,7 @@ impl GPUDeviceMethods for GPUDevice {
format: convert_texture_format(descriptor.format),
usage: match wgt::TextureUsage::from_bits(descriptor.usage) {
Some(t) => t,
- None => {
- valid = false;
- wgt::TextureUsage::empty()
- },
+ None => wgt::TextureUsage::empty(),
},
};
@@ -657,7 +664,6 @@ impl GPUDeviceMethods for GPUDevice {
descriptor.dimension,
descriptor.format,
descriptor.usage,
- valid,
)
}
@@ -670,7 +676,11 @@ impl GPUDeviceMethods for GPUDevice {
.create_sampler_id(self.device.0.backend());
let compare_enable = descriptor.compare.is_some();
let desc = wgt::SamplerDescriptor {
- label: Default::default(),
+ label: descriptor
+ .parent
+ .label
+ .as_ref()
+ .map(|s| String::from(s.as_ref())),
address_mode_u: convert_address_mode(descriptor.addressModeU),
address_mode_v: convert_address_mode(descriptor.addressModeV),
address_mode_w: convert_address_mode(descriptor.addressModeW),
@@ -694,7 +704,7 @@ impl GPUDeviceMethods for GPUDevice {
let sampler = webgpu::WebGPUSampler(sampler_id);
- GPUSampler::new(&self.global(), self.device, compare_enable, sampler, true)
+ GPUSampler::new(&self.global(), self.device, compare_enable, sampler)
}
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createrenderpipeline
@@ -702,7 +712,6 @@ impl GPUDeviceMethods for GPUDevice {
&self,
descriptor: &GPURenderPipelineDescriptor,
) -> DomRoot<GPURenderPipeline> {
- let valid = descriptor.parent.layout.is_valid();
let vertex_module = descriptor.vertexStage.module.id().0;
let vertex_entry_point = descriptor.vertexStage.entryPoint.to_string();
let (fragment_module, fragment_entry_point) = match descriptor.fragmentStage {
@@ -834,7 +843,7 @@ impl GPUDeviceMethods for GPUDevice {
let render_pipeline = webgpu::WebGPURenderPipeline(render_pipeline_id);
- GPURenderPipeline::new(&self.global(), render_pipeline, self.device, valid)
+ GPURenderPipeline::new(&self.global(), render_pipeline, self.device)
}
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-pusherrorscope
diff --git a/components/script/dom/gpupipelinelayout.rs b/components/script/dom/gpupipelinelayout.rs
index a331456b14f..d0809819600 100644
--- a/components/script/dom/gpupipelinelayout.rs
+++ b/components/script/dom/gpupipelinelayout.rs
@@ -6,37 +6,30 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUPipelineLayoutBinding::GPUPipelineLayoutMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
-use std::cell::Cell;
use webgpu::WebGPUPipelineLayout;
#[dom_struct]
pub struct GPUPipelineLayout {
reflector_: Reflector,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
pipeline_layout: WebGPUPipelineLayout,
- valid: Cell<bool>,
}
impl GPUPipelineLayout {
- fn new_inherited(pipeline_layout: WebGPUPipelineLayout, valid: bool) -> Self {
+ fn new_inherited(pipeline_layout: WebGPUPipelineLayout) -> Self {
Self {
reflector_: Reflector::new(),
label: DomRefCell::new(None),
pipeline_layout,
- valid: Cell::new(valid),
}
}
- pub fn new(
- global: &GlobalScope,
- pipeline_layout: WebGPUPipelineLayout,
- valid: bool,
- ) -> DomRoot<Self> {
+ pub fn new(global: &GlobalScope, pipeline_layout: WebGPUPipelineLayout) -> DomRoot<Self> {
reflect_dom_object(
- Box::new(GPUPipelineLayout::new_inherited(pipeline_layout, valid)),
+ Box::new(GPUPipelineLayout::new_inherited(pipeline_layout)),
global,
)
}
@@ -46,20 +39,16 @@ impl GPUPipelineLayout {
pub fn id(&self) -> WebGPUPipelineLayout {
self.pipeline_layout
}
-
- pub fn is_valid(&self) -> bool {
- self.valid.get()
- }
}
impl GPUPipelineLayoutMethods for GPUPipelineLayout {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/gpuqueue.rs b/components/script/dom/gpuqueue.rs
index 275d3144266..c2632dfce1e 100644
--- a/components/script/dom/gpuqueue.rs
+++ b/components/script/dom/gpuqueue.rs
@@ -11,7 +11,7 @@ use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::{
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpubuffer::{GPUBuffer, GPUBufferState};
use crate::dom::gpucommandbuffer::GPUCommandBuffer;
@@ -27,7 +27,7 @@ pub struct GPUQueue {
reflector_: Reflector,
#[ignore_malloc_size_of = "defined in webgpu"]
channel: WebGPU,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
queue: WebGPUQueue,
}
@@ -48,12 +48,12 @@ impl GPUQueue {
impl GPUQueueMethods for GPUQueue {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
@@ -98,8 +98,7 @@ impl GPUQueueMethods for GPUQueue {
let valid = data_offset + content_size <= bytes.len() as u64 &&
buffer.state() == GPUBufferState::Unmapped &&
content_size % wgt::COPY_BUFFER_ALIGNMENT == 0 &&
- buffer_offset % wgt::COPY_BUFFER_ALIGNMENT == 0 &&
- buffer.is_valid();
+ buffer_offset % wgt::COPY_BUFFER_ALIGNMENT == 0;
if !valid {
return Err(Error::Operation);
@@ -130,7 +129,7 @@ impl GPUQueueMethods for GPUQueue {
size: GPUExtent3D,
) -> Fallible<()> {
let bytes = data.to_vec();
- let valid = data_layout.offset <= data.len() as u64 && destination.texture.is_valid();
+ let valid = data_layout.offset <= data.len() as u64;
if !valid {
return Err(Error::Operation);
diff --git a/components/script/dom/gpurenderpassencoder.rs b/components/script/dom/gpurenderpassencoder.rs
index cf25734eeda..ba8cf0a65d2 100644
--- a/components/script/dom/gpurenderpassencoder.rs
+++ b/components/script/dom/gpurenderpassencoder.rs
@@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::Bindings::GPURenderPassEncoderBinding::GPURen
use crate::dom::bindings::num::Finite;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpubindgroup::GPUBindGroup;
use crate::dom::gpubuffer::GPUBuffer;
@@ -25,7 +25,7 @@ pub struct GPURenderPassEncoder {
reflector_: Reflector,
#[ignore_malloc_size_of = "defined in webgpu"]
channel: WebGPU,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
#[ignore_malloc_size_of = "defined in wgpu-core"]
render_pass: DomRefCell<Option<RenderPass>>,
command_encoder: Dom<GPUCommandEncoder>,
@@ -61,12 +61,12 @@ impl GPURenderPassEncoder {
impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
diff --git a/components/script/dom/gpurenderpipeline.rs b/components/script/dom/gpurenderpipeline.rs
index 3a9bebba945..88e55848b91 100644
--- a/components/script/dom/gpurenderpipeline.rs
+++ b/components/script/dom/gpurenderpipeline.rs
@@ -7,32 +7,25 @@ use crate::dom::bindings::codegen::Bindings::GPURenderPipelineBinding::GPURender
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::reflector::Reflector;
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
-use std::cell::Cell;
use webgpu::{WebGPUDevice, WebGPURenderPipeline};
#[dom_struct]
pub struct GPURenderPipeline {
reflector_: Reflector,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
render_pipeline: WebGPURenderPipeline,
device: WebGPUDevice,
- valid: Cell<bool>,
}
impl GPURenderPipeline {
- fn new_inherited(
- render_pipeline: WebGPURenderPipeline,
- device: WebGPUDevice,
- valid: bool,
- ) -> Self {
+ fn new_inherited(render_pipeline: WebGPURenderPipeline, device: WebGPUDevice) -> Self {
Self {
reflector_: Reflector::new(),
label: DomRefCell::new(None),
render_pipeline,
- valid: Cell::new(valid),
device,
}
}
@@ -41,14 +34,9 @@ impl GPURenderPipeline {
global: &GlobalScope,
render_pipeline: WebGPURenderPipeline,
device: WebGPUDevice,
- valid: bool,
) -> DomRoot<Self> {
reflect_dom_object(
- Box::new(GPURenderPipeline::new_inherited(
- render_pipeline,
- device,
- valid,
- )),
+ Box::new(GPURenderPipeline::new_inherited(render_pipeline, device)),
global,
)
}
@@ -62,12 +50,12 @@ impl GPURenderPipeline {
impl GPURenderPipelineMethods for GPURenderPipeline {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/gpusampler.rs b/components/script/dom/gpusampler.rs
index 97e6c1dc37f..cba3ec3b018 100644
--- a/components/script/dom/gpusampler.rs
+++ b/components/script/dom/gpusampler.rs
@@ -6,33 +6,25 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUSamplerBinding::GPUSamplerMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
-use std::cell::Cell;
use webgpu::{WebGPUDevice, WebGPUSampler};
#[dom_struct]
pub struct GPUSampler {
reflector_: Reflector,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
device: WebGPUDevice,
compare_enable: bool,
sampler: WebGPUSampler,
- valid: Cell<bool>,
}
impl GPUSampler {
- fn new_inherited(
- device: WebGPUDevice,
- compare_enable: bool,
- sampler: WebGPUSampler,
- valid: bool,
- ) -> Self {
+ fn new_inherited(device: WebGPUDevice, compare_enable: bool, sampler: WebGPUSampler) -> Self {
Self {
reflector_: Reflector::new(),
label: DomRefCell::new(None),
- valid: Cell::new(valid),
device,
sampler,
compare_enable,
@@ -44,15 +36,9 @@ impl GPUSampler {
device: WebGPUDevice,
compare_enable: bool,
sampler: WebGPUSampler,
- valid: bool,
) -> DomRoot<Self> {
reflect_dom_object(
- Box::new(GPUSampler::new_inherited(
- device,
- compare_enable,
- sampler,
- valid,
- )),
+ Box::new(GPUSampler::new_inherited(device, compare_enable, sampler)),
global,
)
}
@@ -62,20 +48,16 @@ impl GPUSampler {
pub fn id(&self) -> WebGPUSampler {
self.sampler
}
-
- pub fn is_valid(&self) -> bool {
- self.valid.get()
- }
}
impl GPUSamplerMethods for GPUSampler {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/gpushadermodule.rs b/components/script/dom/gpushadermodule.rs
index 24a96bdaac4..3c752e7fe4a 100644
--- a/components/script/dom/gpushadermodule.rs
+++ b/components/script/dom/gpushadermodule.rs
@@ -6,7 +6,7 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUShaderModuleBinding::GPUShaderModuleMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use webgpu::WebGPUShaderModule;
@@ -14,7 +14,7 @@ use webgpu::WebGPUShaderModule;
#[dom_struct]
pub struct GPUShaderModule {
reflector_: Reflector,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
shader_module: WebGPUShaderModule,
}
@@ -43,12 +43,12 @@ impl GPUShaderModule {
impl GPUShaderModuleMethods for GPUShaderModule {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/gpuswapchain.rs b/components/script/dom/gpuswapchain.rs
index 05fa3c99a5b..5e50e7e57ab 100644
--- a/components/script/dom/gpuswapchain.rs
+++ b/components/script/dom/gpuswapchain.rs
@@ -6,7 +6,7 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUSwapChainBinding::GPUSwapChainMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpucanvascontext::GPUCanvasContext;
use crate::dom::gputexture::GPUTexture;
@@ -18,7 +18,7 @@ pub struct GPUSwapChain {
reflector_: Reflector,
#[ignore_malloc_size_of = "channels are hard"]
channel: WebGPU,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
context: Dom<GPUCanvasContext>,
texture: Dom<GPUTexture>,
}
@@ -67,12 +67,12 @@ impl GPUSwapChain {
impl GPUSwapChainMethods for GPUSwapChain {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
diff --git a/components/script/dom/gputexture.rs b/components/script/dom/gputexture.rs
index 0dbb3022291..4977207942e 100644
--- a/components/script/dom/gputexture.rs
+++ b/components/script/dom/gputexture.rs
@@ -11,19 +11,19 @@ use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::{
};
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::DomRoot;
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gpudevice::{convert_texture_format, convert_texture_view_dimension};
use crate::dom::gputextureview::GPUTextureView;
use dom_struct::dom_struct;
-use std::cell::Cell;
+use std::string::String;
use webgpu::{wgt, WebGPU, WebGPUDevice, WebGPURequest, WebGPUTexture, WebGPUTextureView};
#[dom_struct]
pub struct GPUTexture {
reflector_: Reflector,
texture: WebGPUTexture,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
device: WebGPUDevice,
#[ignore_malloc_size_of = "channels are hard"]
channel: WebGPU,
@@ -34,7 +34,6 @@ pub struct GPUTexture {
dimension: GPUTextureDimension,
format: GPUTextureFormat,
texture_usage: u32,
- valid: Cell<bool>,
}
impl GPUTexture {
@@ -48,7 +47,6 @@ impl GPUTexture {
dimension: GPUTextureDimension,
format: GPUTextureFormat,
texture_usage: u32,
- valid: bool,
) -> Self {
Self {
reflector_: Reflector::new(),
@@ -62,7 +60,6 @@ impl GPUTexture {
dimension,
format,
texture_usage,
- valid: Cell::new(valid),
}
}
@@ -77,7 +74,6 @@ impl GPUTexture {
dimension: GPUTextureDimension,
format: GPUTextureFormat,
texture_usage: u32,
- valid: bool,
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPUTexture::new_inherited(
@@ -90,7 +86,6 @@ impl GPUTexture {
dimension,
format,
texture_usage,
- valid,
)),
global,
)
@@ -107,20 +102,16 @@ impl GPUTexture {
pub fn id(&self) -> WebGPUTexture {
self.texture
}
-
- pub fn is_valid(&self) -> bool {
- self.valid.get()
- }
}
impl GPUTextureMethods for GPUTexture {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
@@ -145,7 +136,11 @@ impl GPUTextureMethods for GPUTexture {
let format = descriptor.format.unwrap_or(self.format);
let desc = wgt::TextureViewDescriptor {
- label: Default::default(),
+ label: descriptor
+ .parent
+ .label
+ .as_ref()
+ .map(|s| String::from(s.as_ref())),
format: convert_texture_format(format),
dimension: convert_texture_view_dimension(dimension),
aspect: match descriptor.aspect {
@@ -184,7 +179,7 @@ impl GPUTextureMethods for GPUTexture {
let texture_view = WebGPUTextureView(texture_view_id);
- GPUTextureView::new(&self.global(), texture_view, &self, self.valid.get())
+ GPUTextureView::new(&self.global(), texture_view, &self)
}
/// https://gpuweb.github.io/gpuweb/#dom-gputexture-destroy
diff --git a/components/script/dom/gputextureview.rs b/components/script/dom/gputextureview.rs
index 06cb5a0ddbf..208352f3ff7 100644
--- a/components/script/dom/gputextureview.rs
+++ b/components/script/dom/gputextureview.rs
@@ -6,34 +6,27 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureViewMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
-use crate::dom::bindings::str::DOMString;
+use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::gputexture::GPUTexture;
use dom_struct::dom_struct;
-use std::cell::Cell;
use webgpu::WebGPUTextureView;
#[dom_struct]
pub struct GPUTextureView {
reflector_: Reflector,
- label: DomRefCell<Option<DOMString>>,
+ label: DomRefCell<Option<USVString>>,
texture_view: WebGPUTextureView,
texture: Dom<GPUTexture>,
- valid: Cell<bool>,
}
impl GPUTextureView {
- fn new_inherited(
- texture_view: WebGPUTextureView,
- texture: &GPUTexture,
- valid: bool,
- ) -> GPUTextureView {
+ fn new_inherited(texture_view: WebGPUTextureView, texture: &GPUTexture) -> GPUTextureView {
Self {
reflector_: Reflector::new(),
texture: Dom::from_ref(texture),
label: DomRefCell::new(None),
texture_view,
- valid: Cell::new(valid),
}
}
@@ -41,10 +34,9 @@ impl GPUTextureView {
global: &GlobalScope,
texture_view: WebGPUTextureView,
texture: &GPUTexture,
- valid: bool,
) -> DomRoot<GPUTextureView> {
reflect_dom_object(
- Box::new(GPUTextureView::new_inherited(texture_view, texture, valid)),
+ Box::new(GPUTextureView::new_inherited(texture_view, texture)),
global,
)
}
@@ -54,20 +46,16 @@ impl GPUTextureView {
pub fn id(&self) -> WebGPUTextureView {
self.texture_view
}
-
- pub fn is_valid(&self) -> bool {
- self.valid.get()
- }
}
impl GPUTextureViewMethods for GPUTextureView {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn GetLabel(&self) -> Option<DOMString> {
+ fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
- fn SetLabel(&self, value: Option<DOMString>) {
+ fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
}
diff --git a/components/script/dom/webidls/GPUObjectBase.webidl b/components/script/dom/webidls/GPUObjectBase.webidl
index c9a35992fb8..524016d15ce 100644
--- a/components/script/dom/webidls/GPUObjectBase.webidl
+++ b/components/script/dom/webidls/GPUObjectBase.webidl
@@ -5,9 +5,9 @@
// https://gpuweb.github.io/gpuweb/#gpuobjectbase
[Exposed=(Window)]
interface mixin GPUObjectBase {
- attribute DOMString? label;
+ attribute USVString? label;
};
dictionary GPUObjectDescriptorBase {
- DOMString? label;
+ USVString label;
};