Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Kernel - Resource [GPU] [LIB].c
    »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".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
#if defined(TgCOMPILE_GPU_SUPPORT)

/* == Kernel ============================================================================================================================================================ */


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

/* ---- tgKN_GPU_CXT_DATA__Init ----------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgKN_GPU_CXT_DATA__Init( C_TgKN_GPU_CXT_DATA_ID tiCXT_DATA )
{
    P_STg2_KN_GPU_Context__External     psCxt_Ext;

    TgERROR( tiCXT_DATA.m.iI >= 0 && tiCXT_DATA.m.iI < KTgKN_GPU_MAX_RESOURCE_CONTEXT );

    tgKN_GPU_CS_Inst_LIB__Init( tiCXT_DATA.m.iI );
    tgKN_GPU_HS_Inst_LIB__Init( tiCXT_DATA.m.iI );
    tgKN_GPU_DS_Inst_LIB__Init( tiCXT_DATA.m.iI );
    tgKN_GPU_GS_Inst_LIB__Init( tiCXT_DATA.m.iI );
    tgKN_GPU_PS_Inst_LIB__Init( tiCXT_DATA.m.iI );

    /*tgKN_GPU_IL_LIB__Init( tiCXT_DATA.m.iI ); */

    tgKN_GPU_TX_IMG_Inst_LIB__Init( tiCXT_DATA.m.iI );
    tgKN_GPU_TX_CBE_Inst_LIB__Init( tiCXT_DATA.m.iI );
    tgKN_GPU_TX_VOL_Inst_LIB__Init( tiCXT_DATA.m.iI );

    psCxt_Ext = g_asKN_GPU_Context_External + tiCXT_DATA.m.iI;

    /*  **VALID** in Release/Final Build */
    psCxt_Ext->m_tiTX_IMG_Black = tgKN_GPU_TX_IMG_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_BLACK") ), KTg_BLACK_709_U32, TgT("LIB_BLACK") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_IMG_Black ) );

    psCxt_Ext->m_tiTX_IMG_White = tgKN_GPU_TX_IMG_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_WHITE") ), KTg_WHITE_709_U32, TgT("LIB_WHITE") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_IMG_White ) );

    psCxt_Ext->m_tiTX_IMG_Red = tgKN_GPU_TX_IMG_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_RED") ), KTg_RED_709_U32, TgT("LIB_RED") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_IMG_Red ) );

    psCxt_Ext->m_tiTX_IMG_Green = tgKN_GPU_TX_IMG_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_GREEN") ), KTg_GREEN_709_U32, TgT("LIB_GREEN") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_IMG_Green ) );

    psCxt_Ext->m_tiTX_IMG_Blue = tgKN_GPU_TX_IMG_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_BLUE") ), KTg_BLUE_709_U32, TgT("LIB_BLUE") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_IMG_Blue ) );

    psCxt_Ext->m_tiTX_IMG_Yellow = tgKN_GPU_TX_IMG_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_YELLOW") ), KTg_YELLOW_709_U32, TgT("LIB_YELLOW") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_IMG_Yellow ) );

    psCxt_Ext->m_tiTX_IMG_Magenta = tgKN_GPU_TX_IMG_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_MAGENTA") ), KTg_MAGENTA_709_U32, TgT("LIB_MAGENTA") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_IMG_Magenta ) );

    psCxt_Ext->m_tiTX_IMG_Cyan = tgKN_GPU_TX_IMG_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_CYAN") ), KTg_CYAN_709_U32, TgT("LIB_CYAN") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_IMG_Cyan ) );

    psCxt_Ext->m_tiTX_VOL_Black = tgKN_GPU_TX_VOL_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_BLACK") ), KTg_BLACK_709_U32, TgT("LIB_BLACK") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_VOL_Black ) );

    psCxt_Ext->m_tiTX_VOL_White = tgKN_GPU_TX_VOL_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_WHITE") ), KTg_WHITE_709_U32, TgT("LIB_WHITE") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_VOL_White ) );

    psCxt_Ext->m_tiTX_CBE_Black = tgKN_GPU_TX_CBE_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_BLACK") ), KTg_BLACK_709_U32, TgT("LIB_BLACK") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_CBE_Black ) );

    psCxt_Ext->m_tiTX_CBE_White = tgKN_GPU_TX_CBE_Inst__Init_Colour( tiCXT_DATA, tgSZ_Hash( TgT("LIB_WHITE") ), KTg_WHITE_709_U32, TgT("LIB_WHITE") );
    TgVERIFY( tgKN_GPU_RSI_ID_Is_Valid( psCxt_Ext->m_tiTX_CBE_White ) );
}


/* ---- tgKN_GPU_CXT_DATA__Free ----------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgKN_GPU_CXT_DATA__Free( C_TgKN_GPU_CXT_DATA_ID tiCXT_DATA )
{
    TgPARAM_CHECK_INDEX( tiCXT_DATA.m.iI, g_asKN_GPU_Context_External );

    /* Release all of the default textures. */

    tgKN_GPU_TX_VOL_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_VOL_White );
    tgKN_GPU_TX_VOL_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_VOL_Black );

    tgKN_GPU_TX_CBE_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_CBE_White );
    tgKN_GPU_TX_CBE_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_CBE_Black );

    tgKN_GPU_TX_IMG_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_IMG_Cyan );
    tgKN_GPU_TX_IMG_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_IMG_Magenta );
    tgKN_GPU_TX_IMG_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_IMG_Yellow );
    tgKN_GPU_TX_IMG_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_IMG_Blue );
    tgKN_GPU_TX_IMG_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_IMG_Green );
    tgKN_GPU_TX_IMG_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_IMG_Red );
    tgKN_GPU_TX_IMG_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_IMG_White );
    tgKN_GPU_TX_IMG_Inst__Release( g_asKN_GPU_Context_External[tiCXT_DATA.m.iI].m_tiTX_IMG_Black );

    tgKN_GPU_TX_VOL_Inst_LIB__Free( tiCXT_DATA.m.iI );
    tgKN_GPU_TX_CBE_Inst_LIB__Free( tiCXT_DATA.m.iI );
    tgKN_GPU_TX_IMG_Inst_LIB__Free( tiCXT_DATA.m.iI );

    tgKN_GPU_PS_Inst_LIB__Free( tiCXT_DATA.m.iI );
    tgKN_GPU_GS_Inst_LIB__Free( tiCXT_DATA.m.iI );
    tgKN_GPU_DS_Inst_LIB__Free( tiCXT_DATA.m.iI );
    tgKN_GPU_HS_Inst_LIB__Free( tiCXT_DATA.m.iI );
    tgKN_GPU_CS_Inst_LIB__Free( tiCXT_DATA.m.iI );

    /*tgKN_GPU_IL_LIB__Free( tiCXT_DATA.m.iI ); */
}


/*# defined(TgCOMPILE_GPU_SUPPORT) */
#endif