Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Kernel.h
    »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(TGS_KERNEL_H)
#define TGS_KERNEL_H
#pragma once

#if !defined(TGS_PLATFORM_KERNEL_H)
#error This file should not be included directly - use the correct platform include wrapper
#endif

#include "TgS KERNEL/TgS Kernel - Constants.h"
#include "TgS KERNEL/TgS Kernel - Type.h"
#include "TgS KERNEL/TgS Kernel - Data.h"


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

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Module Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgEXTN TgVOID                               tgKN_Unit_Test_External( TgVOID ); /* Do not ever execute */

TgEXTN TgRESULT                             tgKN_Module_Init( TgVOID );
TgEXTN TgRESULT                             tgKN_Module_Boot( TgVOID );
TgEXTN TgVOID                               tgKN_Module_Stop( TgVOID );
TgEXTN TgVOID                               tgKN_Module_Free( TgVOID );
TgEXTN TgRESULT                             tgKN_Module_Update( C_TgFLOAT32 );

TgEXTN TgVOID                               tgKN_Load_Config( TgVOID );
TgEXTN TgVOID                               tgKN_Save_Config( TgVOID );

TgEXTN TgBOOL                               tgKN_Query_Init( TgVOID );
TgEXTN TgBOOL                               tgKN_Query_Boot( TgVOID );
TgEXTN TgSIZE                               tgKN_Query_Fixed_Memory( TgVOID );

#if TgS_STAT_KERNEL
TgEXTN TgVOID                               tgKN_Stats( P_STg2_Output );
#endif


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Kernel Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* -- Message System ---------------------------------------------------------------------------------------------------------------------------------------------------- */

TgEXTN TgKN_NOTIFY_ID                       tgKN_Notify_Start( TgKN_FCN_NOTIFY_CALLBACK, C_TgUINTPTR, TgUINT32 );
TgEXTN TgRESULT                             tgKN_Notify_End( C_TgKN_NOTIFY_ID );
TgEXTN TgRESULT                             tgKN_Notify_MSG( C_TgUINT32, C_TgUINT32, C_TgUINT32 );

/* -- File Functions ---------------------------------------------------------------------------------------------------------------------------------------------------- */

TgEXTN TgKN_FS_MOUNT_ID                     tgKN_File_System_Mount( C_TgKN_FILE_SYSTEM_ID, C_ETgFILE_IO_ACCESS, CPCU_TgCHAR );
TgEXTN TgUINT32                             tgKN_FS_Query_Free_Space( C_TgKN_FS_MOUNT_ID ); /* #IMPLEMENT */
TgEXTN  P_TgVOID                            tgKN_FILE_ALLOCATOR__Default_Malloc_Pool( C_TgSIZE );

                                            /* Blocking File System Functions. */
                                            /*   These will be executed out of order from the other commands, as a highest order */
                                            /*   request.  If the desire behavior is to stall until the operations are completed */
                                            /*   in the job list as well, then use a custom call back function in a job operation */
TgEXTN TgKN_FILE_ID                         tgKN_FS_BL_Open( CPCU_STg2_KN_File_Open_Command );
TgEXTN TgRESULT                             tgKN_FS_BL_Read( PCU_STg2_KN_File_Read_Command );
TgEXTN TgRESULT                             tgKN_FS_BL_Cache( CPCU_STg2_KN_File_Cache_Command );
TgEXTN TgRESULT                             tgKN_FS_BL_Write( PCU_STg2_KN_File_Write_Command );
TgEXTN TgRESULT                             tgKN_FS_BL_Flush( C_TgKN_FILE_ID );
TgEXTN TgRESULT                             tgKN_FS_BL_Close( C_TgKN_FILE_ID );

                                            /* Job File System Functions. */
TgEXTN TgKN_FILE_JOB_ID                     tgKN_FS_JB_Read( CPCU_STg2_KN_File_Read_Command );
TgEXTN TgKN_FILE_JOB_ID                     tgKN_FS_JB_Cache( CPCU_STg2_KN_File_Cache_Command );
TgEXTN TgKN_FILE_JOB_ID                     tgKN_FS_JB_Write( CPCU_STg2_KN_File_Write_Command );
TgEXTN TgKN_FILE_JOB_ID                     tgKN_FS_JB_Flush( C_TgKN_FILE_ID );
TgEXTN TgKN_FILE_JOB_ID                     tgKN_FS_JB_Close( C_TgKN_FILE_ID );

