ID3D12Device::CreateCommittedResource

Creates a committed resource.

Syntax


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                      riidResource,
    void                        **ppvResource
);
            

Parameters

Parameter Description
pHeapProperties A pointer to a D3D12_HEAP_PROPERTIES structure that describes the heap properties for the resource.
HeapFlags Flags that specify heap options for the resource. Must be 0.
pDesc A pointer to a D3D12_RESOURCE_DESC structure that describes the resource.
InitialState One of the D3D12_RESOURCE_STATES enumeration constants that specifies the initial state of the resource.
pOptimizedClearValue A pointer to a D3D12_CLEAR_VALUE structure that describes the optimized clear value for the resource. Can be NULL.
riidResource The globally unique identifier (GUID) for the resource type.
ppvResource A pointer to a memory block that receives a pointer to the resource.

Return value

If the method succeeds, it returns S_OK. Otherwise, it returns one of the Direct3D 12 Return Codes.

Remarks

A committed resource is a resource for which the entire memory is committed in a single heap.

The heap that is created is selected by the Direct3D 12 runtime based on the D3D12_HEAP_PROPERTIES and D3D12_RESOURCE_DESC. For example, if D3D12_HEAP_TYPE_DEFAULT is specified in D3D12_HEAP_PROPERTIES, the runtime selects a heap from the GPU-supported memory.

When you create a texture resource, you can specify an optimized clear value. This value is used by the ClearRenderTargetView and ClearDepthStencilView methods. If you specify a clear value for a resource that can be cleared, the runtime may be able to optimize clear operations.

Note: For most use cases, it is recommended to use CreatePlacedResource and then CreateCommittedResource1 (or CreateReservedResource) for more control over memory allocation.
Important: The HeapFlags parameter must be 0. The Direct3D 12 runtime manages heap flags.

See Also