[vulkan] Re-defining DynamicRendering scheduler/framebuffer and RenderAttachment with direct copy

This commit is contained in:
CamilleLaVey 2026-01-31 22:47:09 -04:00
parent c295c9c30c
commit a176746184
1 changed files with 28 additions and 2 deletions

View File

@ -6,8 +6,10 @@
#include <memory>
#include <mutex>
#include <optional>
#include <thread>
#include <utility>
#include <vector>
#include <fmt/format.h>
@ -129,8 +131,32 @@ void Scheduler::RequestRenderpass(const Framebuffer* framebuffer) {
}
if (use_dynamic_rendering) {
const VkRenderingInfo rendering_info = framebuffer->RenderingInfo();
Record([rendering_info](vk::CommandBuffer cmdbuf) { cmdbuf.BeginRendering(&rendering_info); });
const VkRenderingInfo fb_rendering_info = framebuffer->RenderingInfo();
std::vector<VkRenderingAttachmentInfo> color_infos;
color_infos.reserve(fb_rendering_info.colorAttachmentCount);
for (u32 i = 0; i < fb_rendering_info.colorAttachmentCount; ++i) {
color_infos.push_back(fb_rendering_info.pColorAttachments[i]);
}
std::optional<VkRenderingAttachmentInfo> depth_info;
std::optional<VkRenderingAttachmentInfo> stencil_info;
if (fb_rendering_info.pDepthAttachment) {
depth_info = *fb_rendering_info.pDepthAttachment;
}
if (fb_rendering_info.pStencilAttachment) {
stencil_info = *fb_rendering_info.pStencilAttachment;
}
Record([rendering_info = fb_rendering_info, color_infos = std::move(color_infos),
depth_info = std::move(depth_info), stencil_info = std::move(stencil_info)](
vk::CommandBuffer cmdbuf) {
VkRenderingInfo info = rendering_info;
info.pColorAttachments = color_infos.empty() ? nullptr : color_infos.data();
info.pDepthAttachment = depth_info ? &*depth_info : nullptr;
info.pStencilAttachment = stencil_info ? &*stencil_info : nullptr;
cmdbuf.BeginRendering(&info);
});
} else {
Record([renderpass, framebuffer_handle, render_area](vk::CommandBuffer cmdbuf) {
const VkRenderPassBeginInfo renderpass_bi{