~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to Source/Core/VideoBackends/D3D/Src/PSTextureEncoder.h

  • Committer: Sérgio Benjamim
  • Date: 2015-02-13 05:54:40 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150213055440-ey2rt3sjpy27km78
Dolphin Triforce branch from code.google, commit b957980 (4.0-315).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Dolphin Emulator Project
 
2
// Licensed under GPLv2
 
3
// Refer to the license.txt file included.
 
4
 
 
5
#ifndef _PSTEXTUREENCODER_H
 
6
#define _PSTEXTUREENCODER_H
 
7
 
 
8
#include "TextureEncoder.h"
 
9
 
 
10
struct ID3D11Texture2D;
 
11
struct ID3D11RenderTargetView;
 
12
struct ID3D11Buffer;
 
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;
 
22
 
 
23
namespace DX11
 
24
{
 
25
 
 
26
class PSTextureEncoder : public TextureEncoder
 
27
{
 
28
 
 
29
public:
 
30
 
 
31
        PSTextureEncoder();
 
32
 
 
33
        void Init();
 
34
        void Shutdown();
 
35
        size_t Encode(u8* dst, unsigned int dstFormat,
 
36
                unsigned int srcFormat, const EFBRectangle& srcRect, bool isIntensity,
 
37
                bool scaleByHalf);
 
38
 
 
39
private:
 
40
        
 
41
        bool m_ready;
 
42
 
 
43
        ID3D11Texture2D* m_out;
 
44
        ID3D11RenderTargetView* m_outRTV;
 
45
        ID3D11Texture2D* m_outStage;
 
46
        ID3D11Buffer* m_encodeParams;
 
47
        ID3D11Buffer* m_quad;
 
48
        ID3D11VertexShader* m_vShader;
 
49
        ID3D11InputLayout* m_quadLayout;
 
50
        ID3D11BlendState* m_efbEncodeBlendState;
 
51
        ID3D11DepthStencilState* m_efbEncodeDepthState;
 
52
        ID3D11RasterizerState* m_efbEncodeRastState;
 
53
        ID3D11SamplerState* m_efbSampler;
 
54
 
 
55
        // Stuff only used in static-linking mode (SM4.0-compatible)
 
56
 
 
57
        bool InitStaticMode();
 
58
        bool SetStaticShader(unsigned int dstFormat, unsigned int srcFormat,
 
59
                bool isIntensity, bool scaleByHalf);
 
60
 
 
61
        typedef unsigned int ComboKey; // Key for a shader combination
 
62
 
 
63
        ComboKey MakeComboKey(unsigned int dstFormat, unsigned int srcFormat,
 
64
                bool isIntensity, bool scaleByHalf)
 
65
        {
 
66
                return (dstFormat << 4) | (srcFormat << 2) | (isIntensity ? (1<<1) : 0)
 
67
                        | (scaleByHalf ? (1<<0) : 0);
 
68
        }
 
69
 
 
70
        typedef std::map<ComboKey, ID3D11PixelShader*> ComboMap;
 
71
 
 
72
        ComboMap m_staticShaders;
 
73
 
 
74
        // Stuff only used for dynamic-linking mode (SM5.0+, available as soon as
 
75
        // Microsoft fixes their bloody HLSL compiler)
 
76
        
 
77
        bool InitDynamicMode();
 
78
        bool SetDynamicShader(unsigned int dstFormat, unsigned int srcFormat,
 
79
                bool isIntensity, bool scaleByHalf);
 
80
 
 
81
        ID3D11PixelShader* m_dynamicShader;
 
82
        ID3D11ClassLinkage* m_classLinkage;
 
83
 
 
84
        // Interface slots
 
85
        UINT m_fetchSlot;
 
86
        UINT m_scaledFetchSlot;
 
87
        UINT m_intensitySlot;
 
88
        UINT m_generatorSlot;
 
89
 
 
90
        // Class instances
 
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];
 
99
 
 
100
        std::vector<ID3D11ClassInstance*> m_linkageArray;
 
101
 
 
102
};
 
103
 
 
104
}
 
105
 
 
106
#endif