/*-------------------------------------------------------------------------------------
 *
 * Copyright (c) Microsoft Corporation
 *
 *-------------------------------------------------------------------------------------*/
import "oaidl.idl";
import "ocidl.idl";

import "dxgi.idl";
import "d3dcommon.idl";

cpp_quote("#include <winapifamily.h>")

#pragma region App Family
cpp_quote("#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)")

#include "d3d12constants.idl"


// Forward declarations
interface ID3D12CommandQueue;

typedef UINT64 D3D12_GPU_VIRTUAL_ADDRESS;

typedef enum D3D12_COMMAND_LIST_TYPE
{
    D3D12_COMMAND_LIST_TYPE_DIRECT      = 0,
    D3D12_COMMAND_LIST_TYPE_BUNDLE      = 1,
    D3D12_COMMAND_LIST_TYPE_COMPUTE     = 2,
    D3D12_COMMAND_LIST_TYPE_COPY        = 3,
} D3D12_COMMAND_LIST_TYPE;

typedef enum D3D12_COMMAND_QUEUE_FLAGS
{
    D3D12_COMMAND_QUEUE_FLAG_NONE = 0x0,
    D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT = 0x1,
} D3D12_COMMAND_QUEUE_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_COMMAND_QUEUE_FLAGS );" )

typedef enum D3D12_COMMAND_QUEUE_PRIORITY
{
    D3D12_COMMAND_QUEUE_PRIORITY_NORMAL = 0,
    D3D12_COMMAND_QUEUE_PRIORITY_HIGH   = 100,
} D3D12_COMMAND_QUEUE_PRIORITY;

typedef struct D3D12_COMMAND_QUEUE_DESC
{
    D3D12_COMMAND_LIST_TYPE Type;
    INT Priority;
    D3D12_COMMAND_QUEUE_FLAGS Flags;
    UINT NodeMask;
} D3D12_COMMAND_QUEUE_DESC;

typedef enum D3D12_PRIMITIVE_TOPOLOGY_TYPE
{
    D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED = 0,
    D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT     = 1,
    D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE      = 2,
    D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE  = 3,
    D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH     = 4
} D3D12_PRIMITIVE_TOPOLOGY_TYPE;

typedef enum D3D12_INPUT_CLASSIFICATION
{
    D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA = 0,
    D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA = 1
} D3D12_INPUT_CLASSIFICATION;

typedef struct D3D12_INPUT_ELEMENT_DESC
{
    LPCSTR SemanticName;
    UINT SemanticIndex;
    DXGI_FORMAT Format;
    UINT InputSlot;
    UINT AlignedByteOffset;
    D3D12_INPUT_CLASSIFICATION InputSlotClass;
    UINT InstanceDataStepRate;
} D3D12_INPUT_ELEMENT_DESC;

// Keep FILL_MODE values in sync with earlier DX versions (HW consumes values directly).
typedef enum D3D12_FILL_MODE
{
    // 1 was POINT in D3D, unused in D3D12
    D3D12_FILL_MODE_WIREFRAME = 2,
    D3D12_FILL_MODE_SOLID = 3
} D3D12_FILL_MODE;

typedef D3D_PRIMITIVE_TOPOLOGY D3D12_PRIMITIVE_TOPOLOGY;

typedef D3D_PRIMITIVE D3D12_PRIMITIVE;

// Keep CULL_MODE values in sync with earlier DX versions (HW consumes values directly).
typedef enum D3D12_CULL_MODE
{
    D3D12_CULL_MODE_NONE = 1,
    D3D12_CULL_MODE_FRONT = 2,
    D3D12_CULL_MODE_BACK = 3
} D3D12_CULL_MODE;

typedef struct D3D12_SO_DECLARATION_ENTRY
{
    UINT Stream;
    LPCSTR SemanticName;
    UINT SemanticIndex;
    BYTE StartComponent;
    BYTE ComponentCount;
    BYTE OutputSlot;
} D3D12_SO_DECLARATION_ENTRY;

typedef struct D3D12_VIEWPORT
{
    FLOAT TopLeftX;
    FLOAT TopLeftY;
    FLOAT Width;
    FLOAT Height;
    FLOAT MinDepth;
    FLOAT MaxDepth;
} D3D12_VIEWPORT;


typedef RECT D3D12_RECT;


typedef struct D3D12_BOX
{
    UINT left;
    UINT top;
    UINT front;
    UINT right;
    UINT bottom;
    UINT back;
} D3D12_BOX;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Depth-Stencil State
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Keep COMPARISON_FUNC values in sync with earlier DX versions (HW consumes values directly).
typedef enum D3D12_COMPARISON_FUNC
{
    D3D12_COMPARISON_FUNC_NEVER = 1,
    D3D12_COMPARISON_FUNC_LESS = 2,
    D3D12_COMPARISON_FUNC_EQUAL = 3,
    D3D12_COMPARISON_FUNC_LESS_EQUAL = 4,
    D3D12_COMPARISON_FUNC_GREATER = 5,
    D3D12_COMPARISON_FUNC_NOT_EQUAL = 6,
    D3D12_COMPARISON_FUNC_GREATER_EQUAL = 7,
    D3D12_COMPARISON_FUNC_ALWAYS = 8
} D3D12_COMPARISON_FUNC;

typedef enum D3D12_DEPTH_WRITE_MASK
{
    D3D12_DEPTH_WRITE_MASK_ZERO = 0,
    D3D12_DEPTH_WRITE_MASK_ALL = 1
} D3D12_DEPTH_WRITE_MASK;

// Keep STENCILOP values in sync with earlier DX versions (HW consumes values directly).
typedef enum D3D12_STENCIL_OP
{
    D3D12_STENCIL_OP_KEEP = 1,
    D3D12_STENCIL_OP_ZERO = 2,
    D3D12_STENCIL_OP_REPLACE = 3,
    D3D12_STENCIL_OP_INCR_SAT = 4,
    D3D12_STENCIL_OP_DECR_SAT = 5,
    D3D12_STENCIL_OP_INVERT = 6,
    D3D12_STENCIL_OP_INCR = 7,
    D3D12_STENCIL_OP_DECR = 8
} D3D12_STENCIL_OP;

typedef struct D3D12_DEPTH_STENCILOP_DESC
{
    D3D12_STENCIL_OP StencilFailOp;
    D3D12_STENCIL_OP StencilDepthFailOp;
    D3D12_STENCIL_OP StencilPassOp;
    D3D12_COMPARISON_FUNC StencilFunc;
} D3D12_DEPTH_STENCILOP_DESC;

typedef struct D3D12_DEPTH_STENCIL_DESC
{
    BOOL DepthEnable;
    D3D12_DEPTH_WRITE_MASK DepthWriteMask;
    D3D12_COMPARISON_FUNC DepthFunc;
    BOOL StencilEnable;
    UINT8 StencilReadMask;
    UINT8 StencilWriteMask;
    D3D12_DEPTH_STENCILOP_DESC FrontFace;
    D3D12_DEPTH_STENCILOP_DESC BackFace;
} D3D12_DEPTH_STENCIL_DESC;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Blend State
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Keep BLEND values in sync with earlier DX versions (HW consumes values directly).
typedef enum D3D12_BLEND
{
    D3D12_BLEND_ZERO = 1,
    D3D12_BLEND_ONE = 2,
    D3D12_BLEND_SRC_COLOR = 3, // PS output oN.rgb (N is current RT being blended)
    D3D12_BLEND_INV_SRC_COLOR = 4, // 1.0f - PS output oN.rgb
    D3D12_BLEND_SRC_ALPHA = 5, // PS output oN.a
    D3D12_BLEND_INV_SRC_ALPHA = 6, // 1.0f - PS output oN.a
    D3D12_BLEND_DEST_ALPHA = 7, // RT(N).a (N is current RT being blended)
    D3D12_BLEND_INV_DEST_ALPHA = 8, // 1.0f - RT(N).a
    D3D12_BLEND_DEST_COLOR = 9, // RT(N).rgb
    D3D12_BLEND_INV_DEST_COLOR = 10,// 1.0f - RT(N).rgb
    D3D12_BLEND_SRC_ALPHA_SAT = 11,// (f,f,f,1), f = min(1 - RT(N).a, oN.a)
    // 12 reserved (was BOTHSRCALPHA)
    // 13 reserved (was BOTHSRCALPHA)
    D3D12_BLEND_BLEND_FACTOR = 14,
    D3D12_BLEND_INV_BLEND_FACTOR = 15,
    D3D12_BLEND_SRC1_COLOR = 16, // PS output o1.rgb
    D3D12_BLEND_INV_SRC1_COLOR = 17, // 1.0f - PS output o1.rgb
    D3D12_BLEND_SRC1_ALPHA = 18, // PS output o1.a
    D3D12_BLEND_INV_SRC1_ALPHA = 19, // 1.0f - PS output o1.a
} D3D12_BLEND;

// Keep BLENDOP values in sync with earlier DX versions (HW consumes values directly).
typedef enum D3D12_BLEND_OP
{
    D3D12_BLEND_OP_ADD = 1,
    D3D12_BLEND_OP_SUBTRACT = 2,
    D3D12_BLEND_OP_REV_SUBTRACT = 3,
    D3D12_BLEND_OP_MIN = 4, // min semantics are like min shader instruction
    D3D12_BLEND_OP_MAX = 5, // max semantics are like max shader instruction
} D3D12_BLEND_OP;

typedef enum D3D12_COLOR_WRITE_ENABLE
{
    D3D12_COLOR_WRITE_ENABLE_RED = 1,
    D3D12_COLOR_WRITE_ENABLE_GREEN = 2,
    D3D12_COLOR_WRITE_ENABLE_BLUE = 4,
    D3D12_COLOR_WRITE_ENABLE_ALPHA = 8,
    D3D12_COLOR_WRITE_ENABLE_ALL = (D3D12_COLOR_WRITE_ENABLE_RED|D3D12_COLOR_WRITE_ENABLE_GREEN|
        D3D12_COLOR_WRITE_ENABLE_BLUE|D3D12_COLOR_WRITE_ENABLE_ALPHA),
} D3D12_COLOR_WRITE_ENABLE;

typedef enum D3D12_LOGIC_OP
{
                                   // Operation: 
                                   // (s == PS output, d = RTV contents)
    D3D12_LOGIC_OP_CLEAR = 0,      // 0
    D3D12_LOGIC_OP_SET,            // 1
    D3D12_LOGIC_OP_COPY,           // s
    D3D12_LOGIC_OP_COPY_INVERTED,  // ~s
    D3D12_LOGIC_OP_NOOP,           // d
    D3D12_LOGIC_OP_INVERT,         // ~d
    D3D12_LOGIC_OP_AND,            // s & d
    D3D12_LOGIC_OP_NAND,           // ~(s & d)
    D3D12_LOGIC_OP_OR,             // s | d
    D3D12_LOGIC_OP_NOR,            // ~(s | d)
    D3D12_LOGIC_OP_XOR,            // s ^ d
    D3D12_LOGIC_OP_EQUIV,          // ~(s ^ d)
    D3D12_LOGIC_OP_AND_REVERSE,    // s & ~d
    D3D12_LOGIC_OP_AND_INVERTED,   // ~s & d
    D3D12_LOGIC_OP_OR_REVERSE,     // s | ~d
    D3D12_LOGIC_OP_OR_INVERTED,    // ~s | d
} D3D12_LOGIC_OP;

typedef struct D3D12_RENDER_TARGET_BLEND_DESC
{
    BOOL BlendEnable;
    BOOL LogicOpEnable; // LogicOpEnable and BlendEnable can't both be true
    D3D12_BLEND SrcBlend;
    D3D12_BLEND DestBlend;
    D3D12_BLEND_OP BlendOp;
    D3D12_BLEND SrcBlendAlpha;
    D3D12_BLEND DestBlendAlpha;
    D3D12_BLEND_OP BlendOpAlpha;
    D3D12_LOGIC_OP LogicOp; // applies to RGBA
    UINT8 RenderTargetWriteMask; // D3D12_COLOR_WRITE_ENABLE
} D3D12_RENDER_TARGET_BLEND_DESC;

typedef struct D3D12_BLEND_DESC
{
    BOOL AlphaToCoverageEnable; // relevant to multisample antialiasing only
    BOOL IndependentBlendEnable; // if FALSE, then replicate the first entry in RenderTarget array to other entries
    D3D12_RENDER_TARGET_BLEND_DESC RenderTarget[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT];
} D3D12_BLEND_DESC;

cpp_quote( "/* Note, the array size for RenderTarget[] above is D3D12_SIMULTANEOUS_RENDERTARGET_COUNT. ")
cpp_quote( "   IDL processing/generation of this header replaces the define; this comment is merely explaining what happened. */" ) 


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Rasterizer State
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

typedef enum D3D12_CONSERVATIVE_RASTERIZATION_MODE
{
    D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF       = 0, // Default
    D3D12_CONSERVATIVE_RASTERIZATION_MODE_ON        = 1,
} D3D12_CONSERVATIVE_RASTERIZATION_MODE;

typedef struct D3D12_RASTERIZER_DESC
{
    D3D12_FILL_MODE FillMode;
    D3D12_CULL_MODE CullMode;
    BOOL FrontCounterClockwise;
    INT DepthBias;
    FLOAT DepthBiasClamp;
    FLOAT SlopeScaledDepthBias;
    BOOL DepthClipEnable;
    BOOL MultisampleEnable;
    BOOL AntialiasedLineEnable;
    UINT ForcedSampleCount;  
    D3D12_CONSERVATIVE_RASTERIZATION_MODE ConservativeRaster;
} D3D12_RASTERIZER_DESC;

[ uuid( c54a6b66-72df-4ee8-8be5-a946a1429214 ), object, local, pointer_default( unique ) ]
interface ID3D12RootSignature
    : ID3D12DeviceChild
{
}

typedef struct D3D12_SHADER_BYTECODE
{
    [annotation("_Field_size_bytes_full_(BytecodeLength)")] const void* pShaderBytecode;
    SIZE_T BytecodeLength;
} D3D12_SHADER_BYTECODE;

typedef struct D3D12_STREAM_OUTPUT_DESC
{
    [annotation("_Field_size_full_(NumEntries)")] const D3D12_SO_DECLARATION_ENTRY* pSODeclaration;
    UINT NumEntries;
    [annotation("_Field_size_full_(NumStrides)")] const UINT* pBufferStrides;
    UINT NumStrides;
    UINT RasterizedStream;
} D3D12_STREAM_OUTPUT_DESC;

typedef struct D3D12_INPUT_LAYOUT_DESC
{
    [annotation("_Field_size_full_(NumElements)")] const D3D12_INPUT_ELEMENT_DESC* pInputElementDescs;
    UINT NumElements;
} D3D12_INPUT_LAYOUT_DESC;

