Rice Video Plugin for GLES1.1
[mupen64plus-pandora.git] / source / rice_gles / src / OGLCombinerNV.h
CommitLineData
d07c171f 1/*
2Copyright (C) 2003 Rice1964
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*/
18
19#ifndef _OGL_COMBINER_NV_H_
20#define _OGL_COMBINER_NV_H_
21
22#include <vector>
23
24#include <SDL_opengl.h>
25
26#include "OGLExtCombiner.h"
27#include "OGLDecodedMux.h"
28
29typedef struct {
30 uint8 a;
31 uint8 b;
32 uint8 c;
33 uint8 d;
34} NVGeneralCombinerType;
35
36typedef struct {
37 uint8 a;
38 uint8 b;
39 uint8 c;
40 uint8 d;
41 uint8 e;
42 uint8 f;
43 uint8 g;
44} NVFinalCombinerType;
45
46typedef struct {
47 GLenum variable;
48 GLenum input;
49 GLenum mapping;
50 GLenum componentUsage;
51} NVCombinerInputType;
52
53typedef struct {
54 GLenum abOutput;
55 GLenum cdOutput;
56 GLenum sumOutput;
57 GLenum scale;
58 GLenum bias;
59 GLboolean abDotProduct;
60 GLboolean cdDotProduct;
61 GLboolean muxSum;
62} NVCombinerOutputType;
63
64
65typedef struct {
66 union {
67 struct {
68 NVGeneralCombinerType s1rgb;
69 NVGeneralCombinerType s1alpha;
70 NVGeneralCombinerType s2rgb;
71 NVGeneralCombinerType s2alpha;
72 NVFinalCombinerType finalrgb;
73 NVFinalCombinerType finalalpha;
74 };
75 struct {
76 NVGeneralCombinerType generalCombiners[4];
77 NVFinalCombinerType finalCombiners[2];
78 };
79 };
80 int stagesUsed;
81 uint8 constant0;
82 uint8 constant1;
83} NVRegisterCombinerParserType;
84
85typedef struct {
86 NVCombinerInputType stage1RGB[4];
87 NVCombinerInputType stage1Alpha[4];
88 NVCombinerOutputType stage1outputRGB;
89 NVCombinerOutputType stage1outputAlpha;
90
91 NVCombinerInputType stage2RGB[4];
92 NVCombinerInputType stage2Alpha[4];
93 NVCombinerOutputType stage2outputRGB;
94 NVCombinerOutputType stage2outputAlpha;
95
96 NVCombinerInputType finalStage[7];
97
98 int numOfStages;
99
100 uint32 dwMux0;
101 uint32 dwMux1;
102
103 uint8 constant0;
104 uint8 constant1;
105#ifdef DEBUGGER
106 NVRegisterCombinerParserType parseResult;
107#endif
108} NVRegisterCombinerSettingType;
109
110class COGLColorCombinerNvidia : public COGLColorCombiner4
111{
112public:
113 bool Initialize(void);
114 void InitCombinerBlenderForSimpleTextureDraw(uint32 tile=0);
115protected:
116 friend class OGLDeviceBuilder;
117
118 void InitCombinerCycle12(void);
119 void DisableCombiner(void);
120 void InitCombinerCycleCopy(void);
121 void InitCombinerCycleFill(void);
122
123
124 int FindCompiledMux(void);
125 void GenerateNVRegisterCombinerSetting(int);
126 void GenerateNVRegisterCombinerSettingConstants(int); // Compile the decodedMux into NV register combiner setting
127 void ApplyFogAtFinalStage();
128
129 void ParseDecodedMux(NVRegisterCombinerParserType &result); // Compile the decodedMux into NV register combiner setting
130 void ParseDecodedMuxForConstant(NVRegisterCombinerParserType &result); // Compile the decodedMux into NV register combiner setting
131 int SaveParserResult(const NVRegisterCombinerParserType &result);
132
133 int StagesNeedToUse(COGLDecodedMux &mux, N64StageNumberType stage);
134 int Parse1Mux(COGLDecodedMux &mux, N64StageNumberType stage, NVGeneralCombinerType &res); // Compile the decodedMux into NV register combiner setting
135 int Parse1Mux2Stages(COGLDecodedMux &mux, N64StageNumberType stage, NVGeneralCombinerType &res, NVGeneralCombinerType &res2);
136 int Parse1MuxForStage2AndFinalStage(COGLDecodedMux &mux, N64StageNumberType stage, NVGeneralCombinerType &res, NVFinalCombinerType &fres);
137 void Parse1MuxForFinalStage(COGLDecodedMux &mux, N64StageNumberType stage, NVFinalCombinerType &fres);
138 void ByPassFinalStage(NVFinalCombinerType &fres);
139 void ByPassGeneralStage(NVGeneralCombinerType &res);
140
141 GLenum ConstMap(uint8 c);
142
143 COGLColorCombinerNvidia(CRender *pRender);
144 ~COGLColorCombinerNvidia();
145
146 std::vector<NVRegisterCombinerSettingType> m_vCompiledSettings;
147
148 bool m_bNVSupported; // Is this NV OGL extension combiner supported by the video card driver?
149
150#ifdef DEBUGGER
151 void DisplaySimpleMuxString(void);
152 void DisplayNVCombinerString(NVRegisterCombinerSettingType &record);
153#endif
154
155};
156
157#endif
158