TgEXTN TgVOID                               tgKN_FS_JB_Cancel( C_TgKN_FILE_JOB_ID );
TgEXTN ETgKN_IO_STATUS                      tgKN_FS_JB_Status( C_TgKN_FILE_JOB_ID );

#if TgS_STAT_COMMON
TgEXTN TgVOID                               tgKN_FS_Stats( PC_STg2_Output );  /* #IMPLEMENT */ /* AA: IMPLEMENT */
#endif

/* -- File Data Handling ------------------------------------------------------------------------------------------------------------------------------------------------ */

/* #IMPLEMENT DATA PACK READING AND LOADING */
TgEXTN TgRESULT                             tgKN_File__Decrement_Reference( C_TgKN_FILE_ID ); /* #IMPLEMENT */


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Kernel GPU Functions                                                                                                                                                  */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
#if defined(TgCOMPILE_GPU_SUPPORT)

TgEXTN TgRESULT                             tgKN_GPU_Enumerate( TgVOID );  /* #IMPLEMENT */

TgEXTN TgRESULT                             tgKN_GPU_Load_Config( TgVOID );
TgEXTN TgRESULT                             tgKN_GPU_Save_Config( TgVOID );

TgEXTN TgRESULT                             tgKN_GPU_Query_Adapter_List( PP_TgCHAR, C_TgSINT32 );
TgEXTN TgRESULT                             tgKN_GPU_Query_Output_List( C_TgSINT32, PP_TgCHAR, C_TgSINT32 );
TgEXTN TgRESULT                             tgKN_GPU_Query_Output_ScanOut_Format_Support( C_TgSINT32, C_TgSINT32, C_ETgKN_GPU_TARGET );
TgEXTN TgSINT32                             tgKN_GPU_Query_Mode_List( P_STg2_KN_GPU_Mode, C_TgSINT32, C_TgSINT32, C_TgSINT32, C_ETgKN_GPU_TARGET );

TgEXTN TgRESULT                             tgKN_GPU_Select_Context__Init_From_Config( P_STg2_KN_GPU_Select );
TgEXTN TgRESULT                             tgKN_GPU_Select_Context__Validate( P_STg2_KN_GPU_Select );

TgEXTN TgRESULT                             tgKN_GPU_Select_Context( PCU_STg2_KN_GPU_Select );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_CXT_ID                      tgKN_GPU_Context__Init( CPCU_STg2_KN_GPU_Select );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_Context__Free( C_TgKN_GPU_CXT_ID );  /* #IMPLEMENT */


/* -- Resource - GPU - Shader ------------------------------------------------------------------------------------------------------------------------------------------- */
/* Resource instances are bound to a specific render resource context.  A single copy of the raw resource is stored in global */
/* memory.  Depending on the platform, instances of the resource may have context specific copies or it may be shared. */

#if !defined(TgS_FINAL)
                                            /* Load BIN - Create a new shader with the given data. If a shader already exists with the resulting hash value, the given */
                                            /* data stream will not be processed and the existing id will be returned. */
                                            /* 1: FS Mount - Kernel File Mount location for the file. */
                                            /* 2: Path - Relative path location for the file. */
                                            /* 2: File - File name - used as resource name. */
                                            /* 3: Allocator - Memory allocation method used for the resource. */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_VS__File_Load( C_TgKN_FS_MOUNT_ID, CPC_TgCHAR, CPC_TgCHAR, C_ETgKN_GPU_ALLOCATOR );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_DS__File_Load( C_TgKN_FS_MOUNT_ID, CPC_TgCHAR, CPC_TgCHAR, C_ETgKN_GPU_ALLOCATOR );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_GS__File_Load( C_TgKN_FS_MOUNT_ID, CPC_TgCHAR, CPC_TgCHAR, C_ETgKN_GPU_ALLOCATOR );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_HS__File_Load( C_TgKN_FS_MOUNT_ID, CPC_TgCHAR, CPC_TgCHAR, C_ETgKN_GPU_ALLOCATOR );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_PS__File_Load( C_TgKN_FS_MOUNT_ID, CPC_TgCHAR, CPC_TgCHAR, C_ETgKN_GPU_ALLOCATOR );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_CS__File_Load( C_TgKN_FS_MOUNT_ID, CPC_TgCHAR, CPC_TgCHAR, C_ETgKN_GPU_ALLOCATOR );  /* #IMPLEMENT */
