Direct3D 12 Functions

This section provides detailed information about the functions available in the Direct3D 12 API. Explore the various categories to understand how to interact with the graphics hardware.

Core Functions

D3D12CreateDevice HRESULT D3D12CreateDevice(IUnknown* pAdapter, D3D_FEATURE_LEVEL FeatureLevel, REFIID riid, void** ppDevice);

Creates a Direct3D 12 device object for a specified graphics adapter.

View Details

ID3D12Device::CreateCommittedResource HRESULT CreateCommittedResource(const D3D12_HEAP_PROPERTIES* pHeapProperties, D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC* pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE* pOptimizedClearValue, REFIID riid, void** ppvResource);

Creates a committed resource, which is a resource whose memory is fully managed by the Direct3D runtime.

View Details

ID3D12GraphicsCommandList::DrawInstanced void DrawInstanced(UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation);

Draws indexed or non-indexed geometry. For each instance, it draws VertexCountPerInstance vertices.

View Details

Pipeline State Functions

ID3D12Device::CreateGraphicsPipelineState HRESULT CreateGraphicsPipelineState(const D3D12_GRAPHICS_PIPELINE_STATE_DESC* pDesc, REFIID riid, void** ppPipelineState);

Creates a graphics pipeline state object (PSO).

View Details

Resource Management Functions

ID3D12Device::CreateCommandAllocator HRESULT CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE type, REFIID riid, void** ppCommandAllocator);

Creates a command allocator object.

View Details

ID3D12Device::CreateCommandList HRESULT CreateCommandList(UINT nodeMask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator* pCommandAllocator, ID3D12PipelineState* pInitialState, REFIID riid, void** ppCommandList);

Creates a command list object.

View Details

Synchronization Functions

ID3D12Device::CreateFence HRESULT CreateFence(UINT64 InitialValue, D3D12_FENCE_FLAGS Flags, REFIID riid, void** ppFence);

Creates a fence object.

View Details

D3D12CreateDevice

Creates a Direct3D 12 device object for a specified graphics adapter.

Syntax

HRESULT D3D12CreateDevice(
  [in]  IUnknown* pAdapter,
  [in]  D3D_FEATURE_LEVEL FeatureLevel,
  [in]  REFIID riid,
  [out] void** ppDevice
);

Parameters

Parameter Description
pAdapter A pointer to an existing Direct3D 11.1 runtime device's IDXGIAdapter interface. This parameter is required.
FeatureLevel A D3D_FEATURE_LEVEL-typed value that specifies the feature level for the device to be created.
riid The globally unique identifier (GUID) for the Direct3D 12 device interface (__uuidof(ID3D12Device)).
ppDevice A pointer to a memory block that receives a pointer to the Direct3D 12 device.

Return Value

Returns S_OK on success, or one of the Direct3D 12 return codes defined in d3d12.h.

Note: For more robust error handling, especially when creating a device, you should use D3D12GetDeviceRemovedReason to get the reason for device removal after D3D12CreateDevice returns a failure.