New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement GPURenderPassEncoder #26769
Merged
+572
−115
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
Implement GPURenderPassEncoder
Add webidls for GPURenderPassEncoder and GPURenderEncoderBase and implement relevant methods.
- Loading branch information
commit 1d4efb48ba904aab93ebad3a2892aed46444088f
| @@ -2,6 +2,8 @@ | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| #![allow(unsafe_code)] | ||
|
|
||
| use crate::dom::bindings::cell::DomRefCell; | ||
| use crate::dom::bindings::codegen::Bindings::GPUComputePassEncoderBinding::GPUComputePassEncoderMethods; | ||
| use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; | ||
| @@ -12,7 +14,6 @@ use crate::dom::gpubindgroup::GPUBindGroup; | ||
| use crate::dom::gpucommandencoder::{GPUCommandEncoder, GPUCommandEncoderState}; | ||
| use crate::dom::gpucomputepipeline::GPUComputePipeline; | ||
| use dom_struct::dom_struct; | ||
| use std::cell::RefCell; | ||
| use webgpu::{ | ||
| wgpu::command::{ | ||
| compute_ffi::{ | ||
| @@ -31,27 +32,22 @@ pub struct GPUComputePassEncoder { | ||
| channel: WebGPU, | ||
| label: DomRefCell<Option<DOMString>>, | ||
| #[ignore_malloc_size_of = "defined in wgpu-core"] | ||
| raw_pass: RefCell<Option<RawPass>>, | ||
| raw_pass: DomRefCell<Option<RawPass>>, | ||
|
This conversation was marked as resolved
by kunalmohan
kunalmohan
Author
Collaborator
|
||
| command_encoder: Dom<GPUCommandEncoder>, | ||
| } | ||
|
|
||
| impl GPUComputePassEncoder { | ||
| #[allow(unsafe_code)] | ||
| fn new_inherited(channel: WebGPU, parent: &GPUCommandEncoder) -> GPUComputePassEncoder { | ||
| GPUComputePassEncoder { | ||
| fn new_inherited(channel: WebGPU, parent: &GPUCommandEncoder) -> Self { | ||
| Self { | ||
| channel, | ||
| reflector_: Reflector::new(), | ||
| label: DomRefCell::new(None), | ||
| raw_pass: RefCell::new(Some(unsafe { RawPass::new_compute(parent.id().0) })), | ||
| raw_pass: DomRefCell::new(Some(unsafe { RawPass::new_compute(parent.id().0) })), | ||
| command_encoder: Dom::from_ref(parent), | ||
| } | ||
| } | ||
|
|
||
| pub fn new( | ||
| global: &GlobalScope, | ||
| channel: WebGPU, | ||
| parent: &GPUCommandEncoder, | ||
| ) -> DomRoot<GPUComputePassEncoder> { | ||
| pub fn new(global: &GlobalScope, channel: WebGPU, parent: &GPUCommandEncoder) -> DomRoot<Self> { | ||
| reflect_dom_object( | ||
| Box::new(GPUComputePassEncoder::new_inherited(channel, parent)), | ||
| global, | ||
| @@ -70,15 +66,13 @@ impl GPUComputePassEncoderMethods for GPUComputePassEncoder { | ||
| *self.label.borrow_mut() = value; | ||
| } | ||
|
|
||
| #[allow(unsafe_code)] | ||
| /// https://gpuweb.github.io/gpuweb/#dom-gpucomputepassencoder-dispatch | ||
| fn Dispatch(&self, x: u32, y: u32, z: u32) { | ||
| if let Some(raw_pass) = self.raw_pass.borrow_mut().as_mut() { | ||
| unsafe { wgpu_compute_pass_dispatch(raw_pass, x, y, z) }; | ||
| } | ||
| } | ||
|
|
||
| #[allow(unsafe_code)] | ||
| /// https://gpuweb.github.io/gpuweb/#dom-gpurenderpassencoder-endpass | ||
| fn EndPass(&self) { | ||
| if let Some(raw_pass) = self.raw_pass.borrow_mut().take() { | ||
| @@ -99,7 +93,6 @@ impl GPUComputePassEncoderMethods for GPUComputePassEncoder { | ||
| } | ||
| } | ||
|
|
||
| #[allow(unsafe_code)] | ||
| /// https://gpuweb.github.io/gpuweb/#dom-gpuprogrammablepassencoder-setbindgroup | ||
| fn SetBindGroup(&self, index: u32, bind_group: &GPUBindGroup, dynamic_offsets: Vec<u32>) { | ||
| if let Some(raw_pass) = self.raw_pass.borrow_mut().as_mut() { | ||
| @@ -115,7 +108,6 @@ impl GPUComputePassEncoderMethods for GPUComputePassEncoder { | ||
| } | ||
| } | ||
|
|
||
| #[allow(unsafe_code)] | ||
| /// https://gpuweb.github.io/gpuweb/#dom-gpucomputepassencoder-setpipeline | ||
| fn SetPipeline(&self, pipeline: &GPUComputePipeline) { | ||
| if let Some(raw_pass) = self.raw_pass.borrow_mut().as_mut() { | ||
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
I'm curious why
DomRefCellis needed here