Home

Resume

Blog

Teikitu


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

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

#include "TgS Kernel - Internal - Constants.h"


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

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Private Types                                                                                                                                                         */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgTYPE_STRUCT(STg2_KN_Notify,)
{
    TgKN_FCN_NOTIFY_CALLBACK                    m_psFCN;
    TgUINTPTR                                   m_uiParam0;
};


/* -- File and File System ---------------------------------------------------------------------------------------------------------------------------------------------- */

TgTYPE_STRUCT(STg2_KN_File_Job,)
{
    STg2_UTS_QU_Node                            m_sFS_Node;
    TgKN_FILE_JOB_ID                            m_tiFile_Job; /*« File Job ID associated with this job. */

    /* Request Input Data - This is used to define the request and inform the choice of physical asset. */
    union
    {
        STg2_KN_File_Open_Command                   m_sOpen;
        STg2_KN_File_Read_Command                   m_sRead;
        STg2_KN_File_Cache_Command                  m_sCache;
        STg2_KN_File_Write_Command                  m_sWrite;
        STg2_KN_File_Cancel_Command                 m_sCancel;
    }                                           m_sCmd;
    ETgFILE_COMMAND                             m_enCmd;
    TgSINT32                                    m_iPad;
    TgKN_FILE_ID                                m_tiFile;
    P_STg1_MP_SM                                m_psmBL;
    TgATOMIC_SINT32                             m_xiStatus; /*« File IO status - used to for job control. */
    TgUINT32                                    m_iPad0;
};

TgTYPE_STRUCT(STg2_KN_File_Info,)
{
    TgKN_FILE_SYSTEM_ID                         m_tiFS; /*« File system to use for opening the file */
    TgKN_FS_MOUNT_ID                            m_tiFS_Mount; /*« File system mount point  */
    TgKN_FILE_ID                                m_tiFile;
    TgUINTXX                                    m_uiPath; /*« Hash of the file location (path) */
    TgUINTXX                                    m_uiFile; /*« Hash of the file name */
    TgSIZE                                      m_uiSize; /*« Maximum size of the output buffer */
    TgSIZE                                      m_uiPos; /*« Current file position */
    TgSIZE                                      m_uiCache_Pos; /*« Position of the logical position within the cache block */
    TgSIZE                                      m_uiCache_Size; /*« Size of the cache (min size is file block size) */
    P_TgUINT08                                  m_puiCache; /*« Cache buffer (if one exists) */

    /* Only modified when under file system processing lock */
    TgSINT32                                    m_enMode; /*« Access mode to use to open the file */
    TgSINT32                                    m_niCmd;
    TgSINT32                                    m_niExecute;
    TgSINT32                                    m_iPad0;
};

TgTYPE_STRUCT(STg2_KN_FS_Mount,)
{
    /*P_STg2_KN_FS_Job_List                       m_asKN_FS; */ /* Storage of Job entries */
    TgKN_FS_MOUNT_ID                            m_tiFS_Mount;
    TgKN_FILE_SYSTEM_ID                         m_tiFS;
    TgSINT32                                    m_enMode; /*« Access mode to use for the file system */
    TgSINT32                                    m_iPad;
};

typedef TgSIZE(*TgFCN_KN_FILE_SYSTEM_FREE_SPACE)( C_TgKN_FS_MOUNT_ID );
typedef TgVOID(*TgFCN_KN_FILE_SYSTEM_MOUNT)( C_TgKN_FS_MOUNT_ID, CPCU_TgCHAR );
typedef TgVOID(*TgFCN_KN_FILE_SYSTEM_EXECUTE)( P_STg2_KN_File_Job );

TgTYPE_STRUCT(STg2_KN_File_System,)
{
    STg2_UTM_SN_ISO                             m_sAdd_Lock;
    STg2_UTM_SNC_ISO                            m_sProcess_Lock;
    STg2_UTM_AM_ST_ISO                          m_sComplete_Job;
    STg2_UTS_QU                                 m_sAdd_Queue; /* Modify only when in add lock */
    STg2_UTS_QU                                 m_sProcess_Queue; /* Modify only when in process lock */
    TgKN_FILE_SYSTEM_ID                         m_tiFS;
    TgSINT32                                    m_niExecute; /* Number of in flight operations | Modify only when in process lock*/
    TgSINT32                                    m_niMax_Execute;
    TgFCN_KN_FILE_SYSTEM_FREE_SPACE             m_pfnFree_Space;
    TgFCN_KN_FILE_SYSTEM_MOUNT                  m_pfnMount;
    TgFCN_KN_FILE_SYSTEM_EXECUTE                m_pfnExecute_Job;
#if 0 != (264 % TgCOMPILE_CACHE_LINE_SIZE)
    TgUINT08                                    m_uiPad1[TgCOMPILE_CACHE_LINE_SIZE - (264 % TgCOMPILE_CACHE_LINE_SIZE)];
#endif
};

