Skip to content

Commit

Permalink
Remove validation for GPUBindGroup, GPUBindGroupLayout, GPUPipelineLa…
Browse files Browse the repository at this point in the history
…yout
  • Loading branch information
kunalmohan committed Jun 19, 2020
1 parent 48ef306 commit f973099
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 531 deletions.
33 changes: 4 additions & 29 deletions components/script/dom/gpubindgrouplayout.rs
Expand Up @@ -3,61 +3,40 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::{
GPUBindGroupLayoutEntry, GPUBindGroupLayoutMethods,
};
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::globalscope::GlobalScope;
use dom_struct::dom_struct;
use std::cell::Cell;
use std::collections::HashMap;
use webgpu::{WebGPU, WebGPUBindGroupLayout};
use webgpu::WebGPUBindGroupLayout;

#[dom_struct]
pub struct GPUBindGroupLayout {
reflector_: Reflector,
label: DomRefCell<Option<DOMString>>,
bind_group_layout: WebGPUBindGroupLayout,
#[ignore_malloc_size_of = "defined in webgpu"]
entry_map: HashMap<u32, GPUBindGroupLayoutEntry>,
#[ignore_malloc_size_of = "defined in webgpu"]
channel: WebGPU,
valid: Cell<bool>,
}

impl GPUBindGroupLayout {
fn new_inherited(
channel: WebGPU,
bind_group_layout: WebGPUBindGroupLayout,
entry_map: HashMap<u32, GPUBindGroupLayoutEntry>,
valid: bool,
) -> Self {
fn new_inherited(bind_group_layout: WebGPUBindGroupLayout, valid: bool) -> Self {
Self {
reflector_: Reflector::new(),
channel,
label: DomRefCell::new(None),
bind_group_layout,
entry_map,
valid: Cell::new(valid),
}
}

pub fn new(
global: &GlobalScope,
channel: WebGPU,
bind_group_layout: WebGPUBindGroupLayout,
entry_map: HashMap<u32, GPUBindGroupLayoutEntry>,
valid: bool,
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPUBindGroupLayout::new_inherited(
channel,
bind_group_layout,
entry_map,
valid,
)),
Box::new(GPUBindGroupLayout::new_inherited(bind_group_layout, valid)),
global,
)
}
Expand All @@ -71,10 +50,6 @@ impl GPUBindGroupLayout {
pub fn id(&self) -> WebGPUBindGroupLayout {
self.bind_group_layout
}

pub fn entries(&self) -> &HashMap<u32, GPUBindGroupLayoutEntry> {
&self.entry_map
}
}

impl GPUBindGroupLayoutMethods for GPUBindGroupLayout {
Expand Down
13 changes: 10 additions & 3 deletions components/script/dom/gpucomputepipeline.rs
Expand Up @@ -10,27 +10,34 @@ use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
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>>,
compute_pipeline: WebGPUComputePipeline,
valid: Cell<bool>,
}

impl GPUComputePipeline {
fn new_inherited(compute_pipeline: WebGPUComputePipeline) -> Self {
fn new_inherited(compute_pipeline: WebGPUComputePipeline, valid: bool) -> Self {
Self {
reflector_: Reflector::new(),
label: DomRefCell::new(None),
compute_pipeline,
valid: Cell::new(valid),
}
}

pub fn new(global: &GlobalScope, compute_pipeline: WebGPUComputePipeline) -> DomRoot<Self> {
pub fn new(
global: &GlobalScope,
compute_pipeline: WebGPUComputePipeline,
valid: bool,
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPUComputePipeline::new_inherited(compute_pipeline)),
Box::new(GPUComputePipeline::new_inherited(compute_pipeline, valid)),
global,
)
}
Expand Down

0 comments on commit f973099

Please sign in to comment.