CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/Directx9/DrawEngineDX9.h
Views: 1401
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include <d3d9.h>
21
#include <wrl/client.h>
22
23
#include "Common/Data/Collections/Hashmaps.h"
24
#include "GPU/GPUState.h"
25
#include "GPU/Common/GPUDebugInterface.h"
26
#include "GPU/Common/IndexGenerator.h"
27
#include "GPU/Common/VertexDecoderCommon.h"
28
#include "GPU/Common/DrawEngineCommon.h"
29
#include "GPU/Common/GPUStateUtils.h"
30
#include "GPU/MiscTypes.h"
31
32
struct DecVtxFormat;
33
struct UVScale;
34
35
class VSShader;
36
class ShaderManagerDX9;
37
class TextureCacheDX9;
38
class FramebufferManagerDX9;
39
40
class TessellationDataTransferDX9 : public TessellationDataTransfer {
41
public:
42
TessellationDataTransferDX9() {}
43
~TessellationDataTransferDX9() {}
44
void SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) override;
45
};
46
47
// Handles transform, lighting and drawing.
48
class DrawEngineDX9 : public DrawEngineCommon {
49
public:
50
DrawEngineDX9(Draw::DrawContext *draw);
51
~DrawEngineDX9();
52
53
void DeviceLost() override { draw_ = nullptr; }
54
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
55
56
void SetShaderManager(ShaderManagerDX9 *shaderManager) {
57
shaderManager_ = shaderManager;
58
}
59
void SetTextureCache(TextureCacheDX9 *textureCache) {
60
textureCache_ = textureCache;
61
}
62
void SetFramebufferManager(FramebufferManagerDX9 *fbManager) {
63
framebufferManager_ = fbManager;
64
}
65
void InitDeviceObjects();
66
void DestroyDeviceObjects();
67
68
void BeginFrame();
69
70
// So that this can be inlined
71
void Flush() {
72
if (!numDrawVerts_)
73
return;
74
DoFlush();
75
}
76
77
void FinishDeferred() {
78
if (!numDrawVerts_)
79
return;
80
DecodeVerts(decoded_);
81
}
82
83
void DispatchFlush() override {
84
if (!numDrawVerts_)
85
return;
86
Flush();
87
}
88
89
protected:
90
// Not currently supported.
91
bool UpdateUseHWTessellation(bool enable) const override { return false; }
92
93
private:
94
void Invalidate(InvalidationCallbackFlags flags);
95
void DoFlush();
96
97
void ApplyDrawState(int prim);
98
void ApplyDrawStateLate();
99
100
HRESULT SetupDecFmtForDraw(const DecVtxFormat &decFmt, u32 pspFmt, IDirect3DVertexDeclaration9 **ppVertexDeclaration);
101
102
LPDIRECT3DDEVICE9 device_ = nullptr;
103
Draw::DrawContext *draw_;
104
105
DenseHashMap<u32, Microsoft::WRL::ComPtr<IDirect3DVertexDeclaration9>> vertexDeclMap_;
106
107
// SimpleVertex
108
Microsoft::WRL::ComPtr<IDirect3DVertexDeclaration9> transformedVertexDecl_;
109
110
// Other
111
ShaderManagerDX9 *shaderManager_ = nullptr;
112
TextureCacheDX9 *textureCache_ = nullptr;
113
FramebufferManagerDX9 *framebufferManager_ = nullptr;
114
115
// Hardware tessellation
116
TessellationDataTransferDX9 *tessDataTransferDX9;
117
118
FBOTexState fboTexBindState_ = FBO_TEX_NONE;
119
120
int lastRenderStepId_ = -1;
121
122
bool fboTexNeedsBind_ = false;
123
};
124
125