mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
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>
This commit is contained in:
parent
3d816d6d24
commit
d7eb0c5c38
6 changed files with 31 additions and 132 deletions
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue