Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Effect - Effect - Scene.c_inc
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/* == Effects =========================================================================================================================================================== */
#if T_EFFECT_SCENE


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Parent File Local Functions                                                                                                                                           */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#if T_EFFECT_RENDER
static TgVOID                               T_NAME(tgFX__Scene__, _Cull__Insert_Frame_Mesh)( PC_STg2_SE_Context, C_TgSINT32, TgFX_DATA_INST_ID );
#else
static TgVOID                               T_NAME(tgFX__Scene__, _Insert_Into_Scene_Context)( TgVOID );
#endif
static TgVOID                               T_NAME(tgFX_, __Update_BA)( TgFX_DATA_INST_ID );




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Private Functions and Data                                                                                                                                            */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgEXTN TgFX_DATA_INST_ID                    T_NAME(tgFX__, _Query_Effect_Update_Head)( C_ETgFX_UPDATE );

TgEXTN TgVOID                               T_NAME(tgFX__Client__, _Init_Scene)( TgVOID );
TgEXTN TgVOID                               T_NAME(tgFX__Client__, _Boot_Scene)( TgVOID );
#if T_EFFECT_RENDER
TgEXTN TgFX_DATA_INST_ID                    T_NAME(tgFX__, _Reset_Scene_Particle_Head)( C_ETgFX_UPDATE );
TgEXTN TgFX_DATA_INST_ID                    T_NAME(tgFX__, _Reset_Scene_Mesh_Head)( C_ETgFX_UPDATE );
TgEXTN TgSIZE                               T_NAME(tgFX__, _Scene_Active_Count)( C_ETgFX_UPDATE );
/*# T_EFFECT_RENDER */
#else
TgEXTN TgFX_DATA_INST_ID                    T_NAME(tgFX__, _Reset_Scene_Effect_Head)( C_ETgFX_UPDATE );
/*# T_EFFECT_RENDER */
#endif

TgEXTN T_NAME(STg2_FX__,)                   T_NAME(g_asFX__,)[T_TYPE(KTgFX_MAX_,)];




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Profile Markers                                                                                                                                                       */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

static PROFILE_ARRAY_DEFINE( ETgFX_UPDATE__MAX, T_TYPE(FX_, _SCENE__CULL) );
static PROFILE_DEFINE( T_TYPE(FX_, _SCENE__CULL_TOTAL) );
static PROFILE_ARRAY_DEFINE( ETgFX_UPDATE__MAX, T_TYPE(FX_, _SCENE__UPDATE_BA) );
static PROFILE_DEFINE( T_TYPE(FX_, _SCENE__UPDATE_BA_TOTAL) );
static PROFILE_DEFINE( T_TYPE(FX_, _SCENE__FINISH_TOTAL) );




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Types                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgTYPE_STRUCT_ALIGN(STg2_FX_Job__Scene__Cull_Data,16,)
{
    ETgFX_UPDATE                                m_enUpdate;
    TgSINT32                                    m_iView_Index;
    P_STg2_SE_Context                           m_psScene_Context;
};
TgCOMPILER_ASSERT( sizeof( STg2_FX_Job__Scene__Cull_Data ) <= KTgJOB_DATA_SIZE, 0 );

TgTYPE_STRUCT_ALIGN(STg2_FX_Job__Scene__Bounding_Box,16,)
{
    ETgFX_UPDATE                                m_enUpdate;
    TgUINT32                                    m_uiPad[3];
};
TgCOMPILER_ASSERT( sizeof( STg2_FX_Job__Scene__Bounding_Box ) <= KTgJOB_DATA_SIZE, 0 );

TgTYPE_STRUCT_ALIGN(STg2_FX_Job__Scene__Finish,16,)
{
    P_STg2_SE_Context                           m_psScene_Context;
    TgSINT32                                    m_iView_Index;
    TgUINT32                                    m_uiPad;
};
TgCOMPILER_ASSERT( sizeof( STg2_FX_Job__Scene__Finish ) <= KTgJOB_DATA_SIZE, 0 );




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Functions and Data                                                                                                                                         */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

static TgVOID                               T_NAME(tgFX__Client__, _Init_Scene_Cull)( TgVOID );
#if T_EFFECT_RENDER
static TgBOOL                               T_NAME(tgFX__Scene__, _Cull_Test)( PC_STg2_SE_Context, T_NAME(P_STg2_FX__,) );
/*# T_EFFECT_RENDER */
#endif
static TgVOID                               T_NAME(tgFX__Scene__, _Cull)( PC_STg2_SE_Context, C_TgSINT32, C_ETgFX_UPDATE );
static TgRESULT                             T_NAME(tgFX__Scene__Job__, _Cull)( PC_STg2_Job );
static TgVOID                               T_NAME(tgFX__Scene__, _Refresh_BA)( C_ETgFX_UPDATE );
static TgRESULT                             T_NAME(tgFX__Scene__Job__, _Refresh_BA)( PC_STg2_Job );
static TgVOID                               T_NAME(tgFX__Scene__, _Finish)( PC_STg2_SE_Context, C_TgSINT32 );
static TgRESULT                             T_NAME(tgFX__Scene__Job__, _Finish)( PC_STg2_Job );

