ppsspp/GPU/Directx9/DrawEngineDX9.h

122 lines
3.2 KiB
C
Raw Normal View History

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
#include <d3d9.h>
#include "Common/Data/Collections/Hashmaps.h"
#include "GPU/GPUState.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/Common/IndexGenerator.h"
#include "GPU/Common/VertexDecoderCommon.h"
#include "GPU/Common/DrawEngineCommon.h"
#include "GPU/Common/GPUStateUtils.h"
2013-08-17 11:23:51 +02:00
struct DecVtxFormat;
struct UVScale;
class VSShader;
class ShaderManagerDX9;
class TextureCacheDX9;
class FramebufferManagerDX9;
2013-08-17 11:23:51 +02:00
class TessellationDataTransferDX9 : public TessellationDataTransfer {
public:
TessellationDataTransferDX9() {}
~TessellationDataTransferDX9() {}
void SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) override;
};
2013-08-17 11:23:51 +02:00
// Handles transform, lighting and drawing.
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);
~DrawEngineDX9();
2023-02-26 11:05:52 +01:00
void DeviceLost() override { draw_ = nullptr; }
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
void SetShaderManager(ShaderManagerDX9 *shaderManager) {
2013-08-17 11:23:51 +02:00
shaderManager_ = shaderManager;
}
void SetTextureCache(TextureCacheDX9 *textureCache) {
2013-08-17 11:23:51 +02:00
textureCache_ = textureCache;
}
void SetFramebufferManager(FramebufferManagerDX9 *fbManager) {
2013-08-17 11:23:51 +02:00
framebufferManager_ = fbManager;
}
void InitDeviceObjects();
void DestroyDeviceObjects();
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();
}
void FinishDeferred() {
2023-10-02 00:50:20 +02:00
if (!numDrawVerts_)
return;
DecodeVerts(decoded_);
}
void DispatchFlush() override {
2023-10-02 00:50:20 +02:00
if (!numDrawVerts_)
return;
Flush();
}
2014-09-14 14:04:09 -07:00
protected:
// Not currently supported.
2023-06-12 20:20:06 +02:00
bool UpdateUseHWTessellation(bool enable) const override { return false; }
2013-08-17 11:23:51 +02:00
private:
void Invalidate(InvalidationCallbackFlags flags);
void DoFlush();
2013-08-17 11:23:51 +02:00
void ApplyDrawState(int prim);
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;
Draw::DrawContext *draw_;
2013-08-17 11:23:51 +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;
// Hardware tessellation
TessellationDataTransferDX9 *tessDataTransferDX9;
FBOTexState fboTexBindState_ = FBO_TEX_NONE;
int lastRenderStepId_ = -1;
bool fboTexNeedsBind_ = false;
2013-08-17 11:23:51 +02:00
};