Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/GPUCommonHW.h
5683 views
1
#pragma once
2
3
#include "GPUCommon.h"
4
5
// Shared GPUCommon implementation for the HW backends.
6
// Things that are irrelevant for SoftGPU should live here.
7
class GPUCommonHW : public GPUCommon {
8
public:
9
GPUCommonHW(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
10
~GPUCommonHW() override;
11
12
// This can fail, and if so no render pass is active.
13
void SetCurFramebufferDirty(bool dirty) override { curFramebufferDirty_ = dirty; }
14
void PrepareCopyDisplayToOutput(const DisplayLayoutConfig &config) override;
15
void CopyDisplayToOutput(const DisplayLayoutConfig &config) override;
16
void DoState(PointerWrap &p) override;
17
void DeviceLost() override;
18
void DeviceRestore(Draw::DrawContext *draw) override;
19
20
void BeginHostFrame(const DisplayLayoutConfig &config) override;
21
22
u32 CheckGPUFeatures() const override;
23
24
// From GPUDebugInterface.
25
bool GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferType type, int maxRes) override;
26
bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer) override;
27
bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override;
28
bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override;
29
std::vector<const VirtualFramebuffer *> GetFramebufferList() const override;
30
bool GetCurrentTexture(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
31
bool GetCurrentClut(GPUDebugBuffer &buffer) override;
32
33
FramebufferManagerCommon *GetFramebufferManagerCommon() override {
34
return framebufferManager_;
35
}
36
TextureCacheCommon *GetTextureCacheCommon() override {
37
return textureCache_;
38
}
39
40
// Using string because it's generic - makes no assumptions on the size of the shader IDs of this backend.
41
std::vector<std::string> DebugGetShaderIDs(DebugShaderType shader) override;
42
std::string DebugGetShaderString(std::string id, DebugShaderType shader, DebugShaderStringType stringType) override;
43
44
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
45
void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override;
46
47
u32 DrawSync(int mode) override;
48
int ListSync(int listid, int mode) override;
49
50
bool FramebufferDirty() override;
51
bool FramebufferReallyDirty() override;
52
53
void Execute_VertexType(u32 op, u32 diff);
54
void Execute_VertexTypeSkinning(u32 op, u32 diff);
55
56
void Execute_Prim(u32 op, u32 diff);
57
void Execute_Bezier(u32 op, u32 diff);
58
void Execute_Spline(u32 op, u32 diff);
59
void Execute_BlockTransferStart(u32 op, u32 diff);
60
61
void Execute_TexSize0(u32 op, u32 diff);
62
void Execute_TexLevel(u32 op, u32 diff);
63
void Execute_LoadClut(u32 op, u32 diff);
64
65
void Execute_WorldMtxNum(u32 op, u32 diff);
66
void Execute_WorldMtxData(u32 op, u32 diff);
67
void Execute_ViewMtxNum(u32 op, u32 diff);
68
void Execute_ViewMtxData(u32 op, u32 diff);
69
void Execute_ProjMtxNum(u32 op, u32 diff);
70
void Execute_ProjMtxData(u32 op, u32 diff);
71
void Execute_TgenMtxNum(u32 op, u32 diff);
72
void Execute_TgenMtxData(u32 op, u32 diff);
73
void Execute_BoneMtxNum(u32 op, u32 diff);
74
void Execute_BoneMtxData(u32 op, u32 diff);
75
76
void Execute_TexFlush(u32 op, u32 diff);
77
78
// TODO: Have these return an error code if they jump to a bad address. If bad, stop the FastRunLoop.
79
typedef void (GPUCommonHW::*CmdFunc)(u32 op, u32 diff);
80
81
void FastRunLoop(DisplayList &list) override;
82
void ExecuteOp(u32 op, u32 diff) override;
83
84
bool PresentedThisFrame() const override;
85
86
private:
87
void CheckDepthUsage(VirtualFramebuffer *vfb) override;
88
void CheckFlushOp(int cmd, u32 diff);
89
90
protected:
91
size_t FormatGPUStatsCommon(char *buf, size_t size);
92
void UpdateCmdInfo() override;
93
94
void PreExecuteOp(u32 op, u32 diff) override;
95
void ClearCacheNextFrame() override;
96
97
// Needs to be called on GPU thread, not reporting thread.
98
void BuildReportingInfo() override;
99
void UpdateMSAALevel(Draw::DrawContext *draw) override;
100
101
void CheckDisplayResized() override;
102
void CheckRenderResized(const DisplayLayoutConfig &config) override;
103
void CheckConfigChanged(const DisplayLayoutConfig &config) override;
104
105
u32 CheckGPUFeaturesLate(u32 features) const;
106
107
int msaaLevel_ = 0;
108
bool sawExactEqualDepth_ = false;
109
ShaderManagerCommon *shaderManager_ = nullptr;
110
bool curFramebufferDirty_ = false;
111
};
112
113