typedef enum D3D12_INDEX_BUFFER_STRIP_CUT_VALUE
{
    D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED = 0,
    D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF = 1,
    D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF = 2
} D3D12_INDEX_BUFFER_STRIP_CUT_VALUE;

typedef struct D3D12_CACHED_PIPELINE_STATE
{
    [annotation("_Field_size_bytes_full_(CachedBlobSizeInBytes)")] const void* pCachedBlob;
    SIZE_T CachedBlobSizeInBytes;
} D3D12_CACHED_PIPELINE_STATE;

typedef enum D3D12_PIPELINE_STATE_FLAGS
{
    D3D12_PIPELINE_STATE_FLAG_NONE = 0x0,
    D3D12_PIPELINE_STATE_FLAG_TOOL_DEBUG = 0x1,

} D3D12_PIPELINE_STATE_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_PIPELINE_STATE_FLAGS );" )

typedef struct D3D12_GRAPHICS_PIPELINE_STATE_DESC
{
    ID3D12RootSignature*          pRootSignature;
    D3D12_SHADER_BYTECODE         VS;
    D3D12_SHADER_BYTECODE         PS;
    D3D12_SHADER_BYTECODE         DS;
    D3D12_SHADER_BYTECODE         HS;
    D3D12_SHADER_BYTECODE         GS;
    D3D12_STREAM_OUTPUT_DESC      StreamOutput;
    D3D12_BLEND_DESC              BlendState;
    UINT                          SampleMask;
    D3D12_RASTERIZER_DESC         RasterizerState;
    D3D12_DEPTH_STENCIL_DESC      DepthStencilState;
    D3D12_INPUT_LAYOUT_DESC       InputLayout;
    D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue;
    D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType;
    UINT                          NumRenderTargets;
    DXGI_FORMAT                   RTVFormats[ D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT ];
    DXGI_FORMAT                   DSVFormat;
    DXGI_SAMPLE_DESC              SampleDesc;
    UINT                          NodeMask;
    D3D12_CACHED_PIPELINE_STATE   CachedPSO;
    D3D12_PIPELINE_STATE_FLAGS    Flags;
} D3D12_GRAPHICS_PIPELINE_STATE_DESC;

typedef struct D3D12_COMPUTE_PIPELINE_STATE_DESC
{
    ID3D12RootSignature*   pRootSignature;
    D3D12_SHADER_BYTECODE  CS;
    UINT                   NodeMask;
    D3D12_CACHED_PIPELINE_STATE   CachedPSO;
    D3D12_PIPELINE_STATE_FLAGS    Flags;
} D3D12_COMPUTE_PIPELINE_STATE_DESC;

// D3D12 Caps
typedef enum D3D12_FEATURE
{
    D3D12_FEATURE_D3D12_OPTIONS,
    D3D12_FEATURE_ARCHITECTURE,
    D3D12_FEATURE_FEATURE_LEVELS,
    D3D12_FEATURE_FORMAT_SUPPORT,
    D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS,
    D3D12_FEATURE_FORMAT_INFO,
    D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT,
} D3D12_FEATURE;

typedef enum D3D12_SHADER_MIN_PRECISION_SUPPORT
{
    D3D12_SHADER_MIN_PRECISION_SUPPORT_NONE   = 0x0,
    D3D12_SHADER_MIN_PRECISION_SUPPORT_10_BIT = 0x1,
    D3D12_SHADER_MIN_PRECISION_SUPPORT_16_BIT = 0x2
} D3D12_SHADER_MIN_PRECISION_SUPPORT;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_SHADER_MIN_PRECISION_SUPPORT );" )

typedef enum D3D12_TILED_RESOURCES_TIER
{
    D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED = 0,
    D3D12_TILED_RESOURCES_TIER_1        = 1,
    D3D12_TILED_RESOURCES_TIER_2        = 2,
    D3D12_TILED_RESOURCES_TIER_3        = 3,
} D3D12_TILED_RESOURCES_TIER;

typedef enum D3D12_RESOURCE_BINDING_TIER
{
    D3D12_RESOURCE_BINDING_TIER_1 = 1,
    D3D12_RESOURCE_BINDING_TIER_2 = 2,
    D3D12_RESOURCE_BINDING_TIER_3 = 3,
} D3D12_RESOURCE_BINDING_TIER;

typedef enum D3D12_CONSERVATIVE_RASTERIZATION_TIER { 
  D3D12_CONSERVATIVE_RASTERIZATION_TIER_NOT_SUPPORTED  = 0,
  D3D12_CONSERVATIVE_RASTERIZATION_TIER_1         = 1,
  D3D12_CONSERVATIVE_RASTERIZATION_TIER_2         = 2,
  D3D12_CONSERVATIVE_RASTERIZATION_TIER_3         = 3,
} D3D12_CONSERVATIVE_RASTERIZATION_TIER;


typedef enum D3D12_FORMAT_SUPPORT1
{
    D3D12_FORMAT_SUPPORT1_NONE                       = 0,
    D3D12_FORMAT_SUPPORT1_BUFFER                      = 0x00000001,
    D3D12_FORMAT_SUPPORT1_IA_VERTEX_BUFFER            = 0x00000002,
    D3D12_FORMAT_SUPPORT1_IA_INDEX_BUFFER             = 0x00000004,
    D3D12_FORMAT_SUPPORT1_SO_BUFFER                   = 0x00000008,
    D3D12_FORMAT_SUPPORT1_TEXTURE1D                   = 0x00000010,
    D3D12_FORMAT_SUPPORT1_TEXTURE2D                   = 0x00000020,
    D3D12_FORMAT_SUPPORT1_TEXTURE3D                   = 0x00000040,
    D3D12_FORMAT_SUPPORT1_TEXTURECUBE                 = 0x00000080,
    D3D12_FORMAT_SUPPORT1_SHADER_LOAD                 = 0x00000100,
    D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE               = 0x00000200,
    D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE_COMPARISON    = 0x00000400,
    D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE_MONO_TEXT     = 0x00000800,
    D3D12_FORMAT_SUPPORT1_MIP                         = 0x00001000,
    D3D12_FORMAT_SUPPORT1_RENDER_TARGET               = 0x00004000,
    D3D12_FORMAT_SUPPORT1_BLENDABLE                   = 0x00008000,
    D3D12_FORMAT_SUPPORT1_DEPTH_STENCIL               = 0x00010000,
    D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RESOLVE         = 0x00040000,
    D3D12_FORMAT_SUPPORT1_DISPLAY                     = 0x00080000,
    D3D12_FORMAT_SUPPORT1_CAST_WITHIN_BIT_LAYOUT      = 0x00100000,
    D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RENDERTARGET    = 0x00200000,
    D3D12_FORMAT_SUPPORT1_MULTISAMPLE_LOAD            = 0x00400000,
    D3D12_FORMAT_SUPPORT1_SHADER_GATHER               = 0x00800000,
    D3D12_FORMAT_SUPPORT1_BACK_BUFFER_CAST            = 0x01000000,
    D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW = 0x02000000,
    D3D12_FORMAT_SUPPORT1_SHADER_GATHER_COMPARISON    = 0x04000000,
    D3D12_FORMAT_SUPPORT1_DECODER_OUTPUT              = 0x08000000,
    D3D12_FORMAT_SUPPORT1_VIDEO_PROCESSOR_OUTPUT      = 0x10000000,
    D3D12_FORMAT_SUPPORT1_VIDEO_PROCESSOR_INPUT       = 0x20000000,
    D3D12_FORMAT_SUPPORT1_VIDEO_ENCODER               = 0x40000000,
} D3D12_FORMAT_SUPPORT1;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_FORMAT_SUPPORT1 );" )

typedef enum D3D12_FORMAT_SUPPORT2
{
    D3D12_FORMAT_SUPPORT2_NONE                                              = 0,
    D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_ADD                                    = 0x00000001,
    D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS                            = 0x00000002,
    D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE      = 0x00000004,
    D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE                               = 0x00000008,
    D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX                      = 0x00000010,
    D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX                    = 0x00000020,
    D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD                                    = 0x00000040,
    D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE                                   = 0x00000080,
    D3D12_FORMAT_SUPPORT2_OUTPUT_MERGER_LOGIC_OP                            = 0x00000100,
    D3D12_FORMAT_SUPPORT2_TILED                                             = 0x00000200,
    D3D12_FORMAT_SUPPORT2_MULTIPLANE_OVERLAY                                = 0x00004000,
} D3D12_FORMAT_SUPPORT2;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_FORMAT_SUPPORT2 );" )

typedef enum D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS
{
    D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_NONE           = 0,
    D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_TILED_RESOURCE = 0x00000001,
} D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS );" )

typedef enum D3D12_CROSS_NODE_SHARING_TIER
{
    D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED    = 0,
    D3D12_CROSS_NODE_SHARING_TIER_1_EMULATED  = 1,
    D3D12_CROSS_NODE_SHARING_TIER_1           = 2,
    D3D12_CROSS_NODE_SHARING_TIER_2           = 3,
} D3D12_CROSS_NODE_SHARING_TIER;


typedef enum D3D12_RESOURCE_HEAP_TIER
{
    D3D12_RESOURCE_HEAP_TIER_1 = 1,
    D3D12_RESOURCE_HEAP_TIER_2 = 2,
} D3D12_RESOURCE_HEAP_TIER;

// D3D12_FEATURE_D3D12_OPTIONS
typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS
{
    [annotation("_Out_")] BOOL DoublePrecisionFloatShaderOps;
    [annotation("_Out_")] BOOL OutputMergerLogicOp;
    [annotation("_Out_")] D3D12_SHADER_MIN_PRECISION_SUPPORT MinPrecisionSupport;
    [annotation("_Out_")] D3D12_TILED_RESOURCES_TIER TiledResourcesTier;
    [annotation("_Out_")] D3D12_RESOURCE_BINDING_TIER ResourceBindingTier;
    [annotation("_Out_")] BOOL PSSpecifiedStencilRefSupported;
    [annotation("_Out_")] BOOL TypedUAVLoadAdditionalFormats;
    [annotation("_Out_")] BOOL ROVsSupported;
    [annotation("_Out_")] D3D12_CONSERVATIVE_RASTERIZATION_TIER ConservativeRasterizationTier;
    [annotation("_Out_")] UINT MaxGPUVirtualAddressBitsPerResource;
    [annotation("_Out_")] BOOL StandardSwizzle64KBSupported;
    [annotation("_Out_")] D3D12_CROSS_NODE_SHARING_TIER CrossNodeSharingTier;
    [annotation("_Out_")] BOOL CrossAdapterRowMajorTextureSupported;
    [annotation("_Out_")] BOOL VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation;
    [annotation("_Out_")] D3D12_RESOURCE_HEAP_TIER ResourceHeapTier;
} D3D12_FEATURE_DATA_D3D12_OPTIONS;

// D3D12_FEATURE_ARCHITECTURE
typedef struct D3D12_FEATURE_DATA_ARCHITECTURE
{
    [annotation("_In_")]  UINT NodeIndex;
    [annotation("_Out_")] BOOL TileBasedRenderer;
    [annotation("_Out_")] BOOL UMA; // Needed for applications to understand WRITE_COMBINE
    [annotation("_Out_")] BOOL CacheCoherentUMA; // Only TRUE when UMA is also TRUE
} D3D12_FEATURE_DATA_ARCHITECTURE;

// D3D12_FEATURE_FEATURE_LEVELS
typedef struct D3D12_FEATURE_DATA_FEATURE_LEVELS
{
    [annotation("_In_")] UINT NumFeatureLevels;
    [annotation("_In_reads_(NumFeatureLevels)")] const D3D_FEATURE_LEVEL* pFeatureLevelsRequested;
    [annotation("_Out_")] D3D_FEATURE_LEVEL MaxSupportedFeatureLevel;
} D3D12_FEATURE_DATA_FEATURE_LEVELS;

// D3D12_FEATURE_FORMAT_SUPPORT
typedef struct D3D12_FEATURE_DATA_FORMAT_SUPPORT
{
    [annotation("_In_")] DXGI_FORMAT Format;
    [annotation("_Out_")] D3D12_FORMAT_SUPPORT1 Support1;
    [annotation("_Out_")] D3D12_FORMAT_SUPPORT2 Support2;
} D3D12_FEATURE_DATA_FORMAT_SUPPORT;

// D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS
typedef struct D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS
{
    [annotation("_In_")] DXGI_FORMAT Format;
    [annotation("_In_")] UINT SampleCount;
    [annotation("_In_")] D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags;
    [annotation("_Out_")] UINT NumQualityLevels;
} D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS;

// D3D12_FEATURE_FORMAT_INFO
typedef struct D3D12_FEATURE_DATA_FORMAT_INFO
{
    DXGI_FORMAT Format;
    UINT8 PlaneCount;
} D3D12_FEATURE_DATA_FORMAT_INFO;

// D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT
typedef struct D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT
{
    UINT MaxGPUVirtualAddressBitsPerResource;
    UINT MaxGPUVirtualAddressBitsPerProcess;
} D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT;


typedef struct D3D12_RESOURCE_ALLOCATION_INFO
{
    UINT64 SizeInBytes;
    UINT64 Alignment;
} D3D12_RESOURCE_ALLOCATION_INFO;

typedef enum D3D12_HEAP_TYPE
{
    D3D12_HEAP_TYPE_DEFAULT   = 1, 
    D3D12_HEAP_TYPE_UPLOAD    = 2,
    D3D12_HEAP_TYPE_READBACK  = 3,
    D3D12_HEAP_TYPE_CUSTOM    = 4,
} D3D12_HEAP_TYPE;

typedef enum D3D12_CPU_PAGE_PROPERTY
{
    D3D12_CPU_PAGE_PROPERTY_UNKNOWN = 0,
    D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE = 1,
    D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE = 2,
    D3D12_CPU_PAGE_PROPERTY_WRITE_BACK = 3,
} D3D12_CPU_PAGE_PROPERTY;

typedef enum D3D12_MEMORY_POOL
{
    D3D12_MEMORY_POOL_UNKNOWN = 0,
    D3D12_MEMORY_POOL_L0 = 1, // Maximum bandwidth for CPU
    D3D12_MEMORY_POOL_L1 = 2, // More bandwidth for GPU, less for CPU
} D3D12_MEMORY_POOL;

typedef struct D3D12_HEAP_PROPERTIES
{
    D3D12_HEAP_TYPE Type;
    D3D12_CPU_PAGE_PROPERTY CPUPageProperty;
    D3D12_MEMORY_POOL MemoryPoolPreference;
    UINT CreationNodeMask;
    UINT VisibleNodeMask;
} D3D12_HEAP_PROPERTIES;

