Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS (DX12) Kernel - Internal - D3DX.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".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/* == Kernel ============================================================================================================================================================ */
#if !defined(TGS_DX12_KERNEL_INTERNAL_D3DX_H)
#define TGS_DX12_KERNEL_INTERNAL_D3DX_H

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

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Private GPU Functions                                                                                                                                                 */
/*    Reference: MSFT d3dx12.h - Translated to support both C and C++ using MSFT standard                                                                                 */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_BOX_CLASS_DEFINED)
#define CD3DX12_BOX_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_BOX_LR(
    _Out_ D3D12_BOX *pBox,
    LONG Left,
    LONG Right );

TgINLINE TgVOID _CD3DX12_BOX_LTRB(
    _Out_ D3D12_BOX *pBox,
    LONG Left,
    LONG Top,
    LONG Right,
    LONG Bottom );

#endif     /* CD3DX12_BOX_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_RANGE_CLASS_DEFINED)
#define CD3DX12_RANGE_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_RANGE_Init(
    _Out_ D3D12_RANGE *pRange,
    SIZE_T begin,
    SIZE_T end );

#endif     /* CD3DX12_RANGE_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_TEXTURE_COPY_LOCATION_CLASS_DEFINED)
#define CD3DX12_TEXTURE_COPY_LOCATION_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_TEXTURE_COPY_LOCATION_Init_Footprint(
    _Out_ D3D12_TEXTURE_COPY_LOCATION *pTex_Copy,
    ID3D12Resource* pRes,
    D3D12_PLACED_SUBRESOURCE_FOOTPRINT const *pFootprint );

TgINLINE TgVOID _CD3DX12_TEXTURE_COPY_LOCATION_Init_Sub_Resource(
    _Out_ D3D12_TEXTURE_COPY_LOCATION *pTex_Copy,
    ID3D12Resource* pRes,
    UINT Sub );

#endif     /* CD3DX12_TEXTURE_COPY_LOCATION_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_RESOURCE_BARRIER_CLASS_DEFINED)
#define CD3DX12_RESOURCE_BARRIER_CLASS_DEFINED

TgINLINE TgVOID __CD3DX12_RESOURCE_BARRIER_Transition(
    _Out_ D3D12_RESOURCE_BARRIER* pResourceX,
    _In_ ID3D12Resource* pResource,
    D3D12_RESOURCE_STATES stateBefore,
    D3D12_RESOURCE_STATES stateAfter,
    UINT subresource,
    D3D12_RESOURCE_BARRIER_FLAGS flags );

TgINLINE TgVOID __CD3DX12_RESOURCE_BARRIER_Aliasing(
    _Out_ D3D12_RESOURCE_BARRIER* pResourceX,
    _In_ ID3D12Resource* pResourceBefore,
    _In_ ID3D12Resource* pResourceAfter );

TgINLINE TgVOID __CD3DX12_RESOURCE_BARRIER_UAV(
    _Out_ D3D12_RESOURCE_BARRIER* pResourceX,
    _In_ ID3D12Resource* pResource );

#endif     /* CD3DX12_RESOURCE_BARRIER_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_RESOURCE_DESC_CLASS_DEFINED)
#define CD3DX12_RESOURCE_DESC_CLASS_DEFINED

TgINLINE UINT D3D12CalcSubresource( UINT MipSlice, UINT ArraySlice, UINT PlaneSlice, UINT MipLevels, UINT ArraySize );
TgINLINE UINT8 D3D12GetFormatPlaneCount( _In_ ID3D12Device* pDevice, DXGI_FORMAT Format );

TgINLINE TgVOID __CD3DX12_RESOURCE_DESC_Buffer_From_AllococationInfo(
    _Out_ D3D12_RESOURCE_DESC* pResourceX,
    const D3D12_RESOURCE_ALLOCATION_INFO *pResAllocInfo );

TgINLINE TgVOID __CD3DX12_RESOURCE_DESC_Buffer(
    _Out_ D3D12_RESOURCE_DESC* pResourceX,
    UINT64 width );

TgINLINE TgVOID __CD3DX12_RESOURCE_DESC_Tex1D(
    _Out_ D3D12_RESOURCE_DESC* pResourceX,
    DXGI_FORMAT format,
    UINT64 width );