static TgATOMIC_SINT32                      T_NAME(s_axiFX__Scene__Fence__, _Cull)[ETgFX_UPDATE__MAX];
static STg2_Job                             T_NAME(s_asFX__Scene__Job__, _Cull)[ETgFX_UPDATE__MAX];
static TgATOMIC_SINT32                      T_NAME(s_axiFX__Scene__Fence__, _Refresh_BA)[ETgFX_UPDATE__MAX];
static STg2_Job                             T_NAME(s_asFX__Scene__Job__, _Refresh_BA)[ETgFX_UPDATE__MAX];
static TgATOMIC_SINT32                      T_NAME(s_xiFX__Scene__Fence__, _Finish);
static STg2_Job                             T_NAME(s_sFX__Scene__Job__, _Finish);

#if T_EFFECT_RENDER
static TgFX_DATA_INST_ID                    T_NAME(s_atiFX__, __Scene__Particle_Head)[ETgFX_UPDATE__MAX];
static TgSIZE                               T_NAME(s_nuiFX__, __Scene__Particle_Active)[ETgFX_UPDATE__MAX];
static TgFX_DATA_INST_ID                    T_NAME(s_atiFX__, __Scene__Mesh_Head)[ETgFX_UPDATE__MAX];
static TgSIZE                               T_NAME(s_nuiFX__, __Scene__Mesh_Active)[ETgFX_UPDATE__MAX];
/*# T_EFFECT_RENDER */
#else
static TgFX_DATA_INST_ID                    T_NAME(s_atiFX__, __Scene__Effect_Head)[ETgFX_UPDATE__MAX];
static TgSINT32                             T_NAME(s_niFX__, __Scene__Effect_Active);
/*# T_EFFECT_RENDER */
#endif
static TgFX_DATA_INST_ID                    T_NAME(s_atiFX__, __Scene__Culled_Head)[ETgFX_UPDATE__MAX];
static TgSINT32                             T_NAME(s_niFX__, __Scene__Culled);




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgFX__Client__Submit_Job__, _Scene_Cull ------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID T_NAME(tgFX__Client__Submit_Job__, _Scene_Cull)( PC_STg2_SE_Context psSE_Context, C_TgSINT32 iView_Index )
{
    union
    {
        P_STg2_FX_Job__Scene__Cull_Data     psJob;
        P_TgUINT08                          pui;
    }                                   psData;

    T_NAME(tgFX__Client__, _Init_Scene_Cull)();

    psData.pui = T_NAME(s_asFX__Scene__Job__, _Cull)[ETgFX_UPDATE__DEFAULT].m_auiData;
    psData.psJob->m_enUpdate = ETgFX_UPDATE__DEFAULT;
    psData.psJob->m_iView_Index = iView_Index;
    psData.psJob->m_psScene_Context = psSE_Context;

    tgAM32_INC( &g_xiFX_Fence__SCENE_CULLING );
    tgAM32_INC( T_NAME(s_axiFX__Scene__Fence__, _Cull) + ETgFX_UPDATE__DEFAULT );
    tgJM_Queue_Job( g_sJob_Queue__Render_Normal, T_NAME(s_asFX__Scene__Job__, _Cull) + ETgFX_UPDATE__DEFAULT );

    psData.pui = T_NAME(s_asFX__Scene__Job__, _Cull)[ETgFX_UPDATE__EXTERNAL].m_auiData;
    psData.psJob->m_enUpdate = ETgFX_UPDATE__EXTERNAL;
    psData.psJob->m_iView_Index = iView_Index;
    psData.psJob->m_psScene_Context = psSE_Context;

    tgAM32_INC( &g_xiFX_Fence__SCENE_CULLING );
    tgAM32_INC( T_NAME(s_axiFX__Scene__Fence__, _Cull) + ETgFX_UPDATE__EXTERNAL );
    tgJM_Queue_Job( g_sJob_Queue__Render_Normal, T_NAME(s_asFX__Scene__Job__, _Cull) + ETgFX_UPDATE__EXTERNAL );
}


