Skip to content

Commit

Permalink
Fix event order and some logic. Can now change skip buffer effect whi…
Browse files Browse the repository at this point in the history
…le running in background.
  • Loading branch information
hrydgard committed Feb 1, 2024
1 parent 337de54 commit a07a2e4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions GPU/Common/PresentationCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
if (usePostShader) {
// When we render to temp framebuffers during post, we switch position, not UV.
// The flipping here is only because D3D has a clip coordinate system that doesn't match their screen coordinate system.
// The flipping here is only because D3D has a clip coordinate system that doesn't match their screen coordinate system.
bool flipped = flags & OutputFlags::POSITION_FLIPPED;
float y0 = flipped ? 1.0f : -1.0f;
float y1 = flipped ? -1.0f : 1.0f;
Expand Down
6 changes: 3 additions & 3 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
// We only bind it in FramebufferManager::CopyDisplayToOutput (unless non-buffered)...
// We do, however, start the frame in other ways.

if ((g_Config.bSkipBufferEffects && !g_Config.bSoftwareRendering) || Core_IsStepping()) {
if ((skipBufferEffects && !g_Config.bSoftwareRendering) || Core_IsStepping()) {
// We need to clear here already so that drawing during the frame is done on a clean slate.
if (Core_IsStepping() && gpuStats.numFlips != 0) {
draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::KEEP, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_BackBuffer");
Expand All @@ -1348,12 +1348,12 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
System_Notify(SystemNotification::KEEP_SCREEN_AWAKE);
} else if (!Core_ShouldRunBehind() && strcmp(screenManager()->topScreen()->tag(), "DevMenu") != 0) {
// Just to make sure.
if (PSP_IsInited() && !g_Config.bSkipBufferEffects) {
if (PSP_IsInited() && !skipBufferEffects) {
PSP_BeginHostFrame();
gpu->CopyDisplayToOutput(true);
PSP_EndHostFrame();
}
if (!gpu->PresentedThisFrame()) {
if (!framebufferBound && !gpu->PresentedThisFrame()) {
draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, }, "EmuScreen_Behind");
}
// Need to make sure the UI texture is available, for "darken".
Expand Down
35 changes: 18 additions & 17 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,23 +1061,6 @@ void NativeFrame(GraphicsContext *graphicsContext) {
ProcessWheelRelease(NKCODE_EXT_MOUSEWHEEL_UP, startTime, false);
ProcessWheelRelease(NKCODE_EXT_MOUSEWHEEL_DOWN, startTime, false);

std::vector<PendingMessage> toProcess;
{
std::lock_guard<std::mutex> lock(pendingMutex);
toProcess = std::move(pendingMessages);
pendingMessages.clear();
}

for (const auto &item : toProcess) {
if (HandleGlobalMessage(item.message, item.value)) {
// TODO: Add a to-string thingy.
INFO_LOG(SYSTEM, "Handled global message: %d / %s", (int)item.message, item.value.c_str());
}
g_screenManager->sendMessage(item.message, item.value.c_str());
}

g_requestManager.ProcessRequests();

// it's ok to call this redundantly with DoFrame from EmuScreen
Achievements::Idle();

Expand All @@ -1104,6 +1087,24 @@ void NativeFrame(GraphicsContext *graphicsContext) {

g_screenManager->update();

// Do this after g_screenManager.update() so we can receive setting changes before rendering.
std::vector<PendingMessage> toProcess;
{
std::lock_guard<std::mutex> lock(pendingMutex);
toProcess = std::move(pendingMessages);
pendingMessages.clear();
}

for (const auto &item : toProcess) {
if (HandleGlobalMessage(item.message, item.value)) {
// TODO: Add a to-string thingy.
INFO_LOG(SYSTEM, "Handled global message: %d / %s", (int)item.message, item.value.c_str());
}
g_screenManager->sendMessage(item.message, item.value.c_str());
}

g_requestManager.ProcessRequests();

// Apply the UIContext bounds as a 2D transformation matrix.
// TODO: This should be moved into the draw context...
Matrix4x4 ortho = ComputeOrthoMatrix(g_display.dp_xres, g_display.dp_yres);
Expand Down

0 comments on commit a07a2e4

Please sign in to comment.