~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to Source/Core/VideoBackends/Software/Src/SWPixelEngine.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 _PIXELENGINE_H
 
6
#define _PIXELENGINE_H
 
7
 
 
8
#include "Common.h"
 
9
#include "VideoCommon.h"
 
10
 
 
11
class PointerWrap;
 
12
 
 
13
namespace SWPixelEngine
 
14
{
 
15
        // internal hardware addresses
 
16
        enum
 
17
        {
 
18
                PE_ZCONF                 = 0x000, // Z Config
 
19
                PE_ALPHACONF     = 0x002, // Alpha Config
 
20
                PE_DSTALPHACONF  = 0x004, // Destination Alpha Config
 
21
                PE_ALPHAMODE     = 0x006, // Alpha Mode Config
 
22
                PE_ALPHAREAD     = 0x008, // Alpha Read
 
23
                PE_CTRL_REGISTER = 0x00a, // Control
 
24
                PE_TOKEN_REG     = 0x00e, // Token
 
25
                PE_BBOX_LEFT     = 0x010, // Flip Left
 
26
                PE_BBOX_RIGHT    = 0x012, // Flip Right
 
27
                PE_BBOX_TOP              = 0x014, // Flip Top
 
28
                PE_BBOX_BOTTOM   = 0x016, // Flip Bottom
 
29
 
 
30
                // NOTE: Order not verified
 
31
                // These indicate the number of quads that are being used as input/output for each particular stage
 
32
                PE_PERF_ZCOMP_INPUT_ZCOMPLOC_L  = 0x18,
 
33
                PE_PERF_ZCOMP_INPUT_ZCOMPLOC_H  = 0x1a,
 
34
                PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_L = 0x1c,
 
35
                PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_H = 0x1e,
 
36
                PE_PERF_ZCOMP_INPUT_L           = 0x20,
 
37
                PE_PERF_ZCOMP_INPUT_H           = 0x22,
 
38
                PE_PERF_ZCOMP_OUTPUT_L          = 0x24,
 
39
                PE_PERF_ZCOMP_OUTPUT_H          = 0x26,
 
40
                PE_PERF_BLEND_INPUT_L           = 0x28,
 
41
                PE_PERF_BLEND_INPUT_H           = 0x2a,
 
42
                PE_PERF_EFB_COPY_CLOCKS_L       = 0x2c,
 
43
                PE_PERF_EFB_COPY_CLOCKS_H       = 0x2e,
 
44
        };
 
45
 
 
46
        union UPEZConfReg
 
47
        {
 
48
                u16 Hex;
 
49
                struct 
 
50
                {
 
51
                        u16 ZCompEnable         : 1; // Z Comparator Enable
 
52
                        u16 Function            : 3;
 
53
                        u16 ZUpdEnable          : 1;
 
54
                        u16                                     : 11;
 
55
                };
 
56
        };
 
57
 
 
58
        union UPEAlphaConfReg
 
59
        {
 
60
                u16 Hex;
 
61
                struct 
 
62
                {
 
63
                        u16 BMMath                      : 1; // GX_BM_BLEND || GX_BM_SUBSTRACT
 
64
                        u16 BMLogic                     : 1; // GX_BM_LOGIC
 
65
                        u16 Dither                      : 1;
 
66
                        u16 ColorUpdEnable      : 1;
 
67
                        u16 AlphaUpdEnable      : 1;
 
68
                        u16 DstFactor           : 3;
 
69
                        u16 SrcFactor           : 3;
 
70
                        u16 Substract           : 1; // Additive mode by default
 
71
                        u16 BlendOperator       : 4;
 
72
                };
 
73
        };
 
74
 
 
75
        union UPEDstAlphaConfReg
 
76
        {
 
77
                u16 Hex;
 
78
                struct 
 
79
                {
 
80
                        u16 DstAlpha            : 8;
 
81
                        u16 Enable                      : 1;
 
82
                        u16                                     : 7;
 
83
                };
 
84
        };
 
85
 
 
86
        union UPEAlphaModeConfReg
 
87
        {
 
88
                u16 Hex;
 
89
                struct 
 
90
                {
 
91
                        u16 Threshold           : 8;
 
92
                        u16 CompareMode         : 8;
 
93
                };
 
94
        };
 
95
 
 
96
                union UPEAlphaReadReg
 
97
        {
 
98
                u16 Hex;
 
99
                struct 
 
100
                {
 
101
                        u16 ReadMode    : 3;
 
102
                        u16                             : 13;
 
103
                };
 
104
        };
 
105
 
 
106
                union UPECtrlReg
 
107
        {
 
108
                struct 
 
109
                {
 
110
                        u16 PETokenEnable       :       1;
 
111
                        u16 PEFinishEnable      :       1;
 
112
                        u16 PEToken                     :       1; // write only
 
113
                        u16 PEFinish            :       1; // write only
 
114
                        u16                                     :       12;
 
115
                };
 
116
                u16 Hex;
 
117
                UPECtrlReg() {Hex = 0; }
 
118
                UPECtrlReg(u16 _hex) {Hex = _hex; }
 
119
        };
 
120
 
 
121
        struct PEReg
 
122
        {
 
123
                UPEZConfReg zconf;
 
124
                UPEAlphaConfReg alphaConf;
 
125
                UPEDstAlphaConfReg dstAlpha;
 
126
                UPEAlphaModeConfReg alphaMode;
 
127
                UPEAlphaReadReg alphaRead;
 
128
                UPECtrlReg ctrl;
 
129
                u16 unk0;
 
130
                u16 token;
 
131
 
 
132
                u16 boxLeft;
 
133
                u16 boxRight;
 
134
                u16 boxTop;
 
135
                u16 boxBottom;
 
136
 
 
137
                u16 perfZcompInputZcomplocLo;
 
138
                u16 perfZcompInputZcomplocHi;
 
139
                u16 perfZcompOutputZcomplocLo;
 
140
                u16 perfZcompOutputZcomplocHi;
 
141
                u16 perfZcompInputLo;
 
142
                u16 perfZcompInputHi;
 
143
                u16 perfZcompOutputLo;
 
144
                u16 perfZcompOutputHi;
 
145
                u16 perfBlendInputLo;
 
146
                u16 perfBlendInputHi;
 
147
                u16 perfEfbCopyClocksLo;
 
148
                u16 perfEfbCopyClocksHi;
 
149
 
 
150
                // NOTE: hardware doesn't process individual pixels but quads instead. Current software renderer architecture works on pixels though, so we have this "quad" hack here to only increment the registers on every fourth rendered pixel
 
151
                void IncZInputQuadCount(bool early_ztest)
 
152
                {
 
153
                        static int quad = 0;
 
154
                        if (++quad != 3)
 
155
                                return;
 
156
                        quad = 0;
 
157
 
 
158
                        if (early_ztest)
 
159
                        {
 
160
                                if (++perfZcompInputZcomplocLo == 0)
 
161
                                        perfZcompInputZcomplocHi++;
 
162
                        }
 
163
                        else
 
164
                        {
 
165
                                if (++perfZcompInputLo == 0)
 
166
                                        perfZcompInputHi++;
 
167
                        }
 
168
                }
 
169
                void IncZOutputQuadCount(bool early_ztest)
 
170
                {
 
171
                        static int quad = 0;
 
172
                        if (++quad != 3)
 
173
                                return;
 
174
                        quad = 0;
 
175
 
 
176
                        if (early_ztest)
 
177
                        {
 
178
                                if (++perfZcompOutputZcomplocLo == 0)
 
179
                                        perfZcompOutputZcomplocHi++;
 
180
                        }
 
181
                        else
 
182
                        {
 
183
                                if (++perfZcompOutputLo == 0)
 
184
                                        perfZcompOutputHi++;
 
185
                        }
 
186
                }
 
187
                void IncBlendInputQuadCount()
 
188
                {
 
189
                        static int quad = 0;
 
190
                        if (++quad != 3)
 
191
                                return;
 
192
                        quad = 0;
 
193
 
 
194
                        if (++perfBlendInputLo == 0)
 
195
                                perfBlendInputHi++;
 
196
                }
 
197
        };
 
198
 
 
199
        extern PEReg pereg;
 
200
 
 
201
        void Init();
 
202
        void DoState(PointerWrap &p);
 
203
 
 
204
        // Read
 
205
        void Read16(u16& _uReturnValue, const u32 _iAddress);
 
206
 
 
207
        // Write
 
208
        void Write16(const u16 _iValue, const u32 _iAddress);
 
209
        void Write32(const u32 _iValue, const u32 _iAddress);
 
210
 
 
211
        // gfx backend support
 
212
        void SetToken(const u16 _token, const int _bSetTokenAcknowledge);
 
213
        void SetFinish(void);
 
214
        bool AllowIdleSkipping();
 
215
 
 
216
} // end of namespace SWPixelEngine
 
217
 
 
218
#endif