/* ---- tgFX__Client__Submit_Job__, _Refresh_BA ------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID T_NAME(tgFX__Client__Submit_Job__, _Refresh_BA)( TgVOID )
{
    union
    {
        P_STg2_FX_Job__Scene__Bounding_Box  psJob;
        P_TgUINT08                          pui;
    }                                   psData;

    psData.pui = T_NAME(s_asFX__Scene__Job__, _Refresh_BA)[ETgFX_UPDATE__DEFAULT].m_auiData;
    psData.psJob->m_enUpdate = ETgFX_UPDATE__DEFAULT;

    tgAM32_INC( &g_xiFX_Fence__SCENE_BOUNDING_BOX );
    tgAM32_INC( T_NAME(s_axiFX__Scene__Fence__, _Refresh_BA) + ETgFX_UPDATE__DEFAULT );
    tgJM_Queue_Job( g_sJob_Queue__Render_Normal, T_NAME(s_asFX__Scene__Job__, _Refresh_BA) + ETgFX_UPDATE__DEFAULT );

    psData.pui = T_NAME(s_asFX__Scene__Job__, _Refresh_BA)[ETgFX_UPDATE__EXTERNAL].m_auiData;
    psData.psJob->m_enUpdate = ETgFX_UPDATE__EXTERNAL;

    tgAM32_INC( &g_xiFX_Fence__SCENE_BOUNDING_BOX );
    tgAM32_INC( T_NAME(s_axiFX__Scene__Fence__, _Refresh_BA) + ETgFX_UPDATE__EXTERNAL );
    tgJM_Queue_Job( g_sJob_Queue__Render_Normal, T_NAME(s_asFX__Scene__Job__, _Refresh_BA) + ETgFX_UPDATE__EXTERNAL );
}


/* ---- tgFX__Client__Submit_Job__, _Scene_Finish ----------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID T_NAME(tgFX__Client__Submit_Job__, _Scene_Finish)( PC_STg2_SE_Context psSE_Context, C_TgSINT32 iView_Index )
{
    union
    {
        P_STg2_FX_Job__Scene__Finish        psJob;
        P_TgUINT08                          pui;
    }                                   psData;

    psData.pui = T_NAME(s_sFX__Scene__Job__, _Finish).m_auiData;
    psData.psJob->m_iView_Index = iView_Index;
    psData.psJob->m_psScene_Context = psSE_Context;

    tgAM32_INC( &g_xiFX_Fence__SCENE_FINISH );
    tgAM32_INC( &T_NAME(s_xiFX__Scene__Fence__, _Finish) );
    tgJM_Queue_Job( g_sJob_Queue__Render_Normal, &T_NAME(s_sFX__Scene__Job__, _Finish) );
}




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Private Functions                                                                                                                                                     */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgFX__Client__, _Init_Scene ------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID T_NAME(tgFX__Client__, _Init_Scene)( TgVOID )
{
    TgSINT32                            iIndex;

    PROFILE_ARRAY_INIT( 0, TgT("DEFAULT"), T_TYPE(FX_, _SCENE__CULL) );
    PROFILE_ARRAY_INIT( 1, TgT("EXTERNAL"), T_TYPE(FX_, _SCENE__CULL) );
    PROFILE_INIT( T_TYPE(FX_, _SCENE__CULL_TOTAL) );

    PROFILE_ARRAY_INIT( 0, TgT("DEFAULT"), T_TYPE(FX_, _SCENE__UPDATE_BA) );
    PROFILE_ARRAY_INIT( 1, TgT("EXTERNAL"), T_TYPE(FX_, _SCENE__UPDATE_BA) );
    PROFILE_INIT( T_TYPE(FX_, _SCENE__UPDATE_BA_TOTAL) );

    PROFILE_INIT( T_TYPE(FX_, _SCENE__FINISH_TOTAL) );

    for (iIndex = 0; iIndex < ETgFX_UPDATE__MAX; ++iIndex)
    {
        T_NAME(s_axiFX__Scene__Fence__, _Cull)[iIndex] = 0;
        memset( T_NAME(s_asFX__Scene__Job__, _Cull) + iIndex, 0, sizeof( STg2_Job ) );
        T_NAME(s_axiFX__Scene__Fence__, _Refresh_BA)[iIndex] = 0;
        memset( T_NAME(s_asFX__Scene__Job__, _Refresh_BA) + iIndex, 0, sizeof( STg2_Job ) );
    };

    T_NAME(s_xiFX__Scene__Fence__, _Finish) = 0;
    memset( &T_NAME(s_sFX__Scene__Job__, _Finish), 0, sizeof( STg2_Job ) );

    T_NAME(tgFX__Client__, _Init_Scene_Cull)();
}


