From c295c9c30c96e730dedf832b5afc9dff2c3f2712 Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Sat, 31 Jan 2026 22:19:16 -0400 Subject: [PATCH] [vulkan] Establishin pColorAttachments pass thorugh DynamicRendering commands --- .../renderer_vulkan/vk_texture_cache.cpp | 70 +++++++++++++++++++ .../renderer_vulkan/vk_texture_cache.h | 6 +- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 9d6f3e1c8b..b35ea2537b 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -2377,6 +2378,65 @@ Framebuffer::Framebuffer(TextureCacheRuntime& runtime, ImageView* color_buffer, Framebuffer::~Framebuffer() = default; +Framebuffer::Framebuffer(Framebuffer&& other) noexcept + : framebuffer{std::move(other.framebuffer)}, + renderpass{std::exchange(other.renderpass, VkRenderPass{})}, + render_area{other.render_area}, + samples{other.samples}, + num_color_buffers{other.num_color_buffers}, + num_images{other.num_images}, + images{other.images}, + image_ranges{other.image_ranges}, + rt_map{other.rt_map}, + has_depth{other.has_depth}, + has_stencil{other.has_stencil}, + is_rescaled{other.is_rescaled}, + color_attachment_infos{other.color_attachment_infos}, + depth_attachment_info{other.depth_attachment_info}, + rendering_info{other.rendering_info} { + other.num_color_buffers = 0; + other.num_images = 0; + other.has_depth = false; + other.has_stencil = false; + other.rendering_info.pColorAttachments = nullptr; + other.rendering_info.pDepthAttachment = nullptr; + other.rendering_info.pStencilAttachment = nullptr; + FixupRenderingInfoPointers(); +} + +Framebuffer& Framebuffer::operator=(Framebuffer&& other) noexcept { + if (this == &other) { + return *this; + } + + framebuffer = std::move(other.framebuffer); + renderpass = std::exchange(other.renderpass, VkRenderPass{}); + render_area = other.render_area; + samples = other.samples; + num_color_buffers = other.num_color_buffers; + num_images = other.num_images; + images = other.images; + image_ranges = other.image_ranges; + rt_map = other.rt_map; + has_depth = other.has_depth; + has_stencil = other.has_stencil; + is_rescaled = other.is_rescaled; + color_attachment_infos = other.color_attachment_infos; + depth_attachment_info = other.depth_attachment_info; + rendering_info = other.rendering_info; + + other.num_color_buffers = 0; + other.num_images = 0; + other.has_depth = false; + other.has_stencil = false; + other.rendering_info.pColorAttachments = nullptr; + other.rendering_info.pDepthAttachment = nullptr; + other.rendering_info.pStencilAttachment = nullptr; + + FixupRenderingInfoPointers(); + return *this; +} + void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime, std::span color_buffers, ImageView* depth_buffer, bool is_rescaled_) { @@ -2490,6 +2550,16 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime, .height = render_area.height, .layers = static_cast((std::max)(num_layers, 1)), }); + + FixupRenderingInfoPointers(); +} + +void Framebuffer::FixupRenderingInfoPointers() noexcept { + rendering_info.pColorAttachments = rendering_info.colorAttachmentCount > 0 + ? color_attachment_infos.data() + : nullptr; + rendering_info.pDepthAttachment = has_depth ? &depth_attachment_info : nullptr; + rendering_info.pStencilAttachment = has_stencil ? &depth_attachment_info : nullptr; } void TextureCacheRuntime::AccelerateImageUpload( diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index d67a5e3293..973cf08250 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -154,8 +154,8 @@ public: Framebuffer(const Framebuffer&) = delete; Framebuffer& operator=(const Framebuffer&) = delete; - Framebuffer(Framebuffer&&) = default; - Framebuffer& operator=(Framebuffer&&) = default; + Framebuffer(Framebuffer&&) noexcept; + Framebuffer& operator=(Framebuffer&&) noexcept; void CreateFramebuffer(TextureCacheRuntime& runtime, std::span color_buffers, ImageView* depth_buffer, @@ -231,6 +231,8 @@ private: std::array color_attachment_infos{}; VkRenderingAttachmentInfo depth_attachment_info{}; VkRenderingInfo rendering_info{}; + + void FixupRenderingInfoPointers() noexcept; }; class Image : public VideoCommon::ImageBase {