diff --git a/CMakeLists.txt b/CMakeLists.txt index 8df9ff5c86..b3249f2eea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1082,8 +1082,6 @@ endif() set(GPU_GLES GPU/GLES/DepalettizeShaderGLES.cpp GPU/GLES/DepalettizeShaderGLES.h - GPU/GLES/FBO.cpp - GPU/GLES/FBO.h GPU/GLES/GPU_GLES.cpp GPU/GLES/GPU_GLES.h GPU/GLES/FragmentShaderGeneratorGLES.cpp diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 6702b50319..056c1bfc95 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -21,7 +21,7 @@ #include "profiler/profiler.h" #include "gfx_es2/glsl_program.h" -#include "native/thin3d/thin3d.h" +#include "thin3d/thin3d.h" #include "base/timeutil.h" #include "math/lin/matrix4x4.h" diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 8a2a807642..d991bd1a2e 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -35,6 +35,9 @@ public: GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw); virtual ~GPUCommon(); + Draw::DrawContext *GetDrawContext() override { + return draw_; + } void Reinitialize() override; void BeginHostFrame() override; diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 3f985181cd..9d7b44bd6e 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -204,12 +204,18 @@ struct GPUEvent { } }; +namespace Draw { +class DrawContext; +} + class GPUInterface { public: virtual ~GPUInterface() {} static const int DisplayListMaxCount = 64; + virtual Draw::DrawContext *GetDrawContext() = 0; + // Initialization virtual void InitClear() = 0; virtual void Reinitialize() = 0; diff --git a/Qt/Debugger/debugger_displaylist.cpp b/Qt/Debugger/debugger_displaylist.cpp index 36fc859c3b..349dbfea80 100644 --- a/Qt/Debugger/debugger_displaylist.cpp +++ b/Qt/Debugger/debugger_displaylist.cpp @@ -14,10 +14,11 @@ //commented out until someone bothers to maintain it //#include "GPU/GLES/VertexDecoder.h" -Debugger_DisplayList::Debugger_DisplayList(DebugInterface *_cpu, MainWindow* mainWindow_, QWidget *parent) : +Debugger_DisplayList::Debugger_DisplayList(DebugInterface *_cpu, Draw::DrawContext *draw, MainWindow* mainWindow_, QWidget *parent) : QDialog(parent), ui(new Ui::Debugger_DisplayList), cpu(_cpu), + draw_(draw), mainWindow(mainWindow_), currentRenderFrameDisplay(0), currentTextureDisplay(0), @@ -1348,12 +1349,12 @@ void Debugger_DisplayList::UpdateRenderBufferGUI() } else { - fbo_get_dimensions(currentTextureDisplay, &FRAME_WIDTH, &FRAME_HEIGHT); + draw_->GetFramebufferDimensions(currentTextureDisplay, &FRAME_WIDTH, &FRAME_HEIGHT); data = new u8[FRAME_WIDTH * FRAME_HEIGHT * 4]; memset(data,0,FRAME_WIDTH * FRAME_HEIGHT * 4); if(currentRenderFrameDisplay == 0) { - fbo_bind_as_texture(currentTextureDisplay, 0, FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(currentTextureDisplay, 0, Draw::FB_COLOR_BIT, 0); glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, data); } } @@ -1439,7 +1440,7 @@ void Debugger_DisplayList::UpdateRenderBufferListGUI() void Debugger_DisplayList::on_fboList_itemClicked(QTreeWidgetItem *item, int column) { u64 addr = item->data(0,Qt::UserRole).toULongLong(); - FBO* fbo = (FBO*)addr; + Draw::Framebuffer * fbo = (Draw::Framebuffer *)addr; currentTextureDisplay = fbo; UpdateRenderBufferGUI(); } diff --git a/Qt/Debugger/debugger_displaylist.h b/Qt/Debugger/debugger_displaylist.h index ce68d1079a..2c88384269 100644 --- a/Qt/Debugger/debugger_displaylist.h +++ b/Qt/Debugger/debugger_displaylist.h @@ -1,5 +1,4 @@ -#ifndef DEBUGGER_DISPLAYLIST_H -#define DEBUGGER_DISPLAYLIST_H +#pragma once #include "Core/Debugger/DebugInterface.h" @@ -7,7 +6,7 @@ #include #include "GPU/GPUState.h" -#include "GPU/GLES/FBO.h" +#include "thin3d/thin3d.h" class MainWindow; namespace Ui { @@ -38,7 +37,7 @@ class Debugger_DisplayList : public QDialog Q_OBJECT public: - explicit Debugger_DisplayList(DebugInterface *_cpu, MainWindow *mainWindow_, QWidget *parent = 0); + Debugger_DisplayList(DebugInterface *_cpu, Draw::DrawContext *draw, MainWindow *mainWindow_, QWidget *parent = 0); ~Debugger_DisplayList(); void UpdateDisplayList(); @@ -88,12 +87,13 @@ private: Ui::Debugger_DisplayList *ui; DebugInterface* cpu; + Draw::DrawContext* draw_; MainWindow* mainWindow; QTreeWidgetItem* displayListRowSelected; QTreeWidgetItem* displayListDataSelected; QTreeWidgetItem* textureDataSelected; int currentRenderFrameDisplay; - FBO* currentTextureDisplay; + Draw::Framebuffer *currentTextureDisplay; float fboZoomFactor; int maxVtxDisplay; int maxIdxDisplay; @@ -102,5 +102,3 @@ private: std::map vtxBufferSize; std::map idxBufferSize; }; - -#endif // DEBUGGER_DISPLAYLIST_H diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp index e696e94be9..d14e9af57e 100644 --- a/Qt/mainwindow.cpp +++ b/Qt/mainwindow.cpp @@ -140,7 +140,7 @@ void MainWindow::Boot() memoryWindow = new Debugger_Memory(currentDebugMIPS, this, this); memoryTexWindow = new Debugger_MemoryTex(this); - displaylistWindow = new Debugger_DisplayList(currentDebugMIPS, this, this); + displaylistWindow = new Debugger_DisplayList(currentDebugMIPS, gpu->GetDrawContext(), this, this); notifyMapsLoaded(); diff --git a/UI/TextureUtil.cpp b/UI/TextureUtil.cpp index 1acd66fbc7..959c3e85f5 100644 --- a/UI/TextureUtil.cpp +++ b/UI/TextureUtil.cpp @@ -122,20 +122,22 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ size_t fileSize; uint8_t *buffer = VFSReadFile(filename.c_str(), &fileSize); if (!buffer) { + ELOG("Failed to read file %s", filename.c_str()); return false; } bool retval = LoadFromFileData(buffer, fileSize, type); if (retval) { filename_ = filename; - } - else { - ELOG("%s: Failed to load texture %s", __FUNCTION__, filename.c_str()); + } else { + ELOG("Failed to load texture %s", filename.c_str()); } delete[] buffer; return retval; } ManagedTexture *CreateTextureFromFile(Draw::DrawContext *draw, const char *filename, ImageFileType type) { + if (!draw) + return nullptr; ManagedTexture *mtex = new ManagedTexture(draw); if (!mtex->LoadFromFile(filename, type)) { delete mtex; @@ -146,6 +148,8 @@ ManagedTexture *CreateTextureFromFile(Draw::DrawContext *draw, const char *filen // TODO: Remove the code duplication between this and LoadFromFileData ManagedTexture *CreateTextureFromFileData(Draw::DrawContext *draw, const uint8_t *data, int size, ImageFileType type) { + if (!draw) + return nullptr; ManagedTexture *mtex = new ManagedTexture(draw); mtex->LoadFromFileData(data, size, type); return mtex; diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index dff0117a7e..66b682ffec 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -144,16 +144,14 @@ void AndroidEGLGraphicsContext::SwapBuffers() { // Doesn't do much. Just to fit in. class AndroidJavaEGLGraphicsContext : public GraphicsContext { public: - AndroidJavaEGLGraphicsContext() : draw_(nullptr) {} - bool Init(ANativeWindow *wnd, int desiredBackbufferSizeX, int desiredBackbufferSizeY, int backbufferFormat, int androidVersion) { + AndroidJavaEGLGraphicsContext() { CheckGLExtensions(); draw_ = Draw::T3DCreateGLContext(); - return true; } - void Shutdown() override { + ~AndroidJavaEGLGraphicsContext() { delete draw_; - draw_ = nullptr; } + void Shutdown() override {} void SwapBuffers() override {} void SwapInterval(int interval) override {} void Resize() override {} @@ -617,10 +615,10 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_shutdown(JNIEnv *, jclass) { // JavaEGL extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env, jobject obj) { - ILOG("NativeApp.displayInit()"); if (javaGL && !graphicsContext) { graphicsContext = new AndroidJavaEGLGraphicsContext(); } + ILOG("NativeApp.displayInit() (graphicsContext=%p)", graphicsContext); if (!renderer_inited) { NativeInitGraphics(graphicsContext); @@ -722,6 +720,9 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayShutdown(JNIEnv *en if (renderer_inited) { NativeDeviceLost(); NativeShutdownGraphics(); + graphicsContext->Shutdown(); + delete graphicsContext; + graphicsContext = nullptr; renderer_inited = false; NativeMessageReceived("recreateviews", ""); } @@ -1094,6 +1095,7 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J graphicsContext->Shutdown(); delete graphicsContext; + graphicsContext = nullptr; renderLoopRunning = false; WLOG("Render loop function exited."); return true; diff --git a/ext/native/gfx/GLStateCache.h b/ext/native/gfx/GLStateCache.h index 26323a7806..e46133709f 100644 --- a/ext/native/gfx/GLStateCache.h +++ b/ext/native/gfx/GLStateCache.h @@ -1,6 +1,7 @@ #pragma once #include +#include // for memcmp #include "gfx/gl_common.h" #include "gfx_es2/gpu_features.h" diff --git a/ext/native/thin3d/thin3d_gl.cpp b/ext/native/thin3d/thin3d_gl.cpp index dfcff8fb0b..9bb4ede624 100644 --- a/ext/native/thin3d/thin3d_gl.cpp +++ b/ext/native/thin3d/thin3d_gl.cpp @@ -12,6 +12,10 @@ #include "gfx_es2/gpu_features.h" #include "gfx/gl_lost_manager.h" +#ifdef IOS +extern void bindDefaultFBO(); +#endif + namespace Draw { static const unsigned short compToGL[] = { @@ -1224,10 +1228,6 @@ public: FBColorDepth colorDepth; }; - -#ifdef IOS -extern void bindDefaultFBO(); -#endif // On PC, we always use GL_DEPTH24_STENCIL8. // On Android, we try to use what's available. diff --git a/ios/ViewController.mm b/ios/ViewController.mm index b08f4c6406..573ff11628 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -21,7 +21,6 @@ #include "Core/Config.h" #include "Common/GraphicsContext.h" -#include "GPU/GLES/FBO.h" #include #include