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:
Samson 2024-08-30 13:23:17 +02:00 committed by GitHub
parent 83a40c5180
commit 817a91f2ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 276 additions and 361 deletions

View file

@ -12,7 +12,7 @@ use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView};
use super::bindings::error::Fallible;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
GPUExtent3DDict, GPUTextureAspect, GPUTextureDimension, GPUTextureFormat, GPUTextureMethods,
GPUTextureAspect, GPUTextureDimension, GPUTextureFormat, GPUTextureMethods,
GPUTextureViewDescriptor,
};
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
@ -33,8 +33,9 @@ pub struct GPUTexture {
#[ignore_malloc_size_of = "channels are hard"]
#[no_trace]
channel: WebGPU,
#[ignore_malloc_size_of = "defined in webgpu"]
texture_size: GPUExtent3DDict,
#[ignore_malloc_size_of = "defined in wgpu"]
#[no_trace]
texture_size: wgt::Extent3d,
mip_level_count: u32,
sample_count: u32,
dimension: GPUTextureDimension,
@ -49,7 +50,7 @@ impl GPUTexture {
texture: WebGPUTexture,
device: &GPUDevice,
channel: WebGPU,
texture_size: GPUExtent3DDict,
texture_size: wgt::Extent3d,
mip_level_count: u32,
sample_count: u32,
dimension: GPUTextureDimension,
@ -79,7 +80,7 @@ impl GPUTexture {
texture: WebGPUTexture,
device: &GPUDevice,
channel: WebGPU,
texture_size: GPUExtent3DDict,
texture_size: wgt::Extent3d,
mip_level_count: u32,
sample_count: u32,
dimension: GPUTextureDimension,
@ -230,7 +231,7 @@ impl GPUTextureMethods for GPUTexture {
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-depthorarraylayers>
fn DepthOrArrayLayers(&self) -> u32 {
self.texture_size.depthOrArrayLayers
self.texture_size.depth_or_array_layers
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-miplevelcount>