diff options
author | Samson <16504129+sagudev@users.noreply.github.com> | 2024-12-16 19:58:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-16 18:58:53 +0000 |
commit | d7eb0c5c38ad08f3ff11a162e824ea872c3afdb8 (patch) | |
tree | 44a5efba634217ef548897bd25200eef56e53831 /components | |
parent | 3d816d6d24d8e5a2b2d607abbf602dbf33578630 (diff) | |
download | servo-d7eb0c5c38ad08f3ff11a162e824ea872c3afdb8.tar.gz servo-d7eb0c5c38ad08f3ff11a162e824ea872c3afdb8.zip |
Update wgpu to better handle optional attachment load/store ops (#34646)
* Update wgpu to better handle attachment load/store ops
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Update expectations
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Diffstat (limited to 'components')
-rw-r--r-- | components/script/dom/webgpu/gpucommandencoder.rs | 25 | ||||
-rw-r--r-- | components/script/dom/webgpu/gpuconvert.rs | 22 | ||||
-rw-r--r-- | components/webgpu/wgpu_thread.rs | 2 |
3 files changed, 25 insertions, 24 deletions
diff --git a/components/script/dom/webgpu/gpucommandencoder.rs b/components/script/dom/webgpu/gpucommandencoder.rs index 712fb3edd28..7567e187cd2 100644 --- a/components/script/dom/webgpu/gpucommandencoder.rs +++ b/components/script/dom/webgpu/gpucommandencoder.rs @@ -24,7 +24,6 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::webgpu::gpubuffer::GPUBuffer; use crate::dom::webgpu::gpucommandbuffer::GPUCommandBuffer; use crate::dom::webgpu::gpucomputepassencoder::GPUComputePassEncoder; -use crate::dom::webgpu::gpuconvert::{convert_load_op, convert_store_op}; use crate::dom::webgpu::gpudevice::GPUDevice; use crate::dom::webgpu::gpurenderpassencoder::GPURenderPassEncoder; use crate::script_runtime::CanGc; @@ -154,21 +153,21 @@ impl GPUCommandEncoderMethods<crate::DomTypeHolder> for GPUCommandEncoder { &self, descriptor: &GPURenderPassDescriptor, ) -> Fallible<DomRoot<GPURenderPassEncoder>> { - let depth_stencil_attachment = descriptor.depthStencilAttachment.as_ref().map(|depth| { + let depth_stencil_attachment = descriptor.depthStencilAttachment.as_ref().map(|ds| { wgpu_com::RenderPassDepthStencilAttachment { depth: wgpu_com::PassChannel { - load_op: convert_load_op(depth.depthLoadOp), - store_op: convert_store_op(depth.depthStoreOp), - clear_value: *depth.depthClearValue.unwrap_or_default(), - read_only: depth.depthReadOnly, + load_op: ds.depthLoadOp.as_ref().map(Convert::convert), + store_op: ds.depthStoreOp.as_ref().map(Convert::convert), + clear_value: *ds.depthClearValue.unwrap_or_default(), + read_only: ds.depthReadOnly, }, stencil: wgpu_com::PassChannel { - load_op: convert_load_op(depth.stencilLoadOp), - store_op: convert_store_op(depth.stencilStoreOp), - clear_value: depth.stencilClearValue, - read_only: depth.stencilReadOnly, + load_op: ds.stencilLoadOp.as_ref().map(Convert::convert), + store_op: ds.stencilStoreOp.as_ref().map(Convert::convert), + clear_value: ds.stencilClearValue, + read_only: ds.stencilReadOnly, }, - view: depth.view.id().0, + view: ds.view.id().0, } }); @@ -178,8 +177,8 @@ impl GPUCommandEncoderMethods<crate::DomTypeHolder> for GPUCommandEncoder { .map(|color| -> Fallible<_> { Ok(Some(wgpu_com::RenderPassColorAttachment { resolve_target: color.resolveTarget.as_ref().map(|t| t.id().0), - load_op: convert_load_op(Some(color.loadOp)), - store_op: convert_store_op(Some(color.storeOp)), + load_op: color.loadOp.convert(), + store_op: color.storeOp.convert(), clear_value: color .clearValue .as_ref() diff --git a/components/script/dom/webgpu/gpuconvert.rs b/components/script/dom/webgpu/gpuconvert.rs index f9ad05d2dc1..ee4e6e7f09c 100644 --- a/components/script/dom/webgpu/gpuconvert.rs +++ b/components/script/dom/webgpu/gpuconvert.rs @@ -406,19 +406,21 @@ impl Convert<wgt::BlendComponent> for &GPUBlendComponent { } } -pub fn convert_load_op(op: Option<GPULoadOp>) -> wgpu_com::LoadOp { - match op { - Some(GPULoadOp::Load) => wgpu_com::LoadOp::Load, - Some(GPULoadOp::Clear) => wgpu_com::LoadOp::Clear, - None => wgpu_com::LoadOp::Clear, +impl Convert<wgpu_com::LoadOp> for &GPULoadOp { + fn convert(self) -> wgpu_com::LoadOp { + match self { + GPULoadOp::Load => wgpu_com::LoadOp::Load, + GPULoadOp::Clear => wgpu_com::LoadOp::Clear, + } } } -pub fn convert_store_op(op: Option<GPUStoreOp>) -> wgpu_com::StoreOp { - match op { - Some(GPUStoreOp::Store) => wgpu_com::StoreOp::Store, - Some(GPUStoreOp::Discard) => wgpu_com::StoreOp::Discard, - None => wgpu_com::StoreOp::Discard, +impl Convert<wgpu_com::StoreOp> for &GPUStoreOp { + fn convert(self) -> wgpu_com::StoreOp { + match self { + GPUStoreOp::Store => wgpu_com::StoreOp::Store, + GPUStoreOp::Discard => wgpu_com::StoreOp::Discard, + } } } diff --git a/components/webgpu/wgpu_thread.rs b/components/webgpu/wgpu_thread.rs index 2db67d2029f..7374670355b 100644 --- a/components/webgpu/wgpu_thread.rs +++ b/components/webgpu/wgpu_thread.rs @@ -481,7 +481,7 @@ impl WGPU { wgpu_core::pipeline::ShaderModuleSource::Wgsl(Cow::Borrowed(&program)); let desc = ShaderModuleDescriptor { label: label.map(|s| s.into()), - shader_bound_checks: wgt::ShaderBoundChecks::default(), + runtime_checks: wgt::ShaderRuntimeChecks::checked(), }; let (_, error) = global.device_create_shader_module( device_id, |