From 29bc07eb0acf3fdf0289f7f1d07cd156a3085924 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 20 Mar 2016 20:04:49 +0100 Subject: [PATCH] SoftGPU with Vulkan runs but displays black --- Core/CoreParameter.h | 4 +++- Core/System.cpp | 2 +- GPU/GPU.cpp | 5 +++-- GPU/GPU.h | 4 +++- GPU/Software/SoftGpu.cpp | 10 ++-------- GPU/Software/SoftGpu.h | 7 ++++++- UI/EmuScreen.cpp | 1 + ext/native/thin3d/thin3d_vulkan.cpp | 2 ++ 8 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Core/CoreParameter.h b/Core/CoreParameter.h index 1cbe2aab12..e19984a171 100644 --- a/Core/CoreParameter.h +++ b/Core/CoreParameter.h @@ -38,14 +38,16 @@ enum GPUCore { class FileLoader; class GraphicsContext; +class Thin3DContext; // PSP_CoreParameter() struct CoreParameter { - CoreParameter() : collectEmuLog(0), unthrottle(false), fpsLimit(0), updateRecent(true), freezeNext(false), frozen(false), mountIsoLoader(nullptr) {} + CoreParameter() : thin3d(nullptr), collectEmuLog(0), unthrottle(false), fpsLimit(0), updateRecent(true), freezeNext(false), frozen(false), mountIsoLoader(nullptr) {} CPUCore cpuCore; GPUCore gpuCore; GraphicsContext *graphicsContext; // TODO: Find a better place. + Thin3DContext *thin3d; bool enableSound; // there aren't multiple sound cores. std::string fileToStart; diff --git a/Core/System.cpp b/Core/System.cpp index 110f88f04f..d1613cc617 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -425,7 +425,7 @@ bool PSP_InitUpdate(std::string *error_string) { bool success = coreParameter.fileToStart != ""; *error_string = coreParameter.errorString; if (success) { - success = GPU_Init(coreParameter.graphicsContext); + success = GPU_Init(coreParameter.graphicsContext, coreParameter.thin3d); if (!success) { PSP_Shutdown(); *error_string = "Unable to initialize rendering engine."; diff --git a/GPU/GPU.cpp b/GPU/GPU.cpp index eb02c65748..f5bec931d5 100644 --- a/GPU/GPU.cpp +++ b/GPU/GPU.cpp @@ -45,7 +45,8 @@ static void SetGPU(T *obj) { #ifdef USE_CRT_DBG #undef new #endif -bool GPU_Init(GraphicsContext *ctx) { + +bool GPU_Init(GraphicsContext *ctx, Thin3DContext *thin3d) { switch (PSP_CoreParameter().gpuCore) { case GPU_NULL: SetGPU(new NullGPU()); @@ -54,7 +55,7 @@ bool GPU_Init(GraphicsContext *ctx) { SetGPU(new GLES_GPU(ctx)); break; case GPU_SOFTWARE: - SetGPU(new SoftGPU(ctx)); + SetGPU(new SoftGPU(ctx, thin3d)); break; case GPU_DIRECTX9: #if defined(_WIN32) diff --git a/GPU/GPU.h b/GPU/GPU.h index 55c5aaf566..6989ba4d18 100644 --- a/GPU/GPU.h +++ b/GPU/GPU.h @@ -107,5 +107,7 @@ extern GPUStatistics gpuStats; extern GPUInterface *gpu; extern GPUDebugInterface *gpuDebug; -bool GPU_Init(GraphicsContext *ctx); +class Thin3DContext; + +bool GPU_Init(GraphicsContext *ctx, Thin3DContext *thin3d); void GPU_Shutdown(); diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index d14d7872e3..c9e44c2cbe 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -42,18 +42,14 @@ FormatBuffer fb; FormatBuffer depthbuf; u32 clut[4096]; -static Thin3DContext *thin3d = nullptr; -static Thin3DTexture *fbTex = nullptr; static Thin3DVertexFormat *vformat = nullptr; static Thin3DDepthStencilState *depth = nullptr; static Thin3DBuffer *vdata = nullptr; static Thin3DBuffer *idata = nullptr; -static std::vector fbTexBuffer; -SoftGPU::SoftGPU(GraphicsContext *gfxCtx) - : gfxCtx_(gfxCtx) +SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Thin3DContext *_thin3D) + : gfxCtx_(gfxCtx), thin3d(_thin3D) { - thin3d = gfxCtx_->CreateThin3DContext(); fbTex = thin3d->CreateTexture(LINEAR2D, RGBA8888, 480, 272, 1, 1); std::vector components; @@ -87,8 +83,6 @@ SoftGPU::~SoftGPU() { vformat = nullptr; fbTex->Release(); fbTex = nullptr; - thin3d->Release(); - thin3d = nullptr; } void SoftGPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) { diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index 423b4f22d3..481fd4ae6b 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -45,10 +45,12 @@ typedef struct { } FormatBuffer; class ShaderManager; +class Thin3DContext; +class Thin3DTexture; class SoftGPU : public GPUCommon { public: - SoftGPU(GraphicsContext *gfxCtx); + SoftGPU(GraphicsContext *gfxCtx, Thin3DContext *_thin3D); ~SoftGPU(); void InitClear() override {} void ExecuteOp(u32 op, u32 diff) override; @@ -102,4 +104,7 @@ private: GEBufferFormat displayFormat_; GraphicsContext *gfxCtx_; + Thin3DTexture *fbTex; + Thin3DContext *thin3d; + std::vector fbTexBuffer; }; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index d89ab487f4..735612fd90 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -118,6 +118,7 @@ void EmuScreen::bootGame(const std::string &filename) { } // Preserve the existing graphics context. coreParam.graphicsContext = PSP_CoreParameter().graphicsContext; + coreParam.thin3d = screenManager()->getThin3DContext(); coreParam.enableSound = g_Config.bEnableSound; coreParam.fileToStart = filename; coreParam.mountIso = ""; diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index eec08f88e4..95d863c63c 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -704,6 +704,8 @@ void Thin3DVKContext::Begin(bool clear, uint32_t colorval, float depthVal, int s VkResult result = vkResetDescriptorPool(device_, frame->descriptorPool, 0); assert(result == VK_SUCCESS); + noScissor_.extent.width = pixel_xres; + noScissor_.extent.height = pixel_yres; scissorDirty_ = true; viewportDirty_ = true; }