Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Effect - Effect - Client.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 =========================================================================================================================================================== */


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  External Functions and Data                                                                                                                                           */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgEXTN P_TgUINT08                           T_NAME(tgFX_, __Reserve_Update_Command)( C_ETgFX_COMMAND );
TgEXTN TgSIZE                               T_NAME(tgFX__Update__, _Process_Update_Command_Buffer)( CP_TgUINT08, TgSIZE );

#if T_EFFECT_UPDATE
TgEXTN TgVOID                               T_NAME(tgFX__Client__, _Init_Update)( TgVOID );
TgEXTN TgVOID                               T_NAME(tgFX__Client__, _Boot_Update)( TgVOID );
/*# T_EFFECT_UPDATE */
#endif

#if T_EFFECT_SCENE
TgEXTN TgVOID                               T_NAME(tgFX__Client__, _Init_Scene)( TgVOID );
TgEXTN TgVOID                               T_NAME(tgFX__Client__, _Boot_Scene)( TgVOID );
/*# T_EFFECT_SCENE */
#endif

#if T_EFFECT_RENDER
TgEXTN TgVOID                               T_NAME(tgFX__Client__, _Init_Render)( TgVOID );
TgEXTN TgVOID                               T_NAME(tgFX__Client__, _Boot_Render)( TgVOID );
/*# T_EFFECT_RENDER */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Exported Data                                                                                                                                                         */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgEXTN ETgFX_EFFECT_STATE                   T_NAME(g_aenFX__, __Shared__State)[T_TYPE(KTgFX_MAX_,)];
TgEXTN STg2_UTM_AM_ST_ISO                   T_NAME(g_sFX__, __Client__Stack);
TgEXTN T_NAME(STg2_FX__,)                   T_NAME(g_asFX__,)[T_TYPE(KTgFX_MAX_,)];
#if T_EFFECT_UPDATE || T_EFFECT_RENDER
TgEXTN TgUINT08                             T_NAME(g_asFX_Command__, __ToClient)[ETgFX_COMMAND__TO_CLIENT__BYTE_MAX];
TgEXTN volatile TgATOMIC_UINTXX             T_NAME(g_uiFX_Command__, __ToClient_Offset);
/*# T_EFFECT_UPDATE || T_EFFECT_RENDER */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Data                                                                                                                                                           */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#if T_EFFECT_UPDATE || T_EFFECT_RENDER
TgUINT08                                    T_NAME(g_asFX_Command__, __ToClient)[ETgFX_COMMAND__TO_CLIENT__BYTE_MAX];
volatile TgATOMIC_UINTXX                    T_NAME(g_uiFX_Command__, __ToClient_Offset);
/*# T_EFFECT_UPDATE || T_EFFECT_RENDER */
#endif

PROFILE_DEFINE( T_TYPE(FX_, _COMMANDS__UPDATE) );

#if T_EFFECT_UPDATE
PROFILE_DEFINE( T_TYPE(FX_, _UPDATE__DATA) );
PROFILE_DEFINE( T_TYPE(FX_, _UPDATE_EXTERNAL__DATA) );
/*# T_EFFECT_UPDATE */
#endif

#if T_EFFECT_RENDER
PROFILE_DEFINE( T_TYPE(FX_, _RENDER_PATCH_CONTEXT) );
PROFILE_DEFINE( T_TYPE(FX_, _RENDER_UPDATE) );
PROFILE_DEFINE( T_TYPE(FX_, _RENDER_GENERATE) );
/*# T_EFFECT_RENDER */
#endif

#if TgS_DEBUG_EFFECT
TgCN_VAR_ID                                 T_NAME(g_tiFX_Debug__, __Disable_Create);
TgCN_VAR_ID                                 T_NAME(g_tiFX_Debug__, __Disable_Update);
TgCN_VAR_ID                                 T_NAME(g_tiFX_Debug__, __Disable_Scene_Cull);
TgCN_VAR_ID                                 T_NAME(g_tiFX_Debug__, __Disable_Render);
TgCN_VAR_ID                                 T_NAME(g_tiFX_Debug__, __Draw_BA);
TgCN_VAR_ID                                 T_NAME(g_tiFX_Debug__, __Draw_Debug);
/*# TgS_DEBUG_EFFECT */
#endif