/* ---- tgFX__Client__, _Boot ------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID T_NAME(tgFX__Client__, _Boot_Scene)( TgVOID )
{
    T_NAME(s_asFX__Scene__Job__, _Cull)[ETgFX_UPDATE__DEFAULT].m_pfnExecute = T_NAME(tgFX__Scene__Job__, _Cull);
    T_NAME(s_asFX__Scene__Job__, _Cull)[ETgFX_UPDATE__DEFAULT].m_pxiFinish = T_NAME(s_axiFX__Scene__Fence__, _Cull) + ETgFX_UPDATE__DEFAULT;
    T_NAME(s_asFX__Scene__Job__, _Cull)[ETgFX_UPDATE__EXTERNAL].m_pfnExecute = T_NAME(tgFX__Scene__Job__, _Cull);
    T_NAME(s_asFX__Scene__Job__, _Cull)[ETgFX_UPDATE__EXTERNAL].m_pxiFinish = T_NAME(s_axiFX__Scene__Fence__, _Cull) + ETgFX_UPDATE__EXTERNAL;

    T_NAME(s_asFX__Scene__Job__, _Refresh_BA)[ETgFX_UPDATE__DEFAULT].m_pfnExecute = T_NAME(tgFX__Scene__Job__, _Refresh_BA);
    T_NAME(s_asFX__Scene__Job__, _Refresh_BA)[ETgFX_UPDATE__DEFAULT].m_pxiTrigger = T_NAME(s_axiFX__Scene__Fence__, _Cull) + ETgFX_UPDATE__DEFAULT;
    T_NAME(s_asFX__Scene__Job__, _Refresh_BA)[ETgFX_UPDATE__DEFAULT].m_pxiFinish = T_NAME(s_axiFX__Scene__Fence__, _Refresh_BA) + ETgFX_UPDATE__DEFAULT;
    T_NAME(s_asFX__Scene__Job__, _Refresh_BA)[ETgFX_UPDATE__EXTERNAL].m_pfnExecute = T_NAME(tgFX__Scene__Job__, _Refresh_BA);
    T_NAME(s_asFX__Scene__Job__, _Refresh_BA)[ETgFX_UPDATE__EXTERNAL].m_pxiTrigger = T_NAME(s_axiFX__Scene__Fence__, _Cull) + ETgFX_UPDATE__EXTERNAL;
    T_NAME(s_asFX__Scene__Job__, _Refresh_BA)[ETgFX_UPDATE__EXTERNAL].m_pxiFinish = T_NAME(s_axiFX__Scene__Fence__, _Refresh_BA) + ETgFX_UPDATE__EXTERNAL;

    T_NAME(s_sFX__Scene__Job__, _Finish).m_pfnExecute = T_NAME(tgFX__Scene__Job__, _Finish);
    T_NAME(s_sFX__Scene__Job__, _Finish).m_pxiFinish = &T_NAME(s_xiFX__Scene__Fence__, _Finish);
}


#if T_EFFECT_RENDER

/* ---- tgFX__, _Reset_Scene_Particle_Head ------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgFX_DATA_INST_ID T_NAME(tgFX__, _Reset_Scene_Particle_Head)( C_ETgFX_UPDATE enUpdate )
{
    TgFX_DATA_INST_ID                   tiActive;

    tiActive = T_NAME(s_atiFX__, __Scene__Particle_Head)[enUpdate];
    T_NAME(s_atiFX__, __Scene__Particle_Head)[enUpdate] = KTgFX_DATA_INST_ID__INVALID;

    return (tiActive);
}


/* ---- tgFX__, _Reset_Scene_Mesh_Head ---------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgFX_DATA_INST_ID T_NAME(tgFX__, _Reset_Scene_Mesh_Head)( C_ETgFX_UPDATE enUpdate )
{
    TgFX_DATA_INST_ID                   tiActive;

    tiActive = T_NAME(s_atiFX__, __Scene__Mesh_Head)[enUpdate];
    T_NAME(s_atiFX__, __Scene__Mesh_Head)[enUpdate] = KTgFX_DATA_INST_ID__INVALID;

    return (tiActive);
}


/* ---- tgFX__, _Scene_Active_Count ------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE T_NAME(tgFX__, _Scene_Active_Count)( C_ETgFX_UPDATE enUpdate )
{
    return (T_NAME(s_nuiFX__, __Scene__Particle_Active)[enUpdate] + T_NAME(s_nuiFX__, __Scene__Mesh_Active)[enUpdate]);
}

/*# T_EFFECT_RENDER */
#else

/* ---- tgFX__, _Reset_Scene_Effect_Head -------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgFX_DATA_INST_ID T_NAME(tgFX__, _Reset_Scene_Effect_Head)( C_ETgFX_UPDATE enUpdate )
{
    TgFX_DATA_INST_ID                   tiActive;

    tiActive = T_NAME(s_atiFX__, __Scene__Effect_Head)[enUpdate];
    T_NAME(s_atiFX__, __Scene__Effect_Head)[enUpdate] = KTgFX_DATA_INST_ID__INVALID;

    return (tiActive);
}

/*# T_EFFECT_RENDER */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Functions                                                                                                                                                  */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgFX__Client__, _Init_Scene_Cull -------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgVOID T_NAME(tgFX__Client__, _Init_Scene_Cull)( TgVOID )
{
    TgSINT32                            iIndex;

#if T_EFFECT_RENDER
    for (iIndex = 0; iIndex < ETgFX_UPDATE__MAX; ++iIndex)
    {
        T_NAME(s_atiFX__, __Scene__Particle_Head)[iIndex] = KTgFX_DATA_INST_ID__INVALID;
        T_NAME(s_atiFX__, __Scene__Mesh_Head)[iIndex] = KTgFX_DATA_INST_ID__INVALID;
        T_NAME(s_nuiFX__, __Scene__Particle_Active)[iIndex] = 0;
        T_NAME(s_nuiFX__, __Scene__Mesh_Active)[iIndex] = 0;
        T_NAME(s_atiFX__, __Scene__Culled_Head)[iIndex] = KTgFX_DATA_INST_ID__INVALID;
    };
/*# T_EFFECT_RENDER */
#else
    for (iIndex = 0; iIndex < ETgFX_UPDATE__MAX; ++iIndex)
    {
        T_NAME(s_atiFX__, __Scene__Effect_Head)[iIndex] = KTgFX_DATA_INST_ID__INVALID;
        T_NAME(s_atiFX__, __Scene__Culled_Head)[iIndex] = KTgFX_DATA_INST_ID__INVALID;
    };
    T_NAME(s_niFX__, __Scene__Effect_Active) = 0;
/*# T_EFFECT_RENDER */
#endif
    T_NAME(s_niFX__, __Scene__Culled) = 0;
}


