Example #1
0
void COGLColorCombinerNvidia::InitCombinerCycle12(void)
{
    if( !m_bNVSupported )   {COGLColorCombiner4::InitCombinerCycle12(); return;}

    glEnable(GL_REGISTER_COMBINERS_NV);

#ifdef DEBUGGER
    if( debuggerDropCombiners )
    {
        m_vCompiledSettings.clear();
        m_dwLastMux0 = m_dwLastMux1 = 0;
        debuggerDropCombiners = false;
    }
#endif

    m_pOGLRender->EnableMultiTexture();
    bool combinerIsChanged = false;

    if( m_pDecodedMux->m_dwMux0 != m_dwLastMux0 || m_pDecodedMux->m_dwMux1 != m_dwLastMux1  || m_lastIndex < 0 )
    {
        combinerIsChanged = true;
        m_lastIndex = FindCompiledMux();
        if( m_lastIndex < 0 )       // Can not found
        {
            NVRegisterCombinerParserType result;
            ParseDecodedMux(result);
            m_lastIndex= SaveParserResult(result);
        }

        m_dwLastMux0 = m_pDecodedMux->m_dwMux0;
        m_dwLastMux1 = m_pDecodedMux->m_dwMux1;
        GenerateNVRegisterCombinerSetting(m_lastIndex);
    }

    m_pOGLRender->SetAllTexelRepeatFlag();

    if( m_bCycleChanged || combinerIsChanged || gRDP.texturesAreReloaded || gRDP.colorsAreReloaded )
    {
        gRDP.texturesAreReloaded = false; 
        if( m_bCycleChanged || combinerIsChanged )
        {
            GenerateNVRegisterCombinerSettingConstants(m_lastIndex);
            GenerateNVRegisterCombinerSetting(m_lastIndex);
            ApplyFogAtFinalStage();
        }
        else if( gRDP.colorsAreReloaded )
        {
            GenerateNVRegisterCombinerSettingConstants(m_lastIndex);
        }

        gRDP.colorsAreReloaded = false;
    }
}
Example #2
0
int CNvTNTCombiner::ParseDecodedMux()
{
    TNT2CombinerSaveType res;
    res.numOfUnits = 2;

    (*m_ppDecodedMux)->To_AB_Add_CD_Format();

    for( int i=0; i<res.numOfUnits*2; i++ ) // Set combiner for each texture unit
    {
        // For each texture unit, set both RGB and Alpha channel
        // Keep in mind that the m_pDecodeMux has been reformated and simplified very well

        TNT2CombinerType &unit = res.units[i/2];
        TNT2CombType &comb = unit.Combs[i%2];

        CombinerFormatType type = (*m_ppDecodedMux)->splitType[i];
        N64CombinerType &m = (*m_ppDecodedMux)->m_n64Combiners[i];

        comb.arg0 = comb.arg1 = comb.arg2 = comb.arg3 = MUX_0;
        unit.ops[i%2] = 0x0104; //Add;
        //Subtract

        switch( type )
        {
        case CM_FMT_TYPE_NOT_USED:
            comb.arg0 = MUX_COMBINED;
            comb.arg1 = MUX_1;
            comb.arg2 = MUX_0;
            comb.arg3 = MUX_1;
        case CM_FMT_TYPE_D:             // = A
            comb.arg0 = m.d;
            comb.arg1 = MUX_1;
            comb.arg2 = MUX_0;
            comb.arg3 = MUX_0;
            break;
        case CM_FMT_TYPE_A_ADD_D:           // = A+D
            comb.arg0 = m.a;
            comb.arg1 = MUX_1;
            comb.arg2 = m.d;
            comb.arg3 = MUX_1;
            if( isComb(m.d) )
            {
                swap(comb.arg0, comb.arg2);
                swap(comb.arg1, comb.arg3);
            }
            break;
        case CM_FMT_TYPE_A_SUB_B:           // = A-B
            comb.arg0 = m.a^MUX_COMPLEMENT;
            comb.arg1 = MUX_1;
            unit.ops[i%2] = GL_SUBTRACT_ARB;
            comb.arg2 = m.b;
            comb.arg3 = MUX_1;
            break;
        case CM_FMT_TYPE_A_MOD_C:           // = A*C
            comb.arg0 = m.a;
            comb.arg1 = m.c;
            comb.arg2 = MUX_0;
            comb.arg3 = MUX_0;
            break;
        case CM_FMT_TYPE_A_MOD_C_ADD_D: // = A*C+D
            comb.arg0 = m.a;
            comb.arg1 = m.c;
            comb.arg2 = m.d;
            comb.arg3 = MUX_1;
            if( isComb(m.d) )
            {
                swap(comb.arg0, comb.arg2);
                swap(comb.arg1, comb.arg3);
            }
            break;
        case CM_FMT_TYPE_A_LERP_B_C:        // = (A-B)*C+B
            comb.arg0 = m.a;
            comb.arg1 = m.c;
            comb.arg2 = m.c^MUX_COMPLEMENT;
            comb.arg3 = m.b;
            if( isComb(m.b) )
            {
                swap(comb.arg0, comb.arg2);
                swap(comb.arg1, comb.arg3);
            }
            break;
        case CM_FMT_TYPE_A_SUB_B_ADD_D: // = A-B+D
            // fix me, to use 2 texture units
            if( isTex(m.b) && isTex(m.d) )
            {
                comb.arg0 = m.a;
                comb.arg1 = m.b;
                comb.arg2 = m.d;
                comb.arg3 = MUX_1;
                if( isComb(m.d) )
                {
                    swap(comb.arg0, comb.arg2);
                    swap(comb.arg1, comb.arg3);
                }
            }
            else if( isTex(m.b) && !isComb(m.d) )
            {
                comb.arg0 = m.a^MUX_COMPLEMENT;
                comb.arg1 = MUX_1;
                comb.arg2 = m.b;
                comb.arg3 = MUX_1;
                unit.ops[i%2] = GL_SUBTRACT_ARB;
            }
            else if( !isTex(m.b) && isTex(m.d) )
            {
                comb.arg0 = m.a;
                comb.arg1 = MUX_1;
                comb.arg2 = m.d;
                comb.arg3 = MUX_1;
                if( isComb(m.d) )
                {
                    swap(comb.arg0, comb.arg2);
                    swap(comb.arg1, comb.arg3);
                }
            }
            else
            {
                comb.arg0 = m.a;
                comb.arg1 = m.b;
                comb.arg2 = m.d;
                comb.arg3 = MUX_1;
                if( isComb(m.d) )
                {
                    swap(comb.arg0, comb.arg2);
                    swap(comb.arg1, comb.arg3);
                }
            }
            break;
        case CM_FMT_TYPE_A_SUB_B_MOD_C: // = (A-B)*C
            comb.arg0 = m.a^MUX_COMPLEMENT;
            comb.arg1 = m.c;
            comb.arg2 = m.c;
            comb.arg3 = m.b;
            unit.ops[i%2] = GL_SUBTRACT_ARB;
            break;
        case CM_FMT_TYPE_AB_ADD_CD:         // = AB+CD
            comb.arg0 = m.a;
            comb.arg1 = m.b;
            comb.arg2 = m.c;
            comb.arg3 = m.d;
            if( isComb(m.d) || isComb(m.c) )
            {
                swap(comb.arg0, comb.arg2);
                swap(comb.arg1, comb.arg3);
            }

            break;
        case CM_FMT_TYPE_AB_SUB_CD:         // = AB-CD
            comb.arg0 = m.a^MUX_COMPLEMENT;
            comb.arg1 = m.b;
            unit.ops[i%2] = GL_SUBTRACT_ARB;
            comb.arg2 = m.c;
            comb.arg3 = m.d;
            break;
        case CM_FMT_TYPE_A_B_C_D:           // = (A-B)*C+D
        default:
            if( !isComb(m.d) && !isTex(m.d) )
            {
                comb.arg0 = m.a^MUX_COMPLEMENT;
                comb.arg1 = m.c;
                unit.ops[i%2] = GL_SUBTRACT_ARB;
                comb.arg2 = m.c;
                comb.arg3 = m.b;
            }
            else if( !isComb(m.b) && !isTex(m.b) )
            {
                comb.arg0 = m.a;
                comb.arg1 = m.c;
                comb.arg2 = m.d;
                comb.arg3 = MUX_1;
                if( isComb(m.d) )
                {
                    swap(comb.arg0, comb.arg2);
                    swap(comb.arg1, comb.arg3);
                }
            }
            else if( !isComb(m.c) && !isTex(m.c) )
            {
                comb.arg0 = m.a;
                comb.arg1 = m.b;
                comb.arg2 = m.d;
                comb.arg3 = MUX_1;
                if( isComb(m.d) )
                {
                    swap(comb.arg0, comb.arg2);
                    swap(comb.arg1, comb.arg3);
                }
            }
            else
            {
                comb.arg0 = m.a;
                comb.arg1 = m.c;
                comb.arg2 = m.d;
                comb.arg3 = MUX_1;
                if( isComb(m.d) )
                {
                    swap(comb.arg0, comb.arg2);
                    swap(comb.arg1, comb.arg3);
                }
            }
            break;
        }
    }

    ParseDecodedMuxForConstants(res);
    return SaveParserResult(res);
}