typedef enum D3D12_HEAP_FLAGS
{
    D3D12_HEAP_FLAG_NONE = 0x0,
    D3D12_HEAP_FLAG_SHARED = 0x1,
    D3D12_HEAP_FLAG_DENY_BUFFERS = 0x4,
    D3D12_HEAP_FLAG_ALLOW_DISPLAY = 0x8,
    D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER = 0x20,
    D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES = 0x40,
    D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES = 0x80,

    // These are convenience aliases to manage resource heap tier restrictions. They cannot be bitwise OR'ed together cleanly.
    D3D12_HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES = 0x0,
    D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS = 0xC0,
    D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES = 0x44,
    D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES = 0x84,

} D3D12_HEAP_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_HEAP_FLAGS );" )

typedef struct D3D12_HEAP_DESC 
{
    UINT64 SizeInBytes;
    D3D12_HEAP_PROPERTIES Properties;
    UINT64 Alignment;
    D3D12_HEAP_FLAGS Flags;
} D3D12_HEAP_DESC;

typedef enum D3D12_RESOURCE_DIMENSION
{
    D3D12_RESOURCE_DIMENSION_UNKNOWN = 0,
    D3D12_RESOURCE_DIMENSION_BUFFER = 1,
    D3D12_RESOURCE_DIMENSION_TEXTURE1D = 2,
    D3D12_RESOURCE_DIMENSION_TEXTURE2D = 3,
    D3D12_RESOURCE_DIMENSION_TEXTURE3D = 4,
} D3D12_RESOURCE_DIMENSION;

typedef enum D3D12_TEXTURE_LAYOUT
{
    D3D12_TEXTURE_LAYOUT_UNKNOWN = 0,
    D3D12_TEXTURE_LAYOUT_ROW_MAJOR = 1, // Must be used with buffers.  Can be used with cross-adapter shared textures.
    D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE = 2,
    D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE = 3,
} D3D12_TEXTURE_LAYOUT; 

typedef enum D3D12_RESOURCE_FLAGS
{
    D3D12_RESOURCE_FLAG_NONE = 0x0,
    D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET = 0x1,
    D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL = 0x2,
    D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS = 0x4,
    D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE = 0x8,
    D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER = 0x10,
    D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS = 0x20,
} D3D12_RESOURCE_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_FLAGS );" )

typedef struct D3D12_RESOURCE_DESC
{
    D3D12_RESOURCE_DIMENSION Dimension;
    UINT64 Alignment;
    UINT64 Width;
    UINT Height;
    UINT16 DepthOrArraySize;
    UINT16 MipLevels;
    DXGI_FORMAT Format;
    DXGI_SAMPLE_DESC SampleDesc;
    D3D12_TEXTURE_LAYOUT Layout;
    D3D12_RESOURCE_FLAGS Flags;
} D3D12_RESOURCE_DESC;

typedef struct D3D12_DEPTH_STENCIL_VALUE
{
    FLOAT Depth;
    UINT8 Stencil;
} D3D12_DEPTH_STENCIL_VALUE;

typedef struct D3D12_CLEAR_VALUE
{
    DXGI_FORMAT Format;
    union
    {
        FLOAT Color[4];
        D3D12_DEPTH_STENCIL_VALUE DepthStencil;
    };
} D3D12_CLEAR_VALUE;

typedef struct D3D12_RANGE
{
    SIZE_T Begin;
    SIZE_T End; // One past end, so (End - Begin) = Size
} D3D12_RANGE;

typedef struct D3D12_SUBRESOURCE_INFO
{
    UINT64 Offset;
    UINT RowPitch;
    UINT DepthPitch;
} D3D12_SUBRESOURCE_INFO;

typedef struct D3D12_TILED_RESOURCE_COORDINATE
{
    UINT X;
    UINT Y;
    UINT Z;
    UINT Subresource; 
} D3D12_TILED_RESOURCE_COORDINATE;

typedef struct D3D12_TILE_REGION_SIZE
{
    UINT NumTiles; 
    BOOL UseBox; 
    UINT Width; 
    UINT16 Height;
    UINT16 Depth;
} D3D12_TILE_REGION_SIZE;

typedef enum D3D12_TILE_RANGE_FLAGS
{
    D3D12_TILE_RANGE_FLAG_NONE = 0,
    D3D12_TILE_RANGE_FLAG_NULL = 1,
    D3D12_TILE_RANGE_FLAG_SKIP = 2,
    D3D12_TILE_RANGE_FLAG_REUSE_SINGLE_TILE = 4,
} D3D12_TILE_RANGE_FLAGS;

typedef struct D3D12_SUBRESOURCE_TILING
{
    UINT WidthInTiles;
    UINT16 HeightInTiles;
    UINT16 DepthInTiles;
    UINT StartTileIndexInOverallResource;
} D3D12_SUBRESOURCE_TILING;

typedef struct D3D12_TILE_SHAPE
{
    UINT WidthInTexels; 
    UINT HeightInTexels;
    UINT DepthInTexels;
} D3D12_TILE_SHAPE;

typedef struct D3D12_PACKED_MIP_INFO
{
    UINT8 NumStandardMips;
    UINT8 NumPackedMips;
    UINT NumTilesForPackedMips;
    UINT StartTileIndexInOverallResource;
} D3D12_PACKED_MIP_INFO;

typedef enum D3D12_TILE_MAPPING_FLAGS 
{
    D3D12_TILE_MAPPING_FLAG_NONE = 0x0,
    D3D12_TILE_MAPPING_FLAG_NO_HAZARD = 0x1,
} D3D12_TILE_MAPPING_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_TILE_MAPPING_FLAGS );" )

typedef enum D3D12_TILE_COPY_FLAGS 
{
    D3D12_TILE_COPY_FLAG_NONE = 0x0,
    D3D12_TILE_COPY_FLAG_NO_HAZARD = 0x1,
    D3D12_TILE_COPY_FLAG_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x2,
    D3D12_TILE_COPY_FLAG_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 0x4,
} D3D12_TILE_COPY_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_TILE_COPY_FLAGS );" )

// Resource Barrier
typedef enum D3D12_RESOURCE_STATES
{
    D3D12_RESOURCE_STATE_COMMON                    = 0,

    D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER  = 0x0001,
    D3D12_RESOURCE_STATE_INDEX_BUFFER                = 0x0002,
    D3D12_RESOURCE_STATE_RENDER_TARGET               = 0x0004,
    D3D12_RESOURCE_STATE_UNORDERED_ACCESS            = 0x0008,
    D3D12_RESOURCE_STATE_DEPTH_WRITE                 = 0x0010,
    D3D12_RESOURCE_STATE_DEPTH_READ                  = 0x0020,
    D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE   = 0x0040,
    D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE       = 0x0080,
    D3D12_RESOURCE_STATE_STREAM_OUT                  = 0x0100,
    D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT           = 0x0200,
    D3D12_RESOURCE_STATE_COPY_DEST                   = 0x0400,
    D3D12_RESOURCE_STATE_COPY_SOURCE                 = 0x0800,
    D3D12_RESOURCE_STATE_RESOLVE_DEST                = 0x1000,
    D3D12_RESOURCE_STATE_RESOLVE_SOURCE              = 0x2000,
    D3D12_RESOURCE_STATE_GENERIC_READ =
        /*D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER*/ 0x0001 |
        /*D3D12_RESOURCE_STATE_INDEX_BUFFER*/               0x0002 |
        /*D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE*/  0x0040 |
        /*D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE*/      0x0080 |
        /*D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT*/          0x0200 |
        /*D3D12_RESOURCE_STATE_COPY_SOURCE*/                0x0800,

    D3D12_RESOURCE_STATE_PRESENT                = 0,
    D3D12_RESOURCE_STATE_PREDICATION            = /*D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT*/ 0x0200,


} D3D12_RESOURCE_STATES;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_STATES );" )

typedef enum D3D12_RESOURCE_BARRIER_TYPE
{
    D3D12_RESOURCE_BARRIER_TYPE_TRANSITION,
    D3D12_RESOURCE_BARRIER_TYPE_ALIASING,
    D3D12_RESOURCE_BARRIER_TYPE_UAV,
} D3D12_RESOURCE_BARRIER_TYPE;

interface ID3D12Resource;

typedef struct D3D12_RESOURCE_TRANSITION_BARRIER
{
    ID3D12Resource* pResource;
    UINT Subresource;
    D3D12_RESOURCE_STATES StateBefore;
    D3D12_RESOURCE_STATES StateAfter;
} D3D12_RESOURCE_TRANSITION_BARRIER;

typedef struct D3D12_RESOURCE_ALIASING_BARRIER
{
    ID3D12Resource* pResourceBefore;
    ID3D12Resource* pResourceAfter;
} D3D12_RESOURCE_ALIASING_BARRIER;

typedef struct D3D12_RESOURCE_UAV_BARRIER
{
    ID3D12Resource* pResource;
} D3D12_RESOURCE_UAV_BARRIER;

typedef enum D3D12_RESOURCE_BARRIER_FLAGS
{
    D3D12_RESOURCE_BARRIER_FLAG_NONE       = 0x0,
    D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY = 0x1,
    D3D12_RESOURCE_BARRIER_FLAG_END_ONLY   = 0x2,
} D3D12_RESOURCE_BARRIER_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_BARRIER_FLAGS );" )

typedef struct D3D12_RESOURCE_BARRIER
{
    D3D12_RESOURCE_BARRIER_TYPE    Type;
    D3D12_RESOURCE_BARRIER_FLAGS    Flags;

    union
    {
        D3D12_RESOURCE_TRANSITION_BARRIER Transition;
        D3D12_RESOURCE_ALIASING_BARRIER   Aliasing;
        D3D12_RESOURCE_UAV_BARRIER        UAV;
    };
} D3D12_RESOURCE_BARRIER;

typedef struct D3D12_SUBRESOURCE_FOOTPRINT
{
    DXGI_FORMAT Format;
    UINT        Width;
    UINT        Height;
    UINT        Depth;
    UINT        RowPitch; // Must be a multiple of D3D12_TEXTURE_DATA_PITCH_ALIGNMENT
} D3D12_SUBRESOURCE_FOOTPRINT;

typedef struct D3D12_PLACED_SUBRESOURCE_FOOTPRINT
{
    UINT64                         Offset; // Must be a multiple of D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT
    D3D12_SUBRESOURCE_FOOTPRINT Footprint;
} D3D12_PLACED_SUBRESOURCE_FOOTPRINT;

typedef enum D3D12_TEXTURE_COPY_TYPE
{
    D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX  = 0,
    D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT   = 1,
} D3D12_TEXTURE_COPY_TYPE;

typedef struct D3D12_TEXTURE_COPY_LOCATION
{
    ID3D12Resource* pResource;
    D3D12_TEXTURE_COPY_TYPE Type;
    union
    {
        D3D12_PLACED_SUBRESOURCE_FOOTPRINT PlacedFootprint;
        UINT SubresourceIndex;
    };
} D3D12_TEXTURE_COPY_LOCATION;

// D3D12 view descriptions
typedef enum D3D12_SHADER_COMPONENT_MAPPING
{
    D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0 = 0,
    D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1 = 1,
    D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2 = 2,
    D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3 = 3,
    D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0 = 4,
    D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1 = 5,
} D3D12_SHADER_COMPONENT_MAPPING;

cpp_quote( "#define D3D12_SHADER_COMPONENT_MAPPING_MASK 0x7 ")
cpp_quote( "#define D3D12_SHADER_COMPONENT_MAPPING_SHIFT 3 ")
cpp_quote( "#define D3D12_SHADER_COMPONENT_MAPPING_ALWAYS_SET_BIT_AVOIDING_ZEROMEM_MISTAKES (1<<(D3D12_SHADER_COMPONENT_MAPPING_SHIFT*4)) ")
cpp_quote( "#define D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(Src0,Src1,Src2,Src3) ((((Src0)&D3D12_SHADER_COMPONENT_MAPPING_MASK)| \\")
cpp_quote( "                                                                (((Src1)&D3D12_SHADER_COMPONENT_MAPPING_MASK)<<D3D12_SHADER_COMPONENT_MAPPING_SHIFT)| \\")
cpp_quote( "                                                                (((Src2)&D3D12_SHADER_COMPONENT_MAPPING_MASK)<<(D3D12_SHADER_COMPONENT_MAPPING_SHIFT*2))| \\")
cpp_quote( "                                                                (((Src3)&D3D12_SHADER_COMPONENT_MAPPING_MASK)<<(D3D12_SHADER_COMPONENT_MAPPING_SHIFT*3))| \\")
cpp_quote( "                                                                D3D12_SHADER_COMPONENT_MAPPING_ALWAYS_SET_BIT_AVOIDING_ZEROMEM_MISTAKES))")
cpp_quote( "#define D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(ComponentToExtract,Mapping) ((D3D12_SHADER_COMPONENT_MAPPING)(Mapping >> (D3D12_SHADER_COMPONENT_MAPPING_SHIFT*ComponentToExtract) & D3D12_SHADER_COMPONENT_MAPPING_MASK))")
cpp_quote( "#define D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(0,1,2,3) ")
 
typedef enum D3D12_BUFFER_SRV_FLAGS
{
    D3D12_BUFFER_SRV_FLAG_NONE = 0,
    D3D12_BUFFER_SRV_FLAG_RAW  = 0x00000001,      // allow device multi-component reads with DWORD addressing
} D3D12_BUFFER_SRV_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_BUFFER_SRV_FLAGS );" )

typedef struct D3D12_BUFFER_SRV
{
    UINT64 FirstElement;
    UINT NumElements;
    UINT StructureByteStride; // if nonzero, format must be DXGI_FORMAT_UNKNOWN
    D3D12_BUFFER_SRV_FLAGS Flags;
} D3D12_BUFFER_SRV;

typedef struct D3D12_TEX1D_SRV
{
    UINT MostDetailedMip;
    UINT MipLevels;
    FLOAT ResourceMinLODClamp;
} D3D12_TEX1D_SRV;

typedef struct D3D12_TEX1D_ARRAY_SRV
{
    UINT MostDetailedMip;
    UINT MipLevels;
    UINT FirstArraySlice;
    UINT ArraySize;
    FLOAT ResourceMinLODClamp;
} D3D12_TEX1D_ARRAY_SRV;

typedef struct D3D12_TEX2D_SRV
{
    UINT MostDetailedMip;
    UINT MipLevels;
    UINT PlaneSlice;
    FLOAT ResourceMinLODClamp;
} D3D12_TEX2D_SRV;

typedef struct D3D12_TEX2D_ARRAY_SRV
{
    UINT MostDetailedMip;
    UINT MipLevels;
    UINT FirstArraySlice;
    UINT ArraySize;
    UINT PlaneSlice;
    FLOAT ResourceMinLODClamp;
} D3D12_TEX2D_ARRAY_SRV;

typedef struct D3D12_TEX3D_SRV
{
    UINT MostDetailedMip;
    UINT MipLevels;
    FLOAT ResourceMinLODClamp;
} D3D12_TEX3D_SRV;

typedef struct D3D12_TEXCUBE_SRV
{
    UINT MostDetailedMip;
    UINT MipLevels;
    FLOAT ResourceMinLODClamp;
} D3D12_TEXCUBE_SRV;

typedef struct D3D12_TEXCUBE_ARRAY_SRV
{
    UINT MostDetailedMip;
    UINT MipLevels;
    UINT First2DArrayFace;
    UINT NumCubes;
    FLOAT ResourceMinLODClamp;
} D3D12_TEXCUBE_ARRAY_SRV;

typedef struct D3D12_TEX2DMS_SRV
{
    // don't need to define anything specific for this view dimension
    UINT UnusedField_NothingToDefine;
} D3D12_TEX2DMS_SRV;

typedef struct D3D12_TEX2DMS_ARRAY_SRV
{
    UINT FirstArraySlice;
    UINT ArraySize;
} D3D12_TEX2DMS_ARRAY_SRV;

typedef enum D3D12_SRV_DIMENSION {
    D3D12_SRV_DIMENSION_UNKNOWN = 0,
    D3D12_SRV_DIMENSION_BUFFER = 1,
    D3D12_SRV_DIMENSION_TEXTURE1D = 2,
    D3D12_SRV_DIMENSION_TEXTURE1DARRAY = 3,
    D3D12_SRV_DIMENSION_TEXTURE2D = 4,
    D3D12_SRV_DIMENSION_TEXTURE2DARRAY = 5,
    D3D12_SRV_DIMENSION_TEXTURE2DMS = 6,
    D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY = 7,
    D3D12_SRV_DIMENSION_TEXTURE3D = 8,
    D3D12_SRV_DIMENSION_TEXTURECUBE = 9,
    D3D12_SRV_DIMENSION_TEXTURECUBEARRAY = 10,
} D3D12_SRV_DIMENSION;

typedef struct D3D12_SHADER_RESOURCE_VIEW_DESC
{
    DXGI_FORMAT Format;
    D3D12_SRV_DIMENSION ViewDimension;
    UINT Shader4ComponentMapping;

    union
    {
        D3D12_BUFFER_SRV Buffer;
        D3D12_TEX1D_SRV Texture1D;
        D3D12_TEX1D_ARRAY_SRV Texture1DArray;
        D3D12_TEX2D_SRV Texture2D;
        D3D12_TEX2D_ARRAY_SRV Texture2DArray;
        D3D12_TEX2DMS_SRV Texture2DMS;
        D3D12_TEX2DMS_ARRAY_SRV Texture2DMSArray;
        D3D12_TEX3D_SRV Texture3D;
        D3D12_TEXCUBE_SRV TextureCube;
        D3D12_TEXCUBE_ARRAY_SRV TextureCubeArray;
    };
} D3D12_SHADER_RESOURCE_VIEW_DESC;

typedef struct D3D12_CONSTANT_BUFFER_VIEW_DESC
{
    D3D12_GPU_VIRTUAL_ADDRESS BufferLocation;
    UINT SizeInBytes; 
} D3D12_CONSTANT_BUFFER_VIEW_DESC;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Sampler
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef enum D3D12_FILTER
{
    // Bits used in defining enumeration of valid filters:
    // bits [1:0] - mip: 0 == point, 1 == linear, 2,3 unused
    // bits [3:2] - mag: 0 == point, 1 == linear, 2,3 unused
    // bits [5:4] - min: 0 == point, 1 == linear, 2,3 unused
    // bit  [6]   - aniso
    // bits [8:7] - reduction type:
    //                0 == standard filtering
    //                1 == comparison
    //                2 == min
    //                3 == max
    // bit  [31]  - mono 1-bit (narrow-purpose filter) [no longer supported in D3D12]

    D3D12_FILTER_MIN_MAG_MIP_POINT                              = 0x00000000,
    D3D12_FILTER_MIN_MAG_POINT_MIP_LINEAR                       = 0x00000001,
    D3D12_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT                 = 0x00000004,
    D3D12_FILTER_MIN_POINT_MAG_MIP_LINEAR                       = 0x00000005,
    D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT                       = 0x00000010,
    D3D12_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR                = 0x00000011,
    D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT                       = 0x00000014,
    D3D12_FILTER_MIN_MAG_MIP_LINEAR                             = 0x00000015,
    D3D12_FILTER_ANISOTROPIC                                    = 0x00000055,
    D3D12_FILTER_COMPARISON_MIN_MAG_MIP_POINT                   = 0x00000080,
    D3D12_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR            = 0x00000081,
    D3D12_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT      = 0x00000084,
    D3D12_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR            = 0x00000085,
    D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT            = 0x00000090,
    D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR     = 0x00000091,
    D3D12_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT            = 0x00000094,
    D3D12_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR                  = 0x00000095,
    D3D12_FILTER_COMPARISON_ANISOTROPIC                         = 0x000000d5,
    D3D12_FILTER_MINIMUM_MIN_MAG_MIP_POINT                      = 0x00000100,
    D3D12_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR               = 0x00000101,
    D3D12_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT         = 0x00000104,
    D3D12_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR               = 0x00000105,
    D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT               = 0x00000110,
    D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR        = 0x00000111,
    D3D12_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT               = 0x00000114,
    D3D12_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR                     = 0x00000115,
    D3D12_FILTER_MINIMUM_ANISOTROPIC                            = 0x00000155,
    D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_POINT                      = 0x00000180,
    D3D12_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR               = 0x00000181,
    D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT         = 0x00000184,
    D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR               = 0x00000185,
    D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT               = 0x00000190,
    D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR        = 0x00000191,
    D3D12_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT               = 0x00000194,
    D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR                     = 0x00000195,
    D3D12_FILTER_MAXIMUM_ANISOTROPIC                            = 0x000001d5
} D3D12_FILTER;

typedef enum D3D12_FILTER_TYPE
{
    D3D12_FILTER_TYPE_POINT = 0,
    D3D12_FILTER_TYPE_LINEAR = 1,
} D3D12_FILTER_TYPE;

typedef enum D3D12_FILTER_REDUCTION_TYPE
{
    D3D12_FILTER_REDUCTION_TYPE_STANDARD = 0,
    D3D12_FILTER_REDUCTION_TYPE_COMPARISON = 1,
    D3D12_FILTER_REDUCTION_TYPE_MINIMUM = 2,
    D3D12_FILTER_REDUCTION_TYPE_MAXIMUM = 3,
} D3D12_FILTER_REDUCTION_TYPE;

const UINT D3D12_FILTER_REDUCTION_TYPE_MASK = 0x00000003;
const UINT D3D12_FILTER_REDUCTION_TYPE_SHIFT = 7;

const UINT D3D12_FILTER_TYPE_MASK = 0x00000003;
const UINT D3D12_MIN_FILTER_SHIFT = 4;
const UINT D3D12_MAG_FILTER_SHIFT = 2;
const UINT D3D12_MIP_FILTER_SHIFT = 0;

const UINT D3D12_ANISOTROPIC_FILTERING_BIT = 0x00000040;

// encode enum entry for most filters except anisotropic filtering
cpp_quote( "#define D3D12_ENCODE_BASIC_FILTER( min, mag, mip, reduction )                                                     \\" )
cpp_quote( "                                   ( ( D3D12_FILTER ) (                                                           \\" )
cpp_quote( "                                   ( ( ( min ) & D3D12_FILTER_TYPE_MASK ) << D3D12_MIN_FILTER_SHIFT ) |           \\" )
cpp_quote( "                                   ( ( ( mag ) & D3D12_FILTER_TYPE_MASK ) << D3D12_MAG_FILTER_SHIFT ) |           \\" )
cpp_quote( "                                   ( ( ( mip ) & D3D12_FILTER_TYPE_MASK ) << D3D12_MIP_FILTER_SHIFT ) |           \\" )
cpp_quote( "                                   ( ( ( reduction ) & D3D12_FILTER_REDUCTION_TYPE_MASK ) << D3D12_FILTER_REDUCTION_TYPE_SHIFT ) ) ) " )

// encode enum entry for anisotropic filtering (with or without comparison filtering)
cpp_quote( "#define D3D12_ENCODE_ANISOTROPIC_FILTER( reduction )                                                  \\" )
cpp_quote( "                                         ( ( D3D12_FILTER ) (                                         \\" )
cpp_quote( "                                         D3D12_ANISOTROPIC_FILTERING_BIT |                            \\" )
cpp_quote( "                                         D3D12_ENCODE_BASIC_FILTER( D3D12_FILTER_TYPE_LINEAR,         \\" )
cpp_quote( "                                                                    D3D12_FILTER_TYPE_LINEAR,         \\" )
cpp_quote( "                                                                    D3D12_FILTER_TYPE_LINEAR,         \\" )
cpp_quote( "                                                                    reduction ) ) )                     " )

cpp_quote( "#define D3D12_DECODE_MIN_FILTER( D3D12Filter )                                                              \\" )
cpp_quote( "                                 ( ( D3D12_FILTER_TYPE )                                                    \\" )
cpp_quote( "                                 ( ( ( D3D12Filter ) >> D3D12_MIN_FILTER_SHIFT ) & D3D12_FILTER_TYPE_MASK ) ) " )

cpp_quote( "#define D3D12_DECODE_MAG_FILTER( D3D12Filter )                                                              \\" )
cpp_quote( "                                 ( ( D3D12_FILTER_TYPE )                                                    \\" )
cpp_quote( "                                 ( ( ( D3D12Filter ) >> D3D12_MAG_FILTER_SHIFT ) & D3D12_FILTER_TYPE_MASK ) ) " )

cpp_quote( "#define D3D12_DECODE_MIP_FILTER( D3D12Filter )                                                              \\" )
cpp_quote( "                                 ( ( D3D12_FILTER_TYPE )                                                    \\" )
cpp_quote( "                                 ( ( ( D3D12Filter ) >> D3D12_MIP_FILTER_SHIFT ) & D3D12_FILTER_TYPE_MASK ) ) " )

cpp_quote( "#define D3D12_DECODE_FILTER_REDUCTION( D3D12Filter )                                                        \\" )
cpp_quote( "                                 ( ( D3D12_FILTER_REDUCTION_TYPE )                                                      \\" )
cpp_quote( "                                 ( ( ( D3D12Filter ) >> D3D12_FILTER_REDUCTION_TYPE_SHIFT ) & D3D12_FILTER_REDUCTION_TYPE_MASK ) ) " )

cpp_quote( "#define D3D12_DECODE_IS_COMPARISON_FILTER( D3D12Filter )                                                    \\" )
cpp_quote( "                                 ( D3D12_DECODE_FILTER_REDUCTION( D3D12Filter ) == D3D12_FILTER_REDUCTION_TYPE_COMPARISON ) " )

cpp_quote( "#define D3D12_DECODE_IS_ANISOTROPIC_FILTER( D3D12Filter )                                               \\" )
cpp_quote( "                            ( ( ( D3D12Filter ) & D3D12_ANISOTROPIC_FILTERING_BIT ) &&                  \\" )
cpp_quote( "                            ( D3D12_FILTER_TYPE_LINEAR == D3D12_DECODE_MIN_FILTER( D3D12Filter ) ) &&   \\" )
cpp_quote( "                            ( D3D12_FILTER_TYPE_LINEAR == D3D12_DECODE_MAG_FILTER( D3D12Filter ) ) &&   \\" )
cpp_quote( "                            ( D3D12_FILTER_TYPE_LINEAR == D3D12_DECODE_MIP_FILTER( D3D12Filter ) ) )      " )

typedef enum D3D12_TEXTURE_ADDRESS_MODE
{
    D3D12_TEXTURE_ADDRESS_MODE_WRAP = 1,
    D3D12_TEXTURE_ADDRESS_MODE_MIRROR = 2,
    D3D12_TEXTURE_ADDRESS_MODE_CLAMP = 3,
    D3D12_TEXTURE_ADDRESS_MODE_BORDER = 4,
    D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE = 5
} D3D12_TEXTURE_ADDRESS_MODE;

typedef struct D3D12_SAMPLER_DESC
{
    D3D12_FILTER Filter;
    D3D12_TEXTURE_ADDRESS_MODE AddressU;
    D3D12_TEXTURE_ADDRESS_MODE AddressV;
    D3D12_TEXTURE_ADDRESS_MODE AddressW;
    FLOAT MipLODBias;
    UINT MaxAnisotropy;
    D3D12_COMPARISON_FUNC ComparisonFunc;
    FLOAT BorderColor[4]; // RGBA
    FLOAT MinLOD;
    FLOAT MaxLOD;
} D3D12_SAMPLER_DESC;

typedef enum D3D12_BUFFER_UAV_FLAGS
{
    D3D12_BUFFER_UAV_FLAG_NONE =   0,
    D3D12_BUFFER_UAV_FLAG_RAW  =   0x00000001,
} D3D12_BUFFER_UAV_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_BUFFER_UAV_FLAGS );" )

typedef struct D3D12_BUFFER_UAV
{
    UINT64 FirstElement;
    UINT NumElements;
    UINT StructureByteStride; // if nonzero, format must be DXGI_FORMAT_UNKNOWN
    UINT64 CounterOffsetInBytes;
    D3D12_BUFFER_UAV_FLAGS Flags;
} D3D12_BUFFER_UAV;

typedef struct D3D12_TEX1D_UAV
{
    UINT MipSlice;
} D3D12_TEX1D_UAV;

typedef struct D3D12_TEX1D_ARRAY_UAV
{
    UINT MipSlice;
    UINT FirstArraySlice;
    UINT ArraySize;
} D3D12_TEX1D_ARRAY_UAV;

typedef struct D3D12_TEX2D_UAV
{
    UINT MipSlice;
    UINT PlaneSlice;
} D3D12_TEX2D_UAV;

typedef struct D3D12_TEX2D_ARRAY_UAV
{
    UINT MipSlice;
    UINT FirstArraySlice;
    UINT ArraySize;
    UINT PlaneSlice;
} D3D12_TEX2D_ARRAY_UAV;

typedef struct D3D12_TEX3D_UAV
{
    UINT MipSlice;
    UINT FirstWSlice;
    UINT WSize;
} D3D12_TEX3D_UAV;