/* ---- tgFX__Scene__, _Scene_Cull_Test --------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgBOOL T_NAME(tgFX__Scene__, _Cull_Test)( PC_STg2_SE_Context UNUSED_PARAM psSE_Context, T_NAME(P_STg2_FX__,) psEffect )
{
#if TgS_DEBUG_EFFECT
    TgBOOL                              bDisable;
    if ((TgTRUE == tgCN_Var_Query_Bool( &bDisable, T_NAME( g_tiFX_Debug__, __Disable_Scene_Cull ) )) && (TgTRUE == bDisable))
        return (TgTRUE);
/*# TgS_DEBUG_EFFECT */
#endif

    if (0 != psEffect->m_uiRender__Visible)
        return (TgFALSE);

    /* #TODO: Frustum Test */

    /* #TODO: Viz Graph Test */

    /* #TODO: Occlusion Test */
    return (TgTRUE);
}


/* ---- tgFX__Scene__, _Scene_Cull -------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgVOID T_NAME(tgFX__Scene__, _Cull)( PC_STg2_SE_Context psSE_Context, C_TgSINT32 iView_Index, C_ETgFX_UPDATE enUpdate )
{
    TgRN_TARGET_ID                      tiRN_Target;
    TgUINT32                            uiFlags;
    TgSINT32                            iIndex_In_SE_Context;
    TgFX_DATA_INST_ID                   tiActive;
    TgFX_DATA_INST_ID                   tiNext_Active;
    TgBOOL                              bFirstCull;
    T_NAME(P_STg2_FX__,)                psEffect;
    ETgFX_NEXT                          enFX_Next;
#if T_EFFECT_RENDER
    TgSINT32                            iView_Inst_Index;
/*# T_EFFECT_RENDER */
#endif

    PROFILE_ARRAY_START( enUpdate, T_TYPE(FX_, _SCENE__CULL) );
    PROFILE_START( T_TYPE(FX_, _SCENE__CULL_TOTAL) );

    tiRN_Target = psSE_Context->m_asView[iView_Index].m_tiRN_Target;

    uiFlags = KTgRN_DATA_MESH__IN_FRUSTUM | KTgRN_DATA_MESH__NO_LOD | KTgRN_DATA_MESH__NO_LIGHTING;
    iIndex_In_SE_Context = 0;
    bFirstCull = TgTRUE;

#if T_EFFECT_RENDER
    /* If we have already generated one view for the scene context, then we can reuse the frame mesh data - cull against all existing inserted objects */
    tiActive = T_NAME(s_atiFX__, __Scene__Particle_Head)[enUpdate];
    if (TgFALSE != tgFX_DATA_INST_ID_Is_Valid( tiActive ))
    {
        bFirstCull = TgFALSE;
        do
        {
            psEffect = T_NAME(g_asFX__,) + tiActive.m.iI;

            if (TgTRUE == T_NAME(tgFX__Scene__, _Cull_Test)( psSE_Context, psEffect ))
            {
                iView_Inst_Index = tgAM32_XADD( psSE_Context->m_asView[iView_Index].m_aniRN_Frame_Mesh_Inst + ETgSE_DRAW_TYPE__TRANSPARENT, 1 );
                if (iView_Inst_Index < psSE_Context->m_asView[iView_Index].m_aniRN_Max_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__TRANSPARENT])
                    psSE_Context->m_asView[iView_Index].m_apiRN_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__TRANSPARENT][iView_Inst_Index] = psEffect->m_iIndex_In_SE_Context;
            }

            /* Completed processing the effect */
            tiActive = psEffect->m_tiNext[ETgFX_NEXT__SCENE];
        }
        while (TgFALSE != tgFX_DATA_INST_ID_Is_Valid( tiActive ));
    };

    tiActive = T_NAME(s_atiFX__, __Scene__Mesh_Head)[enUpdate];
    if (TgFALSE != tgFX_DATA_INST_ID_Is_Valid( tiActive ))
    {
        bFirstCull = TgFALSE;
        do
        {
            psEffect = T_NAME(g_asFX__,) + tiActive.m.iI;

            if (TgTRUE == T_NAME(tgFX__Scene__, _Cull_Test)( psSE_Context, psEffect ))
            {
                if (TgTRUE == tgRN_Material__Is_Opaque( psEffect->m_tiMaterial ))
                {
                    iView_Inst_Index = tgAM32_XADD( psSE_Context->m_asView[iView_Index].m_aniRN_Frame_Mesh_Inst + ETgSE_DRAW_TYPE__OPAQUE, 1 );
                    if (iView_Inst_Index < psSE_Context->m_asView[iView_Index].m_aniRN_Max_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__OPAQUE])
                        psSE_Context->m_asView[iView_Index].m_apiRN_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__OPAQUE][iView_Inst_Index] = psEffect->m_iIndex_In_SE_Context;
                }
                else
                {
                    iView_Inst_Index = tgAM32_XADD( psSE_Context->m_asView[iView_Index].m_aniRN_Frame_Mesh_Inst + ETgSE_DRAW_TYPE__TRANSPARENT, 1 );
                    if (iView_Inst_Index < psSE_Context->m_asView[iView_Index].m_aniRN_Max_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__TRANSPARENT])
                        psSE_Context->m_asView[iView_Index].m_apiRN_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__TRANSPARENT][iView_Inst_Index] = psEffect->m_iIndex_In_SE_Context;
                };
            }

            /* Completed processing the effect */
            tiActive = psEffect->m_tiNext[ETgFX_NEXT__SCENE];
        }
        while (TgFALSE != tgFX_DATA_INST_ID_Is_Valid( tiActive ));
    };

