Fix issue where nothing had started a render pass when we wanted to clear the screen.

This commit is contained in:
Henrik Rydgård 2023-12-11 13:06:15 +01:00
parent e8f70594a4
commit 8d8ff5886b
9 changed files with 25 additions and 5 deletions

View file

@ -123,10 +123,14 @@ void FramebufferManagerCommon::CheckPostShaders() {
void FramebufferManagerCommon::BeginFrame() { void FramebufferManagerCommon::BeginFrame() {
DecimateFBOs(); DecimateFBOs();
presentation_->BeginFrame();
currentRenderVfb_ = nullptr; currentRenderVfb_ = nullptr;
} }
bool FramebufferManagerCommon::PresentedThisFrame() const {
return presentation_->PresentedThisFrame();
}
void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) { void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
displayFramebufPtr_ = framebuf & 0x3FFFFFFF; displayFramebufPtr_ = framebuf & 0x3FFFFFFF;
if (Memory::IsVRAMAddress(displayFramebufPtr_)) if (Memory::IsVRAMAddress(displayFramebufPtr_))

View file

@ -485,6 +485,8 @@ public:
currentFramebufferCopy_ = nullptr; currentFramebufferCopy_ = nullptr;
} }
bool PresentedThisFrame() const;
protected: protected:
virtual void ReadbackFramebuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel, Draw::ReadbackMode mode); 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. // Used for when a shader is required, such as GLES.

View file

@ -931,6 +931,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
draw_->Invalidate(InvalidationFlags::CACHED_RENDER_STATE); draw_->Invalidate(InvalidationFlags::CACHED_RENDER_STATE);
previousUniforms_ = uniforms; previousUniforms_ = uniforms;
presentedThisFrame_ = true;
} }
void PresentationCommon::CalculateRenderResolution(int *width, int *height, int *scaleFactor, bool *upscaling, bool *ssaa) const { void PresentationCommon::CalculateRenderResolution(int *width, int *height, int *scaleFactor, bool *upscaling, bool *ssaa) const {

View file

@ -98,6 +98,13 @@ public:
bool UpdatePostShader(); bool UpdatePostShader();
void BeginFrame() {
presentedThisFrame_ = false;
}
bool PresentedThisFrame() const {
return presentedThisFrame_;
}
void DeviceLost(); void DeviceLost();
void DeviceRestore(Draw::DrawContext *draw); void DeviceRestore(Draw::DrawContext *draw);
@ -159,6 +166,7 @@ protected:
bool usePostShader_ = false; bool usePostShader_ = false;
bool restorePostShader_ = false; bool restorePostShader_ = false;
bool presentedThisFrame_ = false;
ShaderLanguage lang_; ShaderLanguage lang_;
struct PrevFBO { struct PrevFBO {

View file

@ -722,6 +722,10 @@ void GPUCommon::BeginFrame() {
GPURecord::NotifyBeginFrame(); GPURecord::NotifyBeginFrame();
} }
bool GPUCommon::PresentedThisFrame() const {
return framebufferManager_ ? framebufferManager_->PresentedThisFrame() : true;
}
void GPUCommon::SlowRunLoop(DisplayList &list) { void GPUCommon::SlowRunLoop(DisplayList &list) {
const bool dumpThisFrame = dumpThisFrame_; const bool dumpThisFrame = dumpThisFrame_;
while (downcount > 0) { while (downcount > 0) {

View file

@ -226,6 +226,8 @@ public:
fullInfo = reportingFullInfo_; fullInfo = reportingFullInfo_;
} }
bool PresentedThisFrame() const override;
protected: protected:
void ClearCacheNextFrame() override {} void ClearCacheNextFrame() override {}

View file

@ -503,7 +503,6 @@ void GPUCommonHW::UpdateCmdInfo() {
void GPUCommonHW::BeginFrame() { void GPUCommonHW::BeginFrame() {
GPUCommon::BeginFrame(); GPUCommon::BeginFrame();
if (drawEngineCommon_->EverUsedExactEqualDepth() && !sawExactEqualDepth_) { if (drawEngineCommon_->EverUsedExactEqualDepth() && !sawExactEqualDepth_) {
sawExactEqualDepth_ = true; sawExactEqualDepth_ = true;
gstate_c.SetUseFlags(CheckGPUFeatures()); gstate_c.SetUseFlags(CheckGPUFeatures());

View file

@ -253,6 +253,7 @@ public:
virtual bool FramebufferDirty() = 0; virtual bool FramebufferDirty() = 0;
virtual bool FramebufferReallyDirty() = 0; virtual bool FramebufferReallyDirty() = 0;
virtual bool BusyDrawing() = 0; virtual bool BusyDrawing() = 0;
virtual bool PresentedThisFrame() const = 0;
// If any jit is being used inside the GPU. // If any jit is being used inside the GPU.
virtual bool DescribeCodePtr(const u8 *ptr, std::string &name) = 0; virtual bool DescribeCodePtr(const u8 *ptr, std::string &name) = 0;

View file

@ -1568,15 +1568,14 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
PSP_EndHostFrame(); PSP_EndHostFrame();
} }
// This must happen after PSP_EndHostFrame so that things like push buffers are end-frame'd before we start destroying stuff. if (gpu && !gpu->PresentedThisFrame()) {
if (checkPowerDown() || rebind) {
// Shutting down can end up ending the current render pass
draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_NoFrame"); draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_NoFrame");
} }
if (!(mode & ScreenRenderMode::TOP)) { if (!(mode & ScreenRenderMode::TOP)) {
// We're in run-behind mode, but we don't want to draw chat, debug UI and stuff. // We're in run-behind mode, but we don't want to draw chat, debug UI and stuff.
// So, darken and bail here. // So, darken and bail here.
darken(); darken();
return flags; return flags;
} }