typedef enum D3D12_UAV_DIMENSION
{
    D3D12_UAV_DIMENSION_UNKNOWN = 0,
    D3D12_UAV_DIMENSION_BUFFER = 1,
    D3D12_UAV_DIMENSION_TEXTURE1D = 2,
    D3D12_UAV_DIMENSION_TEXTURE1DARRAY = 3,
    D3D12_UAV_DIMENSION_TEXTURE2D = 4,
    D3D12_UAV_DIMENSION_TEXTURE2DARRAY = 5,
    D3D12_UAV_DIMENSION_TEXTURE3D = 8,
} D3D12_UAV_DIMENSION;

typedef struct D3D12_UNORDERED_ACCESS_VIEW_DESC
{
    DXGI_FORMAT Format;
    D3D12_UAV_DIMENSION ViewDimension;

    union
    {
        D3D12_BUFFER_UAV Buffer;
        D3D12_TEX1D_UAV Texture1D;
        D3D12_TEX1D_ARRAY_UAV Texture1DArray;
        D3D12_TEX2D_UAV Texture2D;
        D3D12_TEX2D_ARRAY_UAV Texture2DArray;
        D3D12_TEX3D_UAV Texture3D;
    };
} D3D12_UNORDERED_ACCESS_VIEW_DESC;

typedef struct D3D12_BUFFER_RTV
{
    UINT64 FirstElement;
    UINT NumElements;
} D3D12_BUFFER_RTV;

typedef struct D3D12_TEX1D_RTV
{
    UINT MipSlice;
} D3D12_TEX1D_RTV;

typedef struct D3D12_TEX1D_ARRAY_RTV
{
    UINT MipSlice;
    UINT FirstArraySlice;
    UINT ArraySize;
} D3D12_TEX1D_ARRAY_RTV;

typedef struct D3D12_TEX2D_RTV
{
    UINT MipSlice;
    UINT PlaneSlice;
} D3D12_TEX2D_RTV;

typedef struct D3D12_TEX2DMS_RTV
{
    UINT UnusedField_NothingToDefine;
} D3D12_TEX2DMS_RTV;

typedef struct D3D12_TEX2D_ARRAY_RTV
{
    UINT MipSlice;
    UINT FirstArraySlice;
    UINT ArraySize;
    UINT PlaneSlice;
} D3D12_TEX2D_ARRAY_RTV;

typedef struct D3D12_TEX2DMS_ARRAY_RTV
{
    UINT FirstArraySlice;
    UINT ArraySize;
} D3D12_TEX2DMS_ARRAY_RTV;

typedef struct D3D12_TEX3D_RTV
{
    UINT MipSlice;
    UINT FirstWSlice;
    UINT WSize;
} D3D12_TEX3D_RTV;

typedef enum D3D12_RTV_DIMENSION
{
    D3D12_RTV_DIMENSION_UNKNOWN = 0,
    D3D12_RTV_DIMENSION_BUFFER = 1,
    D3D12_RTV_DIMENSION_TEXTURE1D = 2,
    D3D12_RTV_DIMENSION_TEXTURE1DARRAY = 3,
    D3D12_RTV_DIMENSION_TEXTURE2D = 4,
    D3D12_RTV_DIMENSION_TEXTURE2DARRAY = 5,
    D3D12_RTV_DIMENSION_TEXTURE2DMS = 6,
    D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY = 7,
    D3D12_RTV_DIMENSION_TEXTURE3D = 8,
} D3D12_RTV_DIMENSION;

typedef struct D3D12_RENDER_TARGET_VIEW_DESC
{
    DXGI_FORMAT Format;
    D3D12_RTV_DIMENSION ViewDimension;

    union
    {
        D3D12_BUFFER_RTV Buffer;
        D3D12_TEX1D_RTV Texture1D;
        D3D12_TEX1D_ARRAY_RTV Texture1DArray;
        D3D12_TEX2D_RTV Texture2D;
        D3D12_TEX2D_ARRAY_RTV Texture2DArray;
        D3D12_TEX2DMS_RTV Texture2DMS;
        D3D12_TEX2DMS_ARRAY_RTV Texture2DMSArray;
        D3D12_TEX3D_RTV Texture3D;
    };
} D3D12_RENDER_TARGET_VIEW_DESC;

typedef struct D3D12_TEX1D_DSV
{
    UINT MipSlice;
} D3D12_TEX1D_DSV;

typedef struct D3D12_TEX1D_ARRAY_DSV
{
    UINT MipSlice;
    UINT FirstArraySlice;
    UINT ArraySize;
} D3D12_TEX1D_ARRAY_DSV;

typedef struct D3D12_TEX2D_DSV
{
    UINT MipSlice;
} D3D12_TEX2D_DSV;

typedef struct D3D12_TEX2D_ARRAY_DSV
{
    UINT MipSlice;
    UINT FirstArraySlice;
    UINT ArraySize;
} D3D12_TEX2D_ARRAY_DSV;

typedef struct D3D12_TEX2DMS_DSV
{
    UINT UnusedField_NothingToDefine;
} D3D12_TEX2DMS_DSV;

typedef struct D3D12_TEX2DMS_ARRAY_DSV
{
    UINT FirstArraySlice;
    UINT ArraySize;
} D3D12_TEX2DMS_ARRAY_DSV;

typedef enum D3D12_DSV_FLAGS
{
    D3D12_DSV_FLAG_NONE              = 0x0,
    D3D12_DSV_FLAG_READ_ONLY_DEPTH   = 0x1,
    D3D12_DSV_FLAG_READ_ONLY_STENCIL = 0x2,
} D3D12_DSV_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_DSV_FLAGS );" )

typedef enum D3D12_DSV_DIMENSION
{
    D3D12_DSV_DIMENSION_UNKNOWN = 0,
    D3D12_DSV_DIMENSION_TEXTURE1D = 1,
    D3D12_DSV_DIMENSION_TEXTURE1DARRAY = 2,
    D3D12_DSV_DIMENSION_TEXTURE2D = 3,
    D3D12_DSV_DIMENSION_TEXTURE2DARRAY = 4,
    D3D12_DSV_DIMENSION_TEXTURE2DMS = 5,
    D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY = 6,
} D3D12_DSV_DIMENSION;

typedef struct D3D12_DEPTH_STENCIL_VIEW_DESC
{
    DXGI_FORMAT Format;
    D3D12_DSV_DIMENSION ViewDimension;
    D3D12_DSV_FLAGS Flags;

    union
    {
        D3D12_TEX1D_DSV Texture1D;
        D3D12_TEX1D_ARRAY_DSV Texture1DArray;
        D3D12_TEX2D_DSV Texture2D;
        D3D12_TEX2D_ARRAY_DSV Texture2DArray;
        D3D12_TEX2DMS_DSV Texture2DMS;
        D3D12_TEX2DMS_ARRAY_DSV Texture2DMSArray;
    };
} D3D12_DEPTH_STENCIL_VIEW_DESC;

typedef enum D3D12_CLEAR_FLAGS
{
    // Intentionally no flag for NONE
    D3D12_CLEAR_FLAG_DEPTH   = 0x01,
    D3D12_CLEAR_FLAG_STENCIL = 0x02,
} D3D12_CLEAR_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_CLEAR_FLAGS );" )

typedef enum D3D12_FENCE_FLAGS
{
    D3D12_FENCE_FLAG_NONE = 0x0,
    D3D12_FENCE_FLAG_SHARED = 0x1,
    D3D12_FENCE_FLAG_SHARED_CROSS_ADAPTER = 0x2,
} D3D12_FENCE_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_FENCE_FLAGS );" )


typedef enum D3D12_DESCRIPTOR_HEAP_TYPE
{
    D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
    D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER,
    D3D12_DESCRIPTOR_HEAP_TYPE_RTV,
    D3D12_DESCRIPTOR_HEAP_TYPE_DSV,
    D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES
} D3D12_DESCRIPTOR_HEAP_TYPE;

typedef enum D3D12_DESCRIPTOR_HEAP_FLAGS
{
    D3D12_DESCRIPTOR_HEAP_FLAG_NONE = 0x0,
    D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE = 0x1,
} D3D12_DESCRIPTOR_HEAP_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_DESCRIPTOR_HEAP_FLAGS );" )

typedef struct D3D12_DESCRIPTOR_HEAP_DESC
{
    D3D12_DESCRIPTOR_HEAP_TYPE Type;
    UINT NumDescriptors;
    D3D12_DESCRIPTOR_HEAP_FLAGS Flags;
    UINT NodeMask;
} D3D12_DESCRIPTOR_HEAP_DESC;

typedef enum D3D12_DESCRIPTOR_RANGE_TYPE
{
    D3D12_DESCRIPTOR_RANGE_TYPE_SRV,
    D3D12_DESCRIPTOR_RANGE_TYPE_UAV,
    D3D12_DESCRIPTOR_RANGE_TYPE_CBV,
    D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER
} D3D12_DESCRIPTOR_RANGE_TYPE;

typedef struct D3D12_DESCRIPTOR_RANGE
{
    D3D12_DESCRIPTOR_RANGE_TYPE RangeType;
    UINT NumDescriptors;
    UINT BaseShaderRegister;
    UINT RegisterSpace;
    UINT OffsetInDescriptorsFromTableStart;
} D3D12_DESCRIPTOR_RANGE;


typedef struct D3D12_ROOT_DESCRIPTOR_TABLE
{
    UINT NumDescriptorRanges;
    [annotation("_Field_size_full_(NumDescriptorRanges)")] const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges;
} D3D12_ROOT_DESCRIPTOR_TABLE;


typedef struct D3D12_ROOT_CONSTANTS
{
    UINT ShaderRegister;
    UINT RegisterSpace;
    UINT Num32BitValues;
} D3D12_ROOT_CONSTANTS;

typedef struct D3D12_ROOT_DESCRIPTOR
{
    UINT ShaderRegister;
    UINT RegisterSpace;
} D3D12_ROOT_DESCRIPTOR;

typedef enum D3D12_SHADER_VISIBILITY
{
    D3D12_SHADER_VISIBILITY_ALL = 0,
    D3D12_SHADER_VISIBILITY_VERTEX = 1,
    D3D12_SHADER_VISIBILITY_HULL = 2,
    D3D12_SHADER_VISIBILITY_DOMAIN = 3,
    D3D12_SHADER_VISIBILITY_GEOMETRY = 4,
    D3D12_SHADER_VISIBILITY_PIXEL = 5
} D3D12_SHADER_VISIBILITY;

typedef enum D3D12_ROOT_PARAMETER_TYPE
{
    D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE,
    D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS,
    D3D12_ROOT_PARAMETER_TYPE_CBV,
    D3D12_ROOT_PARAMETER_TYPE_SRV,
    D3D12_ROOT_PARAMETER_TYPE_UAV
} D3D12_ROOT_PARAMETER_TYPE;

typedef struct D3D12_ROOT_PARAMETER
{
    D3D12_ROOT_PARAMETER_TYPE ParameterType;
    union
    {
        D3D12_ROOT_DESCRIPTOR_TABLE    DescriptorTable;
        D3D12_ROOT_CONSTANTS           Constants;
        D3D12_ROOT_DESCRIPTOR          Descriptor;
    };
    D3D12_SHADER_VISIBILITY ShaderVisibility;
} D3D12_ROOT_PARAMETER;

typedef enum D3D12_ROOT_SIGNATURE_FLAGS
{
    D3D12_ROOT_SIGNATURE_FLAG_NONE                               = 0x0,
    D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT = 0x1,
    D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS     = 0x2,
    D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS       = 0x4,
    D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS     = 0x8,
    D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS   = 0x10,
    D3D12_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS      = 0x20,
    D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT                = 0x40,
} D3D12_ROOT_SIGNATURE_FLAGS;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( D3D12_ROOT_SIGNATURE_FLAGS );" )

typedef enum D3D12_STATIC_BORDER_COLOR
{
    D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK, // 0.0f,0.0f,0.0f,0.0f
    D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK, // 0.0f,0.0f,0.0f,1.0f
    D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, // 1.0f,1.0f,1.0f,1.0f
} D3D12_STATIC_BORDER_COLOR;

typedef struct D3D12_STATIC_SAMPLER_DESC
{
    D3D12_FILTER Filter;
    D3D12_TEXTURE_ADDRESS_MODE AddressU;
    D3D12_TEXTURE_ADDRESS_MODE AddressV;
    D3D12_TEXTURE_ADDRESS_MODE AddressW;
    FLOAT MipLODBias;
    UINT MaxAnisotropy;
    D3D12_COMPARISON_FUNC ComparisonFunc;
    D3D12_STATIC_BORDER_COLOR BorderColor; 
    FLOAT MinLOD;
    FLOAT MaxLOD;
    UINT ShaderRegister; 
    UINT RegisterSpace; 
    D3D12_SHADER_VISIBILITY ShaderVisibility;    
} D3D12_STATIC_SAMPLER_DESC;


typedef struct D3D12_ROOT_SIGNATURE_DESC
{
    UINT NumParameters;
    [annotation("_Field_size_full_(NumParameters)")] const D3D12_ROOT_PARAMETER* pParameters;
    UINT NumStaticSamplers;
    [annotation("_Field_size_full_(NumStaticSamplers)")] const D3D12_STATIC_SAMPLER_DESC* pStaticSamplers;
    D3D12_ROOT_SIGNATURE_FLAGS Flags;
} D3D12_ROOT_SIGNATURE_DESC;


typedef enum D3D_ROOT_SIGNATURE_VERSION
{
    D3D_ROOT_SIGNATURE_VERSION_1 = 0x1,
} D3D_ROOT_SIGNATURE_VERSION;

[ uuid( 34AB647B-3CC8-46AC-841B-C0965645C046 ), object, local, pointer_default( unique ) ]
interface ID3D12RootSignatureDeserializer
    : IUnknown
{
    const D3D12_ROOT_SIGNATURE_DESC * GetRootSignatureDesc();
};