/*# T_EFFECT_RENDER */
#else

    tiActive = T_NAME(s_atiFX__, __Scene__Effect_Head)[enUpdate];
    if (TgFALSE != tgFX_DATA_INST_ID_Is_Valid( tiActive ))
    {
        bFirstCull = TgFALSE;
        do
        {
            psEffect = T_NAME(g_asFX__,) + tiActive.m.iI;

            if (TgTRUE == T_NAME(tgFX__Scene__, _Cull_Test)( psSE_Context, psEffect ))
            {
                T_NAME(tgFX__Scene__, _Insert_Into_Scene_Context)();
            }

            /* Completed processing the effect */
            tiActive = psEffect->m_tiNext[ETgFX_NEXT__SCENE];
        }
        while (TgFALSE != tgFX_DATA_INST_ID_Is_Valid( tiActive ));
    };

/*# T_EFFECT_RENDER */
#endif

    /* If this is our first time processing the scene context then parse through all effects from the update list, otherwise they have been added to the scene lists */
    tiActive = T_NAME(s_atiFX__, __Scene__Culled_Head)[enUpdate];
    if (bFirstCull && (TgTRUE != tgFX_DATA_INST_ID_Is_Valid( tiActive )))
    {
        tiActive = T_NAME(tgFX__, _Query_Effect_Update_Head)( enUpdate );
        enFX_Next = ETgFX_NEXT__UPDATE;
    }
    else
    {
        enFX_Next = ETgFX_NEXT__SCENE;
    };

    while (TgFALSE != tgFX_DATA_INST_ID_Is_Valid( tiActive ))
    {
    #if T_EFFECT_RENDER && T_EFFECT_FRAME
        TgVEC_F32_04                                vPos_W;
        TgVEC_F32_04                                qRot_W;
    #endif

        psEffect = T_NAME( g_asFX__, ) + tiActive.m.iI;
        tiNext_Active = psEffect->m_tiNext[enFX_Next];

    #if T_EFFECT_RENDER
        if (TgFALSE == T_NAME(tgFX__Scene__, _Cull_Test)( psSE_Context, psEffect ))
            goto T_NAME(tgFX__Scene__, _Update_BA__Cull_Out);

        if (TgFALSE == tgRN_MESH_SET_ID_Is_Valid( psEffect->m_tiMesh_Set ))
            goto T_NAME( tgFX__Scene__, _Update_BA__Cull_Out );

        /* Effect is within the camera frustum */
        iIndex_In_SE_Context = tgAM32_XADD( &psSE_Context->m_niRN_Frame_Mesh, 1 );
        if (iIndex_In_SE_Context >= psSE_Context->m_niRN_Max_Frame_Mesh)
            goto T_NAME(tgFX__Scene__, _Update_BA__Cull_Out);

        psEffect->m_iIndex_In_SE_Context = iIndex_In_SE_Context;

        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_tiMesh_Set = psEffect->m_tiMesh_Set;
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_iLOD_Index = 0;
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_uiFlags = 0;

    #if T_EFFECT_FRAME
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_vScale = psEffect->m_vScale;
        vPos_W.m_mData = psEffect->m_vPos_W;
        qRot_W.m_mData = psEffect->m_qRot_W;
        F_Init_Quat_F32_34( &psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_xTX, &qRot_W );
        F_SET_T_F32_34( &psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_xTX, &vPos_W );
    /*# T_EFFECT_FRAME */
    #else
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_xTX = KTgX_IDENT_F32_34;
    /*# T_EFFECT_FRAME */
    #endif

        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_vLast_Scale = KTgV_ONE_F32_04.m_mData;
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_xLast_TX = KTgX_IDENT_F32_34;

        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_vBA_Max_W = psEffect->m_vBA_Max_W;
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_vBA_Min_W = psEffect->m_vBA_Min_W;

        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_vAmbient = KTgV_ZERO_F32_04;
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_vLM = KTgV_ZERO_F32_04;
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_tiLM = KTgKN_TX_IMG_ID__INVALID;
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_tiMaterial = psEffect->m_tiMaterial;
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_nuiLight = 0;

        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_iSkeleton_0 = -1;
        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_iSkeleton_1 = -1;

        psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_fOpacity = 1.0F;

        if (TgTRUE != tgRN_MESH_SET_ID_Is_Valid( psEffect->m_tiMesh_Set ))
        {
            psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_uiFlags |= KTgRN_DATA_MESH__PARTICLE;
            psEffect->m_tiNext[ETgFX_NEXT__SCENE] = T_NAME(s_atiFX__, __Scene__Particle_Head)[enUpdate];
            T_NAME(s_atiFX__, __Scene__Particle_Head)[enUpdate] = psEffect->m_tiData;
            T_NAME(s_nuiFX__, __Scene__Particle_Active)[enUpdate] += 1;
        }
        else
        {
            psEffect->m_tiNext[ETgFX_NEXT__SCENE] = T_NAME(s_atiFX__, __Scene__Mesh_Head)[enUpdate];
            T_NAME(s_atiFX__, __Scene__Mesh_Head)[enUpdate] = psEffect->m_tiData;
            T_NAME(s_nuiFX__, __Scene__Mesh_Active)[enUpdate] += 1;
        };

        if (psEffect->m_uiRender__ScreenSpace)
        {
            psSE_Context->m_asRN_Frame_Mesh[iIndex_In_SE_Context].m_uiFlags |= KTgRN_DATA_MESH__SCREEN_SPACE;
        };

        if (TgTRUE == tgRN_Material__Is_Opaque( psEffect->m_tiMaterial ))
        {
            iView_Inst_Index = tgAM32_XADD( psSE_Context->m_asView[iView_Index].m_aniRN_Frame_Mesh_Inst + ETgSE_DRAW_TYPE__OPAQUE, 1 );
            if (iView_Inst_Index < psSE_Context->m_asView[iView_Index].m_aniRN_Max_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__OPAQUE])
                psSE_Context->m_asView[iView_Index].m_apiRN_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__OPAQUE][iView_Inst_Index] = iIndex_In_SE_Context;
        }
        else
        {
            iView_Inst_Index = tgAM32_XADD( psSE_Context->m_asView[iView_Index].m_aniRN_Frame_Mesh_Inst + ETgSE_DRAW_TYPE__TRANSPARENT, 1 );
            if (iView_Inst_Index < psSE_Context->m_asView[iView_Index].m_aniRN_Max_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__TRANSPARENT])
                psSE_Context->m_asView[iView_Index].m_apiRN_Frame_Mesh_Inst[ETgSE_DRAW_TYPE__TRANSPARENT][iView_Inst_Index] = iIndex_In_SE_Context;
        };

        goto T_NAME(tgFX__Scene__, _Update_BA__Cull_Done);

    /*# T_EFFECT_RENDER */
    #else

        if (0 != psEffect->m_uiRender__Visible)
            goto T_NAME(tgFX__Scene__, _Update_BA__Cull_Out);

        /* #TODO: RENDER TARGET TEST */

        T_NAME( tgFX__Scene__, _Insert_Into_Scene_Context )();

        psEffect->m_tiNext[ETgFX_NEXT__SCENE] = T_NAME(s_atiFX__, __Scene__Effect_Head )[enUpdate];
        T_NAME(s_atiFX__, __Scene__Effect_Head)[enUpdate] = psEffect->m_tiData;
        T_NAME(s_niFX__, __Scene__Effect_Active) += 1;

        goto T_NAME(tgFX__Scene__, _Update_BA__Cull_Done);
    /*# T_EFFECT_RENDER */
    #endif


        /* Effect is outside the camera frustum */
