From e0aa187161b4920f73d6e809d4a9fe0f616a5fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 20 Dec 2020 12:11:02 +0100 Subject: [PATCH] UWP: Fix dialog rendering (PPGe). --- Core/Util/PPGeDraw.cpp | 11 ++++++++--- Core/Util/PPGeDraw.h | 11 +++++++++-- GPU/Common/FramebufferManagerCommon.cpp | 2 -- GPU/GPUCommon.cpp | 6 ++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index f103b8bf15d7..78da0e74511d 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -42,6 +42,7 @@ #include "Core/System.h" Atlas g_ppge_atlas; +Draw::DrawContext *g_draw = nullptr; static u32 atlasPtr; static int atlasWidth; @@ -80,7 +81,7 @@ static u32 paletteSize = sizeof(u16) * 16; static u32 vertexStart; static u32 vertexCount; -// Used for formating text +// Used for formatting text struct AtlasCharVertex { float x; @@ -126,6 +127,10 @@ struct PPGeTextDrawerImage { }; std::map textDrawerImages; +void PPGeSetDrawContext(Draw::DrawContext *draw) { + g_draw = draw; +} + // Overwrite the current text lines buffer so it can be drawn later. void PPGePrepareText(const char *text, float x, float y, PPGeAlign align, float scale, float lineHeightScale, int WrapType = PPGE_LINE_NONE, int wrapWidth = 0); @@ -705,8 +710,8 @@ static bool HasTextDrawer() { return textDrawer != nullptr; } - // TODO: Should we pass a draw_? - textDrawer = TextDrawer::Create(nullptr); + // TODO: Should we pass a draw_? Yes! UWP requires it. + textDrawer = TextDrawer::Create(g_draw); if (textDrawer) { textDrawer->SetFontScale(1.0f, 1.0f); textDrawer->SetForcedDPIScale(1.0f); diff --git a/Core/Util/PPGeDraw.h b/Core/Util/PPGeDraw.h index dbff6bb831b0..462c65fe824a 100644 --- a/Core/Util/PPGeDraw.h +++ b/Core/Util/PPGeDraw.h @@ -28,8 +28,15 @@ class PointerWrap; ///////////////////////////////////////////////////////////////////////////////////////////// // PPGeDraw: Super simple internal drawing API for 2D overlays like sceUtility messageboxes -// etc. Goes through the Ge emulation so that it's 100% portable - will work -// splendidly on any existing GPU backend, including the future software backend. +// etc. Goes through the Ge emulation so that it doesn't need to care about backends. +// +// It does need a thin3d Draw-context but only for text rendering. + +namespace Draw { +class DrawContext; +} + +void PPGeSetDrawContext(Draw::DrawContext *draw); // Uploads the necessary texture atlas and other data to kernel RAM, and reserves // space for the display list. The PSP must be inited. diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index e9170ec73542..fac716dc48d1 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1003,8 +1003,6 @@ void FramebufferManagerCommon::DownloadFramebufferOnSwitch(VirtualFramebuffer *v // Some games will draw to some memory once, and use it as a render-to-texture later. // To support this, we save the first frame to memory when we have a safe w/h. // Saving each frame would be slow. - // Seems that Wipeout is using the CPU to read from framebuffers to figure out the lens flare, - // so if this readback isn't done, it's getting garbage. if (!g_Config.bDisableSlowFramebufEffects) { ReadFramebufferToMemory(vfb, 0, 0, vfb->safeWidth, vfb->safeHeight); vfb->usageFlags = (vfb->usageFlags | FB_USAGE_DOWNLOAD) & ~FB_USAGE_DOWNLOAD_CLEAR; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index bf829e1026a5..67b0dab08e59 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -27,6 +27,7 @@ #include "Core/HLE/sceGe.h" #include "Core/Debugger/Breakpoints.h" #include "Core/MemMapHelpers.h" +#include "Core/Util/PPGeDraw.h" #include "GPU/Common/DrawEngineCommon.h" #include "GPU/Common/FramebufferManagerCommon.h" #include "GPU/Common/SplineCommon.h" @@ -412,9 +413,13 @@ GPUCommon::GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : UpdateCmdInfo(); UpdateVsyncInterval(true); + + PPGeSetDrawContext(draw); } GPUCommon::~GPUCommon() { + // Probably not necessary. + PPGeSetDrawContext(nullptr); } void GPUCommon::UpdateCmdInfo() { @@ -478,6 +483,7 @@ void GPUCommon::DeviceLost() { void GPUCommon::DeviceRestore() { draw_ = (Draw::DrawContext *)PSP_CoreParameter().graphicsContext->GetDrawContext(); framebufferManager_->DeviceRestore(draw_); + PPGeSetDrawContext(draw_); } void GPUCommon::UpdateVsyncInterval(bool force) {