Flush deferred clears tied to scissor entries on framebuffer

This commit is contained in:
CamilleLaVey 2026-08-19 20:49:54 -04:00
parent 8206c7abac
commit a4c37b5117
6 changed files with 21 additions and 0 deletions

View file

@ -75,6 +75,8 @@ public:
void Finish(); void Finish();
void FlushDeferredClear() {}
StagingBufferMap UploadStagingBuffer(size_t size, bool deferred = false); StagingBufferMap UploadStagingBuffer(size_t size, bool deferred = false);
StagingBufferMap DownloadStagingBuffer(size_t size, bool deferred = false); StagingBufferMap DownloadStagingBuffer(size_t size, bool deferred = false);

View file

@ -192,6 +192,14 @@ bool Scheduler::DeferDepthStencilClear(const Framebuffer* framebuffer, const VkC
return true; return true;
} }
void Scheduler::FlushDeferredClear() {
if (deferred_clear.framebuffer == nullptr) {
return;
}
RealizeDeferredClear();
EndRenderPass();
}
void Scheduler::RequestRenderpass(const Framebuffer* framebuffer) { void Scheduler::RequestRenderpass(const Framebuffer* framebuffer) {
if (deferred_clear.framebuffer == framebuffer) { if (deferred_clear.framebuffer == framebuffer) {
RealizeDeferredClear(); RealizeDeferredClear();

View file

@ -65,6 +65,9 @@ public:
/// Defers a full depth/stencil clear so it becomes the next render pass. /// Defers a full depth/stencil clear so it becomes the next render pass.
bool DeferDepthStencilClear(const Framebuffer* framebuffer, const VkClearValue& value); bool DeferDepthStencilClear(const Framebuffer* framebuffer, const VkClearValue& value);
/// Realizes any pending deferred clear before its framebuffer can be moved or freed.
void FlushDeferredClear();
/// Requests the current execution context to be able to execute operations only allowed outside /// Requests the current execution context to be able to execute operations only allowed outside
/// of a renderpass. /// of a renderpass.
void RequestOutsideRenderPassOperationContext(); void RequestOutsideRenderPassOperationContext();

View file

@ -1796,6 +1796,10 @@ bool TextureCacheRuntime::CanReportMemoryUsage() const {
return device.CanReportMemoryUsage(); return device.CanReportMemoryUsage();
} }
void TextureCacheRuntime::FlushDeferredClear() {
scheduler.FlushDeferredClear();
}
void TextureCacheRuntime::TickFrame() { void TextureCacheRuntime::TickFrame() {
std::erase_if(pending_msaa_images, [this](const auto& pending) { std::erase_if(pending_msaa_images, [this](const auto& pending) {
return scheduler.IsFree(pending.first); return scheduler.IsFree(pending.first);

View file

@ -60,6 +60,8 @@ public:
void TickFrame(); void TickFrame();
void FlushDeferredClear();
u64 GetDeviceLocalMemory() const; u64 GetDeviceLocalMemory() const;
u64 GetDeviceMemoryUsage() const; u64 GetDeviceMemoryUsage() const;

View file

@ -577,6 +577,7 @@ FramebufferId TextureCache<P>::GetFramebufferId(const RenderTargets& key) {
return id ? &slot_image_views[id] : nullptr; return id ? &slot_image_views[id] : nullptr;
}); });
ImageView* const depth_buffer = key.depth_buffer_id ? &slot_image_views[key.depth_buffer_id] : nullptr; ImageView* const depth_buffer = key.depth_buffer_id ? &slot_image_views[key.depth_buffer_id] : nullptr;
runtime.FlushDeferredClear();
framebuffer_id = slot_framebuffers.insert(runtime, color_buffers, depth_buffer, key); framebuffer_id = slot_framebuffers.insert(runtime, color_buffers, depth_buffer, key);
return framebuffer_id; return framebuffer_id;
} }
@ -2419,6 +2420,7 @@ void TextureCache<P>::RemoveImageViewReferences(std::span<const ImageViewId> rem
template <class P> template <class P>
void TextureCache<P>::RemoveFramebuffers(std::span<const ImageViewId> removed_views) { void TextureCache<P>::RemoveFramebuffers(std::span<const ImageViewId> removed_views) {
runtime.FlushDeferredClear();
auto it = framebuffers.begin(); auto it = framebuffers.begin();
while (it != framebuffers.end()) { while (it != framebuffers.end()) {
if (it->first.Contains(removed_views)) { if (it->first.Contains(removed_views)) {