2017-02-08 16:47:07 +00:00
|
|
|
// Copyright (c) 2017- 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-27 20:57:46 +00:00
|
|
|
#include "Common/CommonWindows.h"
|
|
|
|
|
2017-02-08 17:07:34 +00:00
|
|
|
#include <d3d11.h>
|
|
|
|
|
|
|
|
#include "GPU/GPU.h"
|
|
|
|
#include "GPU/GPUInterface.h"
|
|
|
|
#include "GPU/Common/TextureCacheCommon.h"
|
|
|
|
|
|
|
|
struct VirtualFramebuffer;
|
|
|
|
|
|
|
|
class FramebufferManagerD3D11;
|
2022-08-22 10:20:21 +00:00
|
|
|
class TextureShaderCache;
|
2017-02-08 17:07:34 +00:00
|
|
|
class ShaderManagerD3D11;
|
|
|
|
|
|
|
|
class SamplerCacheD3D11 {
|
|
|
|
public:
|
|
|
|
SamplerCacheD3D11() {}
|
|
|
|
~SamplerCacheD3D11();
|
|
|
|
ID3D11SamplerState *GetOrCreateSampler(ID3D11Device *device, const SamplerCacheKey &key);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::map<SamplerCacheKey, ID3D11SamplerState *> cache_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TextureCacheD3D11 : public TextureCacheCommon {
|
|
|
|
public:
|
|
|
|
TextureCacheD3D11(Draw::DrawContext *draw);
|
|
|
|
~TextureCacheD3D11();
|
|
|
|
|
2022-08-05 11:27:55 +00:00
|
|
|
void StartFrame() override;
|
2017-02-08 17:07:34 +00:00
|
|
|
|
|
|
|
void SetFramebufferManager(FramebufferManagerD3D11 *fbManager);
|
|
|
|
|
|
|
|
void ForgetLastTexture() override;
|
2020-09-20 18:35:42 +00:00
|
|
|
void InvalidateLastTexture() override;
|
2017-02-08 17:07:34 +00:00
|
|
|
|
2017-03-06 15:46:15 +00:00
|
|
|
bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override;
|
2017-02-08 17:07:34 +00:00
|
|
|
|
|
|
|
protected:
|
2017-02-19 22:07:00 +00:00
|
|
|
void BindTexture(TexCacheEntry *entry) override;
|
2017-02-08 17:07:34 +00:00
|
|
|
void Unbind() override;
|
2017-02-23 16:31:24 +00:00
|
|
|
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
2022-08-05 09:44:09 +00:00
|
|
|
void BindAsClutTexture(Draw::Texture *tex) override;
|
2022-08-05 10:34:29 +00:00
|
|
|
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
2017-02-08 17:07:34 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DXGI_FORMAT GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const;
|
2022-04-15 10:34:50 +00:00
|
|
|
static CheckAlphaResult CheckAlpha(const u32 *pixelData, u32 dstFmt, int w);
|
2017-02-19 23:05:23 +00:00
|
|
|
void UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple) override;
|
2017-02-08 17:07:34 +00:00
|
|
|
|
2018-03-25 08:49:28 +00:00
|
|
|
void BuildTexture(TexCacheEntry *const entry) override;
|
2017-02-08 17:07:34 +00:00
|
|
|
|
|
|
|
ID3D11Device *device_;
|
|
|
|
ID3D11DeviceContext *context_;
|
|
|
|
|
2022-07-30 17:55:56 +00:00
|
|
|
ID3D11Resource *&DxTex(TexCacheEntry *entry) {
|
|
|
|
return (ID3D11Resource *&)entry->texturePtr;
|
2017-02-08 17:07:34 +00:00
|
|
|
}
|
|
|
|
ID3D11ShaderResourceView *DxView(TexCacheEntry *entry) {
|
|
|
|
return (ID3D11ShaderResourceView *)entry->textureView;
|
|
|
|
}
|
|
|
|
|
|
|
|
SamplerCacheD3D11 samplerCache_;
|
|
|
|
|
|
|
|
ID3D11ShaderResourceView *lastBoundTexture;
|
2020-10-18 18:06:53 +00:00
|
|
|
ID3D11Buffer *depalConstants_;
|
2017-02-08 17:07:34 +00:00
|
|
|
|
|
|
|
FramebufferManagerD3D11 *framebufferManagerD3D11_;
|
|
|
|
};
|
|
|
|
|
2017-02-22 16:26:52 +00:00
|
|
|
DXGI_FORMAT GetClutDestFormatD3D11(GEPaletteFormat format);
|