mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
webgpu: Clean up GPUCommandEncoders
and add some validation (#33223)
* TextureUsages::from_bits_retain Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Fixup CreateBindGroupLayout Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * GPUExtent3D checking and converting Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Cleanup GPUCommandEncoders and some TODOs Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * validate gpuorigin3d Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * validate GPUColor Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * set good expect 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:
parent
83a40c5180
commit
817a91f2ac
11 changed files with 276 additions and 361 deletions
|
@ -2,26 +2,15 @@
|
|||
* 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/. */
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::{WebGPU, WebGPUCommandBuffer, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUCommandBufferMethods;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::USVString;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::gpubuffer::GPUBuffer;
|
||||
|
||||
impl Eq for DomRoot<GPUBuffer> {}
|
||||
impl Hash for DomRoot<GPUBuffer> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.id().hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
#[dom_struct]
|
||||
pub struct GPUCommandBuffer {
|
||||
|
@ -32,14 +21,12 @@ pub struct GPUCommandBuffer {
|
|||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
command_buffer: WebGPUCommandBuffer,
|
||||
buffers: DomRefCell<HashSet<Dom<GPUBuffer>>>,
|
||||
}
|
||||
|
||||
impl GPUCommandBuffer {
|
||||
fn new_inherited(
|
||||
channel: WebGPU,
|
||||
command_buffer: WebGPUCommandBuffer,
|
||||
buffers: HashSet<DomRoot<GPUBuffer>>,
|
||||
label: USVString,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
@ -47,7 +34,6 @@ impl GPUCommandBuffer {
|
|||
reflector_: Reflector::new(),
|
||||
label: DomRefCell::new(label),
|
||||
command_buffer,
|
||||
buffers: DomRefCell::new(buffers.into_iter().map(|b| Dom::from_ref(&*b)).collect()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,14 +41,12 @@ impl GPUCommandBuffer {
|
|||
global: &GlobalScope,
|
||||
channel: WebGPU,
|
||||
command_buffer: WebGPUCommandBuffer,
|
||||
buffers: HashSet<DomRoot<GPUBuffer>>,
|
||||
label: USVString,
|
||||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPUCommandBuffer::new_inherited(
|
||||
channel,
|
||||
command_buffer,
|
||||
buffers,
|
||||
label,
|
||||
)),
|
||||
global,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue