Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS (DX12) 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_DX12_KERNEL_INTERNAL_TYPE_H)
#define TGS_DX12_KERNEL_INTERNAL_TYPE_H
#pragma once


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

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Private DirectX Type Aliases                                                                                                                                          */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgTYPE_DECLARE( IUnknown,                   IUNKNOWN );

TgTYPE_DECLARE( IDXGIAdapter,               DXGI_ADAPTER );
TgTYPE_DECLARE( IDXGIAdapter3,              DXGI_ADAPTER3 );
TgTYPE_DECLARE( IDXGIOutput,                DXGI_OUTPUT );
TgTYPE_DECLARE( IDXGIOutput5,               DXGI_OUTPUT5 );
TgTYPE_DECLARE( IDXGIDevice,                DXGI_DEVICE );
TgTYPE_DECLARE( IDXGIDevice4,               DXGI_DEVICE4 );
TgTYPE_DECLARE( IDXGISwapChain1,            DXGI_SWAP_CHAIN1 );
TgTYPE_DECLARE( IDXGISwapChain4,            DXGI_SWAP_CHAIN4 );

TgTYPE_DECLARE( ID3DBlob,                   D3D_BLOB );

TgTYPE_DECLARE( ID3D12Device,               D3D12_DEVICE );
TgTYPE_DECLARE( ID3D12Device1,              D3D12_DEVICE1 );
TgTYPE_DECLARE( ID3D12InfoQueue,            D3D12_INFO_QUEUE );
TgTYPE_DECLARE( ID3D12CommandAllocator,     D3D12_COMMAND_ALLOCATOR );
TgTYPE_DECLARE( ID3D12CommandQueue,         D3D12_COMMAND_QUEUE );
TgTYPE_DECLARE( ID3D12CommandList,          D3D12_COMMAND_LIST );
TgTYPE_DECLARE( ID3D12GraphicsCommandList,  D3D12_GRAPHICS_COMMAND_LIST );
TgTYPE_DECLARE( ID3D12DescriptorHeap,       D3D12_DESCRIPTOR_HEAP );
TgTYPE_DECLARE( ID3D12Resource,             D3D12_RESOURCE );
TgTYPE_DECLARE( ID3D12Fence,                D3D12_FENCE );

TgTYPE_PREFIX( DXGI_MODE_DESC1 );
TgTYPE_PREFIX( D3D_FEATURE_LEVEL );

TgTYPE_DECLARE( D3D12_ROOT_SIGNATURE_DESC, D3D12_ROOT_SIG_DESC );
TgTYPE_DECLARE( D3D_ROOT_SIGNATURE_VERSION, D3D_ROOT_SIG_VER );
TgTYPE_DECLARE( D3D12_VERSIONED_ROOT_SIGNATURE_DESC, D3D12_VER_ROOT_SIG_DESC );


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

TgTYPE_STRUCT(STg2_KN_GPU_DXGI_Output,)
{
    P_DXGI_OUTPUT5                              m_pDXGI_Output_5;
    DXGI_OUTPUT_DESC                            m_sDXGI_Output;

    P_DXGI_MODE_DESC1                           m_psMode;
    TgSINT32                                    m_niMode;
    TgSINT32                                    m_niMode_Target_Format[ETgKN_GPU_TARGET__MAX];
    TgSINT32                                    m_iOrdinal;
};

TgTYPE_STRUCT(STg2_KN_GPU_DXGI_Adapter,) /* GPU Adapter - provides scan out to output devices, and one or more GPU nodes */
{
    P_DXGI_ADAPTER3                             m_pDXGI_Adapter_3;
    DXGI_ADAPTER_DESC2                          m_sAdapter;
    P_D3D12_DEVICE1                             m_psDevice1;
    D3D_FEATURE_LEVEL                           m_enFeature_Level;
    TgSINT32                                    m_aiMS[ETgKN_GPU_TARGET__MAX][KTgKN_GPU_MS__MAX];
    TgSINT32                                    m_iOrdinal;
    STg2_KN_GPU_DXGI_Output                     m_asOutput[KTgKN_GPU_MAX_OUTPUT];
    TgSINT32                                    m_niOutput;
    TgUINT32                                    m_uiPad;
    TgKN_GPU_CXT_ID                             m_tiContext;
};


/*  Context - Device - A single GPU node on an adapter
    Context - Output - Manages a single output device
    Context - Resource - Used to manage a single group of memory (a video card, main memory, etc.)
    Context - External - Resource IDs available out side of rendering */

