2 Copyright (C) 2003 Rice1964
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "DirectXDecodedMux.h"
30 //This function is called after Reformat to handel two texels in 1 cycle, D3D can not handle
31 //two texels in a single stage, the texels must be splited into multiple stages
32 void CDirectXDecodedMux::ReformatAgainWithTwoTexels(void)
34 if( CountTexels() < 2 )
37 for( int i=0; i<2; i++ )
39 N64CombinerType &m = m_n64Combiners[i];
40 if( CountTexel1Cycle(m) < 2 )
42 continue; //1st cycle does not have two texels, do nothing here
46 N64CombinerType &m2 = m_n64Combiners[i+2];
48 if( splitType[i] == CM_FMT_TYPE_A_MOD_C ) //Texel0*Texel1
50 if( splitType[i+2] == CM_FMT_TYPE_NOT_USED )
52 //Change Texel1*Texel0 to (SEL(tex1), MOD(tex0))
59 splitType[i+2] = CM_FMT_TYPE_A_MOD_C;
60 splitType[i] = CM_FMT_TYPE_D;
62 else if( splitType[i+2] == CM_FMT_TYPE_A_MOD_C )
64 if( m2.a == MUX_COMBINED )
69 if( m2.a != MUX_TEXEL0 && m2.a != MUX_TEXEL1 )
71 //cool, we can swap m2.a to cycle1 and swap texel from cycle 1 to cycle 2
86 else if( splitType[i+2] == CM_FMT_TYPE_A_MOD_C_ADD_D )
88 if( m2.a == MUX_COMBINED )
93 if( m2.c == MUX_COMBINED && m2.d != MUX_COMBINED )
95 //Cycle1: texel0*texel1
97 if( m2.a != MUX_TEXEL0 && m2.a != MUX_TEXEL1 )
99 //cool, we can swap m2.a to cycle1 and swap texel from cycle 1 to cycle 2
115 else if( splitType[i] == CM_FMT_TYPE_A_ADD_D ) //Texel0+Texel1
117 if( splitType[i+2] == CM_FMT_TYPE_NOT_USED )
119 //Change Texel1*Texel0 to (SEL(tex1), MOD(tex0))
125 splitType[i+2] = CM_FMT_TYPE_A_ADD_D;
126 splitType[i] = CM_FMT_TYPE_D;
128 else if( splitType[i+2] == CM_FMT_TYPE_A_ADD_D )
130 if( m2.a == MUX_COMBINED )
135 if( m2.a != MUX_TEXEL0 && m2.a != MUX_TEXEL1 )
154 if( CountTexel1Cycle(m2) < 2 )
156 continue; //2nd cycle does not have two texels
162 void CDirectXDecodedMux::Reformat(bool do_complement)
164 DecodedMux::Reformat(do_complement);
165 ReformatAgainWithTwoTexels();
166 mType = std::max(std::max(std::max(splitType[0], splitType[1]),splitType[2]),splitType[3]);