UI: Stop caching the draw context in coreParam.

This is possibly getting outdated in some paths of graphics reinit, and
then causing crashes.  Let's just always get it from the graphicsContext.
This commit is contained in:
Unknown W. Brackets 2019-09-28 21:36:03 -07:00
parent 029dd07c8e
commit 5871ab0538
8 changed files with 10 additions and 15 deletions

View file

@ -54,7 +54,6 @@ struct CoreParameter {
GPUCore gpuCore; GPUCore gpuCore;
GraphicsContext *graphicsContext = nullptr; // TODO: Find a better place. GraphicsContext *graphicsContext = nullptr; // TODO: Find a better place.
Draw::DrawContext *thin3d = nullptr;
bool enableSound; // there aren't multiple sound cores. bool enableSound; // there aren't multiple sound cores.
std::string fileToStart; std::string fileToStart;

View file

@ -35,13 +35,12 @@
#include "thread/threadutil.h" #include "thread/threadutil.h"
#include "util/text/utf8.h" #include "util/text/utf8.h"
#include "Common/GraphicsContext.h"
#include "Core/MemMap.h" #include "Core/MemMap.h"
#include "Core/HDRemaster.h" #include "Core/HDRemaster.h"
#include "Core/MIPS/MIPS.h" #include "Core/MIPS/MIPS.h"
#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSAnalyst.h"
#include "Core/Debugger/SymbolMap.h"
#include "Debugger/SymbolMap.h"
#include "Core/Host.h" #include "Core/Host.h"
#include "Core/System.h" #include "Core/System.h"
#include "Core/HLE/HLE.h" #include "Core/HLE/HLE.h"
@ -371,7 +370,8 @@ bool PSP_InitUpdate(std::string *error_string) {
*error_string = coreParameter.errorString; *error_string = coreParameter.errorString;
if (success && gpu == nullptr) { if (success && gpu == nullptr) {
PSP_SetLoading("Starting graphics..."); PSP_SetLoading("Starting graphics...");
success = GPU_Init(coreParameter.graphicsContext, coreParameter.thin3d); Draw::DrawContext *draw = coreParameter.graphicsContext ? coreParameter.graphicsContext->GetDrawContext() : nullptr;
success = GPU_Init(coreParameter.graphicsContext, draw);
if (!success) { if (!success) {
*error_string = "Unable to initialize rendering engine."; *error_string = "Unable to initialize rendering engine.";
} }

View file

@ -108,6 +108,6 @@ namespace Draw {
class DrawContext; class DrawContext;
} }
bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *thin3d); bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw);
bool GPU_IsReady(); bool GPU_IsReady();
void GPU_Shutdown(); void GPU_Shutdown();

View file

@ -50,7 +50,7 @@ class SoftwareDrawEngine;
class SoftGPU : public GPUCommon { class SoftGPU : public GPUCommon {
public: public:
SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *_thin3D); SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
~SoftGPU(); ~SoftGPU();
void CheckGPUFeatures() override {} void CheckGPUFeatures() override {}

View file

@ -238,7 +238,6 @@ void EmuScreen::bootGame(const std::string &filename) {
// Preserve the existing graphics context. // Preserve the existing graphics context.
coreParam.graphicsContext = PSP_CoreParameter().graphicsContext; coreParam.graphicsContext = PSP_CoreParameter().graphicsContext;
coreParam.thin3d = screenManager()->getDrawContext();
coreParam.enableSound = g_Config.bEnableSound; coreParam.enableSound = g_Config.bEnableSound;
coreParam.fileToStart = filename; coreParam.fileToStart = filename;
coreParam.mountIso = ""; coreParam.mountIso = "";

View file

@ -163,8 +163,8 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, bool
Core_UpdateDebugStats(g_Config.bShowDebugStats || g_Config.bLogFrameDrops); Core_UpdateDebugStats(g_Config.bShowDebugStats || g_Config.bLogFrameDrops);
PSP_BeginHostFrame(); PSP_BeginHostFrame();
if (coreParameter.thin3d) if (coreParameter.graphicsContext && coreParameter.graphicsContext->GetDrawContext())
coreParameter.thin3d->BeginFrame(); coreParameter.graphicsContext->GetDrawContext()->BeginFrame();
coreState = CORE_RUNNING; coreState = CORE_RUNNING;
while (coreState == CORE_RUNNING) while (coreState == CORE_RUNNING)
@ -190,8 +190,8 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, bool
} }
PSP_EndHostFrame(); PSP_EndHostFrame();
if (coreParameter.thin3d) if (coreParameter.graphicsContext && coreParameter.graphicsContext->GetDrawContext())
coreParameter.thin3d->EndFrame(); coreParameter.graphicsContext->GetDrawContext()->EndFrame();
PSP_Shutdown(); PSP_Shutdown();
@ -335,7 +335,6 @@ int main(int argc, const char* argv[])
coreParameter.cpuCore = cpuCore; coreParameter.cpuCore = cpuCore;
coreParameter.gpuCore = glWorking ? gpuCore : GPUCORE_NULL; coreParameter.gpuCore = glWorking ? gpuCore : GPUCORE_NULL;
coreParameter.graphicsContext = graphicsContext; coreParameter.graphicsContext = graphicsContext;
coreParameter.thin3d = graphicsContext ? graphicsContext->GetDrawContext() : nullptr;
coreParameter.enableSound = false; coreParameter.enableSound = false;
coreParameter.mountIso = mountIso ? mountIso : ""; coreParameter.mountIso = mountIso ? mountIso : "";
coreParameter.mountRoot = mountRoot ? mountRoot : ""; coreParameter.mountRoot = mountRoot ? mountRoot : "";

View file

@ -43,7 +43,6 @@ void LibretroHWRenderContext::ContextReset() {
if (!draw_) { if (!draw_) {
CreateDrawContext(); CreateDrawContext();
PSP_CoreParameter().thin3d = draw_;
bool success = draw_->CreatePresets(); bool success = draw_->CreatePresets();
assert(success); assert(success);
} }

View file

@ -20,7 +20,6 @@ public:
void Shutdown() override { void Shutdown() override {
DestroyDrawContext(); DestroyDrawContext();
PSP_CoreParameter().thin3d = nullptr;
} }
void SwapInterval(int interval) override {} void SwapInterval(int interval) override {}
void Resize() override {} void Resize() override {}