1
0
Fork 0
forked from wry/wry

vulkan: don't call vkCmdClearAttachments if damage is empty

This commit is contained in:
Julian Orth 2025-02-21 11:53:48 +01:00
parent 8a3a377f61
commit bbe8fdecf8

View file

@ -50,7 +50,7 @@ use {
SubmitInfo2, Viewport, WriteDescriptorSet, SubmitInfo2, Viewport, WriteDescriptorSet,
}, },
}, },
isnt::std_1::collections::IsntHashMapExt, isnt::std_1::{collections::IsntHashMapExt, primitive::IsntSliceExt},
linearize::{Linearize, StaticMap, static_map}, linearize::{Linearize, StaticMap, static_map},
std::{ std::{
cell::{Cell, RefCell}, cell::{Cell, RefCell},
@ -543,25 +543,27 @@ impl VulkanRenderer {
unsafe { unsafe {
self.device.device.cmd_begin_rendering(buf, &rendering_info); self.device.device.cmd_begin_rendering(buf, &rendering_info);
} }
if let Some(clear) = manual_clear { if memory.paint_regions.is_not_empty() {
let clear_attachment = ClearAttachment::default() if let Some(clear) = manual_clear {
.color_attachment(0) let clear_attachment = ClearAttachment::default()
.clear_value(clear) .color_attachment(0)
.aspect_mask(ImageAspectFlags::COLOR); .clear_value(clear)
memory.clear_rects.clear(); .aspect_mask(ImageAspectFlags::COLOR);
for region in &memory.paint_regions { memory.clear_rects.clear();
memory.clear_rects.push(ClearRect { for region in &memory.paint_regions {
rect: region.rect, memory.clear_rects.push(ClearRect {
base_array_layer: 0, rect: region.rect,
layer_count: 1, base_array_layer: 0,
}); layer_count: 1,
} });
unsafe { }
self.device.device.cmd_clear_attachments( unsafe {
buf, self.device.device.cmd_clear_attachments(
&[clear_attachment], buf,
&memory.clear_rects, &[clear_attachment],
); &memory.clear_rects,
);
}
} }
} }
} }