TgINLINE TgVOID __CD3DX12_RESOURCE_DESC_Tex2D(
    _Out_ D3D12_RESOURCE_DESC* pResourceX,
    DXGI_FORMAT format,
    UINT64 width,
    UINT height );

TgINLINE TgVOID __CD3DX12_RESOURCE_DESC_Tex3D(
    _Out_ D3D12_RESOURCE_DESC* pResourceX,
    DXGI_FORMAT format,
    UINT64 width,
    UINT height,
    UINT16 depth );

TgINLINE UINT16 __CD3DX12_RESOURCE_DESC_Depth( _In_ const D3D12_RESOURCE_DESC* pResourceX );
TgINLINE UINT16 __CD3DX12_RESOURCE_DESC_ArraySize( _In_ const D3D12_RESOURCE_DESC* pResourceX );
TgINLINE UINT8 __CD3DX12_RESOURCE_DESC_PlaneCount( _In_ const D3D12_RESOURCE_DESC* pResourceX, _In_ ID3D12Device* pDevice );
TgINLINE UINT __CD3DX12_RESOURCE_DESC_Subresources( _In_ const D3D12_RESOURCE_DESC* pResourceX, _In_ ID3D12Device* pDevice );
TgINLINE UINT __CD3DX12_RESOURCE_DESC_CalcSubresource( _In_ D3D12_RESOURCE_DESC* pResourceX, UINT MipSlice, UINT ArraySlice, UINT PlaneSlice );

#endif     /* CD3DX12_RESOURCE_DESC_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_DESCRIPTOR_RANGE_CLASS_DEFINED)
#define CD3DX12_DESCRIPTOR_RANGE_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_DESCRIPTOR_RANGE_Init(
    _Out_ D3D12_DESCRIPTOR_RANGE *pRange,
    D3D12_DESCRIPTOR_RANGE_TYPE rangeType,
    UINT numDescriptors,
    UINT baseShaderRegister );

#endif     /* CD3DX12_DESCRIPTOR_RANGE_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_ROOT_DESCRIPTOR_TABLE_CLASS_DEFINED)
#define CD3DX12_ROOT_DESCRIPTOR_TABLE_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_ROOT_DESCRIPTOR_TABLE_Init(
    _Out_ D3D12_ROOT_DESCRIPTOR_TABLE *pRootDescriptorTable,
    UINT numDescriptorRanges,
    _In_reads_opt_( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges );

#endif     /* CD3DX12_ROOT_DESCRIPTOR_TABLE_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_ROOT_CONSTANTS_CLASS_DEFINED)
#define CD3DX12_ROOT_CONSTANTS_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_ROOT_CONSTANTS_Init(
    _Out_ D3D12_ROOT_CONSTANTS *pRootConstants,
    UINT num32BitValues,
    UINT shaderRegister );

#endif     /* CD3DX12_ROOT_CONSTANTS_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_ROOT_DESCRIPTOR_CLASS_DEFINED)
#define CD3DX12_ROOT_DESCRIPTOR_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_ROOT_DESCRIPTOR_Init(
    _Out_ D3D12_ROOT_DESCRIPTOR *pTable,
    UINT shaderRegister );

#endif     /* CD3DX12_ROOT_DESCRIPTOR_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_ROOT_PARAMETER_CLASS_DEFINED)
#define CD3DX12_ROOT_PARAMETER_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_ROOT_PARAMETER_InitAsDescriptorTable(
    _Out_ D3D12_ROOT_PARAMETER *pRootParam,
    UINT numDescriptorRanges,
    _In_reads_( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges );

TgINLINE TgVOID _CD3DX12_ROOT_PARAMETER_InitAsConstants(
    _Out_ D3D12_ROOT_PARAMETER *pRootParam,
    UINT num32BitValues,
    UINT shaderRegister );

TgINLINE TgVOID _CD3DX12_ROOT_PARAMETER_InitAsConstantBufferView(
    _Out_ D3D12_ROOT_PARAMETER *pRootParam,
    UINT shaderRegister );

TgINLINE TgVOID _CD3DX12_ROOT_PARAMETER_InitAsShaderResourceView(
    _Out_ D3D12_ROOT_PARAMETER *pRootParam,
    UINT shaderRegister );

TgINLINE TgVOID _CD3DX12_ROOT_PARAMETER_InitAsUnorderedAccessView(
    _Out_ D3D12_ROOT_PARAMETER *pRootParam,
    UINT shaderRegister );

