Resolve image aliases before buffer uploads

This commit is contained in:
nmzik
2026-09-14 16:29:43 +04:00
parent bce8924dd6
commit dd408ffd00
5 changed files with 146 additions and 16 deletions
@@ -15,6 +15,7 @@
#include "graphics/guest_gpu/tile.h"
#include "graphics/host_gpu/graphicContext.h"
#include "graphics/host_gpu/hostMemory.h"
#include "graphics/host_gpu/renderer/colorRenderTarget.h"
#include "graphics/host_gpu/renderer/debug.h"
#include "graphics/host_gpu/renderer/image/imageView.h"
#include "graphics/host_gpu/renderer/image/textureCommon.h"
@@ -850,7 +851,8 @@ void RenderExecutor::RebindImages(PreparedBindings& prepared) {
}
}
void RenderExecutor::PrepareGraphicsBindings(std::span<PreparedBindings* const> stages) {
void RenderExecutor::PrepareGraphicsBindings(std::span<PreparedBindings* const> stages,
std::span<RenderColorInfo> colors) {
bool uses_dma = false;
for (auto* stage: stages) {
FindBuffers(*stage);
@@ -859,12 +861,27 @@ void RenderExecutor::PrepareGraphicsBindings(std::span<PreparedBindings* const>
if (uses_dma) {
m_context.PrepareBda();
}
for (auto* stage: stages) {
RebindBuffers(*stage);
}
for (auto* stage: stages) {
RebindImages(*stage);
}
auto& cache = m_context.GetTextureCache();
for (auto& target: colors) {
EXIT_IF(!target.image_id);
const auto old_image = cache.m_slot_images.try_get(target.image_id);
if (old_image == nullptr || (!old_image->registered && !old_image->info.data.Empty()) ||
old_image->binding.needs_rebind) {
if (old_image != nullptr) {
old_image->binding = {};
}
target.image_id = cache.FindImage(target.desc);
BindRenderTarget(target.image_id);
}
}
// Discovery can read back PS5 metadata and submit the scheduler. Reserve draw buffers only
// after image identities are final; attachment layout transitions follow buffer alias copies.
for (auto* stage: stages) {
RebindBuffers(*stage);
}
}
void RenderExecutor::CommitBindings(CommandBuffer& buffer,