ETgFX_EFFECT_STATE                          T_NAME(g_aenFX__, __Shared__State)[T_TYPE( KTgFX_MAX_, )];
T_NAME(STg2_FX__,)                          T_NAME(g_asFX__,)[T_TYPE(KTgFX_MAX_,)];
STg2_UTM_AM_ST_ISO                          T_NAME(g_sFX__, __Client__Stack);




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

static STg2_FX_Descriptor                   T_NAME(s_sFX_Descriptor__,);

static TgUINT32                             T_NAME(s_uiFX__, __Shared__Notify_State);

#if T_EFFECT_UPDATE
static TgATOMIC_SINT32                      T_NAME(s_xiFX_Fence__, __Update);
static STg2_Job                             T_NAME(s_sFX__Job__, __Update)[ETgFX_UPDATE__MAX];

static TgATOMIC_SINT32                      T_NAME(s_xiFX_Fence__, __Update__Process_ClientToUpdate);
static STg2_Job                             T_NAME(s_sFX__Job__, __Update__Process_ClientToUpdate);

static TgUINT08                             T_NAME(s_asFX_Command__, __ClientToUpdate)[ETgFX_COMMAND__CLIENT_TO_UPDATE__BYTE_MAX];
static TgATOMIC_SINT32                      T_NAME(s_uiFX_Command__, __ClientToUpdate_Offset);
/*# T_EFFECT_UPDATE */
#endif

#if T_EFFECT_RENDER
static TgATOMIC_SINT32                      T_NAME(s_xiFX_Fence__, __Scene__Cull);
static STg2_Job                             T_NAME(s_sFX__Job__, __Scene__Cull)[ETgFX_UPDATE__MAX];

static TgATOMIC_SINT32                      T_NAME(s_xiFX_Fence__, __Render__Process_SceneToRender);
static STg2_Job                             T_NAME(s_sFX__Job__, __Render__Process_SceneToRender);

static TgUINT08                             T_NAME(s_asFX_Command__, __SceneToRender)[ETgFX_COMMAND__SCENE_TO_RENDER__BYTE_MAX];
static TgATOMIC_SINT32                      T_NAME(s_uiFX_Command__, __SceneToRender_Offset);

static TgATOMIC_SINT32                      T_NAME(s_xiFX_Fence__, __Render__Generate);
static STg2_Job                             T_NAME(s_sFX__Job__, __Render__Generate);
/*# T_EFFECT_RENDER */
#endif

TgCOMPILER_ASSERT( sizeof( STg2_UTM_Node ) <= sizeof( T_NAME(STg2_FX__,) ), 0 );




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

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

    g_apsFX_Descriptor[T_TYPE( ETgFX__, )] = &T_NAME( s_sFX_Descriptor__, );

#if T_EFFECT_UPDATE || T_EFFECT_RENDER
    T_NAME(g_uiFX_Command__, __ToClient_Offset) = 0;
/*# T_EFFECT_UPDATE || T_EFFECT_RENDER */
#endif

    PROFILE_INIT( T_TYPE(FX_, _COMMANDS__UPDATE) );

#if T_EFFECT_UPDATE
    PROFILE_INIT( T_TYPE(FX_, _UPDATE__DATA) );
    PROFILE_INIT( T_TYPE(FX_, _UPDATE_EXTERNAL__DATA) );
/*# T_EFFECT_UPDATE */
#endif

#if T_EFFECT_RENDER
    PROFILE_INIT( T_TYPE(FX_, _RENDER_PATCH_CONTEXT) );
    PROFILE_INIT( T_TYPE(FX_, _RENDER_UPDATE) );
    PROFILE_INIT( T_TYPE(FX_, _RENDER_GENERATE) );
/*# T_EFFECT_RENDER */
#endif