#endif     /* CD3DX12_ROOT_PARAMETER_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_ROOT_SIGNATURE_DESC_CLASS_DEFINED)
#define CD3DX12_ROOT_SIGNATURE_DESC_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_ROOT_SIGNATURE_DESC_Init(
    _Out_ D3D12_ROOT_SIGNATURE_DESC *pDesc,
    UINT numParameters,
    _In_reads_opt_( numParameters ) const D3D12_ROOT_PARAMETER* _pParameters );

#endif     /* CD3DX12_ROOT_SIGNATURE_DESC_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_SHADER_BYTECODE_CLASS_DEFINED)
#define CD3DX12_SHADER_BYTECODE_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_SHADER_BYTECODE_Init_Blob(
    _Out_ D3D12_SHADER_BYTECODE *pShader,
    ID3DBlob* pShaderBlob );

TgINLINE TgVOID _CD3DX12_SHADER_BYTECODE_Init_Shader_Code(
    _Out_ D3D12_SHADER_BYTECODE *pShader,
    void* _pShaderBytecode,
    SIZE_T bytecodeLength );

#endif     /* CD3DX12_SHADER_BYTECODE_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_DEPTH_STENCIL_DESC_CLASS_DEFINED)
#define CD3DX12_DEPTH_STENCIL_DESC_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_DEPTH_STENCIL_DESC_Init_Default(
    _Out_ D3D12_DEPTH_STENCIL_DESC *pDS );

#endif     /* CD3DX12_DEPTH_STENCIL_DESC_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_BLEND_DESC_CLASS_DEFINED)
#define CD3DX12_BLEND_DESC_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_BLEND_DESC_Init_Default(
    _Out_ D3D12_BLEND_DESC *pBlend );

#endif     /* CD3DX12_BLEND_DESC_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_RASTERIZER_DESC_CLASS_DEFINED)
#define CD3DX12_RASTERIZER_DESC_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_RASTERIZER_DESC_Init_Default(
    _Out_ D3D12_RASTERIZER_DESC *pRast );

#endif     /* CD3DX12_RASTERIZER_DESC_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
#if !defined(CD3DX12_HEAP_PROPERTIES_CLASS_DEFINED)
#define CD3DX12_HEAP_PROPERTIES_CLASS_DEFINED

TgINLINE TgVOID _CD3DX12_HEAP_PROPERTIES_Init_Custom(
    _Out_ D3D12_HEAP_PROPERTIES *pHeap_Property,
    D3D12_CPU_PAGE_PROPERTY cpuPageProperty,
    D3D12_MEMORY_POOL memoryPoolPreference );

TgINLINE TgVOID _CD3DX12_HEAP_PROPERTIES_Init_Type(
    _Out_ D3D12_HEAP_PROPERTIES *pHeap_Property,
    D3D12_HEAP_TYPE type );

TgINLINE TgBOOL _CD3DX12_HEAP_PROPERTIES_IsCPUAccessible(
    _In_ D3D12_HEAP_PROPERTIES *pHeap_Property );

#endif     /* CD3DX12_HEAP_PROPERTIES_CLASS_DEFINED_ */

/* -------------------------------------------------------------------------------- */
/* All arrays must be populated (e.g. by calling GetCopyableFootprints) */
TgINLINE UINT64 _D3DX12_UpdateSubresources(
    _In_ ID3D12GraphicsCommandList* pCmdList,
    _In_ ID3D12Resource* pDestinationResource,
    _In_ ID3D12Resource* pIntermediate,
    _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource,
    _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources,
    UINT64 RequiredSize,
    _In_reads_( NumSubresources ) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts,
    _In_reads_( NumSubresources ) const UINT* pNumRows,
    _In_reads_( NumSubresources ) const UINT64* pRowSizesInBytes,
    _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData );

/* -------------------------------------------------------------------------------- */
/* Heap-allocating UpdateSubresources implementation */
TgINLINE UINT64 _D3DX12_UpdateSubresources_Heap(
    _In_ ID3D12GraphicsCommandList* pCmdList,
    _In_ ID3D12Resource* pDestinationResource,
    _In_ ID3D12Resource* pIntermediate,
    UINT64 IntermediateOffset,
    _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource,
    _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources,
    _In_reads_( NumSubresources ) D3D12_SUBRESOURCE_DATA* pSrcData );

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