Skip to content

Commit

Permalink
Fix issue where nothing had started a render pass when we wanted to c…
Browse files Browse the repository at this point in the history
…lear the screen.
  • Loading branch information
hrydgard committed Dec 11, 2023
1 parent e8f7059 commit 8d8ff58
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 5 deletions.
6 changes: 5 additions & 1 deletion GPU/Common/FramebufferManagerCommon.cpp
Expand Up @@ -123,10 +123,14 @@ void FramebufferManagerCommon::CheckPostShaders() {

void FramebufferManagerCommon::BeginFrame() {
DecimateFBOs();

presentation_->BeginFrame();
currentRenderVfb_ = nullptr;
}

bool FramebufferManagerCommon::PresentedThisFrame() const {
return presentation_->PresentedThisFrame();
}

void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
displayFramebufPtr_ = framebuf & 0x3FFFFFFF;
if (Memory::IsVRAMAddress(displayFramebufPtr_))
Expand Down
2 changes: 2 additions & 0 deletions GPU/Common/FramebufferManagerCommon.h
Expand Up @@ -485,6 +485,8 @@ class FramebufferManagerCommon {
currentFramebufferCopy_ = nullptr;
}

bool PresentedThisFrame() const;

protected:
virtual void ReadbackFramebuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel, Draw::ReadbackMode mode);
// Used for when a shader is required, such as GLES.
Expand Down
1 change: 1 addition & 0 deletions GPU/Common/PresentationCommon.cpp
Expand Up @@ -931,6 +931,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
draw_->Invalidate(InvalidationFlags::CACHED_RENDER_STATE);

previousUniforms_ = uniforms;
presentedThisFrame_ = true;
}

void PresentationCommon::CalculateRenderResolution(int *width, int *height, int *scaleFactor, bool *upscaling, bool *ssaa) const {
Expand Down
8 changes: 8 additions & 0 deletions GPU/Common/PresentationCommon.h
Expand Up @@ -98,6 +98,13 @@ class PresentationCommon {

bool UpdatePostShader();

void BeginFrame() {
presentedThisFrame_ = false;
}
bool PresentedThisFrame() const {
return presentedThisFrame_;
}

void DeviceLost();
void DeviceRestore(Draw::DrawContext *draw);

Expand Down Expand Up @@ -159,6 +166,7 @@ class PresentationCommon {

bool usePostShader_ = false;
bool restorePostShader_ = false;
bool presentedThisFrame_ = false;
ShaderLanguage lang_;

struct PrevFBO {
Expand Down
4 changes: 4 additions & 0 deletions GPU/GPUCommon.cpp
Expand Up @@ -722,6 +722,10 @@ void GPUCommon::BeginFrame() {
GPURecord::NotifyBeginFrame();
}

bool GPUCommon::PresentedThisFrame() const {
return framebufferManager_ ? framebufferManager_->PresentedThisFrame() : true;
}

void GPUCommon::SlowRunLoop(DisplayList &list) {
const bool dumpThisFrame = dumpThisFrame_;
while (downcount > 0) {
Expand Down
2 changes: 2 additions & 0 deletions GPU/GPUCommon.h
Expand Up @@ -226,6 +226,8 @@ class GPUCommon : public GPUInterface, public GPUDebugInterface {
fullInfo = reportingFullInfo_;
}

bool PresentedThisFrame() const override;

protected:
void ClearCacheNextFrame() override {}

Expand Down
1 change: 0 additions & 1 deletion GPU/GPUCommonHW.cpp
Expand Up @@ -503,7 +503,6 @@ void GPUCommonHW::UpdateCmdInfo() {

void GPUCommonHW::BeginFrame() {
GPUCommon::BeginFrame();

if (drawEngineCommon_->EverUsedExactEqualDepth() && !sawExactEqualDepth_) {
sawExactEqualDepth_ = true;
gstate_c.SetUseFlags(CheckGPUFeatures());
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUInterface.h
Expand Up @@ -253,6 +253,7 @@ class GPUInterface {
virtual bool FramebufferDirty() = 0;
virtual bool FramebufferReallyDirty() = 0;
virtual bool BusyDrawing() = 0;
virtual bool PresentedThisFrame() const = 0;

// If any jit is being used inside the GPU.
virtual bool DescribeCodePtr(const u8 *ptr, std::string &name) = 0;
Expand Down
5 changes: 2 additions & 3 deletions UI/EmuScreen.cpp
Expand Up @@ -1568,15 +1568,14 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
PSP_EndHostFrame();
}

// This must happen after PSP_EndHostFrame so that things like push buffers are end-frame'd before we start destroying stuff.
if (checkPowerDown() || rebind) {
// Shutting down can end up ending the current render pass
if (gpu && !gpu->PresentedThisFrame()) {
draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_NoFrame");
}

if (!(mode & ScreenRenderMode::TOP)) {
// We're in run-behind mode, but we don't want to draw chat, debug UI and stuff.
// So, darken and bail here.

darken();
return flags;
}
Expand Down

0 comments on commit 8d8ff58

Please sign in to comment.