#if TgS_DEBUG_EFFECT
    T_NAME(g_tiFX_Debug__, __Disable_Create) = tgCN_Var_Init_Bool( T_TEXT(TgT("Disable_Create_")),  TgT(""), KTgCN_VAR_CHEAT, TgFALSE );
    T_NAME(g_tiFX_Debug__, __Disable_Update) = tgCN_Var_Init_Bool( T_TEXT(TgT("Disable_Update_")), TgT(""), KTgCN_VAR_CHEAT, TgFALSE );
    T_NAME(g_tiFX_Debug__, __Disable_Scene_Cull) = tgCN_Var_Init_Bool( T_TEXT(TgT("Disable_Cull_")), TgT(""), KTgCN_VAR_CHEAT, TgFALSE );
    T_NAME(g_tiFX_Debug__, __Disable_Render) = tgCN_Var_Init_Bool( T_TEXT(TgT("Disable_Render_")), TgT(""), KTgCN_VAR_CHEAT, TgFALSE );
    T_NAME(g_tiFX_Debug__, __Draw_BA) = tgCN_Var_Init_Bool( T_TEXT(TgT("Draw_BA_")), TgT(""), KTgCN_VAR_CHEAT, TgFALSE );
    T_NAME(g_tiFX_Debug__, __Draw_Debug) = tgCN_Var_Init_Bool( T_TEXT(TgT("Draw_Debug_")), TgT(""), KTgCN_VAR_CHEAT, TgFALSE );
/*# TgS_DEBUG_EFFECT */
#endif

    T_NAME(s_sFX_Descriptor__,).m_enEffect = T_TYPE(ETgFX__,);
    T_NAME(s_sFX_Descriptor__,).m_enPrimitive = T_EFFECT_RENDER_PRIMITIVE_TYPE;
    T_NAME(s_sFX_Descriptor__,).m_uiMax = T_TYPE(KTgFX_MAX_,);

    for (iIndex = 0; iIndex < T_TYPE(KTgFX_MAX_,); ++iIndex)
    {
        T_NAME(g_aenFX__, __Shared__State)[iIndex] = ETgFX_EFFECT_STATE__CLIENT__FREE;
    };

    tgCM_UTM_AM_ST_Init( &T_NAME(g_sFX__, __Client__Stack).m_sStack );
    for (iIndex = T_TYPE(KTgFX_MAX_,) - 1; iIndex >= 0; --iIndex)
    {
        tgCM_UTM_AM_ST_Push( &T_NAME(g_sFX__, __Client__Stack).m_sStack, (P_STg2_UTM_Node)(T_NAME(g_asFX__,) + iIndex) );
    };

    T_NAME(s_uiFX__, __Shared__Notify_State) = 0;

#if T_EFFECT_UPDATE
    T_NAME(s_xiFX_Fence__, __Update) = 0;
    for (iIndex = 0; iIndex < ETgFX_UPDATE__MAX; ++iIndex)
    {
        memset( &T_NAME(s_sFX__Job__, __Update)[iIndex], 0, sizeof( STg2_Job ) );
    };

    T_NAME(s_xiFX_Fence__, __Update__Process_ClientToUpdate) = 0;
    memset( &T_NAME(s_sFX__Job__, __Update__Process_ClientToUpdate), 0, sizeof( STg2_Job ) );

    T_NAME(s_uiFX_Command__, __ClientToUpdate_Offset) = 0;
/*# T_EFFECT_UPDATE */
#endif

#if T_EFFECT_RENDER
    T_NAME(s_xiFX_Fence__, __Scene__Cull) = 0;
    for (iIndex = 0; iIndex < ETgFX_UPDATE__MAX; ++iIndex)
    {
        memset( &T_NAME(s_sFX__Job__, __Scene__Cull)[iIndex], 0, sizeof( STg2_Job ) );
    };

    T_NAME(s_xiFX_Fence__, __Render__Process_SceneToRender) = 0;
    memset( &T_NAME(s_sFX__Job__, __Render__Process_SceneToRender), 0, sizeof( STg2_Job ) );

    T_NAME(s_uiFX_Command__, __SceneToRender_Offset) = 0;

    T_NAME(s_xiFX_Fence__, __Render__Generate) = 0;
    memset( &T_NAME(s_sFX__Job__, __Render__Generate), 0, sizeof( STg2_Job ) );
/*# T_EFFECT_RENDER */
#endif
}


