1 // Copyright 2009 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4 
5 #pragma once
6 
7 #include "VideoCommon/BPMemory.h"
8 
9 class Tev
10 {
11   struct InputRegType
12   {
13     unsigned a : 8;
14     unsigned b : 8;
15     unsigned c : 8;
16     signed d : 11;
17   };
18 
19   struct TextureCoordinateType
20   {
21     signed s : 24;
22     signed t : 24;
23   };
24 
25   // color order: ABGR
26   s16 Reg[4][4];
27   s16 KonstantColors[4][4];
28   s16 TexColor[4];
29   s16 RasColor[4];
30   s16 StageKonst[4];
31   s16 Zero16[4];
32 
33   s16 FixedConstants[9];
34   u8 AlphaBump;
35   u8 IndirectTex[4][4];
36   TextureCoordinateType TexCoord;
37 
38   s16* m_ColorInputLUT[16][3];
39   s16* m_AlphaInputLUT[8];  // values must point to ABGR color
40   s16* m_KonstLUT[32][4];
41   s16 m_BiasLUT[4];
42   u8 m_ScaleLShiftLUT[4];
43   u8 m_ScaleRShiftLUT[4];
44 
45   // enumeration for color input LUT
46   enum
47   {
48     BLU_INP,
49     GRN_INP,
50     RED_INP
51   };
52 
53   enum BufferBase
54   {
55     DIRECT = 0,
56     DIRECT_TFETCH = 16,
57     INDIRECT = 32
58   };
59 
60   void SetRasColor(int colorChan, int swaptable);
61 
62   void DrawColorRegular(const TevStageCombiner::ColorCombiner& cc, const InputRegType inputs[4]);
63   void DrawColorCompare(const TevStageCombiner::ColorCombiner& cc, const InputRegType inputs[4]);
64   void DrawAlphaRegular(const TevStageCombiner::AlphaCombiner& ac, const InputRegType inputs[4]);
65   void DrawAlphaCompare(const TevStageCombiner::AlphaCombiner& ac, const InputRegType inputs[4]);
66 
67   void Indirect(unsigned int stageNum, s32 s, s32 t);
68 
69 public:
70   s32 Position[3];
71   u8 Color[2][4];  // must be RGBA for correct swap table ordering
72   TextureCoordinateType Uv[8];
73   s32 IndirectLod[4];
74   bool IndirectLinear[4];
75   s32 TextureLod[16];
76   bool TextureLinear[16];
77 
78   enum
79   {
80     ALP_C,
81     BLU_C,
82     GRN_C,
83     RED_C
84   };
85 
86   void Init();
87 
88   void Draw();
89 
90   void SetRegColor(int reg, int comp, s16 color);
91 };
92