Skip to content

Commit

Permalink
Add Half Skip Mode. May help #18607
Browse files Browse the repository at this point in the history
  • Loading branch information
sum2012 authored and hrydgard committed Sep 17, 2024
1 parent 0bb69a0 commit cf753ff
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ struct Config {
float fCwCheatScrollPosition;
float fGameListScrollPosition;
int iBloomHack; //0 = off, 1 = safe, 2 = balanced, 3 = aggressive
int iSkipGPUReadbackMode; // 0 = off, 1 = skip, 2 = to texture
int iSkipGPUReadbackMode; // 0 = off, 1 = skip, 2 = to texture, 3 = half skip
int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High
bool bHardwareTessellation;
bool bShaderCache; // Hidden ini-only setting, useful for debugging shader compile times.
Expand Down
1 change: 1 addition & 0 deletions Core/ConfigValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ enum class SkipGPUReadbackMode : int {
NO_SKIP,
SKIP,
COPY_TO_TEXTURE,
HALF_SKIP,
};

enum class RemoteISOShareType : int {
Expand Down
33 changes: 29 additions & 4 deletions GPU/Common/FramebufferManagerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@
#include "GPU/GPUInterface.h"
#include "GPU/GPUState.h"

static bool GenerateBoolean() {
int randomNumber = rand() % 100; // Generate a random number between 0 and 99
if (randomNumber < 50) {
return true; // 50% chance of returning true
}
else {
return false; // 50% chance of returning false
}
}

static size_t FormatFramebufferName(const VirtualFramebuffer *vfb, char *tag, size_t len) {
return snprintf(tag, len, "FB_%08x_%08x_%dx%d_%s", vfb->fb_address, vfb->z_address, vfb->bufferWidth, vfb->bufferHeight, GeBufferFormatToString(vfb->fb_format));
}
Expand Down Expand Up @@ -1046,8 +1056,8 @@ void FramebufferManagerCommon::DownloadFramebufferOnSwitch(VirtualFramebuffer *v
// To support this, we save the first frame to memory when we have a safe w/h.
// Saving each frame would be slow.

// TODO: This type of download could be made async, for less stutter on framebuffer creation.
if (GetSkipGPUReadbackMode() == SkipGPUReadbackMode::NO_SKIP && !PSP_CoreParameter().compat.flags().DisableFirstFrameReadback) {
// TODO: This type of download could be made async, for less stutter on framebuffer creation.
if (g_Config.iSkipGPUReadbackMode == (int)SkipGPUReadbackMode::NO_SKIP || (g_Config.iSkipGPUReadbackMode == (int)SkipGPUReadbackMode::HALF_SKIP && GenerateBoolean())) {
ReadFramebufferToMemory(vfb, 0, 0, vfb->safeWidth, vfb->safeHeight, RASTER_COLOR, Draw::ReadbackMode::BLOCK);
vfb->usageFlags = (vfb->usageFlags | FB_USAGE_DOWNLOAD | FB_USAGE_FIRST_FRAME_SAVED) & ~FB_USAGE_DOWNLOAD_CLEAR;
vfb->safeWidth = 0;
Expand All @@ -1063,10 +1073,25 @@ bool FramebufferManagerCommon::ShouldDownloadFramebufferColor(const VirtualFrame

bool FramebufferManagerCommon::ShouldDownloadFramebufferDepth(const VirtualFramebuffer *vfb) {
// Download depth buffer for Syphon Filter lens flares
if (!PSP_CoreParameter().compat.flags().ReadbackDepth || GetSkipGPUReadbackMode() != SkipGPUReadbackMode::NO_SKIP) {
if (!PSP_CoreParameter().compat.flags().ReadbackDepth) {
return false;
}
return (vfb->usageFlags & FB_USAGE_RENDER_DEPTH) != 0 && vfb->width >= 480 && vfb->height >= 272;

bool performDepthReadback = true;

switch (GetSkipGPUReadbackMode()) {
case SkipGPUReadbackMode::SKIP:
performDepthReadback = false;
break;
case SkipGPUReadbackMode::HALF_SKIP:
performDepthReadback = GenerateBoolean();
break;
case SkipGPUReadbackMode::COPY_TO_TEXTURE:
case SkipGPUReadbackMode::NO_SKIP:
break;
}

return performDepthReadback && (vfb->usageFlags & FB_USAGE_RENDER_DEPTH) != 0 && vfb->width >= 480 && vfb->height >= 272;
}

void FramebufferManagerCommon::NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) {
Expand Down
2 changes: 1 addition & 1 deletion UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
CheckBox *disableCulling = graphicsSettings->Add(new CheckBox(&g_Config.bDisableRangeCulling, gr->T("Disable culling")));
disableCulling->SetDisabledPtr(&g_Config.bSoftwareRendering);

static const char *skipGpuReadbackModes[] = { "No (default)", "Skip", "Copy to texture" };
static const char *skipGpuReadbackModes[] = { "No (default)", "Skip", "Copy to texture" , "Half skip"};

PopupMultiChoice *skipGPUReadbacks = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iSkipGPUReadbackMode, gr->T("Skip GPU Readbacks"), skipGpuReadbackModes, 0, ARRAY_SIZE(skipGpuReadbackModes), I18NCat::GRAPHICS, screenManager()));
skipGPUReadbacks->SetDisabledPtr(&g_Config.bSoftwareRendering);
Expand Down

0 comments on commit cf753ff

Please sign in to comment.