Latte: Less aggressive texture readback

By mistake we would read affected textures back after every single drawcall. As an optimization if the same texture gets drawn to multiple times we'll try to only read it back once at the end of the sequence.
This commit is contained in:
Exzap 2023-01-27 09:18:55 +01:00
parent 859dc78e90
commit 404af95a2c
5 changed files with 20 additions and 15 deletions

View file

@ -746,7 +746,7 @@ void LatteTextureLoader_writeReadbackTextureToMemory(LatteTextureDefinition* tex
return;
}
cemuLog_log(LogType::TextureReadback, "[WriteReadbackTex] PhysAddr {:08x} Res {}x{} Fmt {} Slice {} Mip {}", textureData->physAddress, textureData->width, textureData->height, textureData->format, sliceIndex, mipIndex);
cemuLog_log(LogType::TextureReadback, "[TextureReadback-Write] PhysAddr {:08x} Res {}x{} Fmt {} Slice {} Mip {}", textureData->physAddress, textureData->width, textureData->height, textureData->format, sliceIndex, mipIndex);
if (textureData->tileMode == Latte::E_HWTILEMODE::TM_LINEAR_ALIGNED)
{

View file

@ -21,6 +21,7 @@ std::queue<LatteTextureReadbackInfo*> sTextureActiveReadbackQueue; // readbacks
void LatteTextureReadback_StartTransfer(LatteTextureView* textureView)
{
cemuLog_log(LogType::TextureReadback, "[TextureReadback-Start] PhysAddr {:08x} Res {}x{} Fmt {} Slice {} Mip {}", textureView->baseTexture->physAddress, textureView->baseTexture->width, textureView->baseTexture->height, textureView->baseTexture->format, textureView->firstSlice, textureView->firstMip);
// create info entry and store in ordered linked list
LatteTextureReadbackInfo* readbackInfo = g_renderer->texture_createReadback(textureView);
sTextureActiveReadbackQueue.push(readbackInfo);
@ -30,8 +31,8 @@ void LatteTextureReadback_StartTransfer(LatteTextureView* textureView)
}
/*
* Checks for queued transfers and starts them if at least one drawcall has passed since the last write
* Called after a draw operation has finished
* Checks for queued transfers and starts them if at least five drawcalls have passed since the last write
* Called after a draw sequence is completed
* Returns true if at least one transfer was started
*/
bool LatteTextureReadback_Update(bool forceStart)
@ -41,12 +42,14 @@ bool LatteTextureReadback_Update(bool forceStart)
{
LatteTextureReadbackQueueEntry& entry = sTextureScheduledReadbacks[i];
uint32 numPassedDrawcalls = LatteGPUState.drawCallCounter - entry.lastUpdateDrawcallIndex;
// initiate transfer
LatteTextureReadback_StartTransfer(entry.textureView);
// remove element
vectorRemoveByIndex(sTextureScheduledReadbacks, i);
i--;
hasStartedTransfer = true;
if (forceStart || numPassedDrawcalls >= 5)
{
LatteTextureReadback_StartTransfer(entry.textureView);
// remove element
vectorRemoveByIndex(sTextureScheduledReadbacks, i);
i--;
hasStartedTransfer = true;
}
}
return hasStartedTransfer;
}

View file

@ -59,7 +59,6 @@ uint32 VulkanPipelineStableCache::BeginLoading(uint64 cacheTitleId)
// open cache file or create it
cemu_assert_debug(s_cache == nullptr);
const uint32 cacheFileVersion = 1;
s_cache = FileCache::Open(pathCacheFile.generic_wstring(), true, LatteShaderCache_getPipelineCacheExtraVersion(cacheTitleId));
if (!s_cache)
{