Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Kernel - Resource [GPU] [Shader] [CS].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)

#define T( A, ... ) A##CS##__VA_ARGS__
#include "TgS Kernel - Resource [GPU].c_inc"
#undef T


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

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

/* ---- tgKN_GPU_CS__Load_BIN_Internal ---------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgUINTXX tgKN_GPU_CS__Load_BIN_Internal(
    C_TgKN_FILE_ID tiFile, C_TgSIZE uiFile_Offset, C_ETgKN_GPU_ALLOCATOR enAllocator, PCU_STg2_KN_GPU_RS_LIB_DESC pLibRS, C_TgUINTXX uiHash_RS, C_TgSIZE uiIndex )
{
    TgBOOL                              bResult;

    TgPARAM_CHECK(TgTRUE == tgKN_FILE_ID_Is_Valid( tiFile ));
    TgPARAM_CHECK(uiHash_RS != KTgEMPTY_HASH);
    TgPARAM_CHECK(pLibRS == &g_sKN_Lib_CS_DESC);
    TgPARAM_CHECK_INDEX(uiIndex, g_asKN_Lib_CS_Data);
    TgPARAM_CHECK(ETgKN_GPU_ALLOCATOR__INVALID != enAllocator);

    g_asKN_Lib_CS_Data[uiIndex].m_sSH.m_pUCode = 0;
    g_asKN_Lib_CS_Data[uiIndex].m_sSH.m_pHW = 0;
    g_asKN_Lib_CS_Data[uiIndex].m_sSH.m_pData = 0;
    g_asKN_Lib_CS_Data[uiIndex].m_sSH.m_enAllocator = enAllocator;

#if TgS_STAT_KERNEL || TgS_DEBUG_KERNEL
    g_uiKN_Size_GPU_CS[uiIndex] = 0;
#endif

    bResult = tgKN_GPU_PM_CS__Init( pLibRS, uiIndex, enAllocator, uiHash_RS, tiFile, uiFile_Offset );

    /* Check for failure, and return the id to the usage pool before returning with an error state */
    if (TgFALSE == bResult)
    {
        tgCN_PrintF( KTgCN_CHANEL_WARNING, TgT( "%-16.16s(%-32.32s): [Warn] %-57.57s\n" ), TgT("Kernel"), TgT( "tgKN_GPU_CS__Load_BIN_Internal" ),
                     TgT( "Failed to initialize compute shader" ) );
        pLibRS->m_ptiRS[uiIndex] = KTgKN_GPU_RS_ID__INVALID;
        return (KTgEMPTY_HASH);
    };

#if TgS_DEBUG_KERNEL
    tgCN_PrintF( KTgCN_CHANEL_LOADING, TgT( "%-16.16s(%-32.32s): [Load] %-32.32s         | id(% 4d) | % -9d BY\n" ), TgT("Kernel"), TgT("tgKN_GPU_CS__Load_BIN_Internal"),
                 TgT(""), uiIndex, g_szKN_GPU_CS[uiIndex] );
#endif

#if TgS_STAT_KERNEL || TgS_DEBUG_KERNEL
    pLibRS->m_uiSize += g_uiKN_Size_GPU_CS[uiIndex];
#endif

    g_aiKN_Lib_CS_Ref[uiIndex] = 1;
    return (uiHash_RS);
}


/*# defined(TgCOMPILE_GPU_SUPPORT) */
#endif