mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 18:53:58 +01:00
Make the frame-time budget for uploading replacement textures take framerate into account
This commit is contained in:
1 parent
f2de70c904
commit
0f18f054ab
5 files changed
+27
-14
No files matched your search
@@ -34,6 +34,7 @@
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Debugger/MemBlockInfo.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/HW/Display.h"
|
||||
#include "GPU/Common/FramebufferManagerCommon.h"
|
||||
#include "GPU/Common/TextureCacheCommon.h"
|
||||
#include "GPU/Common/TextureDecoder.h"
|
||||
@@ -127,6 +128,14 @@ void TextureCacheCommon::StartFrame() {
|
||||
timesInvalidatedAllThisFrame_ = 0;
|
||||
replacementTimeThisFrame_ = 0.0;
|
||||
|
||||
float fps;
|
||||
__DisplayGetFPS(nullptr, &fps, nullptr);
|
||||
if (fps <= 5.0f) {
|
||||
fps = 60.0f;
|
||||
}
|
||||
// Allow spending half a frame on uploading textures.
|
||||
replacementFrameBudgetSeconds_ = 0.5f / fps;
|
||||
|
||||
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS) {
|
||||
gpuStats.numReplacerTrackedTex = replacer_.GetNumTrackedTextures();
|
||||
gpuStats.numCachedReplacedTextures = replacer_.GetNumCachedReplacedTextures();
|
||||
@@ -530,7 +539,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
|
||||
}
|
||||
}
|
||||
|
||||
if (match && (entry->status & TexCacheEntry::STATUS_TO_REPLACE) && replacementTimeThisFrame_ < replacementFrameBudget_) {
|
||||
if (match && (entry->status & TexCacheEntry::STATUS_TO_REPLACE) && replacementTimeThisFrame_ < replacementFrameBudgetSeconds_) {
|
||||
int w0 = gstate.getTextureWidth(0);
|
||||
int h0 = gstate.getTextureHeight(0);
|
||||
int d0 = 1;
|
||||
@@ -1572,10 +1581,9 @@ ReplacedTexture *TextureCacheCommon::FindReplacement(TexCacheEntry *entry, int *
|
||||
}
|
||||
|
||||
void TextureCacheCommon::PollReplacement(TexCacheEntry *entry, int *w, int *h, int *d) {
|
||||
// Allow some delay to reduce pop-in.
|
||||
constexpr double MAX_BUDGET_PER_TEX = 0.25 / 60.0;
|
||||
|
||||
double budget = std::min(MAX_BUDGET_PER_TEX, replacementFrameBudget_ - replacementTimeThisFrame_);
|
||||
double budget = replacementFrameBudgetSeconds_ - replacementTimeThisFrame_;
|
||||
// Note: Don't avoid the Poll call if budget is 0, we do meaningful things there.
|
||||
// Poll also handles negative budgets.
|
||||
|
||||
double replaceStart = time_now_d();
|
||||
if (entry->replacedTexture->Poll(budget)) {
|
||||
@@ -3157,7 +3165,7 @@ void TextureCacheCommon::DrawImGuiDebug(uint64_t &selectedTextureId) const {
|
||||
ImGui::Text("Texels scaled this frame: %d", texelsScaledThisFrame_);
|
||||
ImGui::Text("Low memory mode: %d", (int)lowMemoryMode_);
|
||||
if (ImGui::CollapsingHeader("Texture Replacement", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::Text("Frame time/budget: %0.3f/%0.3f ms", replacementTimeThisFrame_ * 1000.0f, replacementFrameBudget_ * 1000.0f);
|
||||
ImGui::Text("Frame time/budget: %0.3f/%0.3f ms", replacementTimeThisFrame_ * 1000.0f, replacementFrameBudgetSeconds_ * 1000.0f);
|
||||
ImGui::Text("UNLOADED: %d PENDING: %d NOT_FOUND: %d ACTIVE: %d CANCEL_INIT: %d",
|
||||
replacementStateCounts[(int)ReplacementState::UNLOADED],
|
||||
replacementStateCounts[(int)ReplacementState::PENDING],
|
||||
|
||||
Reference in new issue
Block a user