TgTYPE_STRUCT(STg2_KN_File_System_DESC,)
{
    TgSINT32                                    m_niMax_Execute;
    TgUINT32                                    m_uiPad;
    TgFCN_KN_FILE_SYSTEM_FREE_SPACE             m_pfnFree_Space;
    TgFCN_KN_FILE_SYSTEM_MOUNT                  m_pfnMount;
    TgFCN_KN_FILE_SYSTEM_EXECUTE                m_pfnExecute_Job;
};


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Private GPU Types                                                                                                                                                     */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
#if defined(TgCOMPILE_GPU_SUPPORT)

TgTYPE_STRUCT(STg2_KN_GPU_RS_LIB_DESC,) /* #IMPLEMENT */
{
    P_TgUINTXX                                  m_puiHash; /*« Searchable value when creating a resource instance */
    TgSIZE                                      m_nuiHash;
    TgSIZE                                      m_nuiMax_Hash;
    P_TgKN_GPU_RS_ID                            m_ptiRS; /*« Base ID list - avoids the need to define a data stride */
    TgSINT32 volatile *                         m_piRef; /*« Interlock functions will flush the cache - isolate the ref count */
    P_STg2_UTM_SN                               m_psLock;

    P_STg2_UTM_AM_ST                            m_psList;
    P_TgUINT08                                  m_puiData;
    TgSIZE                                      m_uiStride;

    TgUINTXX                                    (*m_pfnLoad)( C_TgKN_FILE_ID, C_TgSIZE, C_ETgKN_GPU_ALLOCATOR, PCU_STg2_KN_GPU_RS_LIB_DESC, C_TgUINTXX, C_TgSIZE );
    TgVOID                                      (*m_pfnFree)( PCU_STg2_KN_GPU_RS_LIB_DESC, C_TgSIZE );

    TgSIZE                                      m_uiSize;
    TgSINT32                                    m_iMaxList;
    TgUINT32                                    m_iPad0;
};

TgTYPE_STRUCT(STg2_KN_GPU_RSI_LIB_DESC,) /* #IMPLEMENT */
{
    P_TgKN_GPU_RSI_ID                           m_ptiRSI;
    P_TgKN_GPU_RS_ID                            m_ptiRS;
    TgSINT32 volatile *                         m_piRef;
    P_STg2_UTM_SN                               m_psLock;

    P_STg2_UTM_AM_ST                            m_psList;
    P_TgUINT08                                  m_puiData;
    TgSIZE                                      m_uiStride;

    P_STg2_KN_GPU_RS_LIB_DESC                   m_pLibRS;

    TgVOID                                      (*m_pfnInst)( PCU_STg2_KN_GPU_RSI_LIB_DESC, C_TgKN_GPU_RSI_ID );
    TgVOID                                      (*m_pfnFree)( PCU_STg2_KN_GPU_RSI_LIB_DESC, C_TgKN_GPU_RSI_ID );

    TgSIZE                                      m_uiSize;
    TgSINT32                                    m_iMaxList;
    TgUINT32                                    m_iPad0;
};

TgTYPE_STRUCT(STg2_KN_GPU_Context__Device,) /* #IMPLEMENT */
{
    TgKN_GPU_CXT_DEVC_ID                        m_tiID;
    TgSINT32                                    m_iRef;
    TgSINT32                                    m_iPad;
};

TgTYPE_STRUCT(STg2_KN_GPU_Context__Output,) /* #IMPLEMENT */
{
    TgKN_GPU_CXT_SWAP_ID                        m_tiID;
    STg2_KN_GPU_Viewport                        m_sRnd_Viewport;
};

TgTYPE_STRUCT(STg2_KN_GPU_Context__Resource,) /* #IMPLEMENT */
{
    TgKN_GPU_CXT_DATA_ID                        m_tiID;
    TgSINT32                                    m_iRef;
    TgSINT32                                    m_iPad;
    STg2_KN_GPU_RSI_LIB_DESC                    m_sCS_Inst_LIB_DESC;
    STg2_KN_GPU_RSI_LIB_DESC                    m_sHS_Inst_LIB_DESC;
    STg2_KN_GPU_RSI_LIB_DESC                    m_sDS_Inst_LIB_DESC;
    STg2_KN_GPU_RSI_LIB_DESC                    m_sIL_Inst_LIB_DESC;
    STg2_KN_GPU_RSI_LIB_DESC                    m_sGS_Inst_LIB_DESC;
    STg2_KN_GPU_RSI_LIB_DESC                    m_sPS_Inst_LIB_DESC;
    STg2_KN_GPU_RSI_LIB_DESC                    m_sTX_IMG_Inst_LIB_DESC;
    STg2_KN_GPU_RSI_LIB_DESC                    m_sTX_CBE_Inst_LIB_DESC;
    STg2_KN_GPU_RSI_LIB_DESC                    m_sTX_VOL_Inst_LIB_DESC;
};

TgTYPE_STRUCT(STg2_KN_GPU_Context,) /* #IMPLEMENT */
{
    TgKN_GPU_CXT_ID                             m_tiID;
    TgKN_GPU_CXT_DEVC_ID                        m_tiCXT_DEVC;
    TgKN_GPU_CXT_SWAP_ID                        m_tiCXT_SWAP;
    TgKN_GPU_CXT_DATA_ID                        m_tiCXT_DATA;
    TgKN_GPU_CXT_EXTN_ID                        m_tiCXT_EXTN;
};