cpp_quote( "typedef HRESULT (WINAPI* PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)(")
cpp_quote( "                            _In_ const D3D12_ROOT_SIGNATURE_DESC* pRootSignature," )
cpp_quote( "                            _In_ D3D_ROOT_SIGNATURE_VERSION Version," )
cpp_quote( "                            _Out_ ID3DBlob** ppBlob," )
cpp_quote( "                            _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob);" )
cpp_quote( "" )
cpp_quote( "HRESULT WINAPI D3D12SerializeRootSignature(")
cpp_quote( "                            _In_ const D3D12_ROOT_SIGNATURE_DESC* pRootSignature," )
cpp_quote( "                            _In_ D3D_ROOT_SIGNATURE_VERSION Version," )
cpp_quote( "                            _Out_ ID3DBlob** ppBlob," )
cpp_quote( "                            _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob);" )
cpp_quote( "" )
cpp_quote( "typedef HRESULT (WINAPI* PFN_D3D12_CREATE_ROOT_SIGNATURE_DESERIALIZER)(")
cpp_quote( "                                     _In_reads_bytes_(SrcDataSizeInBytes) LPCVOID pSrcData," )
cpp_quote( "                                     _In_ SIZE_T SrcDataSizeInBytes," )
cpp_quote( "                                     _In_ REFIID pRootSignatureDeserializerInterface," )
cpp_quote( "                                     _Out_ void** ppRootSignatureDeserializer);" )
cpp_quote( "" )
cpp_quote( "HRESULT WINAPI D3D12CreateRootSignatureDeserializer(")
cpp_quote( "                                     _In_reads_bytes_(SrcDataSizeInBytes) LPCVOID pSrcData," )
cpp_quote( "                                     _In_ SIZE_T SrcDataSizeInBytes," )
cpp_quote( "                                     _In_ REFIID pRootSignatureDeserializerInterface," )
cpp_quote( "                                     _Out_ void** ppRootSignatureDeserializer);" )



typedef struct D3D12_CPU_DESCRIPTOR_HANDLE
{
    SIZE_T ptr;
} D3D12_CPU_DESCRIPTOR_HANDLE; 


typedef struct D3D12_GPU_DESCRIPTOR_HANDLE
{
    UINT64 ptr;
} D3D12_GPU_DESCRIPTOR_HANDLE;

cpp_quote( "// If rects are supplied in D3D12_DISCARD_REGION, below, the resource " )
cpp_quote( "// must have 2D subresources with all specified subresources the same dimension." )
typedef struct D3D12_DISCARD_REGION
{
    UINT NumRects;
    [annotation("_In_reads_(NumRects)")] const D3D12_RECT* pRects;
    UINT FirstSubresource;
    UINT NumSubresources;
} D3D12_DISCARD_REGION;

typedef enum D3D12_QUERY_HEAP_TYPE
{
    D3D12_QUERY_HEAP_TYPE_OCCLUSION             = 0,
    D3D12_QUERY_HEAP_TYPE_TIMESTAMP             = 1,
    D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS   = 2,
    D3D12_QUERY_HEAP_TYPE_SO_STATISTICS         = 3,
} D3D12_QUERY_HEAP_TYPE;

typedef struct D3D12_QUERY_HEAP_DESC
{
    D3D12_QUERY_HEAP_TYPE Type;
    UINT Count;
    UINT NodeMask;
} D3D12_QUERY_HEAP_DESC; 

typedef enum D3D12_QUERY_TYPE
{
    D3D12_QUERY_TYPE_OCCLUSION                  = 0,
    D3D12_QUERY_TYPE_BINARY_OCCLUSION           = 1,
    D3D12_QUERY_TYPE_TIMESTAMP                  = 2,
    D3D12_QUERY_TYPE_PIPELINE_STATISTICS        = 3,
    D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0      = 4,
    D3D12_QUERY_TYPE_SO_STATISTICS_STREAM1      = 5,
    D3D12_QUERY_TYPE_SO_STATISTICS_STREAM2      = 6,
    D3D12_QUERY_TYPE_SO_STATISTICS_STREAM3      = 7,
} D3D12_QUERY_TYPE;

typedef enum D3D12_PREDICATION_OP
{
    D3D12_PREDICATION_OP_EQUAL_ZERO     = 0,
    D3D12_PREDICATION_OP_NOT_EQUAL_ZERO = 1,
} D3D12_PREDICATION_OP;

typedef struct D3D12_QUERY_DATA_PIPELINE_STATISTICS
{
    UINT64 IAVertices;
    UINT64 IAPrimitives;
    UINT64 VSInvocations;
    UINT64 GSInvocations;
    UINT64 GSPrimitives;
    UINT64 CInvocations;
    UINT64 CPrimitives;
    UINT64 PSInvocations;
    UINT64 HSInvocations;
    UINT64 DSInvocations;
    UINT64 CSInvocations;
} D3D12_QUERY_DATA_PIPELINE_STATISTICS;

typedef struct D3D12_QUERY_DATA_SO_STATISTICS
{
    UINT64 NumPrimitivesWritten;
    UINT64 PrimitivesStorageNeeded;
} D3D12_QUERY_DATA_SO_STATISTICS;

typedef struct D3D12_STREAM_OUTPUT_BUFFER_VIEW
{
    D3D12_GPU_VIRTUAL_ADDRESS BufferLocation;
    UINT64 SizeInBytes;
    D3D12_GPU_VIRTUAL_ADDRESS BufferFilledSizeLocation;
} D3D12_STREAM_OUTPUT_BUFFER_VIEW;

typedef struct D3D12_DRAW_ARGUMENTS
{
    UINT VertexCountPerInstance;
    UINT InstanceCount;
    UINT StartVertexLocation;
    UINT StartInstanceLocation;
} D3D12_DRAW_ARGUMENTS;

typedef struct D3D12_DRAW_INDEXED_ARGUMENTS
{
    UINT IndexCountPerInstance;
    UINT InstanceCount;
    UINT StartIndexLocation;
    INT  BaseVertexLocation;
    UINT StartInstanceLocation;
} D3D12_DRAW_INDEXED_ARGUMENTS;

typedef struct D3D12_DISPATCH_ARGUMENTS
{
    UINT ThreadGroupCountX;
    UINT ThreadGroupCountY;
    UINT ThreadGroupCountZ;
} D3D12_DISPATCH_ARGUMENTS;

typedef struct D3D12_VERTEX_BUFFER_VIEW
{
    D3D12_GPU_VIRTUAL_ADDRESS BufferLocation;
    UINT SizeInBytes; 
    UINT StrideInBytes;
} D3D12_VERTEX_BUFFER_VIEW;

typedef struct D3D12_INDEX_BUFFER_VIEW
{
    D3D12_GPU_VIRTUAL_ADDRESS BufferLocation;
    UINT SizeInBytes; 
    DXGI_FORMAT Format;
} D3D12_INDEX_BUFFER_VIEW;

typedef enum D3D12_INDIRECT_ARGUMENT_TYPE
{
    D3D12_INDIRECT_ARGUMENT_TYPE_DRAW,
    D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED,
    D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH,
    D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW,
    D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW,
    D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT,
    D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW,
    D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW,
    D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW,
} D3D12_INDIRECT_ARGUMENT_TYPE;

typedef struct D3D12_INDIRECT_ARGUMENT_DESC
{
    D3D12_INDIRECT_ARGUMENT_TYPE Type;

    union
    {
        struct
        {
            UINT Slot;
        } VertexBuffer;

        struct
        {
            UINT RootParameterIndex;
            UINT DestOffsetIn32BitValues;
            UINT Num32BitValuesToSet;
        } Constant;

        struct
        {
            UINT RootParameterIndex;
        } ConstantBufferView;

        struct
        {
            UINT RootParameterIndex;
        } ShaderResourceView;

        struct
        {
            UINT RootParameterIndex;
        } UnorderedAccessView;
    };
} D3D12_INDIRECT_ARGUMENT_DESC;

typedef struct D3D12_COMMAND_SIGNATURE_DESC
{
    // The number of bytes between each drawing structure
    UINT ByteStride; 
    UINT NumArgumentDescs;
    [annotation("_Field_size_full_(NumArgumentDescs)")] const D3D12_INDIRECT_ARGUMENT_DESC* pArgumentDescs;
    UINT NodeMask;
} D3D12_COMMAND_SIGNATURE_DESC;

interface ID3D12Device;

[ uuid( c4fec28f-7966-4e95-9f94-f431cb56c3b8 ), object, local, pointer_default( unique ) ]
interface ID3D12Object
    : IUnknown
{
    HRESULT GetPrivateData(
        [annotation("_In_")] REFGUID guid,
        [annotation("_Inout_")] UINT* pDataSize,
        [annotation("_Out_writes_bytes_opt_( *pDataSize )")] void* pData );
    HRESULT SetPrivateData(
        [annotation("_In_")] REFGUID guid,
        [annotation("_In_")] UINT DataSize,
        [annotation("_In_reads_bytes_opt_( DataSize )")] const void* pData );
    HRESULT SetPrivateDataInterface(
        [annotation("_In_")] REFGUID guid,
        [annotation("_In_opt_")] const IUnknown* pData );
    HRESULT SetName(
        [annotation("_In_z_")] LPCWSTR Name );
}

[ uuid( 905db94b-a00c-4140-9df5-2b64ca9ea357 ), object, local, pointer_default( unique ) ]
interface ID3D12DeviceChild
    : ID3D12Object
{
    HRESULT GetDevice( 
        [in] REFIID riid,
        [out, iid_is(riid), annotation("_COM_Outptr_opt_")] void** ppvDevice
        );
}

[ uuid( 63ee58fb-1268-4835-86da-f008ce62f0d6 ), object, local, pointer_default( unique ) ]
interface ID3D12Pageable
    : ID3D12DeviceChild
{
}

[ uuid( 6b3b2502-6e51-45b3-90ee-9884265e8df3 ), object, local, pointer_default( unique ) ]
interface ID3D12Heap
    : ID3D12Pageable
{
    D3D12_HEAP_DESC GetDesc();
}

[ uuid( 696442be-a72e-4059-bc79-5b5c98040fad ), object, local, pointer_default( unique ) ]
interface ID3D12Resource
    : ID3D12Pageable
{
    HRESULT Map(
        UINT Subresource,
        [annotation("_In_opt_")] const D3D12_RANGE* pReadRange,
        [annotation("_Outptr_opt_result_bytebuffer_(_Inexpressible_(\"Dependent on resource\"))")] void** ppData);

    void Unmap(UINT Subresource, [annotation("_In_opt_")] const D3D12_RANGE* pWrittenRange );

    D3D12_RESOURCE_DESC GetDesc();

    D3D12_GPU_VIRTUAL_ADDRESS GetGPUVirtualAddress();

    HRESULT WriteToSubresource(
        UINT DstSubresource,
        [annotation("_In_opt_")] const D3D12_BOX* pDstBox,
        [annotation("_In_")] const void* pSrcData,
        UINT SrcRowPitch,
        UINT SrcDepthPitch );
        
    HRESULT ReadFromSubresource(
        [annotation("_Out_")] void* pDstData,
        UINT DstRowPitch,
        UINT DstDepthPitch,
        UINT SrcSubresource,
        [annotation("_In_opt_")] const D3D12_BOX* pSrcBox );

    HRESULT GetHeapProperties(
        [annotation("_Out_opt_")] D3D12_HEAP_PROPERTIES* pHeapProperties,
        [annotation("_Out_opt_")] D3D12_HEAP_FLAGS* pHeapFlags
        );
}

[ uuid( 6102dee4-af59-4b09-b999-b44d73f09b24 ), object, local, pointer_default( unique ) ]
interface ID3D12CommandAllocator
    : ID3D12Pageable
{
    HRESULT Reset();
}

[ uuid( 0a753dcf-c4d8-4b91-adf6-be5a60d95a76 ), object, local, pointer_default( unique ) ]
interface ID3D12Fence 
    : ID3D12Pageable
{
    UINT64 GetCompletedValue();
    HRESULT SetEventOnCompletion(UINT64 Value, HANDLE hEvent);
    HRESULT Signal(UINT64 Value);
};

[ uuid( 765a30f3-f624-4c6f-a828-ace948622445 ), object, local, pointer_default( unique ) ]
interface ID3D12PipelineState
    : ID3D12Pageable
{
    HRESULT GetCachedBlob([annotation("_COM_Outptr_")] ID3DBlob** ppBlob);
}

[ uuid( 8efb471d-616c-4f49-90f7-127bb763fa51 ), object, local, pointer_default( unique ) ]
interface ID3D12DescriptorHeap
    : ID3D12Pageable
{
    D3D12_DESCRIPTOR_HEAP_DESC GetDesc();

    D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandleForHeapStart();
    D3D12_GPU_DESCRIPTOR_HANDLE GetGPUDescriptorHandleForHeapStart();
}

[ uuid( 0d9658ae-ed45-469e-a61d-970ec583cab4 ), object, local, pointer_default( unique ) ]
interface ID3D12QueryHeap
    : ID3D12Pageable
{
};

[ uuid( c36a797c-ec80-4f0a-8985-a7b2475082d1 ), object, local, pointer_default( unique ) ]
interface ID3D12CommandSignature
    : ID3D12Pageable
{
};

[ uuid( 7116d91c-e7e4-47ce-b8c6-ec8168f437e5 ), object, local, pointer_default( unique ) ]
interface ID3D12CommandList
    : ID3D12DeviceChild
{
    D3D12_COMMAND_LIST_TYPE GetType();
}

