PANDORA: Make GLES context compatible with latest driver (FB only, no X11)
[mupen64plus-pandora.git] / source / rice_gles / src / OGLDecodedMux.cpp
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#include "OGLDecodedMux.h"
20
21//========================================================================
22void COGLDecodedMux::Simplify(void)
23{
24 DecodedMux::Simplify();
25}
26
27void COGLDecodedMux::Reformat(void)
28{
29 DecodedMux::Reformat();
30 mType = max(max(max(splitType[0], splitType[1]),splitType[2]),splitType[3]);
31}
32
33void COGLExtDecodedMux::Simplify(void)
34//========================================================================
35{
36 COGLDecodedMux::Simplify();
37 FurtherFormatForOGL2();
38 Reformat(); // Reformat again
39}
40
41void COGLExtDecodedMux::FurtherFormatForOGL2(void)
42{
43 // This function is used by OGL 1.2, no need to call this function
44 // for Nvidia register combiner
45
46 // And OGL 1.2 extension only supports 1 constant color, we can not use both PRIM and ENV
47 // constant color, and we can not use SPECULAR color as the 2nd color.
48
49 // To futher format the mux.
50 // - For each stage, allow only 1 texel, change the 2nd texel in the same stage to MUX_SHADE
51 // - Only allow 1 constant color. Count PRIM and ENV, left the most used one, and change
52 // the 2nd one to MUX_SHADE
53
54 if( Count(MUX_PRIM) >= Count(MUX_ENV) )
55 {
56 ReplaceVal(MUX_ENV, MUX_PRIM);
57 //ReplaceVal(MUX_ENV, MUX_SHADE);
58 //ReplaceVal(MUX_ENV, MUX_1);
59 //ReplaceVal(MUX_PRIM, MUX_0);
60 }
61 else
62 {
63 //ReplaceVal(MUX_PRIM, MUX_ENV);
64 //ReplaceVal(MUX_PRIM, MUX_SHADE);
65 ReplaceVal(MUX_PRIM, MUX_0);
66 }
67
68 /*
69 // Because OGL 1.2, we may use more than 1 texture unit, but for each texture unit,
70 // we can not use multitexture to do color combiner. Each combiner stage can only
71 // use 1 texture.
72
73 if( isUsed(MUX_TEXEL0) && isUsed(MUX_TEXEL1) )
74 {
75 if( Count(MUX_TEXEL0,0)+Count(MUX_TEXEL0,1) >= Count(MUX_TEXEL1,0)+Count(MUX_TEXEL1,1) )
76 {
77 ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 0);
78 ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 1);
79 }
80 else
81 {
82 ReplaceVal(MUX_TEXEL0, MUX_TEXEL1, 0);
83 ReplaceVal(MUX_TEXEL0, MUX_TEXEL1, 1);
84 }
85
86 if( Count(MUX_TEXEL0,2)+Count(MUX_TEXEL0,3) >= Count(MUX_TEXEL1,2)+Count(MUX_TEXEL1,3) )
87 {
88 ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 2);
89 ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 3);
90 }
91 else
92 {
93 ReplaceVal(MUX_TEXEL0, MUX_TEXEL1, 2);
94 ReplaceVal(MUX_TEXEL0, MUX_TEXEL1, 3);
95 }
96 }
97 */
98}
99
100
101void COGLExtDecodedMuxTNT2::FurtherFormatForOGL2(void)
102{
103 if( Count(MUX_PRIM) >= Count(MUX_ENV) )
104 {
105 //ReplaceVal(MUX_ENV, MUX_PRIM);
106 //ReplaceVal(MUX_ENV, MUX_SHADE);
107 ReplaceVal(MUX_ENV, MUX_1);
108 //ReplaceVal(MUX_PRIM, MUX_0);
109 }
110 else
111 {
112 //ReplaceVal(MUX_PRIM, MUX_ENV);
113 //ReplaceVal(MUX_PRIM, MUX_SHADE);
114 ReplaceVal(MUX_PRIM, MUX_0);
115 }
116}
117