Remove the "GPUInterface" base class. Not really useful, GPUCommon is pretty much the same thing.

This commit is contained in:
Henrik Rydgård 2024-12-02 10:32:57 +01:00
parent 102d62deab
commit 0df2a40487
63 changed files with 344 additions and 402 deletions

View File

@ -1974,7 +1974,7 @@ set(GPU_SOURCES
GPU/Debugger/Stepping.h
GPU/ge_constants.h
GPU/GeConstants.cpp
GPU/GPUInterface.h
GPU/GPUDefinitions.h
GPU/GeDisasm.cpp
GPU/GeDisasm.h
GPU/GPU.cpp

View File

@ -408,6 +408,8 @@ bool Core_Run(GraphicsContext *ctx) {
switch (coreState) {
case CORE_RUNNING_CPU:
case CORE_STEPPING_CPU:
case CORE_RUNNING_GE:
case CORE_STEPPING_GE:
// enter a fast runloop
Core_RunLoop(ctx);
if (coreState == CORE_POWERDOWN) {

View File

@ -28,7 +28,7 @@
#include "Core/Font/PGF.h"
#include "Core/HLE/HLE.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
// These fonts, created by ttf2pgf, don't have complete glyph info and need to be identified.

View File

@ -39,7 +39,7 @@
#include "GPU/Math3D.h"
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#if PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)

View File

@ -54,7 +54,7 @@
#include "GPU/GPU.h"
#include "GPU/GPUState.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/FramebufferManagerCommon.h"
#include "GPU/Common/PostShader.h"
#include "GPU/Debugger/Record.h"

View File

@ -25,7 +25,7 @@
#include "Core/HLE/sceKernel.h"
#include "Core/HLE/FunctionWrappers.h"
#include "Core/Debugger/Breakpoints.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
u64 dmacMemcpyDeadline;

View File

@ -38,7 +38,7 @@
#include "Core/HLE/sceKernelInterrupt.h"
#include "Core/HLE/KernelWaitHelpers.h"
#include "GPU/GPUState.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
static const int LIST_ID_MAGIC = 0x35000000;

View File

@ -17,7 +17,7 @@
#pragma once
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "Core/MemMap.h"
#define SCE_GE_LIST_COMPLETED 0

View File

@ -37,7 +37,7 @@
#include "Core/Reporting.h"
#include "Core/SaveState.h"
#include "Core/System.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "__sceAudio.h"

View File

@ -70,7 +70,7 @@
#include "GPU/Debugger/Playback.h"
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
enum {

View File

@ -31,7 +31,7 @@
#include "Core/HW/MediaEngine.h"
#include "Core/MemMapHelpers.h"
#include "Core/Reporting.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "Core/HLE/sceKernelMemory.h"
#include "Core/Core.h"

View File

@ -30,7 +30,7 @@
#include "Core/HLE/sceKernelMemory.h"
#include "Core/HW/MediaEngine.h"
#include "Core/CoreTiming.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include <map>

View File

@ -29,7 +29,7 @@
#include "Core/HLE/sceKernel.h"
#include "Core/HW/Display.h"
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
// Called when vblank happens (like an internal interrupt.) Not part of state, should be static.
static std::mutex listenersLock;

View File

@ -26,7 +26,7 @@
#include "Core/Reporting.h"
#include "GPU/GPUState.h" // Used by TextureDecoder.h when templates get instanced
#include "GPU/Common/TextureDecoder.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "Core/HW/SimpleAudioDec.h"
#include <algorithm>

View File

@ -57,7 +57,7 @@ extern "C" {
#include "Core/HLE/sceKernelMemory.h"
#include "Core/HLE/scePower.h"
#include "Core/HW/Display.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
namespace Reporting

View File

@ -31,7 +31,7 @@
#include "Core/Core.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/Common/FramebufferManagerCommon.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
// This is used to make non-ASCII paths work for filename.

View File

@ -72,7 +72,7 @@
#include "Common/ExceptionHandlerSetup.h"
#include "Core/HLE/sceAudiocodec.h"
#include "GPU/GPUState.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Debugger/RecordFormat.h"
#include "Core/RetroAchievements.h"

View File

@ -35,7 +35,7 @@
#include "Core/HDRemaster.h"
#include "GPU/ge_constants.h"
#include "GPU/GPUState.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "Core/FileSystems/MetaFileSystem.h"
#include "Core/Util/PPGeDraw.h"
#include "Core/HLE/sceKernel.h"

View File

@ -50,7 +50,7 @@
#include "GPU/Debugger/Debugger.h"
#include "GPU/Debugger/Record.h"
#include "GPU/Debugger/Stepping.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
static size_t FormatFramebufferName(const VirtualFramebuffer *vfb, char *tag, size_t len) {

View File

@ -33,7 +33,7 @@
#include "Core/ConfigValues.h"
#include "GPU/GPU.h"
#include "GPU/ge_constants.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/Draw2D.h"
enum {

View File

@ -20,6 +20,7 @@
#include "Common/StringUtils.h"
#include "Core/Debugger/SymbolMap.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Debugger/Debugger.h"
#include "GPU/Debugger/GECommandTable.h"
#include "GPU/GPUState.h"

View File

@ -23,11 +23,16 @@
#include "Common/Math/expression_parser.h"
#include "Core/MemMap.h"
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUDefinitions.h"
#include "GPU/GPUState.h"
#include "GPU/ge_constants.h"
class FramebufferManagerCommon;
class TextureCacheCommon;
struct VirtualFramebuffer;
struct DisplayList;
struct GPUDebugOp {
u32 pc;
u8 cmd;
@ -219,6 +224,8 @@ public:
virtual void SetCmdValue(u32 op) = 0;
virtual void DispatchFlush() = 0;
virtual void GetStats(char *buffer, size_t bufsize) = 0;
virtual uint32_t SetAddrTranslation(uint32_t value) = 0;
virtual uint32_t GetAddrTranslation() = 0;
@ -226,6 +233,12 @@ public:
virtual FramebufferManagerCommon *GetFramebufferManagerCommon() = 0;
virtual TextureCacheCommon *GetTextureCacheCommon() = 0;
virtual std::vector<const VirtualFramebuffer *> GetFramebufferList() const = 0;
virtual std::vector<std::string> DebugGetShaderIDs(DebugShaderType shader) = 0;
virtual std::string DebugGetShaderString(std::string id, DebugShaderType shader, DebugShaderStringType stringType) = 0;
virtual bool DescribeCodePtr(const u8 *ptr, std::string &name) = 0;
virtual bool GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices) {
return false;
}

View File

@ -42,7 +42,7 @@
#include "GPU/Debugger/Debugger.h"
#include "GPU/Debugger/Record.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "Core/Util/PPGeDraw.h"

View File

@ -30,6 +30,7 @@
#include "GPU/Common/TextureScalerCommon.h"
#include "GPU/Common/TextureShaderCommon.h"
#include "GPU/Common/TextureReplacer.h"
#include "GPU/GPUDefinitions.h"
class Draw2D;

View File

@ -22,7 +22,7 @@
#include <d3d11.h>
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/TextureCacheCommon.h"
struct VirtualFramebuffer;

View File

@ -36,7 +36,7 @@
#include "Core/MemMap.h"
#include "Core/MIPS/MIPS.h"
#include "Core/System.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "GPU/ge_constants.h"
#include "GPU/Debugger/Playback.h"

View File

@ -38,7 +38,7 @@
#include "Core/System.h"
#include "Core/ThreadPools.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "GPU/ge_constants.h"
#include "GPU/Common/TextureDecoder.h"

View File

@ -21,7 +21,7 @@
#include <wrl/client.h>
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/TextureCacheCommon.h"
struct VirtualFramebuffer;

View File

@ -21,7 +21,7 @@
#include "Common/GPU/OpenGL/GLCommon.h"
#include "Common/GPU/OpenGL/GLRenderManager.h"
#include "Common/GPU/thin3d.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "GPU/Common/TextureCacheCommon.h"

View File

@ -22,7 +22,7 @@
#include "Core/Core.h"
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#if PPSSPP_API(ANY_GL)
#include "GPU/GLES/GPU_GLES.h"
@ -39,7 +39,7 @@
#endif
GPUStatistics gpuStats;
GPUInterface *gpu;
GPUCommon *gpu;
GPUDebugInterface *gpuDebug;
template <typename T>

View File

@ -21,7 +21,7 @@
#include <cstring>
#include <cstdint>
class GPUInterface;
class GPUCommon;
class GPUDebugInterface;
class GraphicsContext;
@ -153,7 +153,7 @@ struct GPUStatistics {
};
extern GPUStatistics gpuStats;
extern GPUInterface *gpu;
extern GPUCommon *gpu;
extern GPUDebugInterface *gpuDebug;
namespace Draw {

View File

@ -439,7 +439,7 @@
<ClInclude Include="GPU.h" />
<ClInclude Include="GPUCommon.h" />
<ClInclude Include="GPUCommonHW.h" />
<ClInclude Include="GPUInterface.h" />
<ClInclude Include="GPUDefinitions.h" />
<ClInclude Include="GPUState.h" />
<ClInclude Include="Math3D.h" />
<ClInclude Include="Software\BinManager.h" />

View File

@ -33,7 +33,7 @@
<ClInclude Include="GPUState.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="GPUInterface.h">
<ClInclude Include="GPUDefinitions.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="GPUCommon.h">

View File

@ -1523,6 +1523,7 @@ void GPUCommon::DoState(PointerWrap &p) {
void GPUCommon::InterruptStart(int listid) {
interruptRunning = true;
}
void GPUCommon::InterruptEnd(int listid) {
interruptRunning = false;
isbreak = false;

View File

@ -1,26 +1,166 @@
#pragma once
#include <vector>
#include <list>
#include "ppsspp_config.h"
#include "Common/Common.h"
#include "Common/Swap.h"
#include "Core/MemMap.h"
#include "Common/MemoryUtil.h"
#include "GPU/GPUInterface.h"
#include "GPU/ge_constants.h"
#include "GPU/GPU.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "GPU/Common/ShaderCommon.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/GPUDefinitions.h"
#if defined(__ANDROID__)
#include <atomic>
#endif
// X11, sigh.
#ifdef None
#undef None
#endif
class FramebufferManagerCommon;
class TextureCacheCommon;
class DrawEngineCommon;
class GraphicsContext;
struct PspGeListArgs;
struct GPUgstate;
class PointerWrap;
struct VirtualFramebuffer;
namespace Draw {
class DrawContext;
class DrawContext;
}
enum SignalBehavior {
PSP_GE_SIGNAL_NONE = 0x00,
PSP_GE_SIGNAL_HANDLER_SUSPEND = 0x01,
PSP_GE_SIGNAL_HANDLER_CONTINUE = 0x02,
PSP_GE_SIGNAL_HANDLER_PAUSE = 0x03,
PSP_GE_SIGNAL_SYNC = 0x08,
PSP_GE_SIGNAL_JUMP = 0x10,
PSP_GE_SIGNAL_CALL = 0x11,
PSP_GE_SIGNAL_RET = 0x12,
PSP_GE_SIGNAL_RJUMP = 0x13,
PSP_GE_SIGNAL_RCALL = 0x14,
PSP_GE_SIGNAL_OJUMP = 0x15,
PSP_GE_SIGNAL_OCALL = 0x16,
PSP_GE_SIGNAL_RTBP0 = 0x20,
PSP_GE_SIGNAL_RTBP1 = 0x21,
PSP_GE_SIGNAL_RTBP2 = 0x22,
PSP_GE_SIGNAL_RTBP3 = 0x23,
PSP_GE_SIGNAL_RTBP4 = 0x24,
PSP_GE_SIGNAL_RTBP5 = 0x25,
PSP_GE_SIGNAL_RTBP6 = 0x26,
PSP_GE_SIGNAL_RTBP7 = 0x27,
PSP_GE_SIGNAL_OTBP0 = 0x28,
PSP_GE_SIGNAL_OTBP1 = 0x29,
PSP_GE_SIGNAL_OTBP2 = 0x2A,
PSP_GE_SIGNAL_OTBP3 = 0x2B,
PSP_GE_SIGNAL_OTBP4 = 0x2C,
PSP_GE_SIGNAL_OTBP5 = 0x2D,
PSP_GE_SIGNAL_OTBP6 = 0x2E,
PSP_GE_SIGNAL_OTBP7 = 0x2F,
PSP_GE_SIGNAL_RCBP = 0x30,
PSP_GE_SIGNAL_OCBP = 0x38,
PSP_GE_SIGNAL_BREAK1 = 0xF0,
PSP_GE_SIGNAL_BREAK2 = 0xFF,
};
enum GPURunState {
GPUSTATE_RUNNING = 0,
GPUSTATE_DONE = 1,
GPUSTATE_STALL = 2,
GPUSTATE_INTERRUPT = 3,
GPUSTATE_ERROR = 4,
};
enum GPUSyncType {
GPU_SYNC_DRAW,
GPU_SYNC_LIST,
};
enum class WriteStencil {
NEEDS_CLEAR = 1,
STENCIL_IS_ZERO = 2,
IGNORE_ALPHA = 4,
};
ENUM_CLASS_BITOPS(WriteStencil);
enum class GPUCopyFlag {
NONE = 0,
FORCE_SRC_MATCH_MEM = 1,
FORCE_DST_MATCH_MEM = 2,
// Note: implies src == dst and FORCE_SRC_MATCH_MEM.
MEMSET = 4,
DEPTH_REQUESTED = 8,
DEBUG_NOTIFIED = 16,
DISALLOW_CREATE_VFB = 32,
};
ENUM_CLASS_BITOPS(GPUCopyFlag);
struct DisplayListStackEntry {
u32 pc;
u32 offsetAddr;
u32 baseAddr;
};
struct DisplayList {
int id;
u32 startpc;
u32 pc;
u32 stall;
DisplayListState state;
SignalBehavior signal;
int subIntrBase;
u16 subIntrToken;
DisplayListStackEntry stack[32];
int stackptr;
bool interrupted;
u64 waitTicks;
bool interruptsEnabled;
bool pendingInterrupt;
bool started;
PSPPointer<u32_le> context;
u32 offsetAddr;
bool bboxResult;
u32 stackAddr;
u32 padding; // Android x86-32 does not round the structure size up to the closest multiple of 8 like the other platforms.
};
namespace Draw {
class DrawContext;
}
enum class DLRunType {
Run,
RunDebug,
Step,
};
enum class DLStepType {
None,
Single,
Prim,
Draw,
Texture,
Rendertarget,
};
enum class DLResult {
Done,
Error,
Pause, // used for stepping, breakpoints
};
enum DrawType {
DRAW_UNKNOWN,
DRAW_PRIM,
@ -78,71 +218,91 @@ inline bool IsTrianglePrim(GEPrimitiveType prim) {
return prim > GE_PRIM_LINE_STRIP && prim != GE_PRIM_RECTANGLES;
}
class GPUCommon : public GPUInterface, public GPUDebugInterface {
class GPUCommon : public GPUDebugInterface {
public:
GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
virtual ~GPUCommon() {}
Draw::DrawContext *GetDrawContext() override {
Draw::DrawContext *GetDrawContext() {
return draw_;
}
virtual u32 CheckGPUFeatures() const = 0;
virtual void UpdateCmdInfo() = 0;
bool IsStarted() override {
virtual bool IsStarted() {
return true;
}
void Reinitialize() override;
virtual void Reinitialize();
void BeginHostFrame() override;
void EndHostFrame() override;
virtual void BeginHostFrame();
virtual void EndHostFrame();
void InterruptStart(int listid) override;
void InterruptEnd(int listid) override;
void SyncEnd(GPUSyncType waitType, int listid, bool wokeThreads) override;
void EnableInterrupts(bool enable) override {
void InterruptStart(int listid);
void InterruptEnd(int listid);
void SyncEnd(GPUSyncType waitType, int listid, bool wokeThreads);
void EnableInterrupts(bool enable) {
interruptsEnabled_ = enable;
}
void NotifyDisplayResized() override;
void NotifyRenderResized() override;
void NotifyConfigChanged() override;
virtual void CheckDisplayResized() = 0;
virtual void CheckConfigChanged() = 0;
void DumpNextFrame() override;
virtual void NotifyDisplayResized();
virtual void NotifyRenderResized();
virtual void NotifyConfigChanged();
void DumpNextFrame();
virtual void PreExecuteOp(u32 op, u32 diff) {}
bool InterpretList(DisplayList &list);
DLResult ProcessDLQueue(DLRunType run, DLStepType step) override;
u32 UpdateStall(int listid, u32 newstall) override;
u32 EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointer<PspGeListArgs> args, bool head) override;
u32 DequeueList(int listid) override;
int ListSync(int listid, int mode) override;
u32 DrawSync(int mode) override;
int GetStack(int index, u32 stackPtr) override;
bool GetMatrix24(GEMatrixType type, u32_le *result, u32 cmdbits) override;
void ResetMatrices() override;
void DoState(PointerWrap &p) override;
bool BusyDrawing() override;
u32 Continue() override;
u32 Break(int mode) override;
void ReapplyGfxState() override;
DLResult ProcessDLQueue(DLRunType run, DLStepType step);
u32 UpdateStall(int listid, u32 newstall);
u32 EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointer<PspGeListArgs> args, bool head);
u32 DequeueList(int listid);
virtual int ListSync(int listid, int mode);
virtual u32 DrawSync(int mode);
int GetStack(int index, u32 stackPtr);
virtual bool GetMatrix24(GEMatrixType type, u32_le *result, u32 cmdbits);
virtual void ResetMatrices();
virtual void DoState(PointerWrap &p);
bool BusyDrawing();
u32 Continue();
u32 Break(int mode);
virtual bool FramebufferDirty() = 0;
virtual bool FramebufferReallyDirty() = 0;
virtual void ReapplyGfxState();
virtual void DeviceLost() = 0;
virtual void DeviceRestore(Draw::DrawContext *draw) = 0;
void SwitchToGe();
void DrawImGuiDebugger() override;
void DrawImGuiDebugger();
uint32_t SetAddrTranslation(uint32_t value) override;
uint32_t GetAddrTranslation() override;
void CopyDisplayToOutput(bool reallyDirty) override = 0;
bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) override;
bool PerformMemorySet(u32 dest, u8 v, int size) override;
bool PerformReadbackToMemory(u32 dest, int size) override;
bool PerformWriteColorFromMemory(u32 dest, int size) override;
virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) = 0;
virtual void CopyDisplayToOutput(bool reallyDirty) = 0;
virtual bool PresentedThisFrame() const = 0;
void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat format) override;
bool PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags) override;
// Invalidate any cached content sourced from the specified range.
// If size = -1, invalidate everything.
virtual void InvalidateCache(u32 addr, int size, GPUInvalidationType type) = 0;
virtual bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE);
virtual bool PerformMemorySet(u32 dest, u8 v, int size);
virtual bool PerformReadbackToMemory(u32 dest, int size);
virtual bool PerformWriteColorFromMemory(u32 dest, int size);
virtual void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat format);
virtual bool PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags);
virtual void ExecuteOp(u32 op, u32 diff) = 0;
void Execute_OffsetAddr(u32 op, u32 diff);
void Execute_Vaddr(u32 op, u32 diff);
@ -216,28 +376,30 @@ public:
GPUgstate GetGState() override;
void SetCmdValue(u32 op) override;
DisplayList* getList(int listid) override {
DisplayList* getList(int listid) {
return &dls[listid];
}
const std::list<int>& GetDisplayLists() override {
const std::list<int>& GetDisplayLists() {
return dlQueue;
}
s64 GetListTicks(int listid) const override {
s64 GetListTicks(int listid) const {
if (listid >= 0 && listid < DisplayListMaxCount) {
return dls[listid].waitTicks;
}
return -1;
}
void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) override {
virtual void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) {
primaryInfo = reportingPrimaryInfo_;
fullInfo = reportingFullInfo_;
}
void PSPFrame();
protected:
void ClearCacheNextFrame() override {}
virtual void ClearCacheNextFrame() {}
virtual void CheckRenderResized() {}
@ -256,8 +418,6 @@ protected:
}
}
void PSPFrame() override;
virtual void CheckDepthUsage(VirtualFramebuffer *vfb) {}
virtual void FastRunLoop(DisplayList &list) = 0;
@ -284,6 +444,10 @@ protected:
virtual void UpdateMSAALevel(Draw::DrawContext *draw) {}
enum {
DisplayListMaxCount = 64
};
DrawEngineCommon *drawEngineCommon_ = nullptr;
// TODO: These should live in GPUCommonHW.

55
GPU/GPUDefinitions.h Normal file
View File

@ -0,0 +1,55 @@
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
enum DisplayListStatus {
// The list has been completed
PSP_GE_LIST_COMPLETED = 0,
// The list is queued but not executed yet
PSP_GE_LIST_QUEUED = 1,
// The list is currently being executed
PSP_GE_LIST_DRAWING = 2,
// The list was stopped because it encountered stall address
PSP_GE_LIST_STALLING = 3,
// The list is paused because of a signal or sceGeBreak
PSP_GE_LIST_PAUSED = 4,
};
enum DisplayListState {
// No state assigned, the list is empty
PSP_GE_DL_STATE_NONE = 0,
// The list has been queued
PSP_GE_DL_STATE_QUEUED = 1,
// The list is being executed
PSP_GE_DL_STATE_RUNNING = 2,
// The list was completed and will be removed
PSP_GE_DL_STATE_COMPLETED = 3,
// The list has been paused by a signal
PSP_GE_DL_STATE_PAUSED = 4,
};
enum GPUInvalidationType {
// Affects all memory. Not considered highly.
GPU_INVALIDATE_ALL,
// Indicates some memory may have changed.
GPU_INVALIDATE_HINT,
// Reliable invalidation (where any hashing, etc. is unneeded, it'll always invalidate.)
GPU_INVALIDATE_SAFE,
// Forced invalidation for when the texture hash may not catch changes.
GPU_INVALIDATE_FORCE,
};

View File

@ -1,296 +0,0 @@
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include <list>
#include <string>
#include <vector>
#include "Common/Common.h"
#include "Common/Swap.h"
#include "GPU/GPU.h"
#include "Core/MemMap.h"
#include "GPU/ge_constants.h"
#include "GPU/Common/ShaderCommon.h"
struct PspGeListArgs;
struct GPUgstate;
class PointerWrap;
struct VirtualFramebuffer;
enum DisplayListStatus {
// The list has been completed
PSP_GE_LIST_COMPLETED = 0,
// The list is queued but not executed yet
PSP_GE_LIST_QUEUED = 1,
// The list is currently being executed
PSP_GE_LIST_DRAWING = 2,
// The list was stopped because it encountered stall address
PSP_GE_LIST_STALLING = 3,
// The list is paused because of a signal or sceGeBreak
PSP_GE_LIST_PAUSED = 4,
};
enum DisplayListState {
// No state assigned, the list is empty
PSP_GE_DL_STATE_NONE = 0,
// The list has been queued
PSP_GE_DL_STATE_QUEUED = 1,
// The list is being executed
PSP_GE_DL_STATE_RUNNING = 2,
// The list was completed and will be removed
PSP_GE_DL_STATE_COMPLETED = 3,
// The list has been paused by a signal
PSP_GE_DL_STATE_PAUSED = 4,
};
enum SignalBehavior {
PSP_GE_SIGNAL_NONE = 0x00,
PSP_GE_SIGNAL_HANDLER_SUSPEND = 0x01,
PSP_GE_SIGNAL_HANDLER_CONTINUE = 0x02,
PSP_GE_SIGNAL_HANDLER_PAUSE = 0x03,
PSP_GE_SIGNAL_SYNC = 0x08,
PSP_GE_SIGNAL_JUMP = 0x10,
PSP_GE_SIGNAL_CALL = 0x11,
PSP_GE_SIGNAL_RET = 0x12,
PSP_GE_SIGNAL_RJUMP = 0x13,
PSP_GE_SIGNAL_RCALL = 0x14,
PSP_GE_SIGNAL_OJUMP = 0x15,
PSP_GE_SIGNAL_OCALL = 0x16,
PSP_GE_SIGNAL_RTBP0 = 0x20,
PSP_GE_SIGNAL_RTBP1 = 0x21,
PSP_GE_SIGNAL_RTBP2 = 0x22,
PSP_GE_SIGNAL_RTBP3 = 0x23,
PSP_GE_SIGNAL_RTBP4 = 0x24,
PSP_GE_SIGNAL_RTBP5 = 0x25,
PSP_GE_SIGNAL_RTBP6 = 0x26,
PSP_GE_SIGNAL_RTBP7 = 0x27,
PSP_GE_SIGNAL_OTBP0 = 0x28,
PSP_GE_SIGNAL_OTBP1 = 0x29,
PSP_GE_SIGNAL_OTBP2 = 0x2A,
PSP_GE_SIGNAL_OTBP3 = 0x2B,
PSP_GE_SIGNAL_OTBP4 = 0x2C,
PSP_GE_SIGNAL_OTBP5 = 0x2D,
PSP_GE_SIGNAL_OTBP6 = 0x2E,
PSP_GE_SIGNAL_OTBP7 = 0x2F,
PSP_GE_SIGNAL_RCBP = 0x30,
PSP_GE_SIGNAL_OCBP = 0x38,
PSP_GE_SIGNAL_BREAK1 = 0xF0,
PSP_GE_SIGNAL_BREAK2 = 0xFF,
};
enum GPURunState {
GPUSTATE_RUNNING = 0,
GPUSTATE_DONE = 1,
GPUSTATE_STALL = 2,
GPUSTATE_INTERRUPT = 3,
GPUSTATE_ERROR = 4,
};
enum GPUSyncType {
GPU_SYNC_DRAW,
GPU_SYNC_LIST,
};
enum class WriteStencil {
NEEDS_CLEAR = 1,
STENCIL_IS_ZERO = 2,
IGNORE_ALPHA = 4,
};
ENUM_CLASS_BITOPS(WriteStencil);
enum class GPUCopyFlag {
NONE = 0,
FORCE_SRC_MATCH_MEM = 1,
FORCE_DST_MATCH_MEM = 2,
// Note: implies src == dst and FORCE_SRC_MATCH_MEM.
MEMSET = 4,
DEPTH_REQUESTED = 8,
DEBUG_NOTIFIED = 16,
DISALLOW_CREATE_VFB = 32,
};
ENUM_CLASS_BITOPS(GPUCopyFlag);
struct DisplayListStackEntry {
u32 pc;
u32 offsetAddr;
u32 baseAddr;
};
struct DisplayList {
int id;
u32 startpc;
u32 pc;
u32 stall;
DisplayListState state;
SignalBehavior signal;
int subIntrBase;
u16 subIntrToken;
DisplayListStackEntry stack[32];
int stackptr;
bool interrupted;
u64 waitTicks;
bool interruptsEnabled;
bool pendingInterrupt;
bool started;
PSPPointer<u32_le> context;
u32 offsetAddr;
bool bboxResult;
u32 stackAddr;
u32 padding; // Android x86-32 does not round the structure size up to the closest multiple of 8 like the other platforms.
};
enum GPUInvalidationType {
// Affects all memory. Not considered highly.
GPU_INVALIDATE_ALL,
// Indicates some memory may have changed.
GPU_INVALIDATE_HINT,
// Reliable invalidation (where any hashing, etc. is unneeded, it'll always invalidate.)
GPU_INVALIDATE_SAFE,
// Forced invalidation for when the texture hash may not catch changes.
GPU_INVALIDATE_FORCE,
};
namespace Draw {
class DrawContext;
}
enum class DLRunType {
Run,
RunDebug,
Step,
};
enum class DLStepType {
None,
Single,
Prim,
Draw,
Texture,
Rendertarget,
};
enum class DLResult {
Done,
Error,
Pause, // used for stepping, breakpoints
};
class GPUInterface {
public:
virtual ~GPUInterface() {}
static const int DisplayListMaxCount = 64;
virtual Draw::DrawContext *GetDrawContext() = 0;
// Initialization
virtual bool IsStarted() = 0;
virtual void Reinitialize() = 0;
// Frame managment
virtual void BeginHostFrame() = 0;
virtual void EndHostFrame() = 0;
virtual void CheckDisplayResized() = 0;
virtual void CheckConfigChanged() = 0;
// Draw queue management
virtual DisplayList* getList(int listid) = 0;
// TODO: Much of this should probably be shared between the different GPU implementations.
virtual u32 EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointer<PspGeListArgs> args, bool head) = 0;
virtual u32 DequeueList(int listid) = 0;
virtual u32 UpdateStall(int listid, u32 newstall) = 0;
virtual DLResult ProcessDLQueue(DLRunType run, DLStepType step) = 0;
virtual u32 DrawSync(int mode) = 0;
virtual int ListSync(int listid, int mode) = 0;
virtual u32 Continue() = 0;
virtual u32 Break(int mode) = 0;
virtual int GetStack(int index, u32 stackPtr) = 0;
virtual bool GetMatrix24(GEMatrixType type, u32_le *result, u32 cmdbits) = 0;
virtual void ResetMatrices() = 0;
virtual uint32_t SetAddrTranslation(uint32_t value) = 0;
virtual void InterruptStart(int listid) = 0;
virtual void InterruptEnd(int listid) = 0;
virtual void SyncEnd(GPUSyncType waitType, int listid, bool wokeThreads) = 0;
virtual void ExecuteOp(u32 op, u32 diff) = 0;
// Framebuffer management
virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) = 0;
virtual void PSPFrame() = 0;
virtual void CopyDisplayToOutput(bool reallyDirty) = 0;
// Tells the GPU to update the gpuStats structure.
virtual void GetStats(char *buffer, size_t bufsize) = 0;
virtual void DrawImGuiDebugger() = 0;
// Invalidate any cached content sourced from the specified range.
// If size = -1, invalidate everything.
virtual void InvalidateCache(u32 addr, int size, GPUInvalidationType type) = 0;
// Clear caches, update hardware framebuffers, or similar based on written pixels of known format (typically video.)
virtual void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat format) = 0;
// Update either RAM from VRAM, or VRAM from RAM... or even VRAM from VRAM.
virtual bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) = 0;
virtual bool PerformMemorySet(u32 dest, u8 v, int size) = 0;
// Update PSP memory with render results.
virtual bool PerformReadbackToMemory(u32 dest, int size) = 0;
// Update rendering data (i.e. hardware framebuffers) with data in PSP memory. Format unspecified.
virtual bool PerformWriteColorFromMemory(u32 dest, int size) = 0;
virtual bool PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags = WriteStencil::NEEDS_CLEAR) = 0;
// Will cause the texture cache to be cleared at the start of the next frame.
virtual void ClearCacheNextFrame() = 0;
// Internal hack to avoid interrupts from "PPGe" drawing (utility UI, etc)
virtual void EnableInterrupts(bool enable) = 0;
virtual void DeviceLost() = 0;
virtual void DeviceRestore(Draw::DrawContext *draw) = 0;
virtual void ReapplyGfxState() = 0;
virtual void DoState(PointerWrap &p) = 0;
// Called by the window system if the window size changed. This will be reflected in PSPCoreParam.pixel*.
virtual void NotifyDisplayResized() = 0;
virtual void NotifyRenderResized() = 0;
virtual void NotifyConfigChanged() = 0;
virtual bool FramebufferDirty() = 0;
virtual bool FramebufferReallyDirty() = 0;
virtual bool BusyDrawing() = 0;
virtual bool PresentedThisFrame() const = 0;
// If any jit is being used inside the GPU.
virtual bool DescribeCodePtr(const u8 *ptr, std::string &name) = 0;
// Debugging
virtual void DumpNextFrame() = 0;
virtual void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) = 0;
virtual const std::list<int>& GetDisplayLists() = 0;
// TODO: Currently Qt only, needs to be cleaned up.
virtual std::vector<const VirtualFramebuffer *> GetFramebufferList() const = 0;
virtual s64 GetListTicks(int listid) const = 0;
// For debugging. The IDs returned are opaque, do not poke in them or display them in any way.
virtual std::vector<std::string> DebugGetShaderIDs(DebugShaderType type) = 0;
virtual std::string DebugGetShaderString(std::string id, DebugShaderType type, DebugShaderStringType stringType) = 0;
};

View File

@ -24,7 +24,7 @@
#include "Core/System.h"
#include "Core/MemMap.h"
#include "GPU/ge_constants.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#ifdef _M_SSE

View File

@ -19,7 +19,7 @@
#include "Core/MemMap.h"
#include "GPU/ge_constants.h"
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "GPU/GeDisasm.h"

View File

@ -46,7 +46,7 @@ bool comparePushBufferNames(const GPUMemoryManager *a, const GPUMemoryManager *b
return strcmp(a->Name(), b->Name()) < 0;
}
void DrawGPUMemoryVis(UIContext *ui, GPUInterface *gpu) {
void DrawGPUMemoryVis(UIContext *ui, GPUDebugInterface *gpu) {
// This one will simply display stats.
Draw::DrawContext *draw = ui->GetDrawContext();
@ -97,7 +97,7 @@ void DrawGPUMemoryVis(UIContext *ui, GPUInterface *gpu) {
ui->Flush();
}
void DrawGPUProfilerVis(UIContext *ui, GPUInterface *gpu) {
void DrawGPUProfilerVis(UIContext *ui, GPUDebugInterface *gpu) {
using namespace Draw;
const int padding = 10 + System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT);
const int starty = 50 + System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_TOP);

View File

@ -19,9 +19,9 @@
#include "Common/GPU/thin3d.h"
class GPUInterface;
class GPUDebugInterface;
class UIContext;
// gpu MUST be an instance of GPU_Vulkan. If not, will definitely crash.
void DrawGPUMemoryVis(UIContext *ui, GPUInterface *gpu);
void DrawGPUProfilerVis(UIContext *ui, GPUInterface *gpu);
void DrawGPUMemoryVis(UIContext *ui, GPUDebugInterface *gpu);
void DrawGPUProfilerVis(UIContext *ui, GPUDebugInterface *gpu);

View File

@ -18,7 +18,7 @@
#pragma once
#include "Common/Data/Collections/Hashmaps.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "Common/GPU/Vulkan/VulkanContext.h"
#include "GPU/Common/TextureCacheCommon.h"

View File

@ -18,7 +18,7 @@
#include "Core/HLE/sceUmd.h"
#include "Core/SaveState.h"
#include "Core/System.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "UI/GamepadEmu.h"
MainWindow::MainWindow(QWidget *parent, bool fullscreen) :

View File

@ -15,7 +15,7 @@
#include "Core/MemMap.h"
#include "Core/System.h"
#include "Core/Core.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "Common/File/Path.h"
#include "Common/System/System.h"
#include "Common/System/Request.h"

View File

@ -20,7 +20,7 @@
#include "Core/System.h"
#include "Core/Util/GameDB.h"
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
// TODO: This should be moved here or to Common, doesn't belong in /GPU
#include "GPU/Vulkan/DebugVisVulkan.h"
#include "GPU/Common/FramebufferManagerCommon.h"
@ -190,7 +190,7 @@ static void DrawFrameTiming(UIContext *ctx, const Bounds &bounds) {
ctx->RebindTexture();
}
void DrawFramebufferList(UIContext *ctx, GPUInterface *gpu, const Bounds &bounds) {
void DrawFramebufferList(UIContext *ctx, GPUDebugInterface *gpu, const Bounds &bounds) {
if (!gpu) {
return;
}

View File

@ -62,7 +62,7 @@
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/MIPS/JitCommon/JitState.h"
#include "GPU/Debugger/Record.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/GPUState.h"
#include "UI/MiscScreens.h"
#include "UI/DevScreens.h"

View File

@ -62,7 +62,7 @@ using namespace std::placeholders;
#include "Core/System.h"
#include "Core/FileSystems/VirtualDiscFileSystem.h"
#include "GPU/GPUState.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/FramebufferManagerCommon.h"
#if !PPSSPP_PLATFORM(UWP)
#include "GPU/Vulkan/DebugVisVulkan.h"

View File

@ -78,7 +78,7 @@
#include "GPU/Common/TextureReplacer.h"
#include "GPU/Common/PostShader.h"
#include "android/jni/TestRunner.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/FramebufferManagerCommon.h"
#include "Core/Core.h" // for Core_IsStepping

View File

@ -62,7 +62,7 @@
#include "UI/InstallZipScreen.h"
#include "Core/Config.h"
#include "Core/Loaders.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "Common/Data/Text/I18n.h"
#if PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(MAC)

View File

@ -46,7 +46,7 @@
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/HLE/sceUtility.h"
#include "GPU/GPUState.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/PostShader.h"
#include "UI/ControlMappingScreen.h"

View File

@ -110,7 +110,7 @@
#include "Core/TiltEventProcessor.h"
#include "Core/ThreadPools.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "UI/AudioCommon.h"
#include "UI/BackgroundAudio.h"
#include "UI/ControlMappingScreen.h"

View File

@ -157,7 +157,7 @@
<ClInclude Include="..\..\GPU\GPU.h" />
<ClInclude Include="..\..\GPU\GPUCommon.h" />
<ClInclude Include="..\..\GPU\GPUCommonHW.h" />
<ClInclude Include="..\..\GPU\GPUInterface.h" />
<ClInclude Include="..\..\GPU\GPUDefinitions.h" />
<ClInclude Include="..\..\GPU\GPUState.h" />
<ClInclude Include="..\..\GPU\Math3D.h" />
<ClInclude Include="..\..\GPU\Software\BinManager.h" />

View File

@ -106,7 +106,7 @@
<ClInclude Include="..\..\GPU\ge_constants.h" />
<ClInclude Include="..\..\GPU\GPU.h" />
<ClInclude Include="..\..\GPU\GPUCommon.h" />
<ClInclude Include="..\..\GPU\GPUInterface.h" />
<ClInclude Include="..\..\GPU\GPUDefinitions.h" />
<ClInclude Include="..\..\GPU\GPUState.h" />
<ClInclude Include="..\..\GPU\Math3D.h" />
<ClInclude Include="..\..\GPU\Software\BinManager.h" />

View File

@ -2,7 +2,7 @@
#include <algorithm>
#include "Common/CommonWindows.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/GPUCommon.h"
class CtrlDisplayListView
{

View File

@ -46,7 +46,7 @@
#include "Windows/MainWindow.h"
#include "Windows/main.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/Common/GPUStateUtils.h"
#include "GPU/GPUState.h"

View File

@ -17,6 +17,7 @@
#pragma once
#include "Common/Common.h"
#include "Common/CommonWindows.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/Debugger/Debugger.h"

View File

@ -3,7 +3,7 @@
#include "Windows/GEDebugger/CtrlDisplayListView.h"
#include "Windows/MainWindow.h"
#include "Windows/main.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/GPUState.h"
#include "Core/Config.h"

View File

@ -4,7 +4,7 @@
#include "Windows/resource.h"
#include "Windows/W32Util/DialogManager.h"
#include "Windows/W32Util/Misc.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/GPUCommon.h"
class CtrlDisplayListView;

View File

@ -22,7 +22,7 @@
#include "Windows/GEDebugger/SimpleGLWindow.h"
#include "Core/System.h"
#include "Core/Config.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/Common/SplineCommon.h"
#include "GPU/GPUState.h"

View File

@ -81,7 +81,7 @@
#include "Windows/CaptureDevice.h"
#include "Windows/TouchInputHandler.h"
#include "Windows/MainWindowMenu.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "UI/OnScreenDisplay.h"
#include "UI/GameSettingsScreen.h"

View File

@ -10,7 +10,7 @@
#include "Common/Log.h"
#include "Core/Config.h"
#include "Core/System.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
retro_video_refresh_t LibretroGraphicsContext::video_cb;

View File

@ -6,7 +6,7 @@
#include "Core/Config.h"
#include "Core/ConfigValues.h"
#include "Core/System.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "Common/Data/Text/Parsers.h"
#include "libretro/LibretroVulkanContext.h"

View File

@ -40,7 +40,7 @@
#include "Core/ELF/ParamSFO.h"
#include "GPU/GPUState.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUCommon.h"
#include "GPU/Common/FramebufferManagerCommon.h"
#include "GPU/Common/TextureScalerCommon.h"
#include "GPU/Common/PresentationCommon.h"