aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/gpurenderpipeline.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/gpurenderpipeline.rs')
-rw-r--r--components/script/dom/gpurenderpipeline.rs32
1 files changed, 24 insertions, 8 deletions
diff --git a/components/script/dom/gpurenderpipeline.rs b/components/script/dom/gpurenderpipeline.rs
index bb618a248a9..b59ea0e8501 100644
--- a/components/script/dom/gpurenderpipeline.rs
+++ b/components/script/dom/gpurenderpipeline.rs
@@ -3,48 +3,51 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell;
+use crate::dom::bindings::codegen::Bindings::GPUAdapterBinding::GPULimits;
use crate::dom::bindings::codegen::Bindings::GPURenderPipelineBinding::GPURenderPipelineMethods;
-use crate::dom::bindings::reflector::reflect_dom_object;
-use crate::dom::bindings::reflector::Reflector;
+use crate::dom::bindings::error::{Error, Fallible};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::USVString;
use crate::dom::globalscope::GlobalScope;
+use crate::dom::gpubindgrouplayout::GPUBindGroupLayout;
use dom_struct::dom_struct;
-use webgpu::{WebGPUDevice, WebGPURenderPipeline};
+use std::string::String;
+use webgpu::{WebGPUBindGroupLayout, WebGPURenderPipeline};
#[dom_struct]
pub struct GPURenderPipeline {
reflector_: Reflector,
label: DomRefCell<Option<USVString>>,
render_pipeline: WebGPURenderPipeline,
- device: WebGPUDevice,
+ bind_group_layouts: Vec<WebGPUBindGroupLayout>,
}
impl GPURenderPipeline {
fn new_inherited(
render_pipeline: WebGPURenderPipeline,
- device: WebGPUDevice,
label: Option<USVString>,
+ bgls: Vec<WebGPUBindGroupLayout>,
) -> Self {
Self {
reflector_: Reflector::new(),
label: DomRefCell::new(label),
render_pipeline,
- device,
+ bind_group_layouts: bgls,
}
}
pub fn new(
global: &GlobalScope,
render_pipeline: WebGPURenderPipeline,
- device: WebGPUDevice,
label: Option<USVString>,
+ bgls: Vec<WebGPUBindGroupLayout>,
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPURenderPipeline::new_inherited(
render_pipeline,
- device,
label,
+ bgls,
)),
global,
)
@@ -67,4 +70,17 @@ impl GPURenderPipelineMethods for GPURenderPipeline {
fn SetLabel(&self, value: Option<USVString>) {
*self.label.borrow_mut() = value;
}
+
+ /// https://gpuweb.github.io/gpuweb/#dom-gpupipelinebase-getbindgrouplayout
+ fn GetBindGroupLayout(&self, index: u32) -> Fallible<DomRoot<GPUBindGroupLayout>> {
+ if index > self.bind_group_layouts.len() as u32 || index > GPULimits::empty().maxBindGroups
+ {
+ return Err(Error::Range(String::from("Index out of bounds")));
+ }
+ return Ok(GPUBindGroupLayout::new(
+ &self.global(),
+ self.bind_group_layouts[index as usize],
+ None,
+ ));
+ }
}