[ uuid( 5b160d0f-ac1b-4185-8ba8-b3ae42a5a455 ), object, local, pointer_default( unique ) ]
interface ID3D12GraphicsCommandList
    : ID3D12CommandList
{
    HRESULT Close();

    HRESULT Reset(
        [annotation("_In_")] ID3D12CommandAllocator* pAllocator,
        [annotation("_In_opt_")] ID3D12PipelineState* pInitialState
        );

    void ClearState(
        [annotation("_In_opt_")] ID3D12PipelineState* pPipelineState
        );

    void DrawInstanced(
        [annotation("_In_")] UINT VertexCountPerInstance,
        [annotation("_In_")] UINT InstanceCount,
        [annotation("_In_")] UINT StartVertexLocation,
        [annotation("_In_")] UINT StartInstanceLocation
        );

    void DrawIndexedInstanced(
        [annotation("_In_")] UINT IndexCountPerInstance,
        [annotation("_In_")] UINT InstanceCount,
        [annotation("_In_")] UINT StartIndexLocation,
        [annotation("_In_")] INT BaseVertexLocation,
        [annotation("_In_")] UINT StartInstanceLocation
        );

    void Dispatch(
        [annotation("_In_")] UINT ThreadGroupCountX,
        [annotation("_In_")] UINT ThreadGroupCountY,
        [annotation("_In_")] UINT ThreadGroupCountZ
        );

    void CopyBufferRegion(
        [annotation("_In_")] ID3D12Resource* pDstBuffer,
        UINT64 DstOffset,
        [annotation("_In_")] ID3D12Resource* pSrcBuffer,
        UINT64 SrcOffset,
        UINT64 NumBytes
        );

    void CopyTextureRegion(
        [annotation("_In_")] const D3D12_TEXTURE_COPY_LOCATION* pDst,
        UINT DstX, UINT DstY, UINT DstZ,
        [annotation("_In_")] const D3D12_TEXTURE_COPY_LOCATION* pSrc,
        [annotation("_In_opt_")] const D3D12_BOX* pSrcBox
        );

    void CopyResource(
        [annotation("_In_")] ID3D12Resource* pDstResource,
        [annotation("_In_")] ID3D12Resource* pSrcResource
        );

    void CopyTiles(
        [annotation("_In_")] ID3D12Resource* pTiledResource,
        [annotation("_In_")] const D3D12_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate,
        [annotation("_In_")] const D3D12_TILE_REGION_SIZE* pTileRegionSize,
        [annotation("_In_")] ID3D12Resource* pBuffer,
        UINT64 BufferStartOffsetInBytes,
        D3D12_TILE_COPY_FLAGS Flags
        );

    void ResolveSubresource(
        [annotation("_In_")] ID3D12Resource* pDstResource,
        [annotation("_In_")] UINT DstSubresource,
        [annotation("_In_")] ID3D12Resource* pSrcResource,
        [annotation("_In_")] UINT SrcSubresource,
        [annotation("_In_")] DXGI_FORMAT Format
        );

    void IASetPrimitiveTopology(
        [annotation("_In_")] D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology
        );

    void RSSetViewports(
        [annotation("_In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE)")] UINT NumViewports,
        [annotation("_In_reads_( NumViewports)")] const D3D12_VIEWPORT* pViewports
        );

    void RSSetScissorRects(
        [annotation("_In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE)")] UINT NumRects,
        [annotation("_In_reads_( NumRects)")] const D3D12_RECT* pRects
        );

    void OMSetBlendFactor(
        [annotation("_In_opt_")] const FLOAT BlendFactor[ 4 ]
        );

    void OMSetStencilRef(
        [annotation("_In_")] UINT StencilRef
        );

    void SetPipelineState(
        [annotation("_In_")] ID3D12PipelineState* pPipelineState
        );

    void ResourceBarrier(
        [annotation("_In_")] UINT NumBarriers,
        [annotation("_In_reads_(NumBarriers)")] const D3D12_RESOURCE_BARRIER* pBarriers
        );

    void ExecuteBundle(
        [annotation("_In_")] ID3D12GraphicsCommandList* pCommandList
        );

    void SetDescriptorHeaps(
        [annotation("_In_")] UINT NumDescriptorHeaps,
        [annotation("_In_reads_(NumDescriptorHeaps)")] ID3D12DescriptorHeap** ppDescriptorHeaps
        );

    void SetComputeRootSignature(
        [annotation("_In_")] ID3D12RootSignature* pRootSignature
        );

    void SetGraphicsRootSignature(
        [annotation("_In_")] ID3D12RootSignature* pRootSignature
        );

    void SetComputeRootDescriptorTable(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor
        );

    void SetGraphicsRootDescriptorTable(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor
        );

    // Single constant
    void SetComputeRoot32BitConstant(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] UINT SrcData,
        [annotation("_In_")] UINT DestOffsetIn32BitValues
        );

    void SetGraphicsRoot32BitConstant(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] UINT SrcData,
        [annotation("_In_")] UINT DestOffsetIn32BitValues
        );

    // Group of constants
    void SetComputeRoot32BitConstants(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] UINT Num32BitValuesToSet,
        [annotation("_In_reads_(Num32BitValuesToSet*sizeof(UINT))")] const void* pSrcData,
        [annotation("_In_")] UINT DestOffsetIn32BitValues
        );

    void SetGraphicsRoot32BitConstants(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] UINT Num32BitValuesToSet,
        [annotation("_In_reads_(Num32BitValuesToSet*sizeof(UINT))")] const void* pSrcData,
        [annotation("_In_")] UINT DestOffsetIn32BitValues
        );

    // CBV
    void SetComputeRootConstantBufferView(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] D3D12_GPU_VIRTUAL_ADDRESS BufferLocation
        );

    void SetGraphicsRootConstantBufferView(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] D3D12_GPU_VIRTUAL_ADDRESS BufferLocation
        );

    // SRV 
    void SetComputeRootShaderResourceView(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] D3D12_GPU_VIRTUAL_ADDRESS BufferLocation
        );

    void SetGraphicsRootShaderResourceView(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] D3D12_GPU_VIRTUAL_ADDRESS BufferLocation
        );

    // UAV 
    void SetComputeRootUnorderedAccessView(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] D3D12_GPU_VIRTUAL_ADDRESS BufferLocation
        );

    void SetGraphicsRootUnorderedAccessView(
        [annotation("_In_")] UINT RootParameterIndex,
        [annotation("_In_")] D3D12_GPU_VIRTUAL_ADDRESS BufferLocation
        );

    void IASetIndexBuffer(
        [annotation("_In_opt_")] const D3D12_INDEX_BUFFER_VIEW* pView
        );

    void IASetVertexBuffers(
        [annotation("_In_")] UINT StartSlot,
        [annotation("_In_")] UINT NumViews,
        [annotation("_In_reads_opt_(NumViews)")] const D3D12_VERTEX_BUFFER_VIEW* pViews
        );

    void SOSetTargets(
        [annotation("_In_")] UINT StartSlot,
        [annotation("_In_")] UINT NumViews,
        [annotation("_In_reads_opt_(NumViews)")] const D3D12_STREAM_OUTPUT_BUFFER_VIEW* pViews
        );

    void OMSetRenderTargets(
        [annotation("_In_")] UINT NumRenderTargetDescriptors,
        [annotation("_In_")] const D3D12_CPU_DESCRIPTOR_HANDLE* pRenderTargetDescriptors,
        [annotation("_In_")] BOOL RTsSingleHandleToDescriptorRange,
        [annotation("_In_opt_")] const D3D12_CPU_DESCRIPTOR_HANDLE* pDepthStencilDescriptor
        );

    void ClearDepthStencilView(
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView,
        [annotation("_In_")] D3D12_CLEAR_FLAGS ClearFlags,
        [annotation("_In_")] FLOAT Depth,
        [annotation("_In_")] UINT8 Stencil,
        [annotation("_In_")] UINT NumRects,
        [annotation("_In_reads_(NumRects)")] const D3D12_RECT* pRects
        );

    void ClearRenderTargetView(
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView,
        [annotation("_In_")] const FLOAT ColorRGBA[4],
        [annotation("_In_")] UINT NumRects,
        [annotation("_In_reads_(NumRects)")] const D3D12_RECT* pRects
        );

    void ClearUnorderedAccessViewUint(
        [annotation("_In_")] D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle,
        [annotation("_In_")] ID3D12Resource* pResource,
        [annotation("_In_")] const UINT Values[4],
        [annotation("_In_")] UINT NumRects,
        [annotation("_In_reads_(NumRects)")] const D3D12_RECT* pRects
        );

    void ClearUnorderedAccessViewFloat(
        [annotation("_In_")] D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle,
        [annotation("_In_")] ID3D12Resource* pResource,
        [annotation("_In_")] const FLOAT Values[4],
        [annotation("_In_")] UINT NumRects,
        [annotation("_In_reads_(NumRects)")] const D3D12_RECT* pRects
        );

    void DiscardResource(
        [annotation("_In_")] ID3D12Resource* pResource,
        [annotation("_In_opt_")] const D3D12_DISCARD_REGION* pRegion
        );

    void BeginQuery(
        [annotation("_In_")] ID3D12QueryHeap* pQueryHeap,
        [annotation("_In_")] D3D12_QUERY_TYPE Type,
        [annotation("_In_")] UINT Index
        );

    void EndQuery(
        [annotation("_In_")] ID3D12QueryHeap* pQueryHeap,
        [annotation("_In_")] D3D12_QUERY_TYPE Type,
        [annotation("_In_")] UINT Index
        );

    void ResolveQueryData(
        [annotation("_In_")] ID3D12QueryHeap* pQueryHeap,
        [annotation("_In_")] D3D12_QUERY_TYPE Type,
        [annotation("_In_")] UINT StartIndex,
        [annotation("_In_")] UINT NumQueries,
        [annotation("_In_")] ID3D12Resource* pDestinationBuffer,
        [annotation("_In_")] UINT64 AlignedDestinationBufferOffset
        );

    void SetPredication(
        [annotation("_In_opt_")] ID3D12Resource* pBuffer,
        [annotation("_In_")] UINT64 AlignedBufferOffset,
        [annotation("_In_")] D3D12_PREDICATION_OP Operation
        );

    void SetMarker(UINT Metadata, [annotation("_In_reads_bytes_opt_(Size)")] const void* pData, UINT Size);
    void BeginEvent(UINT Metadata, [annotation("_In_reads_bytes_opt_(Size)")] const void* pData, UINT Size);
    void EndEvent();

    void ExecuteIndirect(
        [annotation("_In_")] ID3D12CommandSignature* pCommandSignature,
        [annotation("_In_")] UINT MaxCommandCount,
        [annotation("_In_")] ID3D12Resource* pArgumentBuffer,
        [annotation("_In_")] UINT64 ArgumentBufferOffset,
        [annotation("_In_opt_")] ID3D12Resource* pCountBuffer,
        [annotation("_In_")] UINT64 CountBufferOffset
        );
}



[ uuid( 0ec870a6-5d7e-4c22-8cfc-5baae07616ed ), object, local, pointer_default( unique ) ]
interface ID3D12CommandQueue
    : ID3D12Pageable
{
    void UpdateTileMappings(
        [annotation("_In_")] ID3D12Resource* pResource,
        UINT NumResourceRegions,
        [annotation("_In_reads_opt_(NumResourceRegions)")] const D3D12_TILED_RESOURCE_COORDINATE* pResourceRegionStartCoordinates,
        [annotation("_In_reads_opt_(NumResourceRegions)")] const D3D12_TILE_REGION_SIZE* pResourceRegionSizes,
        [annotation("_In_opt_")] ID3D12Heap* pHeap,
        UINT NumRanges,
        [annotation("_In_reads_opt_(NumRanges)")] const D3D12_TILE_RANGE_FLAGS* pRangeFlags,
        [annotation("_In_reads_opt_(NumRanges)")] const UINT* pHeapRangeStartOffsets,
        [annotation("_In_reads_opt_(NumRanges)")] const UINT* pRangeTileCounts,
        D3D12_TILE_MAPPING_FLAGS Flags );

    void CopyTileMappings(
        [annotation("_In_")] ID3D12Resource* pDstResource,
        [annotation("_In_")] const D3D12_TILED_RESOURCE_COORDINATE* pDstRegionStartCoordinate,
        [annotation("_In_")] ID3D12Resource* pSrcResource,
        [annotation("_In_")] const D3D12_TILED_RESOURCE_COORDINATE* pSrcRegionStartCoordinate,
        [annotation("_In_")] const D3D12_TILE_REGION_SIZE* pRegionSize,
        D3D12_TILE_MAPPING_FLAGS Flags );

    void ExecuteCommandLists(
        [annotation("_In_")] UINT NumCommandLists,
        [annotation("_In_reads_(NumCommandLists)")] ID3D12CommandList * const * ppCommandLists
        );

    void SetMarker(UINT Metadata, [annotation("_In_reads_bytes_opt_(Size)")] const void* pData, UINT Size);
    void BeginEvent(UINT Metadata, [annotation("_In_reads_bytes_opt_(Size)")] const void* pData, UINT Size);
    void EndEvent();

    HRESULT Signal(ID3D12Fence* pFence, UINT64 Value);
    HRESULT Wait(ID3D12Fence* pFence, UINT64 Value);

    HRESULT GetTimestampFrequency(
        [annotation("_Out_")] UINT64* pFrequency
        );

    HRESULT GetClockCalibration(
        [annotation("_Out_")] UINT64* pGpuTimestamp,
        [annotation("_Out_")] UINT64* pCpuTimestamp
        );

    D3D12_COMMAND_QUEUE_DESC GetDesc();
}

