Skip to content

Commit

Permalink
UWP: Fix dialog rendering (PPGe).
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 20, 2020
1 parent e05c3ef commit e0aa187
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
11 changes: 8 additions & 3 deletions Core/Util/PPGeDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "Core/System.h"

Atlas g_ppge_atlas;
Draw::DrawContext *g_draw = nullptr;

static u32 atlasPtr;
static int atlasWidth;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -126,6 +127,10 @@ struct PPGeTextDrawerImage {
};
std::map<PPGeTextDrawerCacheKey, PPGeTextDrawerImage> 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);
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions Core/Util/PPGeDraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions GPU/Common/FramebufferManagerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions GPU/GPUCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e0aa187

Please sign in to comment.