2012-12-28 20:58:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-03-03 04:42:55 +00:00
|
|
|
#include "ppsspp_config.h"
|
2013-08-12 15:40:36 +00:00
|
|
|
#include "Common/Common.h"
|
2013-10-27 01:11:17 +00:00
|
|
|
#include "Common/MemoryUtil.h"
|
2013-08-08 06:27:29 +00:00
|
|
|
#include "GPU/GPUInterface.h"
|
2017-01-28 10:39:34 +00:00
|
|
|
#include "GPU/GPUState.h"
|
2013-09-22 07:18:46 +00:00
|
|
|
#include "GPU/Common/GPUDebugInterface.h"
|
2012-12-28 20:58:00 +00:00
|
|
|
|
2016-10-12 09:13:16 +00:00
|
|
|
#if defined(__ANDROID__)
|
2013-08-12 15:51:19 +00:00
|
|
|
#include <atomic>
|
2017-08-17 13:48:52 +00:00
|
|
|
#endif
|
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
class FramebufferManagerCommon;
|
|
|
|
class TextureCacheCommon;
|
2017-01-21 19:42:40 +00:00
|
|
|
class DrawEngineCommon;
|
2017-01-30 15:50:35 +00:00
|
|
|
class GraphicsContext;
|
2022-08-18 07:38:17 +00:00
|
|
|
struct VirtualFramebuffer;
|
|
|
|
|
2017-01-30 15:50:35 +00:00
|
|
|
namespace Draw {
|
|
|
|
class DrawContext;
|
|
|
|
}
|
2016-12-21 17:07:17 +00:00
|
|
|
|
2017-01-28 10:39:34 +00:00
|
|
|
enum DrawType {
|
|
|
|
DRAW_UNKNOWN,
|
|
|
|
DRAW_PRIM,
|
|
|
|
DRAW_SPLINE,
|
|
|
|
DRAW_BEZIER,
|
|
|
|
};
|
|
|
|
|
2017-03-14 12:21:24 +00:00
|
|
|
enum {
|
|
|
|
FLAG_FLUSHBEFOREONCHANGE = 2,
|
2018-02-26 15:39:38 +00:00
|
|
|
FLAG_EXECUTE = 4,
|
2017-03-14 12:21:24 +00:00
|
|
|
FLAG_EXECUTEONCHANGE = 8,
|
|
|
|
FLAG_READS_PC = 16,
|
|
|
|
FLAG_WRITES_PC = 32,
|
|
|
|
FLAG_DIRTYONCHANGE = 64, // NOTE: Either this or FLAG_EXECUTE*, not both!
|
|
|
|
};
|
|
|
|
|
2017-11-24 16:54:56 +00:00
|
|
|
struct TransformedVertex {
|
|
|
|
union {
|
|
|
|
struct {
|
2021-10-31 04:03:01 +00:00
|
|
|
float x, y, z, pos_w; // in case of morph, preblend during decode
|
2017-11-24 16:54:56 +00:00
|
|
|
};
|
|
|
|
float pos[4];
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
struct {
|
2021-10-31 04:03:01 +00:00
|
|
|
float u; float v; float uv_w; // scaled by uscale, vscale, if there
|
2017-11-24 16:54:56 +00:00
|
|
|
};
|
|
|
|
float uv[3];
|
|
|
|
};
|
2021-10-24 19:07:57 +00:00
|
|
|
float fog;
|
2017-11-24 16:54:56 +00:00
|
|
|
union {
|
|
|
|
u8 color0[4]; // prelit
|
|
|
|
u32 color0_32;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
u8 color1[4]; // prelit
|
|
|
|
u32 color1_32;
|
|
|
|
};
|
2022-06-11 09:22:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
void CopyFromWithOffset(const TransformedVertex &other, float xoff, float yoff) {
|
|
|
|
this->x = other.x + xoff;
|
|
|
|
this->y = other.y + yoff;
|
|
|
|
memcpy(&this->z, &other.z, sizeof(*this) - sizeof(float) * 2);
|
|
|
|
}
|
2017-11-24 16:54:56 +00:00
|
|
|
};
|
|
|
|
|
2017-11-05 19:10:05 +00:00
|
|
|
class GPUCommon : public GPUInterface, public GPUDebugInterface {
|
2012-12-28 20:58:00 +00:00
|
|
|
public:
|
2017-01-30 15:50:35 +00:00
|
|
|
GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
|
2015-07-26 20:38:40 +00:00
|
|
|
virtual ~GPUCommon();
|
2015-09-05 19:23:58 +00:00
|
|
|
|
2017-02-06 10:55:54 +00:00
|
|
|
Draw::DrawContext *GetDrawContext() override {
|
|
|
|
return draw_;
|
|
|
|
}
|
2022-09-20 08:02:15 +00:00
|
|
|
virtual u32 CheckGPUFeatures() const;
|
2022-11-21 16:59:56 +00:00
|
|
|
|
|
|
|
void CheckDisplayResized() override;
|
2022-11-22 22:29:50 +00:00
|
|
|
void CheckConfigChanged() override;
|
2018-02-26 10:35:37 +00:00
|
|
|
|
2018-04-10 10:22:02 +00:00
|
|
|
void UpdateCmdInfo();
|
|
|
|
|
2017-12-03 18:54:38 +00:00
|
|
|
bool IsReady() override {
|
|
|
|
return true;
|
|
|
|
}
|
2022-11-21 13:54:48 +00:00
|
|
|
void CancelReady() override {}
|
2015-10-14 20:18:29 +00:00
|
|
|
void Reinitialize() override;
|
2012-12-29 01:10:29 +00:00
|
|
|
|
2016-01-06 22:53:21 +00:00
|
|
|
void BeginHostFrame() override;
|
|
|
|
void EndHostFrame() override;
|
|
|
|
|
2015-10-14 20:18:29 +00:00
|
|
|
void InterruptStart(int listid) override;
|
|
|
|
void InterruptEnd(int listid) override;
|
|
|
|
void SyncEnd(GPUSyncType waitType, int listid, bool wokeThreads) override;
|
|
|
|
void EnableInterrupts(bool enable) override {
|
2013-04-01 06:02:46 +00:00
|
|
|
interruptsEnabled_ = enable;
|
|
|
|
}
|
2013-02-03 23:41:16 +00:00
|
|
|
|
2022-11-21 14:14:20 +00:00
|
|
|
void NotifyDisplayResized() override;
|
|
|
|
void NotifyRenderResized() override;
|
|
|
|
void NotifyConfigChanged() override;
|
|
|
|
|
2017-06-03 02:39:11 +00:00
|
|
|
void DumpNextFrame() override;
|
2016-12-21 17:13:58 +00:00
|
|
|
|
2015-10-14 20:18:29 +00:00
|
|
|
void ExecuteOp(u32 op, u32 diff) override;
|
|
|
|
void PreExecuteOp(u32 op, u32 diff) override;
|
2017-01-24 09:44:02 +00:00
|
|
|
|
2022-09-17 23:27:51 +00:00
|
|
|
bool InterpretList(DisplayList &list);
|
2017-11-05 19:33:28 +00:00
|
|
|
void ProcessDLQueue();
|
2015-10-14 20:18:29 +00:00
|
|
|
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;
|
2022-09-28 05:29:55 +00:00
|
|
|
bool GetMatrix24(GEMatrixType type, u32_le *result, u32 cmdbits) override;
|
|
|
|
void ResetMatrices() override;
|
2015-10-14 20:18:29 +00:00
|
|
|
void DoState(PointerWrap &p) override;
|
|
|
|
bool BusyDrawing() override;
|
|
|
|
u32 Continue() override;
|
|
|
|
u32 Break(int mode) override;
|
|
|
|
void ReapplyGfxState() override;
|
2022-10-02 06:18:42 +00:00
|
|
|
uint32_t SetAddrTranslation(uint32_t value) override;
|
|
|
|
uint32_t GetAddrTranslation() override;
|
2012-12-28 20:58:00 +00:00
|
|
|
|
2022-08-24 02:29:06 +00:00
|
|
|
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
|
2020-03-01 21:55:28 +00:00
|
|
|
void CopyDisplayToOutput(bool reallyDirty) override = 0;
|
2017-11-05 19:33:28 +00:00
|
|
|
void InitClear() override = 0;
|
2022-10-04 03:17:25 +00:00
|
|
|
bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) override;
|
2016-12-21 17:26:06 +00:00
|
|
|
bool PerformMemorySet(u32 dest, u8 v, int size) override;
|
2022-10-09 20:49:41 +00:00
|
|
|
bool PerformReadbackToMemory(u32 dest, int size) override;
|
|
|
|
bool PerformWriteColorFromMemory(u32 dest, int size) override;
|
2016-12-21 17:26:06 +00:00
|
|
|
|
2016-12-21 17:33:08 +00:00
|
|
|
void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override;
|
2022-10-09 20:49:41 +00:00
|
|
|
void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat format) override;
|
|
|
|
bool PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags) override;
|
2016-12-21 17:33:08 +00:00
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
void Execute_OffsetAddr(u32 op, u32 diff);
|
2017-01-28 10:53:28 +00:00
|
|
|
void Execute_Vaddr(u32 op, u32 diff);
|
|
|
|
void Execute_Iaddr(u32 op, u32 diff);
|
2014-04-16 15:12:21 +00:00
|
|
|
void Execute_Origin(u32 op, u32 diff);
|
|
|
|
void Execute_Jump(u32 op, u32 diff);
|
2018-08-25 17:38:56 +00:00
|
|
|
void Execute_JumpFast(u32 op, u32 diff);
|
2014-04-16 15:12:21 +00:00
|
|
|
void Execute_BJump(u32 op, u32 diff);
|
|
|
|
void Execute_Call(u32 op, u32 diff);
|
2018-08-25 17:38:56 +00:00
|
|
|
void Execute_CallFast(u32 op, u32 diff);
|
2014-04-16 15:12:21 +00:00
|
|
|
void Execute_Ret(u32 op, u32 diff);
|
|
|
|
void Execute_End(u32 op, u32 diff);
|
|
|
|
|
2017-11-13 17:57:59 +00:00
|
|
|
void Execute_VertexType(u32 op, u32 diff);
|
2018-04-10 10:22:02 +00:00
|
|
|
void Execute_VertexTypeSkinning(u32 op, u32 diff);
|
2017-11-13 17:57:59 +00:00
|
|
|
|
2018-02-26 10:18:52 +00:00
|
|
|
void Execute_Prim(u32 op, u32 diff);
|
2017-01-21 19:42:40 +00:00
|
|
|
void Execute_Bezier(u32 op, u32 diff);
|
|
|
|
void Execute_Spline(u32 op, u32 diff);
|
|
|
|
void Execute_BoundingBox(u32 op, u32 diff);
|
2017-01-23 15:57:16 +00:00
|
|
|
void Execute_BlockTransferStart(u32 op, u32 diff);
|
2017-01-21 19:42:40 +00:00
|
|
|
|
2018-02-26 10:26:52 +00:00
|
|
|
void Execute_LoadClut(u32 op, u32 diff);
|
|
|
|
|
2017-11-13 17:57:59 +00:00
|
|
|
void Execute_TexSize0(u32 op, u32 diff);
|
2017-02-13 21:02:26 +00:00
|
|
|
void Execute_TexLevel(u32 op, u32 diff);
|
2017-01-28 10:39:34 +00:00
|
|
|
|
2017-01-23 19:56:25 +00:00
|
|
|
void Execute_WorldMtxNum(u32 op, u32 diff);
|
|
|
|
void Execute_WorldMtxData(u32 op, u32 diff);
|
|
|
|
void Execute_ViewMtxNum(u32 op, u32 diff);
|
|
|
|
void Execute_ViewMtxData(u32 op, u32 diff);
|
|
|
|
void Execute_ProjMtxNum(u32 op, u32 diff);
|
|
|
|
void Execute_ProjMtxData(u32 op, u32 diff);
|
|
|
|
void Execute_TgenMtxNum(u32 op, u32 diff);
|
|
|
|
void Execute_TgenMtxData(u32 op, u32 diff);
|
|
|
|
void Execute_BoneMtxNum(u32 op, u32 diff);
|
|
|
|
void Execute_BoneMtxData(u32 op, u32 diff);
|
|
|
|
|
2017-01-24 09:44:02 +00:00
|
|
|
void Execute_MorphWeight(u32 op, u32 diff);
|
|
|
|
|
2017-11-24 16:54:56 +00:00
|
|
|
void Execute_ImmVertexAlphaPrim(u32 op, u32 diff);
|
|
|
|
|
2017-01-24 09:44:02 +00:00
|
|
|
void Execute_Unknown(u32 op, u32 diff);
|
|
|
|
|
2017-01-23 20:00:44 +00:00
|
|
|
int EstimatePerVertexCost();
|
|
|
|
|
2017-01-23 19:56:25 +00:00
|
|
|
// Note: Not virtual!
|
2017-11-14 08:13:13 +00:00
|
|
|
void Flush();
|
2022-01-22 21:12:59 +00:00
|
|
|
void DispatchFlush() override;
|
2017-01-23 19:56:25 +00:00
|
|
|
|
2016-02-10 14:22:28 +00:00
|
|
|
#ifdef USE_CRT_DBG
|
|
|
|
#undef new
|
|
|
|
#endif
|
2013-10-27 01:11:17 +00:00
|
|
|
void *operator new(size_t s) {
|
|
|
|
return AllocateAlignedMemory(s, 16);
|
|
|
|
}
|
|
|
|
void operator delete(void *p) {
|
|
|
|
FreeAlignedMemory(p);
|
|
|
|
}
|
2016-02-10 14:22:28 +00:00
|
|
|
#ifdef USE_CRT_DBG
|
|
|
|
#define new DBG_NEW
|
|
|
|
#endif
|
2013-10-27 01:11:17 +00:00
|
|
|
|
2014-06-14 15:42:18 +00:00
|
|
|
// From GPUDebugInterface.
|
2015-10-14 20:18:29 +00:00
|
|
|
bool GetCurrentDisplayList(DisplayList &list) override;
|
2017-02-14 11:42:35 +00:00
|
|
|
bool GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferType type, int maxRes) override;
|
|
|
|
bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer) override;
|
|
|
|
bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override;
|
2022-10-11 05:35:42 +00:00
|
|
|
bool GetCurrentTexture(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
|
2017-10-18 11:03:49 +00:00
|
|
|
bool GetCurrentClut(GPUDebugBuffer &buffer) override;
|
|
|
|
bool GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices) override;
|
2017-02-17 23:43:02 +00:00
|
|
|
bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override;
|
2017-02-14 11:42:35 +00:00
|
|
|
|
2017-10-20 09:06:06 +00:00
|
|
|
std::vector<std::string> DebugGetShaderIDs(DebugShaderType shader) override { return std::vector<std::string>(); };
|
|
|
|
std::string DebugGetShaderString(std::string id, DebugShaderType shader, DebugShaderStringType stringType) override {
|
|
|
|
return "N/A";
|
|
|
|
}
|
2017-10-24 13:38:16 +00:00
|
|
|
bool DescribeCodePtr(const u8 *ptr, std::string &name) override;
|
2017-10-20 09:06:06 +00:00
|
|
|
|
2015-10-14 20:18:29 +00:00
|
|
|
std::vector<DisplayList> ActiveDisplayLists() override;
|
|
|
|
void ResetListPC(int listID, u32 pc) override;
|
|
|
|
void ResetListStall(int listID, u32 stall) override;
|
|
|
|
void ResetListState(int listID, DisplayListState state) override;
|
2014-06-14 15:42:18 +00:00
|
|
|
|
2015-10-14 20:18:29 +00:00
|
|
|
GPUDebugOp DissassembleOp(u32 pc, u32 op) override;
|
|
|
|
std::vector<GPUDebugOp> DissassembleOpRange(u32 startpc, u32 endpc) override;
|
2014-06-14 15:42:18 +00:00
|
|
|
|
2015-10-14 20:18:29 +00:00
|
|
|
void NotifySteppingEnter() override;
|
|
|
|
void NotifySteppingExit() override;
|
2014-06-14 15:42:18 +00:00
|
|
|
|
2015-10-14 20:18:29 +00:00
|
|
|
u32 GetRelativeAddress(u32 data) override;
|
|
|
|
u32 GetVertexAddress() override;
|
|
|
|
u32 GetIndexAddress() override;
|
|
|
|
GPUgstate GetGState() override;
|
|
|
|
void SetCmdValue(u32 op) override;
|
2014-06-14 15:42:18 +00:00
|
|
|
|
2022-04-14 22:35:22 +00:00
|
|
|
void UpdateUVScaleOffset();
|
2017-08-17 11:53:13 +00:00
|
|
|
|
2015-10-14 20:18:29 +00:00
|
|
|
DisplayList* getList(int listid) override {
|
2014-06-14 15:42:18 +00:00
|
|
|
return &dls[listid];
|
|
|
|
}
|
|
|
|
|
2015-10-14 20:18:29 +00:00
|
|
|
const std::list<int>& GetDisplayLists() override {
|
2014-06-14 15:42:18 +00:00
|
|
|
return dlQueue;
|
|
|
|
}
|
2022-08-16 08:55:44 +00:00
|
|
|
std::vector<FramebufferInfo> GetFramebufferList() const override;
|
2015-10-14 20:18:29 +00:00
|
|
|
void ClearShaderCache() override {}
|
|
|
|
void CleanupBeforeUI() override {}
|
2014-06-14 15:42:18 +00:00
|
|
|
|
2022-08-16 08:55:44 +00:00
|
|
|
s64 GetListTicks(int listid) const override {
|
2017-06-03 21:13:37 +00:00
|
|
|
if (listid >= 0 && listid < DisplayListMaxCount) {
|
|
|
|
return dls[listid].waitTicks;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-02-26 10:58:17 +00:00
|
|
|
bool FramebufferDirty() override;
|
|
|
|
bool FramebufferReallyDirty() override;
|
|
|
|
|
2017-03-14 12:21:24 +00:00
|
|
|
typedef void (GPUCommon::*CmdFunc)(u32 op, u32 diff);
|
|
|
|
|
2018-03-13 12:35:44 +00:00
|
|
|
void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) override {
|
|
|
|
primaryInfo = reportingPrimaryInfo_;
|
|
|
|
fullInfo = reportingFullInfo_;
|
|
|
|
}
|
|
|
|
|
2012-12-28 20:58:00 +00:00
|
|
|
protected:
|
2020-11-06 23:56:48 +00:00
|
|
|
void DeviceLost() override;
|
|
|
|
void DeviceRestore() override;
|
|
|
|
|
2022-11-21 16:59:56 +00:00
|
|
|
void CheckRenderResized();
|
|
|
|
|
2022-11-13 16:04:47 +00:00
|
|
|
// Add additional common features dependent on other features, which may be backend-determined.
|
|
|
|
u32 CheckGPUFeaturesLate(u32 features) const;
|
|
|
|
|
2015-12-14 01:17:21 +00:00
|
|
|
inline bool IsTrianglePrim(GEPrimitiveType prim) const {
|
|
|
|
return prim != GE_PRIM_RECTANGLES && prim > GE_PRIM_LINE_STRIP;
|
|
|
|
}
|
|
|
|
|
2017-04-03 14:45:58 +00:00
|
|
|
void SetDrawType(DrawType type, GEPrimitiveType prim) {
|
2017-01-28 10:39:34 +00:00
|
|
|
if (type != lastDraw_) {
|
2017-11-14 08:13:13 +00:00
|
|
|
// We always flush when drawing splines/beziers so no need to do so here
|
2022-10-02 02:22:16 +00:00
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET | DIRTY_VERTEXSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE);
|
2017-01-28 10:39:34 +00:00
|
|
|
lastDraw_ = type;
|
|
|
|
}
|
2017-04-03 22:06:45 +00:00
|
|
|
// Prim == RECTANGLES can cause CanUseHardwareTransform to flip, so we need to dirty.
|
2017-08-15 10:02:47 +00:00
|
|
|
// Also, culling may be affected so dirty the raster state.
|
2015-12-14 01:17:21 +00:00
|
|
|
if (IsTrianglePrim(prim) != IsTrianglePrim(lastPrim_)) {
|
2017-11-14 08:13:13 +00:00
|
|
|
Flush();
|
2022-10-02 02:22:16 +00:00
|
|
|
gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VERTEXSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE);
|
2017-04-03 22:06:45 +00:00
|
|
|
lastPrim_ = prim;
|
|
|
|
}
|
2017-01-28 10:39:34 +00:00
|
|
|
}
|
|
|
|
|
2017-06-04 05:28:29 +00:00
|
|
|
void BeginFrame() override;
|
2020-03-01 06:27:00 +00:00
|
|
|
void UpdateVsyncInterval(bool force);
|
2016-12-21 18:58:10 +00:00
|
|
|
|
2018-02-26 10:52:16 +00:00
|
|
|
virtual void FastRunLoop(DisplayList &list);
|
|
|
|
|
2013-04-28 21:23:30 +00:00
|
|
|
void SlowRunLoop(DisplayList &list);
|
2014-04-05 19:04:10 +00:00
|
|
|
void UpdatePC(u32 currentPC, u32 newPC);
|
2015-07-26 20:38:40 +00:00
|
|
|
void UpdateState(GPURunState state);
|
2022-08-18 07:38:17 +00:00
|
|
|
void FastLoadBoneMatrix(u32 target);
|
2022-09-06 05:45:34 +00:00
|
|
|
void FlushImm();
|
2017-11-05 19:10:05 +00:00
|
|
|
|
|
|
|
// TODO: Unify this.
|
|
|
|
virtual void FinishDeferred() {}
|
2013-04-03 15:10:35 +00:00
|
|
|
|
2017-08-15 10:02:47 +00:00
|
|
|
void AdvanceVerts(u32 vertType, int count, int bytesRead) {
|
|
|
|
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
|
|
|
|
int indexShift = ((vertType & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT) - 1;
|
|
|
|
gstate_c.indexAddr += count << indexShift;
|
|
|
|
} else {
|
|
|
|
gstate_c.vertexAddr += bytesRead;
|
|
|
|
}
|
|
|
|
}
|
2016-12-21 17:33:08 +00:00
|
|
|
|
2020-09-20 19:33:06 +00:00
|
|
|
size_t FormatGPUStatsCommon(char *buf, size_t size);
|
|
|
|
|
2022-11-20 11:57:32 +00:00
|
|
|
virtual void BuildReportingInfo() = 0;
|
|
|
|
|
2020-05-13 07:06:13 +00:00
|
|
|
FramebufferManagerCommon *framebufferManager_ = nullptr;
|
|
|
|
TextureCacheCommon *textureCache_ = nullptr;
|
|
|
|
DrawEngineCommon *drawEngineCommon_ = nullptr;
|
|
|
|
ShaderManagerCommon *shaderManager_ = nullptr;
|
2022-02-01 03:32:46 +00:00
|
|
|
bool flushOnParams_ = true;
|
2016-12-21 17:07:17 +00:00
|
|
|
|
2017-01-30 15:50:35 +00:00
|
|
|
GraphicsContext *gfxCtx_;
|
|
|
|
Draw::DrawContext *draw_;
|
|
|
|
|
2018-02-26 10:44:02 +00:00
|
|
|
struct CommandInfo {
|
|
|
|
uint64_t flags;
|
|
|
|
GPUCommon::CmdFunc func;
|
2022-09-25 11:59:52 +00:00
|
|
|
|
|
|
|
// Dirty flags are mashed into the regular flags by a left shift of 8.
|
|
|
|
void AddDirty(u64 dirty) {
|
|
|
|
flags |= dirty << 8;
|
|
|
|
}
|
|
|
|
void RemoveDirty(u64 dirty) {
|
|
|
|
flags &= ~(dirty << 8);
|
|
|
|
}
|
2018-02-26 10:44:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static CommandInfo cmdInfo_[256];
|
|
|
|
|
2013-04-05 06:19:28 +00:00
|
|
|
typedef std::list<int> DisplayListQueue;
|
2012-12-29 01:10:29 +00:00
|
|
|
|
2013-09-21 20:18:20 +00:00
|
|
|
int nextListID;
|
2013-04-05 06:19:28 +00:00
|
|
|
DisplayList dls[DisplayListMaxCount];
|
2012-12-28 20:58:00 +00:00
|
|
|
DisplayList *currentList;
|
|
|
|
DisplayListQueue dlQueue;
|
2012-12-29 01:10:29 +00:00
|
|
|
|
2018-06-23 04:25:07 +00:00
|
|
|
bool interruptRunning = false;
|
|
|
|
GPURunState gpuState = GPUSTATE_RUNNING;
|
2013-04-04 07:35:38 +00:00
|
|
|
bool isbreak;
|
2013-04-07 19:45:42 +00:00
|
|
|
u64 drawCompleteTicks;
|
2013-04-09 07:56:04 +00:00
|
|
|
u64 busyTicks;
|
2012-12-29 01:10:29 +00:00
|
|
|
|
2013-04-28 21:23:30 +00:00
|
|
|
int downcount;
|
2013-04-03 15:10:35 +00:00
|
|
|
u64 startingTicks;
|
|
|
|
u32 cycleLastPC;
|
|
|
|
int cyclesExecuted;
|
|
|
|
|
2021-02-15 18:29:34 +00:00
|
|
|
bool dumpNextFrame_ = false;
|
|
|
|
bool dumpThisFrame_ = false;
|
2017-06-03 22:03:59 +00:00
|
|
|
bool debugRecording_;
|
2013-04-01 06:02:46 +00:00
|
|
|
bool interruptsEnabled_;
|
2022-11-21 14:14:20 +00:00
|
|
|
bool displayResized_ = false;
|
|
|
|
bool renderResized_ = false;
|
|
|
|
bool configChanged_ = false;
|
2022-11-13 16:13:22 +00:00
|
|
|
bool sawExactEqualDepth_ = false;
|
2018-03-22 21:25:04 +00:00
|
|
|
DrawType lastDraw_ = DRAW_UNKNOWN;
|
|
|
|
GEPrimitiveType lastPrim_ = GE_PRIM_INVALID;
|
2013-02-03 23:41:16 +00:00
|
|
|
|
2018-02-26 10:18:52 +00:00
|
|
|
int vertexCost_ = 0;
|
|
|
|
|
2017-11-24 16:54:56 +00:00
|
|
|
// No idea how big this buffer needs to be.
|
|
|
|
enum {
|
|
|
|
MAX_IMMBUFFER_SIZE = 32,
|
|
|
|
};
|
|
|
|
|
|
|
|
TransformedVertex immBuffer_[MAX_IMMBUFFER_SIZE];
|
|
|
|
int immCount_ = 0;
|
2022-09-06 05:45:34 +00:00
|
|
|
GEPrimitiveType immPrim_ = GE_PRIM_INVALID;
|
2022-09-06 06:13:16 +00:00
|
|
|
uint32_t immFlags_ = 0;
|
2022-09-18 03:15:40 +00:00
|
|
|
bool immFirstSent_ = false;
|
2017-11-24 16:54:56 +00:00
|
|
|
|
2022-10-02 06:18:42 +00:00
|
|
|
uint32_t edramTranslation_ = 0x400;
|
|
|
|
|
2022-09-28 05:29:55 +00:00
|
|
|
// Whe matrix data overflows, the CPU visible values wrap and bleed between matrices.
|
|
|
|
// But this doesn't actually change the values used by rendering.
|
|
|
|
// The CPU visible values affect the GPU when list contexts are restored.
|
|
|
|
// Note: not maintained by all backends, here for save stating.
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u32 bone[12 * 8];
|
|
|
|
u32 world[12];
|
|
|
|
u32 view[12];
|
|
|
|
u32 proj[16];
|
|
|
|
u32 tgen[12];
|
|
|
|
};
|
|
|
|
u32 all[12 * 8 + 12 + 12 + 16 + 12];
|
|
|
|
} matrixVisible;
|
|
|
|
|
2018-03-13 12:35:44 +00:00
|
|
|
std::string reportingPrimaryInfo_;
|
|
|
|
std::string reportingFullInfo_;
|
|
|
|
|
2013-08-14 04:42:48 +00:00
|
|
|
private:
|
2022-08-18 07:38:17 +00:00
|
|
|
void CheckDepthUsage(VirtualFramebuffer *vfb);
|
|
|
|
void DoBlockTransfer(u32 skipDrawReason);
|
|
|
|
void DoExecuteCall(u32 target);
|
|
|
|
void PopDLQueue();
|
|
|
|
void CheckDrawSync();
|
|
|
|
int GetNextListIndex();
|
|
|
|
|
2014-06-14 15:42:18 +00:00
|
|
|
// Debug stats.
|
|
|
|
double timeSteppingStarted_;
|
|
|
|
double timeSpentStepping_;
|
2020-03-08 18:10:16 +00:00
|
|
|
int lastVsync_ = -1;
|
2013-02-03 23:41:16 +00:00
|
|
|
};
|
2017-03-14 12:21:24 +00:00
|
|
|
|
|
|
|
struct CommonCommandTableEntry {
|
|
|
|
uint8_t cmd;
|
|
|
|
uint8_t flags;
|
|
|
|
uint64_t dirty;
|
|
|
|
GPUCommon::CmdFunc func;
|
|
|
|
};
|