2013-08-17 09:23:51 +00: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
|
|
|
|
|
2017-02-04 17:46:12 +00:00
|
|
|
#include <d3d9.h>
|
2024-03-24 17:40:25 +00:00
|
|
|
#include <wrl/client.h>
|
2014-10-19 19:11:09 +00:00
|
|
|
|
2015-07-26 20:38:40 +00:00
|
|
|
#include "GPU/GPU.h"
|
2013-08-17 09:23:51 +00:00
|
|
|
#include "GPU/GPUInterface.h"
|
2014-09-13 11:53:04 +00:00
|
|
|
#include "GPU/Common/TextureCacheCommon.h"
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2014-09-09 15:12:42 +00:00
|
|
|
struct VirtualFramebuffer;
|
2022-08-22 10:20:21 +00:00
|
|
|
class TextureShaderCache;
|
2014-09-09 15:12:42 +00:00
|
|
|
|
2014-09-09 07:53:01 +00:00
|
|
|
class FramebufferManagerDX9;
|
|
|
|
class ShaderManagerDX9;
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2014-09-13 11:53:04 +00:00
|
|
|
class TextureCacheDX9 : public TextureCacheCommon {
|
2013-08-17 09:23:51 +00:00
|
|
|
public:
|
2022-08-23 09:11:04 +00:00
|
|
|
TextureCacheDX9(Draw::DrawContext *draw, Draw2D *draw2D);
|
2013-09-15 10:46:14 +00:00
|
|
|
~TextureCacheDX9();
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2022-08-05 11:27:55 +00:00
|
|
|
void StartFrame() override;
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2017-02-08 14:58:46 +00:00
|
|
|
void SetFramebufferManager(FramebufferManagerDX9 *fbManager);
|
2014-09-09 07:53:01 +00:00
|
|
|
|
2023-02-24 20:53:12 +00:00
|
|
|
void ForgetLastTexture() override;
|
2014-09-09 07:53:01 +00:00
|
|
|
|
2022-10-11 05:35:42 +00:00
|
|
|
bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
|
2017-10-18 11:03:49 +00:00
|
|
|
|
2023-02-26 10:05:52 +00:00
|
|
|
void DeviceLost() override { draw_ = nullptr; }
|
2023-02-25 14:59:35 +00:00
|
|
|
void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; }
|
|
|
|
|
2016-01-05 05:29:03 +00:00
|
|
|
protected:
|
2017-02-19 22:07:00 +00:00
|
|
|
void BindTexture(TexCacheEntry *entry) override;
|
2017-02-08 14:43:53 +00:00
|
|
|
void Unbind() override;
|
2017-02-23 16:31:24 +00:00
|
|
|
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
2022-08-24 07:31:47 +00:00
|
|
|
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
|
2022-09-14 06:42:25 +00:00
|
|
|
void *GetNativeTextureView(const TexCacheEntry *entry) override;
|
2016-01-05 05:29:03 +00:00
|
|
|
|
2014-09-09 07:53:01 +00:00
|
|
|
private:
|
2022-08-05 13:40:31 +00:00
|
|
|
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
2020-09-13 20:37:16 +00:00
|
|
|
|
2014-09-09 07:53:01 +00:00
|
|
|
D3DFORMAT GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const;
|
2017-02-19 23:05:23 +00:00
|
|
|
void UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple) override;
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2018-03-25 08:49:28 +00:00
|
|
|
void BuildTexture(TexCacheEntry *const entry) override;
|
2016-05-01 23:20:05 +00:00
|
|
|
|
2024-03-24 17:40:25 +00:00
|
|
|
static LPDIRECT3DBASETEXTURE9 &DxTex(const TexCacheEntry *entry) {
|
2022-07-30 18:41:31 +00:00
|
|
|
return *(LPDIRECT3DBASETEXTURE9 *)&entry->texturePtr;
|
2015-03-16 02:46:36 +00:00
|
|
|
}
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2024-03-24 17:40:25 +00:00
|
|
|
Microsoft::WRL::ComPtr<IDirect3DDevice9> device_;
|
|
|
|
Microsoft::WRL::ComPtr<IDirect3DDevice9Ex> deviceEx_;
|
2017-03-02 10:39:02 +00:00
|
|
|
|
2024-03-24 17:40:25 +00:00
|
|
|
Microsoft::WRL::ComPtr<IDirect3DVertexDeclaration9> pFramebufferVertexDecl;
|
2017-02-05 19:13:28 +00:00
|
|
|
|
2024-03-24 17:40:25 +00:00
|
|
|
IDirect3DBaseTexture9 *lastBoundTexture = nullptr;
|
2013-08-17 09:23:51 +00:00
|
|
|
float maxAnisotropyLevel;
|
2013-08-19 18:36:43 +00:00
|
|
|
|
2017-02-08 14:58:46 +00:00
|
|
|
FramebufferManagerDX9 *framebufferManagerDX9_;
|
2013-08-17 09:23:51 +00:00
|
|
|
};
|
|
|
|
|
2014-09-09 07:53:01 +00:00
|
|
|
D3DFORMAT getClutDestFormat(GEPaletteFormat format);
|