/* ---- tgFX__Client__, _Boot ------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID T_NAME(tgFX__Client__, _Boot)( TgVOID )
{

}


/* ---- tgFX__Client__, _Stop ------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID T_NAME(tgFX__Client__, _Stop)( TgVOID )
{
}


/* ---- tgFX__Client__, _Free ---------------------------------------    ------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID T_NAME(tgFX__Client__, _Free)( TgVOID )
{
}


/* ---- tgFX__Client__, _Query_Fixed_Memory ----------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE T_NAME(tgFX__Client__, _Query_Fixed_Memory)( TgVOID )
{
    return ( 0
    #if T_EFFECT_UPDATE || T_EFFECT_RENDER
        + sizeof( T_NAME(g_asFX_Command__, __ToClient) )
        + sizeof( T_NAME(g_uiFX_Command__, __ToClient_Offset) )
    /*# T_EFFECT_UPDATE || T_EFFECT_RENDER */
    #endif

    #if TgS_DEBUG_EFFECT
        + sizeof( T_NAME(g_tiFX_Debug__, __Disable_Create) )
        + sizeof( T_NAME(g_tiFX_Debug__, __Disable_Update) )
        + sizeof( T_NAME(g_tiFX_Debug__, __Disable_Scene_Cull) )
        + sizeof( T_NAME(g_tiFX_Debug__, __Disable_Render) )
        + sizeof( T_NAME(g_tiFX_Debug__, __Draw_BA) )
        + sizeof( T_NAME(g_tiFX_Debug__, __Draw_Debug) )
    /*# TgS_DEBUG_EFFECT */
    #endif

        + sizeof( T_NAME(s_sFX_Descriptor__,) )
        + sizeof( T_NAME(g_aenFX__, __Shared__State) )
        + sizeof( T_NAME(g_sFX__, __Client__Stack) )
        + sizeof( T_NAME(g_asFX__,) )
        + sizeof( T_NAME(s_uiFX__, __Shared__Notify_State) )

    #if T_EFFECT_UPDATE
        + sizeof( T_NAME(s_xiFX_Fence__, __Update) )
        + sizeof( T_NAME(s_sFX__Job__, __Update) )
        + sizeof( T_NAME(s_xiFX_Fence__, __Update__Process_ClientToUpdate) )
        + sizeof( T_NAME(s_sFX__Job__, __Update__Process_ClientToUpdate) )
        + sizeof( T_NAME(s_asFX_Command__, __ClientToUpdate) )
        + sizeof( T_NAME(s_uiFX_Command__, __ClientToUpdate_Offset) )
    /*# T_EFFECT_UPDATE */
    #endif

    #if T_EFFECT_RENDER
        + sizeof( T_NAME(s_xiFX_Fence__, __Scene__Cull) )
        + sizeof( T_NAME(s_sFX__Job__, __Scene__Cull) )
        + sizeof( T_NAME(s_xiFX_Fence__, __Render__Process_SceneToRender) )
        + sizeof( T_NAME(s_sFX__Job__, __Render__Process_SceneToRender) )
        + sizeof( T_NAME(s_asFX_Command__, __SceneToRender) )
        + sizeof( T_NAME(s_uiFX_Command__, __SceneToRender_Offset) )
        + sizeof( T_NAME(s_xiFX_Fence__, __Render__Generate) )
        + sizeof( T_NAME(s_sFX__Job__, __Render__Generate) )
    /*# T_EFFECT_RENDER */
    #endif
    );
}


/* ---- tgFX__Client__, _Create_Data_Inst ------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgFX_DATA_INST_ID T_NAME(tgFX__Client__, _Create_Data_Inst)( C_TgFX_CLIENT_INST_ID tiClient, CP_TgVOID pData_0, CPCU_STg2_FX_Instance psInstance )
{
    union
    {
        P_STg2_UTM_Node                     psNode;
        T_NAME(P_STg2_FX__,)                psEffect;
    }                                   sUnion;
    TgPTRDIFF                           iInstance;
    P_TgUINT08                          puiCommand_Stream;
    TgFX_DATA_INST_ID                   tiData;
    union
    {
        P_TgUINT08                          pui;
        P_STg2_FX_Command__Update__Create   ps;
    }                                   sCreate;
#if T_EFFECT_GROUP
    TgUINT08                            uiCommand[sizeof( STg2_FX_Command__Client__Create ) + 32];
/*# T_EFFECT_GROUP */
#endif

    TgPARAM_CHECK( g_uiFX_Command_Size[ETgFX_COMMAND__CLIENT_TO_UPDATE__CREATE] == sizeof( STg2_FX_Instance ) );
    TgPARAM_CHECK( sizeof( TgUINT64 ) == sizeof( TgFX_DATA_INST_ID ) );

