> ## 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.

# CreateHeap1 (XBOX Series consoles)

> Creates a heap (optionally for a protected session) that can be used with placed resources and reserved resources.

Creates a heap (optionally for a protected session) that can be used with placed resources and reserved resources. Also see [ID3D12Device::CreateHeap](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createheap_public).

## Syntax

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

### Parameters

*pDesc \[in]*<br />Type: const D3D12\_HEAP\_DESC \*

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

*pProtectedSession \[in, optional]*<br />Type: ID3D12ProtectedResourceSession \*

An optional pointer to an object that represents a session for content protection. If provided, this session indicates that the heap should be protected. You can obtain an **ID3D12ProtectedResourceSession** by calling [ID3D12Device4::CreateProtectedResourceSession](/reference/graphics/d3d12/interfaces/id3d12device4/methods/id3d12device4_createprotectedresourcesession_public).

A heap with a protected session can't be created with the [D3D12\_HEAP\_FLAG\_SHARED\_CROSS\_ADAPTER](/reference/graphics/d3d12_x/enums/d3d12_heap_flags) flag.

*riid \[in]*<br />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]*<br />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

**CreateHeap1** 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<br />**Library:** d3d12\_xs.lib<br />**Supported Platforms**: XBOX Series consoles

## See Also


## Related topics

- [CreatePlacedResource2 (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device10/methods/id3d12device10_createplacedresource2_public.md)
- [CreateReservedResource2 (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device10/methods/id3d12device10_createreservedresource2_public.md)
- [CreateCommandList1 (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device4/methods/id3d12device4_createcommandlist1_public.md)
- [CreateMetaCommand (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device5/methods/id3d12device5_createmetacommand_public.md)
- [CreateCommandQueue1 (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device9/methods/id3d12device9_createcommandqueue1_public.md)
