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

@ -5,8 +5,6 @@
//! IPC messages that are received in wgpu thread
//! (usually from script thread more specifically from dom objects)
use std::borrow::Cow;
use arrayvec::ArrayVec;
use base::id::PipelineId;
use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
@ -27,6 +25,7 @@ use wgc::resource::{
BufferDescriptor, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
};
use wgpu_core::command::{RenderPassColorAttachment, RenderPassDepthStencilAttachment};
use wgpu_core::Label;
pub use {wgpu_core as wgc, wgpu_types as wgt};
use crate::identity::*;
@ -46,9 +45,7 @@ pub enum WebGPURequest {
CommandEncoderFinish {
command_encoder_id: id::CommandEncoderId,
device_id: id::DeviceId,
is_error: bool,
// TODO(zakorgy): Serialize CommandBufferDescriptor in wgpu-core
// wgc::command::CommandBufferDescriptor,
desc: wgt::CommandBufferDescriptor<Label<'static>>,
},
CopyBufferToBuffer {
command_encoder_id: id::CommandEncoderId,
@ -93,10 +90,8 @@ pub enum WebGPURequest {
},
CreateCommandEncoder {
device_id: id::DeviceId,
// TODO(zakorgy): Serialize CommandEncoderDescriptor in wgpu-core
// wgc::command::CommandEncoderDescriptor,
command_encoder_id: id::CommandEncoderId,
label: Option<Cow<'static, str>>,
desc: wgt::CommandEncoderDescriptor<Label<'static>>,
},
CreateComputePipeline {
device_id: id::DeviceId,
@ -144,7 +139,7 @@ pub enum WebGPURequest {
CreateTexture {
device_id: id::DeviceId,
texture_id: id::TextureId,
descriptor: Option<TextureDescriptor<'static>>,
descriptor: TextureDescriptor<'static>,
},
CreateTextureView {
texture_id: id::TextureId,
@ -203,7 +198,7 @@ pub enum WebGPURequest {
BeginComputePass {
command_encoder_id: id::CommandEncoderId,
compute_pass_id: ComputePassId,
label: Option<Cow<'static, str>>,
label: Label<'static>,
device_id: id::DeviceId,
},
ComputePassSetPipeline {
@ -240,7 +235,7 @@ pub enum WebGPURequest {
BeginRenderPass {
command_encoder_id: id::CommandEncoderId,
render_pass_id: RenderPassId,
label: Option<Cow<'static, str>>,
label: Label<'static>,
color_attachments: Vec<Option<RenderPassColorAttachment>>,
depth_stencil_attachment: Option<RenderPassDepthStencilAttachment>,
device_id: id::DeviceId,