vk: Ensure all drawable surfaces invalidate fbo cache on deletion

This commit is contained in:
kd-11
2026-08-13 11:39:34 +03:00
committed by kd-11
parent c2eb11eae6
commit ea0e10e704
4 changed files with 27 additions and 17 deletions
+10
View File
@@ -135,6 +135,11 @@ namespace vk
void remove_framebuffers_with_image(const vk::image* image)
{
if (!image)
{
return;
}
remove_framebuffers_with_filter([image](const auto& fbo)
{
return fbo->references(image);
@@ -143,6 +148,11 @@ namespace vk
void remove_framebuffers_with_image(VkImage handle)
{
if (!handle)
{
return;
}
remove_framebuffers_with_filter([handle](const auto& fbo)
{
return fbo->references(handle);
+2 -7
View File
@@ -306,17 +306,12 @@ namespace vk
return (bytes_spilled > 0);
}
render_target::~render_target()
drawable_surface_t::~drawable_surface_t()
{
if (value)
{
vk::remove_framebuffers_with_image(this);
}
if (resolve_surface)
{
vk::remove_framebuffers_with_image(resolve_surface.get());
}
}
// Get the linear resolve target bound to this surface. Initialize if none exists
@@ -331,7 +326,7 @@ namespace vk
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
usage |= (this->info.usage & (VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT));
resolve_surface.reset(new vk::viewable_image(
resolve_surface.reset(new vk::drawable_surface_t(
*g_render_device,
g_render_device->get_memory_mapping().device_local,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+9 -3
View File
@@ -67,7 +67,14 @@ namespace vk
}
};
class render_target : public viewable_image, public rsx::render_target_descriptor<vk::viewable_image*>
struct drawable_surface_t : public viewable_image
{
using viewable_image::viewable_image;
virtual ~drawable_surface_t();
};
class render_target : public drawable_surface_t, public rsx::render_target_descriptor<vk::viewable_image*>
{
// Cyclic reference hazard tracking
image_reference_sync_barrier m_cyclic_ref_tracker;
@@ -103,8 +110,7 @@ namespace vk
u64 spill_request_tag = 0; // timestamp when spilling was requested
bool is_bound = false; // set when the surface is bound for rendering
using viewable_image::viewable_image;
virtual ~render_target();
using drawable_surface_t::drawable_surface_t;
vk::viewable_image* get_surface(rsx::surface_access access_type) override;
bool is_depth_surface() const override;
@@ -93,15 +93,14 @@ namespace vk
return true;
}
bool references(const vk::image* image) const
{
ensure(image);
return std::ranges::find_if(attachments, FN(x->info.image == image->value)) != attachments.end();
}
bool references(VkImage handle) const
{
return std::ranges::find_if(attachments, FN(x->info.image == handle)) != attachments.end();
return !!handle && std::ranges::find_if(attachments, FN(x->info.image == handle)) != attachments.end();
}
bool references(const vk::image* image) const
{
return !!image && references(image->value);
}
framebuffer(const framebuffer&) = delete;