1
// Copyright 2013 Dolphin Emulator Project
2
// Licensed under GPLv2
3
// Refer to the license.txt file included.
9
#include "VideoCommon.h"
13
namespace SWPixelEngine
15
// internal hardware addresses
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
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,
51
u16 ZCompEnable : 1; // Z Comparator Enable
63
u16 BMMath : 1; // GX_BM_BLEND || GX_BM_SUBSTRACT
64
u16 BMLogic : 1; // GX_BM_LOGIC
66
u16 ColorUpdEnable : 1;
67
u16 AlphaUpdEnable : 1;
70
u16 Substract : 1; // Additive mode by default
71
u16 BlendOperator : 4;
75
union UPEDstAlphaConfReg
86
union UPEAlphaModeConfReg
110
u16 PETokenEnable : 1;
111
u16 PEFinishEnable : 1;
112
u16 PEToken : 1; // write only
113
u16 PEFinish : 1; // write only
117
UPECtrlReg() {Hex = 0; }
118
UPECtrlReg(u16 _hex) {Hex = _hex; }
124
UPEAlphaConfReg alphaConf;
125
UPEDstAlphaConfReg dstAlpha;
126
UPEAlphaModeConfReg alphaMode;
127
UPEAlphaReadReg alphaRead;
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;
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)
160
if (++perfZcompInputZcomplocLo == 0)
161
perfZcompInputZcomplocHi++;
165
if (++perfZcompInputLo == 0)
169
void IncZOutputQuadCount(bool early_ztest)
178
if (++perfZcompOutputZcomplocLo == 0)
179
perfZcompOutputZcomplocHi++;
183
if (++perfZcompOutputLo == 0)
187
void IncBlendInputQuadCount()
194
if (++perfBlendInputLo == 0)
202
void DoState(PointerWrap &p);
205
void Read16(u16& _uReturnValue, const u32 _iAddress);
208
void Write16(const u16 _iValue, const u32 _iAddress);
209
void Write32(const u32 _iValue, const u32 _iAddress);
211
// gfx backend support
212
void SetToken(const u16 _token, const int _bSetTokenAcknowledge);
213
void SetFinish(void);
214
bool AllowIdleSkipping();
216
} // end of namespace SWPixelEngine