/*# !defined(TgS_FINAL) */
#endif
                                            /* Load BIN - Create a new shader with the given data. If a shader already exists with the resulting hash value, the given */
                                            /* data stream will not be processed and the existing id will be returned. */
                                            /* 1: File - The file associated with the resource. */
                                            /* 2: Offset - Offset into the file to begin loading. */
                                            /* 3: Allocator - Memory allocation method used for the resource. */
                                            /* 4: Name Hash - Hash of the unique name (key) for this resource. */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_VS__Load( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_DS__Load( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_GS__Load( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_HS__Load( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_PS__Load( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_CS__Load( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX );  /* #IMPLEMENT */

                                            /* This operation is specific to the render context that owns the instance id. */
                                            /* 0: Context for shader instance to be reference incremented (-1 for source context) */
                                            /* 1: Source shader */
                                            /* R: Shader Instance - instance id in parameter context, otherwise the invalid id */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_DS_Inst__Init( C_TgKN_GPU_CXT_DATA_ID, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_GS_Inst__Init( C_TgKN_GPU_CXT_DATA_ID, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_HS_Inst__Init( C_TgKN_GPU_CXT_DATA_ID, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_PS_Inst__Init( C_TgKN_GPU_CXT_DATA_ID, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_CS_Inst__Init( C_TgKN_GPU_CXT_DATA_ID, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */

                                            /* 1: Shader ID */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_DS_Inst__IncRef( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_GS_Inst__IncRef( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_HS_Inst__IncRef( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_PS_Inst__IncRef( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_CS_Inst__IncRef( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */

                                            /* 0: Render Context */
                                            /* 1: Hash - Unique hash of a shader resource */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_DS_Inst__Hash_Find_And_IncRef( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_GS_Inst__Hash_Find_And_IncRef( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_HS_Inst__Hash_Find_And_IncRef( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_PS_Inst__Hash_Find_And_IncRef( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_CS_Inst__Hash_Find_And_IncRef( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX );  /* #IMPLEMENT */

                                            /* Release - Decrements the reference count of the shader instance in the render parent render context.  Once the count */
                                            /* reaches zero the shader data resource will be released.  If it reaches zero the shader data will be unloaded, with the */
                                            /* exception of the default shaders created by the system those will only unload when the render system stops. */
                                            /* 0: Shader ID - System ID value for a shader */
                                            /* R: RefCount - the decremented reference count value */
TgEXTN TgSINT32                             tgKN_GPU_DS_Inst__Release( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgSINT32                             tgKN_GPU_GS_Inst__Release( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgSINT32                             tgKN_GPU_HS_Inst__Release( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgSINT32                             tgKN_GPU_PS_Inst__Release( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgSINT32                             tgKN_GPU_CS_Inst__Release( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */

/* -- Resource - GPU Input ---------------------------------------------------------------------------------------------------------------------------------------------- */

TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_VT_Register( CPCU_STg2_KN_GPU_VT_Element, C_TgSINT32, CPCU_TgCHAR );  /* #IMPLEMENT */
TgEXTN TgSINT32                             tgKN_GPU_VT_Release( C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */

TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_IL_Init( C_TgKN_GPU_CXT_DATA_ID, C_TgKN_GPU_RS_ID, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_IL_Hash_Init( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_IL_IncRef( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgSINT32                             tgKN_GPU_IL_Release( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */

/* -- Resource - GPU - Texture ------------------------------------------------------------------------------------------------------------------------------------------ */
/* Resource instances are bound to a specific render resource context. A single copy of the raw resource is stored in global memory. Depending on the platform, instances */
/* of the resource may have context specific copies or it may be shared. */

                                            /* Load Texture - Create a new texture id with the given data. Return an instance if the unique name is found in the library. */
                                            /* Allocation type is ignored when checking load status for instance creation.   Thus, it is not possible to alter the */
                                            /* allocation type of a texture resource once it has been loaded. */
#if !defined(TgS_FINAL)
                                            /* 1: FS Mount - Kernel File Mount location for the file. */
                                            /* 2: Path - Relative path location for the file. */
                                            /* 2: File - File name - used as resource name. */
                                            /* 3: Allocator - Memory allocation method used for the resource. */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_TX_IMG__File_Load( C_TgKN_FS_MOUNT_ID, CPC_TgCHAR, CPC_TgCHAR, C_ETgKN_GPU_ALLOCATOR );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_TX_CBE__File_Load( C_TgKN_FS_MOUNT_ID, CPC_TgCHAR, CPC_TgCHAR, C_ETgKN_GPU_ALLOCATOR );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_TX_VOL__File_Load( C_TgKN_FS_MOUNT_ID, CPC_TgCHAR, CPC_TgCHAR, C_ETgKN_GPU_ALLOCATOR );  /* #IMPLEMENT */
/* !defined(TgS_FINAL) */
#endif
                                            /* 1: File - The file associated with the resource. */
                                            /* 2: Offset - Offset into the file to begin loading. */
                                            /* 3: Allocator - Memory allocation method used for the resource. */
                                            /* 4: Name Hash - Hash of the unique name (key) for this resource. */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_TX_IMG__Load( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_TX_CBE__Load( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RS_ID                       tgKN_GPU_TX_VOL__Load( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX );  /* #IMPLEMENT */

                                            /* Instance_Texture - Return a new texture id for the given parameter. If the resource is found in the library, the reference */
                                            /* count will be increased and a new texture id will be reserved.  If the resource is not found, then the invalid texture id */
                                            /* is returned. */

TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_IMG_Inst__Init( C_TgKN_GPU_CXT_DATA_ID, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_CBE_Inst__Init( C_TgKN_GPU_CXT_DATA_ID, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_VOL_Inst__Init( C_TgKN_GPU_CXT_DATA_ID, C_TgKN_GPU_RS_ID );  /* #IMPLEMENT */

                                            /* 1: Texture ID */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_IMG_Inst__IncRef( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_CBE_Inst__IncRef( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_VOL_Inst__IncRef( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */

                                            /* 0: Render Context */
                                            /* 1: Hash - Unique hash of a texture resource.  This corresponds to an unique texture name.  It is assumed and verified */
                                            /* during load that there are no hash collisions.  The invalid texture id is returned if the hash is not found. */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_IMG_Inst__Hash_Find_And_IncRef( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_CBE_Inst__Hash_Find_And_IncRef( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_VOL_Inst__Hash_Find_And_IncRef( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX );  /* #IMPLEMENT */

                                            /* Release Texture Resource - If the reference count reaches zero then the resource will be safely queued for deletion. This */
                                            /* may take a couple of frames to guarantee that it is not in the GPU command buffer. */
TgEXTN TgSINT32                             tgKN_GPU_TX_IMG_Inst__Release( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgSINT32                             tgKN_GPU_TX_CBE_Inst__Release( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */
TgEXTN TgSINT32                             tgKN_GPU_TX_VOL_Inst__Release( C_TgKN_GPU_RSI_ID );  /* #IMPLEMENT */

                                            /* Used to create the default textures - made minimally small (4x4) */
                                            /* 0: Render Context */
                                            /* 1: Hash */
                                            /* 2: Colour */
                                            /* 2: Name - used for debug purposes (stored only when render debug is true) */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_IMG_Inst__Init_Colour( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX, C_TgCOLOUR32, CPCU_TgCHAR );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_CBE_Inst__Init_Colour( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX, C_TgCOLOUR32, CPCU_TgCHAR );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_VOL_Inst__Init_Colour( C_TgKN_GPU_CXT_DATA_ID, C_TgUINTXX, C_TgCOLOUR32, CPCU_TgCHAR );  /* #IMPLEMENT */

                                            /* tgKN_GPU_TX_Init_TX_IMG - Create a 1D-2D texture */
                                            /* tgKN_GPU_TX_Init_TX_VOL - Create a 3D texture */
                                            /* tgKN_GPU_TX_Init_TX_CUBE - Create a cube texture */
                                            /* tgKN_GPU_TX_Init_RT_IMG - Create a target for render-to-texture support. The code base will select the target format that */
                                            /* best matches the render pipeline for the given texture format.  Size must not be greater than primary buffer */

                                            /* 0: Render Context */
                                            /* 1: Allocator - On relevant platforms, what memory / access is needed. */
                                            /* 2: Hash - Must be a unique hash value for the texture system */
                                            /* 3: Texture Format */
                                            /* 4: MIP - Skipped when creating render targets */
                                            /* 5: Width (Edge) */
                                            /* 6: Height */
                                            /* 7: Depth */
                                            /* R: Texture ID - may be invalid */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_IMG_Inst__Create( C_TgKN_GPU_CXT_DATA_ID, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX, C_ETgKN_GPU_FORMAT, C_TgSINT32, C_TgSINT32, C_TgSINT32 );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_CBE_Inst__Create( C_TgKN_GPU_CXT_DATA_ID, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX, C_ETgKN_GPU_FORMAT, C_TgSINT32, C_TgSINT32 );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_TX_VOL_Inst__Create( C_TgKN_GPU_CXT_DATA_ID, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX, C_ETgKN_GPU_FORMAT,  C_TgSINT32, C_TgSINT32, C_TgSINT32, C_TgSINT32 );  /* #IMPLEMENT */
TgEXTN TgKN_GPU_RSI_ID                      tgKN_GPU_RT_IMG__Create( C_TgKN_GPU_CXT_DATA_ID, C_ETgKN_GPU_ALLOCATOR, C_TgUINTXX, C_ETgKN_GPU_FORMAT, C_TgSINT32, C_TgSINT32 );  /* #IMPLEMENT */


TgEXTN TgVOID                               tgKN_GPU_PM_TX_IMG__Fast_Lock( PCU_STg2_KN_GPU_TX_Surface, C_TgKN_GPU_RSI_ID, C_TgUINT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_TX_IMG__Lock( PCU_STg2_KN_GPU_TX_Surface, C_TgKN_GPU_RSI_ID, C_TgUINT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_TX_IMG__Fast_Unlock( C_TgKN_GPU_RSI_ID, C_TgUINT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_TX_IMG__Unlock( C_TgKN_GPU_RSI_ID, C_TgUINT32 );  /* #IMPLEMENT */

TgEXTN TgVOID                               tgKN_GPU_PM_TX_CBE__Fast_Lock( PCU_STg2_KN_GPU_TX_Surface, C_TgKN_GPU_RSI_ID, C_TgUINT32, C_ETgKN_GPU_TX_CUBE_FACE );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_TX_CBE__Lock( PCU_STg2_KN_GPU_TX_Surface, C_TgKN_GPU_RSI_ID, C_TgUINT32, C_ETgKN_GPU_TX_CUBE_FACE );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_TX_CBE__Fast_Unlock( C_TgKN_GPU_RSI_ID, C_TgUINT32, C_ETgKN_GPU_TX_CUBE_FACE );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_TX_CBE__Unlock( C_TgKN_GPU_RSI_ID, C_TgUINT32, C_ETgKN_GPU_TX_CUBE_FACE );  /* #IMPLEMENT */

TgEXTN TgVOID                               tgKN_GPU_PM_TX_VOL__Fast_Lock( PCU_STg2_KN_GPU_TX_Surface, C_TgKN_GPU_RSI_ID, C_TgUINT32, C_TgSINT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_TX_VOL__Lock( PCU_STg2_KN_GPU_TX_Surface, C_TgKN_GPU_RSI_ID, C_TgUINT32, C_TgSINT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_TX_VOL__Fast_Unlock( C_TgKN_GPU_RSI_ID, C_TgUINT32, C_TgSINT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_TX_VOL__Unlock( C_TgKN_GPU_RSI_ID, C_TgUINT32, C_TgSINT32 );  /* #IMPLEMENT */

TgEXTN CP_TgCHAR                            tgKN_GPU_PM_Target_To_String( C_ETgKN_GPU_TARGET );  /* #IMPLEMENT */

/* -- Resource - GPU - Streams ------------------------------------------------------------------------------------------------------------------------------------------ */
/* Resource instances are bound to a specific render resource context. A single copy of the raw resource is stored in global memory. Depending on the platform, instances */
/* of the resource may have context specific copies or it may be shared. */

/* -- GPU - State ------------------------------------------------------------------------------------------------------------------------------------------------------- */

                                            /* tgKN_GPU_Reset_State_Context - Reset the entire state context */
                                            /* 0: State Context Index */
TgEXTN TgVOID                               tgKN_GPU_Reset_State_Context( C_TgSINT32 );  /* #IMPLEMENT */

                                            /* tgKN_GPU_Reset_Shader_Cache - Reset all of the current shader cache values. */
                                            /* 0: State Context Index */
TgEXTN TgVOID                               tgKN_GPU_Reset_Shader_Cache( C_TgSINT32 );  /* #IMPLEMENT */

                                            /* tgKN_GPU_Reset_SM_Cache - Reset the cache holding the current shaders. */
                                            /* 0: State Context Index */
TgEXTN TgVOID                               tgKN_GPU_Reset_SM_Cache( C_TgSINT32 );  /* #IMPLEMENT */

                                            /* tgKN_GPU_Reset_VS_Cache - Reset the vertex program constant cache. */
                                            /* 0: State Context Index */
TgEXTN TgVOID                               tgKN_GPU_Reset_VS_Cache( C_TgSINT32 );  /* #IMPLEMENT */

                                            /* tgKN_GPU_Reset_PS_Cache - Reset the fragment program constant cache. */
                                            /* 0: State Context Index */
TgEXTN TgVOID                               tgKN_GPU_Reset_PS_Cache( C_TgSINT32 );  /* #IMPLEMENT */

                                            /* tgKN_GPU_Set_Render_State - Set an individual state.  This is primarily used as an */
                                            /* abstract way to override states outside of that platform state block system.  It */
                                            /* should rarely (never) be used. */
                                            /* 0: State Context Index */
                                            /* 1: State Index */
                                            /* 2: New Value */
TgEXTN TgVOID                               tgKN_GPU_Set_Render_State( C_TgSINT32, C_TgSINT32, C_TgUINT32 );  /* #IMPLEMENT */

                                            /* tgKN_GPU_Query_Render_State - Find the current shadow value of a render state */
                                            /* 0: State Context Index */
                                            /* 1: State Index */
TgEXTN TgUINT32                             tgKN_GPU_Query_Render_State( C_TgSINT32, C_TgSINT32 );  /* #IMPLEMENT */

TgEXTN TgVOID                               tgKN_GPU_PM_Set_RS_Opaque( C_TgSINT32, C_TgFLOAT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_Set_RS_Blend( C_TgSINT32, C_TgFLOAT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_Set_RS_Multiply( C_TgSINT32, C_TgFLOAT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_Set_RS_Test( C_TgSINT32, C_TgFLOAT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_Set_RS_Add( C_TgSINT32, C_TgFLOAT32 );  /* #IMPLEMENT */

TgEXTN TgVOID                               tgKN_GPU_PM_Push_Blend_State( C_TgSINT32 );  /* #IMPLEMENT */
TgEXTN TgVOID                               tgKN_GPU_PM_Pop_Blend_State( C_TgSINT32 );  /* #IMPLEMENT */

TgEXTN TgVOID                               tgKN_GPU_PM_Set_RS( C_TgSINT32, C_TgSINT32, C_TgUINT32 );  /* #IMPLEMENT */


/* -- GPU - State ------------------------------------------------------------------------------------------------------------------------------------------------------- */


/* -- GPU - Unit Test---------------------------------------------------------------------------------------------------------------------------------------------------- */

TgEXTN TgRESULT                             tgUnit_Test__KN_GPU_Render_Context__Create_Resources( C_TgKN_GPU_CXT_ID );
TgEXTN TgRESULT                             tgUnit_Test__KN_GPU_Render_Context__Render( C_TgKN_GPU_CXT_ID );


/*# defined(TgCOMPILE_GPU_SUPPORT) */
#endif

/* ====================================================================================================================================================================== */
#endif