TgCOMPILER_ASSERT( KTgKN_GPU_MAX_CS < 0xFFFF, "Resource Index is max limited to 16 bits for instance id mangle" );


/* ---- GPU Resource - Shader ------------------------------------------------------------------------------------------------------------------------------------------- */

TgTYPE_STRUCT( STg2_KN_GPU_SH_DATA, )
{
    P_TgVOID                                    m_pUCode; /*« Platform copy of the UCode of the shader */
    P_TgVOID                                    m_pHW; /*« Parameter used by the platform layer to set the shader */
    P_TgVOID                                    m_pData; /*« Platform copy of the shader binary */
    ETgKN_GPU_ALLOCATOR                         m_enAllocator; /*« Allocator / Memory region of the data */
    TgUINT32                                    m_iPad0;
};

TgTYPE_STRUCT(STg2_KN_GPU_CS_DATA,)
{
    STg2_KN_GPU_SH_DATA                         m_sSH;
};

TgTYPE_STRUCT(STg2_KN_GPU_HS_DATA,)
{
    STg2_KN_GPU_SH_DATA                         m_sSH;
};

TgTYPE_STRUCT(STg2_KN_GPU_DS_DATA,)
{
    STg2_KN_GPU_SH_DATA                         m_sSH;
};

TgTYPE_STRUCT(STg2_KN_GPU_VS_DATA,)
{
    STg2_KN_GPU_SH_DATA                         m_sSH;
};

TgTYPE_STRUCT(STg2_KN_GPU_GS_DATA,)
{
    STg2_KN_GPU_SH_DATA                         m_sSH;
};

TgTYPE_STRUCT(STg2_KN_GPU_PS_DATA,)
{
    STg2_KN_GPU_SH_DATA                         m_sSH;
};


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

TgTYPE_STRUCT(STg2_KN_GPU_VT_DESC,)
{
    CPU_STg2_KN_GPU_VT_Element                  m_psElement_List;
    TgUINTXX                                    m_uiHash;
    TgSINT32                                    m_niElement;
    TgSINT32                                    m_iPad0;
};


/* ---- GPU Resource - Texture ------------------------------------------------------------------------------------------------------------------------------------------ */

/* Base structure for all the texture types */
TgTYPE_STRUCT(STg2_KN_TX,)
{
    /* Note: The first eight bytes are used by the resource tracker for invalid resources */

                                                /* General definition */
    TgSINT32                                    m_niMIP;
    ETgKN_GPU_FORMAT                            m_enFormat;

                                                /* Resource streaming definition. */
    TgUINT32                                    m_uiLastTouch;
    TgUINT32                                    m_uiPriority;
    ETgKN_GPU_ALLOCATOR                         m_enAllocator;
    TgUINT32                                    m_uiFlags;

                                                /* Hardware interface and data. */
    P_TgVOID                                    m_pHW;
    P_TgVOID                                    m_pData;

                                                  /* Reference count. */
    /*TgUINT32                                    m_nuiRef; */
};

TgTYPE_STRUCT(STg2_KN_GPU_TX_CBE_DATA,)
{
    STg2_KN_TX                                  m_sTX;
    TgSINT32                                    m_iEdge;
    TgUINT32                                    m_iPad0;
};

TgTYPE_STRUCT(STg2_KN_GPU_TX_CBE_DESC,)
{
    TgSINT32                                    m_niMIP;
    ETgKN_GPU_FORMAT                            m_enFormat;
    TgUINTXX                                    m_uiHash;
    TgUINT32                                    m_uiFlags;
    TgSINT32                                    m_iEdge;
};

TgTYPE_STRUCT(STg2_KN_GPU_TX_IMG_DATA,)
{
    STg2_KN_TX                                  m_sTX;
    TgSINT32                                    m_iWidth, m_iHeight;
};

TgTYPE_STRUCT(STg2_KN_GPU_TX_IMG_DESC,)
{
    TgSINT32                                    m_niMIP;
    ETgKN_GPU_FORMAT                            m_enFormat;
    TgUINTXX                                    m_uiHash;
    TgUINT32                                    m_uiFlags;
    TgSINT32                                    m_iWidth, m_iHeight;
    TgSINT32                                    m_iPad0;
};

TgTYPE_STRUCT(STg2_KN_GPU_TX_VOL_DATA,)
{
    STg2_KN_TX                                  m_sTX;
    TgSINT32                                    m_iWidth, m_iHeight, m_iDepth;
    TgUINT32                                    m_iPad0;
};

TgTYPE_STRUCT(STg2_KN_GPU_TX_VOL_DESC,)
{
    TgSINT32                                    m_niMIP;
    ETgKN_GPU_FORMAT                            m_enFormat;
    TgUINTXX                                    m_uiHash;
    TgUINT32                                    m_uiFlags;
    TgSINT32                                    m_iWidth, m_iHeight, m_iDepth;
};


/*# defined(TgCOMPILE_GPU_SUPPORT) */
#endif


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