summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software/Tev.h
blob: 9da27acc52f55e3736494afa3c0ed4e9b74cfb1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include "VideoBackends/Software/BPMemLoader.h"

class PointerWrap;

class Tev
{
	struct InputRegType
	{
		unsigned a : 8;
		unsigned b : 8;
		unsigned c : 8;
		signed   d : 11;
	};

	struct TextureCoordinateType
	{
		signed s : 24;
		signed t : 24;
	};

	// color order: ABGR
	s16 Reg[4][4];
	s16 KonstantColors[4][4];
	s16 TexColor[4];
	s16 RasColor[4];
	s16 StageKonst[4];
	s16 Zero16[4];

	s16 FixedConstants[9];
	u8 AlphaBump;
	u8 IndirectTex[4][4];
	TextureCoordinateType TexCoord;

	s16 *m_ColorInputLUT[16][3];
	s16 *m_AlphaInputLUT[8];        // values must point to ABGR color
	s16 *m_KonstLUT[32][4];
	s16 m_BiasLUT[4];
	u8 m_ScaleLShiftLUT[4];
	u8 m_ScaleRShiftLUT[4];

	// enumeration for color input LUT
	enum
	{
		BLU_INP,
		GRN_INP,
		RED_INP
	};

	enum BufferBase
	{
		DIRECT = 0,
		DIRECT_TFETCH = 16,
		INDIRECT = 32
	};

	void SetRasColor(int colorChan, int swaptable);

	void DrawColorRegular(TevStageCombiner::ColorCombiner& cc, const InputRegType inputs[4]);
	void DrawColorCompare(TevStageCombiner::ColorCombiner& cc, const InputRegType inputs[4]);
	void DrawAlphaRegular(TevStageCombiner::AlphaCombiner& ac, const InputRegType inputs[4]);
	void DrawAlphaCompare(TevStageCombiner::AlphaCombiner& ac, const InputRegType inputs[4]);

	void Indirect(unsigned int stageNum, s32 s, s32 t);

public:
	s32 Position[3];
	u8 Color[2][4]; // must be RGBA for correct swap table ordering
	TextureCoordinateType Uv[8];
	s32 IndirectLod[4];
	bool IndirectLinear[4];
	s32 TextureLod[16];
	bool TextureLinear[16];

	enum
	{
		ALP_C,
		BLU_C,
		GRN_C,
		RED_C
	};

	void Init();

	void Draw();

	void SetRegColor(int reg, int comp, bool konst, s16 color);

	void DoState(PointerWrap &p);
};