> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CreateHeap

> Creates a heap that can be used with placed resources and reserved resources.

Creates a heap that can be used with placed resources and reserved resources.

## Syntax

```cpp theme={null}
HRESULT CreateHeap(
    const D3D12_HEAP_DESC  pDesc,
    const IID & riid,
    void  ppvHeap
)
```

### Parameters

*pDesc \[in]*\
Type: const D3D12\_HEAP\_DESC \*

A pointer to a constant **D3D12\_HEAP\_DESC** structure that describes the heap.

*riid \[in]*\
Type: const IID &

A reference to the globally unique identifier (**GUID**) of the heap interface to return in *ppvHeap*.

While *riidResource* is most commonly the **GUID** of [ID3D12Heap](/reference/graphics/d3d12/interfaces/id3d12heap/id3d12heap_public), it may be the **GUID** of any interface. If the resource object doesn't support the interface for this **GUID**, then creation fails with **E\_NOINTERFACE**.

*ppvHeap \[out, optional]*\
Type: void \*\*

An optional pointer to a memory block that receives the requested interface pointer to the created heap object.

*ppvHeap* can be `nullptr`, to enable capability testing. When *ppvHeap* is `nullptr`, no object is created, and **S\_FALSE** is returned when *pDesc* is valid.

### Return value

Type: HRESULT

If the function succeeds, it returns **S\_OK**. Otherwise, it returns an [**HRESULT**](https://learn.microsoft.com/en-us/windows/desktop/com/structure-of-com-error-codes) [error code](https://learn.microsoft.com/en-us/windows/win32/com/com-error-codes-10).

| Return value   | Description                                      |
| -------------- | ------------------------------------------------ |
| E\_OUTOFMEMORY | There is insufficient memory to create the heap. |

See [Direct3D 12 return codes](https://learn.microsoft.com/en-us/windows/win32/direct3d12/d3d12-graphics-reference-returnvalues) for other possible return values.

## Remarks

**CreateHeap** creates a heap that can be used with placed resources and reserved resources.

Before releasing the final reference on the heap, your application must ensure that the GPU will no longer read or write to this heap.

A placed resource object holds a reference on the heap it is created on; but a reserved resource doesn't hold a reference for each mapping made to a heap.

## Requirements

**Header:** d3d12\_xs.h or d3d12\_x.h\
**Library:** d3d12\_xs.lib or d3d12\_x.lib\
**Supported Platforms**: XBOX Series consoles and XBOX One family

## See Also

[ID3D12Device](/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)

[Shared heaps](https://learn.microsoft.com/en-us/windows/win32/direct3d12/shared-heaps)


## Related topics

- [CreateHeap1 (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device4/methods/id3d12device4_createheap1_public.md)
- [D3D12_FEATURE_DATA_EXISTING_HEAPS](/reference/graphics/d3d12/structs/d3d12_feature_data_existing_heaps_public.md)
- [CreateDescriptorHeap](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createdescriptorheap_public.md)
- [CreateQueryHeap](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createqueryheap_public.md)
- [ApuCreateHeap](/reference/audio/apu/functions/apucreateheap.md)
