Skip to content

Commit

Permalink
vulkan: respect DontCare initop
Browse files Browse the repository at this point in the history
  • Loading branch information
EriKWDev authored and kvark committed Jan 10, 2025
1 parent ae57beb commit 456edfb
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions blade-graphics/src/vulkan/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,38 +161,43 @@ fn make_buffer_image_copy(
fn map_render_target(rt: &crate::RenderTarget) -> vk::RenderingAttachmentInfo<'static> {
let mut vk_info = vk::RenderingAttachmentInfo::default()
.image_view(rt.view.raw)
.image_layout(vk::ImageLayout::GENERAL)
.load_op(vk::AttachmentLoadOp::LOAD);

if let crate::InitOp::Clear(color) = rt.init_op {
let cv = if rt.view.aspects.contains(crate::TexelAspects::COLOR) {
vk::ClearValue {
color: match color {
crate::TextureColor::TransparentBlack => vk::ClearColorValue::default(),
crate::TextureColor::OpaqueBlack => vk::ClearColorValue {
float32: [0.0, 0.0, 0.0, 1.0],
.image_layout(vk::ImageLayout::GENERAL);

match rt.init_op {
crate::InitOp::Load => vk_info = vk_info.load_op(vk::AttachmentLoadOp::LOAD),
crate::InitOp::DontCare => vk_info = vk_info.load_op(vk::AttachmentLoadOp::DONT_CARE),

crate::InitOp::Clear(color) => {
let cv = if rt.view.aspects.contains(crate::TexelAspects::COLOR) {
vk::ClearValue {
color: match color {
crate::TextureColor::TransparentBlack => vk::ClearColorValue::default(),
crate::TextureColor::OpaqueBlack => vk::ClearColorValue {
float32: [0.0, 0.0, 0.0, 1.0],
},
crate::TextureColor::White => vk::ClearColorValue { float32: [1.0; 4] },
},
crate::TextureColor::White => vk::ClearColorValue { float32: [1.0; 4] },
},
}
} else {
vk::ClearValue {
depth_stencil: match color {
crate::TextureColor::TransparentBlack => vk::ClearDepthStencilValue::default(),
crate::TextureColor::OpaqueBlack => vk::ClearDepthStencilValue {
depth: 1.0,
stencil: 0,
},
crate::TextureColor::White => vk::ClearDepthStencilValue {
depth: 1.0,
stencil: !0,
}
} else {
vk::ClearValue {
depth_stencil: match color {
crate::TextureColor::TransparentBlack => {
vk::ClearDepthStencilValue::default()
}
crate::TextureColor::OpaqueBlack => vk::ClearDepthStencilValue {
depth: 1.0,
stencil: 0,
},
crate::TextureColor::White => vk::ClearDepthStencilValue {
depth: 1.0,
stencil: !0,
},
},
},
}
};
}
};

vk_info.load_op = vk::AttachmentLoadOp::CLEAR;
vk_info.clear_value = cv;
vk_info = vk_info.load_op(vk::AttachmentLoadOp::CLEAR).clear_value(cv);
}
}

if let crate::FinishOp::ResolveTo(resolve_view) = rt.finish_op {
Expand Down

0 comments on commit 456edfb

Please sign in to comment.