TgTYPE_STRUCT(STg2_KN_GPU_DX12_Context__Command,) /* A single GPU task, for a single GPU node */
{
    STg2_UTM_Node                               m_sNext;
    TgUINT32                                    m_uiPad;
    ETgKN_GPU_DX12_Command                      m_enCmd;
    union
    {
        P_D3D12_COMMAND_ALLOCATOR                   _Direct;
        P_D3D12_COMMAND_ALLOCATOR                   _Bundle;
    }                                           m_sCmd_Allocator;
    union
    {
        P_D3D12_GRAPHICS_COMMAND_LIST               _Graphics;
        P_D3D12_COMMAND_QUEUE                       _Direct;
        P_D3D12_COMMAND_QUEUE                       _Compute;
        P_D3D12_COMMAND_QUEUE                       _Copy;
    }                                           m_sCmd_Queue;
};

TgTYPE_STRUCT(STg2_KN_GPU_DX12_Context__Device,) /* A single GPU node */
{
    TgKN_GPU_CXT_DEVC_ID                        m_tiID;
    TgSINT32                                    m_iAdapter;
    TgUINT32                                    m_uiNodeMask;
    P_D3D12_COMMAND_ALLOCATOR                   m_psCmd_Allocator__Direct[KTgKN_GPU_DX12_MAX_ALLOCATOR];
    P_D3D12_COMMAND_ALLOCATOR                   m_psCmd_Allocator__Bundle[KTgKN_GPU_DX12_MAX_BUNDLE_ALLOCATOR];
    P_D3D12_COMMAND_QUEUE                       m_psCmd_Queue__Direct;
    P_D3D12_COMMAND_QUEUE                       m_psCmd_Queue__Compute;
    P_D3D12_COMMAND_QUEUE                       m_psCmd_Queue__Copy;
    P_D3D12_GRAPHICS_COMMAND_LIST               m_psCmd_Graphics_List__Init;
    P_D3D12_GRAPHICS_COMMAND_LIST               m_psCmd_Graphics_List__Swap;
    P_D3D12_DESCRIPTOR_HEAP                     m_psHeap_RTV;
    P_D3D12_DESCRIPTOR_HEAP                     m_psHeap_DSV;
    TgUINT32                                    m_uiDescriptor_Size_RTV;
    TgUINT32                                    m_uiIsReset : 1;
    TgUINT32                                    m_uiPad : 31;
    STg2_KN_GPU_DX12_Context__Command           m_asComand[ETgKN_GPU_DX12_COMMAND__MAX * KTgKN_GPU_DX12_MAX_COMMAND];
    STg2_UTM_AM_ST_ISO                          m_asCommand_Free_Stack[ETgKN_GPU_DX12_COMMAND__MAX + 1];
};

TgTYPE_STRUCT(STg2_KN_GPU_DX12_Context__Output,) /* An output device attached to a single GPU node */
{
    TgKN_GPU_CXT_SWAP_ID                        m_tiID;
    DXGI_MODE_DESC1                             m_sMode;
    TgSINT32                                    m_iOutput;
    TgSINT32                                    m_iSample;
    P_DXGI_SWAP_CHAIN4                          m_psSwapChain4;
    P_D3D12_RESOURCE                            m_apsRTV[KTgKN_GPU_DX12_BUFFER_COUNT];
    TgUINT32                                    m_uiSwap_Index;
    DXGI_FORMAT                                 m_enFormat_DS;
    P_D3D12_RESOURCE                            m_psDepth_Stencil;
    D3D12_VIEWPORT                              m_sViewPort;
    D3D12_RECT                                  m_sScissorRect;
    P_D3D12_FENCE                               m_psFence;
    TgUINT64                                    m_uiFenceValues[KTgKN_GPU_DX12_BUFFER_COUNT];
    P_TgVOID                                    m_psFenceEvent;
    TgUINT32                                    m_uiVSync : 2;
    TgUINT32                                    m_uiPad0 : 30;
    TgUINT32                                    m_uiPad1;
};

TgTYPE_STRUCT(STg2_KN_GPU_DX12_Context__Data,) /* Resources that are directly available to one or more GPU nodes */
{
    TgKN_GPU_CXT_DATA_ID                        m_tiID;
};

TgTYPE_STRUCT(STg2_KN_GPU_DX12_Context__External,)
{
    TgKN_GPU_CXT_EXTN_ID                        m_tiID;
};

TgTYPE_STRUCT(STg2_KN_GPU_DX12_Context,)
{
    TgKN_GPU_CXT_ID                             m_tiID;
};


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