mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
fix(ext/webgpu): Allow depthClearValue
to be undefined when depthLoadOp
is not "clear" (#23850)
This commit is contained in:
parent
c89f9f9ad1
commit
529356cc12
2 changed files with 34 additions and 2 deletions
|
@ -79,7 +79,7 @@ pub struct GpuRenderPassColorAttachment {
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct GpuRenderPassDepthStencilAttachment {
|
pub struct GpuRenderPassDepthStencilAttachment {
|
||||||
view: ResourceId,
|
view: ResourceId,
|
||||||
depth_clear_value: f32,
|
depth_clear_value: Option<f32>,
|
||||||
depth_load_op: Option<wgpu_core::command::LoadOp>,
|
depth_load_op: Option<wgpu_core::command::LoadOp>,
|
||||||
depth_store_op: Option<wgpu_core::command::StoreOp>,
|
depth_store_op: Option<wgpu_core::command::StoreOp>,
|
||||||
depth_read_only: bool,
|
depth_read_only: bool,
|
||||||
|
@ -168,7 +168,9 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
|
||||||
store_op: attachment
|
store_op: attachment
|
||||||
.depth_store_op
|
.depth_store_op
|
||||||
.unwrap_or(wgpu_core::command::StoreOp::Store),
|
.unwrap_or(wgpu_core::command::StoreOp::Store),
|
||||||
clear_value: attachment.depth_clear_value,
|
// In "01_webgpu.js", `depthLoadOp` is cheked to ensure its value is not "clear"
|
||||||
|
// when `depthClearValue` is undefined, so the default 0.0 doesn't matter.
|
||||||
|
clear_value: attachment.depth_clear_value.unwrap_or(0.0),
|
||||||
read_only: attachment.depth_read_only,
|
read_only: attachment.depth_read_only,
|
||||||
},
|
},
|
||||||
stencil: wgpu_core::command::PassChannel {
|
stencil: wgpu_core::command::PassChannel {
|
||||||
|
|
|
@ -496,6 +496,36 @@ Deno.test({
|
||||||
device.destroy();
|
device.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test({
|
||||||
|
ignore: isWsl || isLinuxOrMacCI,
|
||||||
|
}, async function beginRenderPassWithoutDepthClearValue() {
|
||||||
|
const adapter = await navigator.gpu.requestAdapter();
|
||||||
|
assert(adapter);
|
||||||
|
const device = await adapter.requestDevice();
|
||||||
|
assert(device);
|
||||||
|
|
||||||
|
const encoder = device.createCommandEncoder();
|
||||||
|
|
||||||
|
const depthTexture = device.createTexture({
|
||||||
|
size: [256, 256],
|
||||||
|
format: "depth32float",
|
||||||
|
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
||||||
|
});
|
||||||
|
const depthView = depthTexture.createView();
|
||||||
|
|
||||||
|
const renderPass = encoder.beginRenderPass({
|
||||||
|
colorAttachments: [],
|
||||||
|
depthStencilAttachment: {
|
||||||
|
view: depthView,
|
||||||
|
depthLoadOp: "load",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert(renderPass);
|
||||||
|
|
||||||
|
device.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
async function checkIsWsl() {
|
async function checkIsWsl() {
|
||||||
return Deno.build.os === "linux" && await hasMicrosoftProcVersion();
|
return Deno.build.os === "linux" && await hasMicrosoftProcVersion();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue