2013-08-17 11:23:51 +02:00
|
|
|
// 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
|
|
|
|
|
2013-09-15 12:46:14 +02:00
|
|
|
#include <d3d9.h>
|
2014-09-10 10:44:22 +02:00
|
|
|
|
2020-10-05 20:58:33 +02:00
|
|
|
#include "Common/Data/Collections/Hashmaps.h"
|
2015-07-26 22:38:40 +02:00
|
|
|
#include "GPU/GPUState.h"
|
2014-08-24 22:16:32 -07:00
|
|
|
#include "GPU/Common/GPUDebugInterface.h"
|
2013-09-15 12:46:14 +02:00
|
|
|
#include "GPU/Common/IndexGenerator.h"
|
2014-09-10 10:44:22 +02:00
|
|
|
#include "GPU/Common/VertexDecoderCommon.h"
|
2014-09-13 15:13:34 +02:00
|
|
|
#include "GPU/Common/DrawEngineCommon.h"
|
2015-10-24 23:49:05 +02:00
|
|
|
#include "GPU/Common/GPUStateUtils.h"
|
2013-08-17 11:23:51 +02:00
|
|
|
|
2013-09-15 08:53:21 -07:00
|
|
|
struct DecVtxFormat;
|
2015-07-26 22:38:40 +02:00
|
|
|
struct UVScale;
|
2013-09-15 08:53:21 -07:00
|
|
|
|
2014-09-10 14:07:30 +02:00
|
|
|
class VSShader;
|
2013-09-15 12:46:14 +02:00
|
|
|
class ShaderManagerDX9;
|
|
|
|
class TextureCacheDX9;
|
|
|
|
class FramebufferManagerDX9;
|
2013-08-17 11:23:51 +02:00
|
|
|
|
2018-07-13 18:35:44 +09:00
|
|
|
class TessellationDataTransferDX9 : public TessellationDataTransfer {
|
|
|
|
public:
|
|
|
|
TessellationDataTransferDX9() {}
|
|
|
|
~TessellationDataTransferDX9() {}
|
2018-09-29 13:39:02 +09:00
|
|
|
void SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) override;
|
2018-07-13 18:35:44 +09:00
|
|
|
};
|
|
|
|
|
2013-08-17 11:23:51 +02:00
|
|
|
// Handles transform, lighting and drawing.
|
2016-04-10 10:21:48 +02:00
|
|
|
class DrawEngineDX9 : public DrawEngineCommon {
|
2013-08-17 11:23:51 +02:00
|
|
|
public:
|
2017-03-02 11:39:02 +01:00
|
|
|
DrawEngineDX9(Draw::DrawContext *draw);
|
2022-12-10 20:32:12 -08:00
|
|
|
~DrawEngineDX9();
|
2014-09-18 00:40:25 +02:00
|
|
|
|
2023-02-26 11:05:52 +01:00
|
|
|
void DeviceLost() override { draw_ = nullptr; }
|
|
|
|
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
|
|
|
|
|
2013-09-15 12:46:14 +02:00
|
|
|
void SetShaderManager(ShaderManagerDX9 *shaderManager) {
|
2013-08-17 11:23:51 +02:00
|
|
|
shaderManager_ = shaderManager;
|
|
|
|
}
|
2013-09-15 12:46:14 +02:00
|
|
|
void SetTextureCache(TextureCacheDX9 *textureCache) {
|
2013-08-17 11:23:51 +02:00
|
|
|
textureCache_ = textureCache;
|
|
|
|
}
|
2013-09-15 12:46:14 +02:00
|
|
|
void SetFramebufferManager(FramebufferManagerDX9 *fbManager) {
|
2013-08-17 11:23:51 +02:00
|
|
|
framebufferManager_ = fbManager;
|
|
|
|
}
|
|
|
|
void InitDeviceObjects();
|
|
|
|
void DestroyDeviceObjects();
|
|
|
|
|
2020-05-24 20:57:59 +02:00
|
|
|
void BeginFrame();
|
2013-08-17 11:23:51 +02:00
|
|
|
|
2013-08-20 18:47:11 +02:00
|
|
|
// So that this can be inlined
|
|
|
|
void Flush() {
|
2023-10-02 00:50:20 +02:00
|
|
|
if (!numDrawVerts_)
|
2013-08-20 18:47:11 +02:00
|
|
|
return;
|
|
|
|
DoFlush();
|
|
|
|
}
|
|
|
|
|
2015-03-14 18:11:00 -07:00
|
|
|
void FinishDeferred() {
|
2023-10-02 00:50:20 +02:00
|
|
|
if (!numDrawVerts_)
|
2015-03-14 18:11:00 -07:00
|
|
|
return;
|
2023-05-23 16:46:43 +02:00
|
|
|
DecodeVerts(decoded_);
|
2015-03-14 18:11:00 -07:00
|
|
|
}
|
|
|
|
|
2023-05-03 22:49:59 +02:00
|
|
|
void DispatchFlush() override {
|
2023-10-02 00:50:20 +02:00
|
|
|
if (!numDrawVerts_)
|
2023-05-03 22:49:59 +02:00
|
|
|
return;
|
|
|
|
Flush();
|
|
|
|
}
|
2014-09-14 14:04:09 -07:00
|
|
|
|
2020-04-04 11:52:32 -07:00
|
|
|
protected:
|
|
|
|
// Not currently supported.
|
2023-06-12 20:20:06 +02:00
|
|
|
bool UpdateUseHWTessellation(bool enable) const override { return false; }
|
2020-04-04 11:52:32 -07:00
|
|
|
|
2013-08-17 11:23:51 +02:00
|
|
|
private:
|
2022-12-01 19:15:38 +01:00
|
|
|
void Invalidate(InvalidationCallbackFlags flags);
|
2014-09-13 13:53:04 +02:00
|
|
|
void DoFlush();
|
|
|
|
|
2013-08-17 11:23:51 +02:00
|
|
|
void ApplyDrawState(int prim);
|
2014-09-13 12:27:20 +02:00
|
|
|
void ApplyDrawStateLate();
|
|
|
|
|
2023-06-12 20:20:06 +02:00
|
|
|
IDirect3DVertexDeclaration9 *SetupDecFmtForDraw(const DecVtxFormat &decFmt, u32 pspFmt);
|
2013-08-17 11:23:51 +02:00
|
|
|
|
2017-06-02 12:03:46 +02:00
|
|
|
LPDIRECT3DDEVICE9 device_ = nullptr;
|
2020-05-24 20:57:59 +02:00
|
|
|
Draw::DrawContext *draw_;
|
2013-08-17 11:23:51 +02:00
|
|
|
|
2023-09-11 12:02:56 +02:00
|
|
|
DenseHashMap<u32, IDirect3DVertexDeclaration9 *> vertexDeclMap_;
|
2017-02-05 19:38:52 +01:00
|
|
|
|
|
|
|
// SimpleVertex
|
2017-06-02 12:03:46 +02:00
|
|
|
IDirect3DVertexDeclaration9* transformedVertexDecl_ = nullptr;
|
2017-02-05 19:38:52 +01:00
|
|
|
|
2013-08-17 11:23:51 +02:00
|
|
|
// Other
|
2017-06-02 12:03:46 +02:00
|
|
|
ShaderManagerDX9 *shaderManager_ = nullptr;
|
|
|
|
TextureCacheDX9 *textureCache_ = nullptr;
|
|
|
|
FramebufferManagerDX9 *framebufferManager_ = nullptr;
|
2014-09-10 10:28:44 +02:00
|
|
|
|
2017-01-10 14:41:01 +09:00
|
|
|
// Hardware tessellation
|
2018-07-13 18:35:44 +09:00
|
|
|
TessellationDataTransferDX9 *tessDataTransferDX9;
|
2020-05-24 20:57:59 +02:00
|
|
|
|
2022-02-19 20:40:27 +01:00
|
|
|
FBOTexState fboTexBindState_ = FBO_TEX_NONE;
|
|
|
|
|
2020-05-24 20:57:59 +02:00
|
|
|
int lastRenderStepId_ = -1;
|
2022-09-03 14:47:47 +02:00
|
|
|
|
|
|
|
bool fboTexNeedsBind_ = false;
|
2013-08-17 11:23:51 +02:00
|
|
|
};
|