Path: blob/master/libmupen64plus/mupen64plus-video-rice/src/DirectXDecodedMux.cpp
2 views
/*1Copyright (C) 2003 Rice196423This program is free software; you can redistribute it and/or4modify it under the terms of the GNU General Public License5as published by the Free Software Foundation; either version 26of the License, or (at your option) any later version.78This program is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11GNU General Public License for more details.1213You should have received a copy of the GNU General Public License14along with this program; if not, write to the Free Software15Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.16*/1718#include "Combiner.h"19#include "DirectXDecodedMux.h"20#include <algorithm>2122#ifdef min23#undef min24#endif25#ifdef max26#undef max27#endif2829//This function is called after Reformat to handel two texels in 1 cycle, D3D can not handle30//two texels in a single stage, the texels must be splited into multiple stages31void CDirectXDecodedMux::ReformatAgainWithTwoTexels(void)32{33if( CountTexels() < 2 )34return;3536for( int i=0; i<2; i++ )37{38N64CombinerType &m = m_n64Combiners[i];39if( CountTexel1Cycle(m) < 2 )40{41continue; //1st cycle does not have two texels, do nothing here42}43else44{45N64CombinerType &m2 = m_n64Combiners[i+2];4647if( splitType[i] == CM_FMT_TYPE_A_MOD_C ) //Texel0*Texel148{49if( splitType[i+2] == CM_FMT_TYPE_NOT_USED )50{51//Change Texel1*Texel0 to (SEL(tex1), MOD(tex0))52m.d = m.a;53m.a = MUX_0;54m2.a = m.c;55m2.c = MUX_COMBINED;56m2.d = m2.b = MUX_0;57m.c = MUX_0;58splitType[i+2] = CM_FMT_TYPE_A_MOD_C;59splitType[i] = CM_FMT_TYPE_D;60}61else if( splitType[i+2] == CM_FMT_TYPE_A_MOD_C )62{63if( m2.a == MUX_COMBINED )64{65swap(m2.a, m2.c);66}6768if( m2.a != MUX_TEXEL0 && m2.a != MUX_TEXEL1 )69{70//cool, we can swap m2.a to cycle1 and swap texel from cycle 1 to cycle 271swap(m.a, m2.a);72}73else74{75if( m.a == m2.a )76{77swap(m.c, m2.a);78}79else80{81swap(m.a, m2.a);82}83}84}85else if( splitType[i+2] == CM_FMT_TYPE_A_MOD_C_ADD_D )86{87if( m2.a == MUX_COMBINED )88{89swap(m2.a, m2.c);90}9192if( m2.c == MUX_COMBINED && m2.d != MUX_COMBINED )93{94//Cycle1: texel0*texel195//Cycle2: a*cmd+d96if( m2.a != MUX_TEXEL0 && m2.a != MUX_TEXEL1 )97{98//cool, we can swap m2.a to cycle1 and swap texel from cycle 1 to cycle 299swap(m.a, m2.a);100}101else102{103if( m.a == m2.a )104{105swap(m.c, m2.a);106}107else108{109swap(m.a, m2.a);110}111}112}113}114else if( splitType[i] == CM_FMT_TYPE_A_ADD_D ) //Texel0+Texel1115{116if( splitType[i+2] == CM_FMT_TYPE_NOT_USED )117{118//Change Texel1*Texel0 to (SEL(tex1), MOD(tex0))119m2.a = m.d;120m2.d = MUX_COMBINED;121m2.b = m2.c = MUX_0;122m.d = m.a;123m.a = MUX_0;124splitType[i+2] = CM_FMT_TYPE_A_ADD_D;125splitType[i] = CM_FMT_TYPE_D;126}127else if( splitType[i+2] == CM_FMT_TYPE_A_ADD_D )128{129if( m2.a == MUX_COMBINED )130{131swap(m2.a, m2.d);132}133134if( m2.a != MUX_TEXEL0 && m2.a != MUX_TEXEL1 )135{136swap(m2.a, m.a);137}138else139{140if( m.a == m2.a )141{142swap(m.d, m2.a);143}144else145{146swap(m.a, m2.a);147}148}149}150}151}152153if( CountTexel1Cycle(m2) < 2 )154{155continue; //2nd cycle does not have two texels156}157}158}159}160161void CDirectXDecodedMux::Reformat(bool do_complement)162{163DecodedMux::Reformat(do_complement);164ReformatAgainWithTwoTexels();165mType = std::max(std::max(std::max(splitType[0], splitType[1]),splitType[2]),splitType[3]);166}167168169170171