#if TgS_DEBUG_EFFECT
    {
        TgBOOL                              bDisable;
        if ((TgTRUE == tgCN_Var_Query_Bool( &bDisable, T_NAME(g_tiFX_Debug__, __Disable_Create) )) && (TgTRUE == bDisable))
        {
            return (KTgFX_DATA_INST_ID__INVALID);
        };
    }
/*# TgS_DEBUG_EFFECT */
#endif

    sUnion.psNode = tgCM_UTM_AM_ST_Pop( &T_NAME(g_sFX__, __Client__Stack).m_sStack );
    if (nullptr == sUnion.psEffect)
    {
        return (KTgFX_DATA_INST_ID__INVALID);
    };

    iInstance = sUnion.psEffect - T_NAME(g_asFX__,);

    TgERROR( ETgFX_EFFECT_STATE__CLIENT__FREE == T_NAME(g_aenFX__, __Shared__State)[iInstance] );

#if T_EFFECT_GROUP
    TgPARAM_CHECK( g_uiFX_Command_Size[ETgFX_COMMAND__CLIENT_TO_UPDATE__CREATE] < sizeof( uiCommand ) );
    puiCommand_Stream = uiCommand + ((TgUINTPTR)uiCommand + 15) % 16;
/*# T_EFFECT_GROUP */
#else
    puiCommand_Stream = T_NAME(tgFX_, __Reserve_Update_Command)( ETgFX_COMMAND__CLIENT_TO_UPDATE__CREATE );
    if (!puiCommand_Stream)
    {
        TgWARNING_MSGF( 0, TgT( "%-16.16s(%-32.32s): Failed allocation in Client to Update command stream.  Create command lost.\n" ), TgT("Effect"),
                        TgTO_TEXT( T_NAME(tgFX__, __Client__Create_Update) ) );
        tgCM_UTM_AM_ST_Push( &T_NAME(g_sFX__, __Client__Stack).m_sStack, sUnion.psNode );
        tgAM_WRITE_FENCE();
        return (KTgFX_DATA_INST_ID__INVALID);
    }
/*# T_EFFECT_GROUP */
#endif

    tgInit_FX_DATA_INST_ID( &tiData, (TgSINT32)iInstance );
    T_NAME(g_aenFX__, __Shared__State)[iInstance] = ETgFX_EFFECT_STATE__CLIENT__RESERVED;
    tgAM_WRITE_FENCE();

    sCreate.pui = puiCommand_Stream;

    sCreate.ps->m_enCommand = ETgFX_COMMAND__CLIENT_TO_UPDATE__CREATE;
    sCreate.ps->m_tiData = tiData;
    sCreate.ps->m_tiClient = tiClient;
    sCreate.ps->m_psFile_Data_0 = pData_0;
    /* #FIX sCreate.ps->m_psFile_Data_1 = pData_1; */
    TgMEMCPY( &sCreate.ps->m_sInstance, sizeof( sCreate.ps->m_sInstance ), psInstance, sizeof( STg2_FX_Instance ) );
    
#if T_EFFECT_GROUP
    T_NAME(tgFX__Update__, _Process_Update_Command_Buffer)( puiCommand_Stream, 0 );
    if (TgTRUE == tgEQ_FX_DATA_INST_ID( T_NAME(g_asFX__,)[tiData.m.iI].m_tiData, tiData ))
        return (tiData);
    return (KTgFX_DATA_INST_ID__INVALID);
    /*# T_EFFECT_GROUP */
#else
    return (tiData);
    /*# T_EFFECT_GROUP */
#endif
}




#undef T_EFFECT_PROCESS_COMMMAND_DEFAULT
#undef T_EFFECT_PROCESS_COMMMAND
#undef T_EFFECT_FRAME
#undef T_EFFECT_TIME_DEFAULT
#undef T_EFFECT_TIME
#undef T_EFFECT_NOTIFY
#undef T_EFFECT_GROUP
#undef T_EFFECT_RENDER_PRIMITIVE_TYPE
#undef T_EFFECT_RENDER
#undef T_EFFECT_SCENE
#undef T_EFFECT_UPDATE

#undef T_TEXT
#undef T_TYPE
#undef T_NAME