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/TextureCacheDX9.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 "GPU/GPU.h"
24
#include "GPU/GPUInterface.h"
25
#include "GPU/Common/TextureCacheCommon.h"
26
27
struct VirtualFramebuffer;
28
class TextureShaderCache;
29
30
class FramebufferManagerDX9;
31
class ShaderManagerDX9;
32
33
class TextureCacheDX9 : public TextureCacheCommon {
34
public:
35
TextureCacheDX9(Draw::DrawContext *draw, Draw2D *draw2D);
36
~TextureCacheDX9();
37
38
void StartFrame() override;
39
40
void SetFramebufferManager(FramebufferManagerDX9 *fbManager);
41
42
void ForgetLastTexture() override;
43
44
bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
45
46
void DeviceLost() override { draw_ = nullptr; }
47
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
48
49
protected:
50
void BindTexture(TexCacheEntry *entry) override;
51
void Unbind() override;
52
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
53
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
54
void *GetNativeTextureView(const TexCacheEntry *entry) override;
55
56
private:
57
void ApplySamplingParams(const SamplerCacheKey &key) override;
58
59
D3DFORMAT GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const;
60
void UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple) override;
61
62
void BuildTexture(TexCacheEntry *const entry) override;
63
64
static LPDIRECT3DBASETEXTURE9 &DxTex(const TexCacheEntry *entry) {
65
return *(LPDIRECT3DBASETEXTURE9 *)&entry->texturePtr;
66
}
67
68
Microsoft::WRL::ComPtr<IDirect3DDevice9> device_;
69
Microsoft::WRL::ComPtr<IDirect3DDevice9Ex> deviceEx_;
70
71
Microsoft::WRL::ComPtr<IDirect3DVertexDeclaration9> pFramebufferVertexDecl;
72
73
IDirect3DBaseTexture9 *lastBoundTexture = nullptr;
74
float maxAnisotropyLevel;
75
76
FramebufferManagerDX9 *framebufferManagerDX9_;
77
};
78
79
D3DFORMAT getClutDestFormat(GEPaletteFormat format);
80
81