[ uuid( 189819f1-1db6-4b57-be54-1821339b85f7 ), object, local, pointer_default( unique ) ]
interface ID3D12Device
    : ID3D12Object
{
    UINT GetNodeCount();

    HRESULT CreateCommandQueue(
        [annotation("_In_")] const D3D12_COMMAND_QUEUE_DESC* pDesc,
        [in] REFIID riid, // Expected: ID3D12CommandQueue
        [out, iid_is(riid), annotation("_COM_Outptr_")] void** ppCommandQueue 
        );

    HRESULT CreateCommandAllocator(
        [annotation("_In_")] D3D12_COMMAND_LIST_TYPE type,
        [in] REFIID riid, // Expected: ID3D12CommandAllocator
        [out, iid_is(riid), annotation("_COM_Outptr_")] void** ppCommandAllocator
        );

    HRESULT CreateGraphicsPipelineState(
        [annotation("_In_")] const D3D12_GRAPHICS_PIPELINE_STATE_DESC* pDesc,
        [in] REFIID riid, // Expected: ID3D12PipelineState
        [out, iid_is(riid), annotation("_COM_Outptr_")] void** ppPipelineState
        );

    HRESULT CreateComputePipelineState(
        [annotation("_In_")] const D3D12_COMPUTE_PIPELINE_STATE_DESC* pDesc,
        [in] REFIID riid, // Expected: ID3D12PipelineState
        [out, iid_is(riid), annotation("_COM_Outptr_")] void** ppPipelineState
        );

    HRESULT CreateCommandList(
        [annotation("_In_")] UINT nodeMask,
        [annotation("_In_")] D3D12_COMMAND_LIST_TYPE type,
        [annotation("_In_")] ID3D12CommandAllocator* pCommandAllocator,
        [annotation("_In_opt_")] ID3D12PipelineState* pInitialState,
        [in] REFIID riid, // Expected: ID3D12CommandList
        [out, iid_is(riid), annotation("_COM_Outptr_")] void** ppCommandList         
        );

    HRESULT CheckFeatureSupport(
        D3D12_FEATURE Feature,
        [annotation("_Inout_updates_bytes_(FeatureSupportDataSize)")] void* pFeatureSupportData,
        UINT FeatureSupportDataSize
        );

    HRESULT CreateDescriptorHeap(
        [annotation("_In_")] const D3D12_DESCRIPTOR_HEAP_DESC* pDescriptorHeapDesc,
        [in] REFIID riid, // Expected ID3D12DescriptorHeap
        [out, iid_is(riid), annotation("_COM_Outptr_")] void** ppvHeap);

    UINT GetDescriptorHandleIncrementSize(
        [annotation("_In_")] D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType);

    HRESULT CreateRootSignature(
        [annotation("_In_")] UINT nodeMask,
        [annotation("_In_reads_(blobLengthInBytes)")] const void* pBlobWithRootSignature,
        [annotation("_In_")] SIZE_T blobLengthInBytes,
        [in] REFIID riid, // Expected ID3D12RootSignature
        [out, iid_is(riid), annotation("_COM_Outptr_")] void** ppvRootSignature);

    void CreateConstantBufferView(
        [annotation("_In_opt_")] const D3D12_CONSTANT_BUFFER_VIEW_DESC* pDesc,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor);

    void CreateShaderResourceView(
        [annotation("_In_opt_")] ID3D12Resource* pResource,
        [annotation("_In_opt_")] const D3D12_SHADER_RESOURCE_VIEW_DESC* pDesc,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor);

    void CreateUnorderedAccessView(
        [annotation("_In_opt_")] ID3D12Resource* pResource,
        [annotation("_In_opt_")] ID3D12Resource* pCounterResource,
        [annotation("_In_opt_")] const D3D12_UNORDERED_ACCESS_VIEW_DESC* pDesc,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor);

    void CreateRenderTargetView(
        [annotation("_In_opt_")] ID3D12Resource* pResource,
        [annotation("_In_opt_")] const D3D12_RENDER_TARGET_VIEW_DESC* pDesc,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor);

    void CreateDepthStencilView(
        [annotation("_In_opt_")] ID3D12Resource* pResource,
        [annotation("_In_opt_")] const D3D12_DEPTH_STENCIL_VIEW_DESC* pDesc,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor);

    void CreateSampler(
        [annotation("_In_")] const D3D12_SAMPLER_DESC* pDesc,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor);

    void CopyDescriptors(
        [annotation("_In_")] UINT NumDestDescriptorRanges,
        [annotation("_In_reads_(NumDestDescriptorRanges)")] const D3D12_CPU_DESCRIPTOR_HANDLE* pDestDescriptorRangeStarts,
        [annotation("_In_reads_opt_(NumDestDescriptorRanges)")] const UINT* pDestDescriptorRangeSizes, // NULL means all ranges 1
        [annotation("_In_")] UINT NumSrcDescriptorRanges,
        [annotation("_In_reads_(NumSrcDescriptorRanges)")] const D3D12_CPU_DESCRIPTOR_HANDLE* pSrcDescriptorRangeStarts,
        [annotation("_In_reads_opt_(NumSrcDescriptorRanges)")] const UINT* pSrcDescriptorRangeSizes, // NULL means all ranges 1
        [annotation("_In_")] D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType);

    void CopyDescriptorsSimple(
        [annotation("_In_")] UINT NumDescriptors,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart,
        [annotation("_In_")] D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart,
        [annotation("_In_")] D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType);

    D3D12_RESOURCE_ALLOCATION_INFO GetResourceAllocationInfo(
        [annotation("_In_")] UINT visibleMask,
        [annotation("_In_")] UINT numResourceDescs,
        [annotation("_In_reads_(numResourceDescs)")] const D3D12_RESOURCE_DESC* pResourceDescs );

    D3D12_HEAP_PROPERTIES GetCustomHeapProperties( 
        [annotation("_In_")] UINT nodeMask,
        D3D12_HEAP_TYPE heapType 
        );

    HRESULT CreateCommittedResource(
        [annotation("_In_")] const D3D12_HEAP_PROPERTIES* pHeapProperties,
        D3D12_HEAP_FLAGS HeapFlags,
        [annotation("_In_")] const D3D12_RESOURCE_DESC* pResourceDesc,
        D3D12_RESOURCE_STATES InitialResourceState,
        [annotation("_In_opt_")] const D3D12_CLEAR_VALUE* pOptimizedClearValue,
        [in] REFIID riidResource, // Expected: ID3D12Resource*
        [out, iid_is(riidResource), annotation("_COM_Outptr_opt_")] void** ppvResource );

    HRESULT CreateHeap(
        [annotation("_In_")] const D3D12_HEAP_DESC* pDesc,
        [in] REFIID riid, // Expected: ID3D12Heap*
        [out, iid_is(riid), annotation("_COM_Outptr_opt_")] void** ppvHeap );

    HRESULT CreatePlacedResource(
        [annotation("_In_")] ID3D12Heap* pHeap,
        UINT64 HeapOffset,
        [annotation("_In_")] const D3D12_RESOURCE_DESC* pDesc,
        D3D12_RESOURCE_STATES InitialState,
        [annotation("_In_opt_")] const D3D12_CLEAR_VALUE* pOptimizedClearValue,
        [in] REFIID riid, // Expected: ID3D12Resource*
        [out, iid_is(riid), annotation("_COM_Outptr_opt_")] void** ppvResource );

    HRESULT CreateReservedResource(
        [annotation("_In_")] const D3D12_RESOURCE_DESC* pDesc,
        D3D12_RESOURCE_STATES InitialState,
        [annotation("_In_opt_")] const D3D12_CLEAR_VALUE* pOptimizedClearValue,
        [in] REFIID riid, // Expected: ID3D12Resource*
        [out, iid_is(riid), annotation("_COM_Outptr_opt_")] void** ppvResource );
        
    HRESULT CreateSharedHandle(
        [annotation("_In_")] ID3D12DeviceChild* pObject,
        [annotation("_In_opt_")] const SECURITY_ATTRIBUTES* pAttributes,
        DWORD Access,
        [annotation("_In_opt_")] LPCWSTR Name,
        [annotation("_Out_")] HANDLE* pHandle );

    HRESULT OpenSharedHandle(
        [annotation("_In_")] HANDLE NTHandle,
        [in] REFIID riid, // Expected: ID3D12Resource*, ID3D12Heap*, or ID3D12Fence
        [out, iid_is(riid), annotation("_COM_Outptr_opt_")] void** ppvObj );

    HRESULT OpenSharedHandleByName(
        [annotation("_In_")] LPCWSTR Name,
        DWORD Access,
        [out, annotation("_Out_")] HANDLE* pNTHandle );

    HRESULT MakeResident(
        UINT NumObjects,
        [annotation("_In_reads_(NumObjects)")] ID3D12Pageable*const* ppObjects );

    HRESULT Evict(
        UINT NumObjects,
        [annotation("_In_reads_(NumObjects)")] ID3D12Pageable*const* ppObjects );

    HRESULT CreateFence(
        UINT64 InitialValue,
        D3D12_FENCE_FLAGS Flags,
        [in] REFIID riid, // Expected: ID3D12Fence
        [out, iid_is(riid), annotation("_COM_Outptr_")] void** ppFence);        

    HRESULT GetDeviceRemovedReason();

    void GetCopyableFootprints(
        [annotation("_In_")] const D3D12_RESOURCE_DESC* pResourceDesc,
        [annotation("_In_range_(0,D3D12_REQ_SUBRESOURCES)")] UINT FirstSubresource,
        [annotation("_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource)")] UINT NumSubresources,
        UINT64 BaseOffset,
        [annotation("_Out_writes_opt_(NumSubresources)")] D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts,
        [annotation("_Out_writes_opt_(NumSubresources)")] UINT* pNumRows,
        [annotation("_Out_writes_opt_(NumSubresources)")] UINT64* pRowSizeInBytes,
        [annotation("_Out_opt_")] UINT64* pTotalBytes );

    HRESULT CreateQueryHeap(
        [annotation("_In_")] const D3D12_QUERY_HEAP_DESC* pDesc,
        [in] REFIID riid, // Expected: ID3D12QueryHeap
        [out, iid_is(riid), annotation("_COM_Outptr_opt_")] void** ppvHeap
        );

    HRESULT SetStablePowerState(BOOL Enable);

    HRESULT CreateCommandSignature(
        [annotation("_In_")] const D3D12_COMMAND_SIGNATURE_DESC* pDesc,
        [annotation("_In_opt_")] ID3D12RootSignature* pRootSignature,
        [in] REFIID riid, // Expected: ID3D12CommandSignature
        [out, iid_is(riid), annotation("_COM_Outptr_opt_")] void** ppvCommandSignature
        );

    void GetResourceTiling( 
        [annotation("_In_")] ID3D12Resource* pTiledResource,
        [annotation("_Out_opt_")] UINT* pNumTilesForEntireResource, 
        [annotation("_Out_opt_")] D3D12_PACKED_MIP_INFO* pPackedMipDesc, 
        [annotation("_Out_opt_")] D3D12_TILE_SHAPE* pStandardTileShapeForNonPackedMips, 
        [annotation("_Inout_opt_")] UINT* pNumSubresourceTilings, 
        [annotation("_In_")] UINT FirstSubresourceTilingToGet, 
        [annotation("_Out_writes_(*pNumSubresourceTilings)")] D3D12_SUBRESOURCE_TILING* pSubresourceTilingsForNonPackedMips
        );

    LUID GetAdapterLuid();
}


typedef struct D3D12_SUBRESOURCE_DATA
{
    const void* pData;
    LONG_PTR RowPitch;
    LONG_PTR SlicePitch;
} D3D12_SUBRESOURCE_DATA;

typedef struct D3D12_MEMCPY_DEST
{
    void* pData;
    SIZE_T RowPitch;
    SIZE_T SlicePitch;
} D3D12_MEMCPY_DEST;



cpp_quote( "#if !defined( D3D12_IGNORE_SDK_LAYERS ) ")
cpp_quote( "#include \"d3d12sdklayers.h\" ")
cpp_quote( "#endif ")


cpp_quote( "" )
cpp_quote( "///////////////////////////////////////////////////////////////////////////" )
cpp_quote( "// D3D12CreateDevice" )
cpp_quote( "// ------------------" )
cpp_quote( "//" )
cpp_quote( "// pAdapter" )
cpp_quote( "//      If NULL, D3D12CreateDevice will choose the primary adapter." )
cpp_quote( "//      If non-NULL, D3D12CreateDevice will use the provided adapter." )
cpp_quote( "// MinimumFeatureLevel" )
cpp_quote( "//      The minimum feature level required for successful device creation." )
cpp_quote( "// riid" )
cpp_quote( "//      The interface IID of the device to be returned. Expected: ID3D12Device." )
cpp_quote( "// ppDevice" )
cpp_quote( "//      Pointer to returned interface. May be NULL." )
cpp_quote( "//" )
cpp_quote( "// Return Values" )
cpp_quote( "//  Any of those documented for " )
cpp_quote( "//          CreateDXGIFactory1" )
cpp_quote( "//          IDXGIFactory::EnumAdapters" )
cpp_quote( "//          D3D12CreateDevice" )
cpp_quote( "//" )
cpp_quote( "///////////////////////////////////////////////////////////////////////////" )
cpp_quote( "typedef HRESULT (WINAPI* PFN_D3D12_CREATE_DEVICE)( _In_opt_ IUnknown*, " )
cpp_quote( "    D3D_FEATURE_LEVEL, " )
cpp_quote( "    _In_ REFIID, _COM_Outptr_opt_ void** );" )
cpp_quote( "" )
cpp_quote( "HRESULT WINAPI D3D12CreateDevice(" )
cpp_quote( "    _In_opt_ IUnknown* pAdapter," )
cpp_quote( "    D3D_FEATURE_LEVEL MinimumFeatureLevel," )
cpp_quote( "    _In_ REFIID riid, // Expected: ID3D12Device" )
cpp_quote( "    _COM_Outptr_opt_ void** ppDevice );" )
cpp_quote( "" )

cpp_quote( "" )
cpp_quote( "typedef HRESULT (WINAPI* PFN_D3D12_GET_DEBUG_INTERFACE)( _In_ REFIID, _COM_Outptr_opt_ void** );" )
cpp_quote( "" )
cpp_quote( "HRESULT WINAPI D3D12GetDebugInterface( _In_ REFIID riid, _COM_Outptr_opt_ void** ppvDebug );" )
cpp_quote( "" )


//----------------------------------------------------------------------------------------------------------
// Old types which are still supported by the runtime for app-compat

cpp_quote("#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */")
#pragma endregion

cpp_quote( "DEFINE_GUID(IID_ID3D12Object,0xc4fec28f,0x7966,0x4e95,0x9f,0x94,0xf4,0x31,0xcb,0x56,0xc3,0xb8);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12DeviceChild,0x905db94b,0xa00c,0x4140,0x9d,0xf5,0x2b,0x64,0xca,0x9e,0xa3,0x57);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12RootSignature,0xc54a6b66,0x72df,0x4ee8,0x8b,0xe5,0xa9,0x46,0xa1,0x42,0x92,0x14);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12RootSignatureDeserializer,0x34AB647B,0x3CC8,0x46AC,0x84,0x1B,0xC0,0x96,0x56,0x45,0xC0,0x46);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12Pageable,0x63ee58fb,0x1268,0x4835,0x86,0xda,0xf0,0x08,0xce,0x62,0xf0,0xd6);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12Heap,0x6b3b2502,0x6e51,0x45b3,0x90,0xee,0x98,0x84,0x26,0x5e,0x8d,0xf3);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12Resource,0x696442be,0xa72e,0x4059,0xbc,0x79,0x5b,0x5c,0x98,0x04,0x0f,0xad);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12CommandAllocator,0x6102dee4,0xaf59,0x4b09,0xb9,0x99,0xb4,0x4d,0x73,0xf0,0x9b,0x24);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12Fence,0x0a753dcf,0xc4d8,0x4b91,0xad,0xf6,0xbe,0x5a,0x60,0xd9,0x5a,0x76);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12PipelineState,0x765a30f3,0xf624,0x4c6f,0xa8,0x28,0xac,0xe9,0x48,0x62,0x24,0x45);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12DescriptorHeap,0x8efb471d,0x616c,0x4f49,0x90,0xf7,0x12,0x7b,0xb7,0x63,0xfa,0x51);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12QueryHeap,0x0d9658ae,0xed45,0x469e,0xa6,0x1d,0x97,0x0e,0xc5,0x83,0xca,0xb4);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12CommandSignature,0xc36a797c,0xec80,0x4f0a,0x89,0x85,0xa7,0xb2,0x47,0x50,0x82,0xd1);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12CommandList,0x7116d91c,0xe7e4,0x47ce,0xb8,0xc6,0xec,0x81,0x68,0xf4,0x37,0xe5);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12GraphicsCommandList,0x5b160d0f,0xac1b,0x4185,0x8b,0xa8,0xb3,0xae,0x42,0xa5,0xa4,0x55);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12CommandQueue,0x0ec870a6,0x5d7e,0x4c22,0x8c,0xfc,0x5b,0xaa,0xe0,0x76,0x16,0xed);" )
cpp_quote( "DEFINE_GUID(IID_ID3D12Device,0x189819f1,0x1db6,0x4b57,0xbe,0x54,0x18,0x21,0x33,0x9b,0x85,0xf7);" )
