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/D3D11/TextureCacheD3D11.h
Views: 1401
1
// Copyright (c) 2017- 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 "Common/CommonWindows.h"
21
22
#include <d3d11.h>
23
24
#include "GPU/GPU.h"
25
#include "GPU/GPUInterface.h"
26
#include "GPU/Common/TextureCacheCommon.h"
27
28
struct VirtualFramebuffer;
29
30
class FramebufferManagerD3D11;
31
class TextureShaderCache;
32
class ShaderManagerD3D11;
33
34
class SamplerCacheD3D11 {
35
public:
36
SamplerCacheD3D11() {}
37
~SamplerCacheD3D11();
38
ID3D11SamplerState *GetOrCreateSampler(ID3D11Device *device, const SamplerCacheKey &key);
39
40
private:
41
std::map<SamplerCacheKey, ID3D11SamplerState *> cache_;
42
};
43
44
class TextureCacheD3D11 : public TextureCacheCommon {
45
public:
46
TextureCacheD3D11(Draw::DrawContext *draw, Draw2D *draw2D);
47
~TextureCacheD3D11();
48
49
void SetFramebufferManager(FramebufferManagerD3D11 *fbManager);
50
51
void ForgetLastTexture() override;
52
53
bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
54
55
void DeviceLost() override { draw_ = nullptr; }
56
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
57
58
protected:
59
void BindTexture(TexCacheEntry *entry) override;
60
void Unbind() override;
61
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
62
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
63
void ApplySamplingParams(const SamplerCacheKey &key) override;
64
void *GetNativeTextureView(const TexCacheEntry *entry) override;
65
66
private:
67
DXGI_FORMAT GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const;
68
void UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple) override;
69
70
void BuildTexture(TexCacheEntry *const entry) override;
71
72
ID3D11Device *device_;
73
ID3D11DeviceContext *context_;
74
75
ID3D11Resource *&DxTex(const TexCacheEntry *entry) {
76
return (ID3D11Resource *&)entry->texturePtr;
77
}
78
ID3D11ShaderResourceView *DxView(const TexCacheEntry *entry) {
79
return (ID3D11ShaderResourceView *)entry->textureView;
80
}
81
82
SamplerCacheD3D11 samplerCache_;
83
84
ID3D11ShaderResourceView *lastBoundTexture;
85
ID3D11Buffer *depalConstants_;
86
};
87
88
DXGI_FORMAT GetClutDestFormatD3D11(GEPaletteFormat format);
89
90