T_NAME(tgFX__Scene__, _Update_BA__Cull_Out):
        psEffect->m_tiNext[ETgFX_NEXT__SCENE] = T_NAME(s_atiFX__, __Scene__Culled_Head)[enUpdate];
        T_NAME(s_atiFX__, __Scene__Culled_Head)[enUpdate] = psEffect->m_tiData;
        T_NAME(s_niFX__, __Scene__Culled) += 1;


        /* Completed processing the effect */
T_NAME(tgFX__Scene__, _Update_BA__Cull_Done):
        tiActive = tiNext_Active;
    };

    if (iIndex_In_SE_Context >= psSE_Context->m_niRN_Max_Frame_Mesh)
    {
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Too many frame instances used for camera (%32.32s).\n" ), TgT("Effect"), TgTO_TEXT( T_NAME(tgFX__Scene__, _Cull) ),
                        psSE_Context->m_asView[iView_Index].m_psCamera->m_szName );
    };

    PROFILE_STOP( T_TYPE(FX_, _SCENE__CULL_TOTAL) );
    PROFILE_ARRAY_STOP( enUpdate, T_TYPE(FX_, _SCENE__CULL) );
}


/* ---- tgFX__Scene__Job__, _Cull --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgRESULT T_NAME(tgFX__Scene__Job__, _Cull)( PC_STg2_Job psJob )
{
    union
    {
        P_STg2_FX_Job__Scene__Cull_Data     psJob;
        P_TgUINT08                          pui;
    }                                   psData;

    psData.pui = psJob->m_auiData;

    T_NAME(tgFX__Scene__, _Cull)( psData.psJob->m_psScene_Context, psData.psJob->m_iView_Index, psData.psJob->m_enUpdate );

    TgVERIFY( 0 == tgAM32_DEC( &g_xiFX_Fence__SCENE_CULLING ) );
    return (KTgS_OK);
}


/* ---- tgFX__Scene__, _Refresh_BA -------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgVOID T_NAME(tgFX__Scene__, _Refresh_BA)( C_ETgFX_UPDATE enUpdate )
{
    TgFX_DATA_INST_ID                   tiActive;
    T_NAME(P_STg2_FX__,)                psEffect;

    PROFILE_ARRAY_START( enUpdate, T_TYPE(FX_, _SCENE__UPDATE_BA) );
    PROFILE_START( T_TYPE(FX_, _SCENE__UPDATE_BA_TOTAL) );

    tiActive = T_NAME(s_atiFX__, __Scene__Culled_Head)[enUpdate];

    while (TgFALSE != tgFX_DATA_INST_ID_Is_Valid( tiActive ))
    {
        psEffect = T_NAME(g_asFX__,) + tiActive.m.iI;
        T_NAME(tgFX_, __Update_BA)( tiActive );
        tiActive = psEffect->m_tiNext[ETgFX_NEXT__SCENE];
    };

    PROFILE_STOP( T_TYPE(FX_, _SCENE__UPDATE_BA_TOTAL) );
    PROFILE_ARRAY_STOP( enUpdate, T_TYPE(FX_, _SCENE__UPDATE_BA) );
}


/* ---- tgFX__Scene__Job__, _Refresh_BA --------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgRESULT T_NAME(tgFX__Scene__Job__, _Refresh_BA)( PC_STg2_Job psJob )
{
    union
    {
        P_STg2_FX_Job__Scene__Bounding_Box  psJob;
        P_TgUINT08                          pui;
    }                                   psData;

    psData.pui = psJob->m_auiData;

    T_NAME(tgFX__Scene__, _Refresh_BA)( psData.psJob->m_enUpdate );

    TgVERIFY( 0 == tgAM32_DEC( &g_xiFX_Fence__SCENE_BOUNDING_BOX ) );
    return (KTgS_OK);
}


/* ---- tgFX__Scene__, _Finish ------------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgVOID T_NAME(tgFX__Scene__, _Finish)( PC_STg2_SE_Context psSE_Context, C_TgSINT32 iView_Index )
{
#if T_EFFECT_RENDER
    TgFX_DATA_INST_ID                   tiActive;
    ETgFX_UPDATE                        enUpdate;
    T_NAME(P_STg2_FX__,)                psEffect;

    PROFILE_START( T_TYPE(FX_, _SCENE__FINISH_TOTAL) );

    for (enUpdate = ETgFX_UPDATE__BEGIN; enUpdate < ETgFX_UPDATE__END; ++enUpdate)
    {
        tiActive = T_NAME(s_atiFX__, __Scene__Mesh_Head)[enUpdate];

        while (TgFALSE != tgFX_DATA_INST_ID_Is_Valid( tiActive ))
        {
            T_NAME(tgFX__Scene__, _Cull__Insert_Frame_Mesh)( psSE_Context, iView_Index, tiActive );
            psEffect = T_NAME(g_asFX__,) + tiActive.m.iI;
            tiActive = psEffect->m_tiNext[ETgFX_NEXT__SCENE];
        };
    };

    PROFILE_STOP( T_TYPE(FX_, _SCENE__FINISH_TOTAL) );
#else
    (void)psSE_Context;
    (void)iView_Index;
/*# T_EFFECT_RENDER */
#endif
}


/* ---- tgFX__Scene__Job__, _Finish ------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgRESULT T_NAME(tgFX__Scene__Job__, _Finish)( PC_STg2_Job psJob )
{
    union
    {
        P_STg2_FX_Job__Scene__Finish        psJob;
        P_TgUINT08                          pui;
    }                                   psData;

    psData.pui = psJob->m_auiData;

    T_NAME(tgFX__Scene__, _Finish)( psData.psJob->m_psScene_Context, psData.psJob->m_iView_Index );

    TgVERIFY( 0 == tgAM32_DEC( &g_xiFX_Fence__SCENE_FINISH ) );
    return (KTgS_OK);
}


/*# T_EFFECT_SCENE */
#endif