1
// Copyright 2013 Dolphin Emulator Project
2
// Licensed under GPLv2
3
// Refer to the license.txt file included.
5
#ifndef _PSTEXTUREENCODER_H
6
#define _PSTEXTUREENCODER_H
8
#include "TextureEncoder.h"
10
struct ID3D11Texture2D;
11
struct ID3D11RenderTargetView;
13
struct ID3D11InputLayout;
14
struct ID3D11VertexShader;
15
struct ID3D11PixelShader;
16
struct ID3D11ClassLinkage;
17
struct ID3D11ClassInstance;
18
struct ID3D11BlendState;
19
struct ID3D11DepthStencilState;
20
struct ID3D11RasterizerState;
21
struct ID3D11SamplerState;
26
class PSTextureEncoder : public TextureEncoder
35
size_t Encode(u8* dst, unsigned int dstFormat,
36
unsigned int srcFormat, const EFBRectangle& srcRect, bool isIntensity,
43
ID3D11Texture2D* m_out;
44
ID3D11RenderTargetView* m_outRTV;
45
ID3D11Texture2D* m_outStage;
46
ID3D11Buffer* m_encodeParams;
48
ID3D11VertexShader* m_vShader;
49
ID3D11InputLayout* m_quadLayout;
50
ID3D11BlendState* m_efbEncodeBlendState;
51
ID3D11DepthStencilState* m_efbEncodeDepthState;
52
ID3D11RasterizerState* m_efbEncodeRastState;
53
ID3D11SamplerState* m_efbSampler;
55
// Stuff only used in static-linking mode (SM4.0-compatible)
57
bool InitStaticMode();
58
bool SetStaticShader(unsigned int dstFormat, unsigned int srcFormat,
59
bool isIntensity, bool scaleByHalf);
61
typedef unsigned int ComboKey; // Key for a shader combination
63
ComboKey MakeComboKey(unsigned int dstFormat, unsigned int srcFormat,
64
bool isIntensity, bool scaleByHalf)
66
return (dstFormat << 4) | (srcFormat << 2) | (isIntensity ? (1<<1) : 0)
67
| (scaleByHalf ? (1<<0) : 0);
70
typedef std::map<ComboKey, ID3D11PixelShader*> ComboMap;
72
ComboMap m_staticShaders;
74
// Stuff only used for dynamic-linking mode (SM5.0+, available as soon as
75
// Microsoft fixes their bloody HLSL compiler)
77
bool InitDynamicMode();
78
bool SetDynamicShader(unsigned int dstFormat, unsigned int srcFormat,
79
bool isIntensity, bool scaleByHalf);
81
ID3D11PixelShader* m_dynamicShader;
82
ID3D11ClassLinkage* m_classLinkage;
86
UINT m_scaledFetchSlot;
91
// Fetch: 0 is RGB, 1 is RGBA, 2 is RGB565, 3 is Z
92
ID3D11ClassInstance* m_fetchClass[4];
93
// ScaledFetch: 0 is off, 1 is on
94
ID3D11ClassInstance* m_scaledFetchClass[2];
95
// Intensity: 0 is off, 1 is on
96
ID3D11ClassInstance* m_intensityClass[2];
97
// Generator: one for each dst format, 16 total
98
ID3D11ClassInstance* m_generatorClass[16];
100
std::vector<ID3D11ClassInstance*> m_linkageArray;