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

# CreatePlacedResource2 (XBOX Series consoles)

> ID3D12Device10::CreatePlacedResource2 creates a placed resource in a heap on XBOX Series consoles Direct3D 12, with extended parameters over the original API.

Creates a resource that is placed in a specific heap. Placed resources are the lightest weight resource objects available, and are the fastest to create and destroy.

Your application can re-use video memory by overlapping multiple Direct3D placed and reserved resources on heap regions. The simple memory re-use model (described in [Remarks](#remarks)) exists to clarify which overlapping resource is valid at any given time. To maximize graphics tool support, with the simple model data-inheritance isn't supported; and finer-grained tile and sub-resource invalidation isn't supported. Only full overlapping resource invalidation occurs.

Requires the DirectX 12 Agility SDK 1.7 or later.

## Syntax

```cpp theme={null}
HRESULT CreatePlacedResource2(
    ID3D12Heap  pHeap,
    UINT64 HeapOffset,
    const D3D12_RESOURCE_DESC1  pDesc,
    D3D12_BARRIER_LAYOUT InitialLayout,
    const D3D12_CLEAR_VALUE  pOptimizedClearValue,
    UINT32 NumCastableFormats,
    DXGI_FORMAT  pCastableFormats,
    const IID & riid,
    void  ppvResource
)
```

### Parameters

*pHeap*\
Type: ID3D12Heap \*

A pointer to the **ID3D12Heap** interface that represents the heap in which the resource is placed.

*HeapOffset*\
Type: UINT64

The offset, in bytes, to the resource. The *HeapOffset* must be a multiple of the resource's alignment, and *HeapOffset* plus the resource size must be smaller than or equal to the heap size. [**GetResourceAllocationInfo**](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_getresourceallocationinfo_public) must be used to understand the sizes of texture resources.

*pDesc*\
Type: const D3D12\_RESOURCE\_DESC1 \*

A pointer to a **D3D12\_RESOURCE\_DESC** structure that describes the resource.

*InitialLayout*\
Type: D3D12\_BARRIER\_LAYOUT

The initial layout of the texture resource; **D3D12\_BARRIER\_LAYOUT::D3D12\_BARRIER\_LAYOUT\_UNDEFINED** for buffers.

*pOptimizedClearValue*\
Type: const D3D12\_CLEAR\_VALUE \*

Specifies a **D3D12\_CLEAR\_VALUE** that describes the default value for a clear color.

*pOptimizedClearValue* specifies a value for which clear operations are most optimal. When the created resource is a texture with either the **D3D12\_RESOURCE\_FLAG\_ALLOW\_RENDER\_TARGET** or **D3D12\_RESOURCE\_FLAG\_ALLOW\_DEPTH\_STENCIL** flags, your application should choose the value that the clear operation will most commonly be called with.

Clear operations can be called with other values, but those operations will not be as efficient as when the value matches the one passed into resource creation.

*pOptimizedClearValue* must be NULL when used with **D3D12\_RESOURCE\_DIMENSION\_BUFFER**.

*NumCastableFormats*\
Type: UINT32

The number of elements in *pCastableFormats*.

*pCastableFormats*\
Type: DXGI\_FORMAT \*

A contiguous array of [DXGI\_FORMAT](https://learn.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format) structures that this resource can be cast to.

*riid*\
Type: const IID &

The globally unique identifier (**GUID**) for the resource interface. This is an input parameter.

The **REFIID**, or **GUID**, of the interface to the resource can be obtained by using the `__uuidof` macro. For example, `__uuidof(ID3D12Resource)` gets the **GUID** of the interface to a resource. Although **riid** is, most commonly, the GUID for [**ID3D12Resource**](/reference/graphics/d3d12_xs/interfaces/ID3D12Resource/id3d12resource_xs), it may be any **GUID** for any interface. If the resource object doesn't support the interface for this **GUID**, then creation fails with **E\_NOINTERFACE**.

*ppvResource*\
Type: void \*\*

A pointer to a memory block that receives a pointer to the resource. *ppvResource* can be NULL, to enable capability testing. When *ppvResource* is NULL, no object will be created and S\_FALSE will be returned when *pResourceDesc* and other parameters are valid.

### Return value

Type: HRESULT

This method returns **E\_OUTOFMEMORY** if there is insufficient memory to create the resource. See [Direct3D 12 Return Codes](https://learn.microsoft.com/en-us/windows/win32/direct3d12/d3d12-graphics-reference-returnvalues) for other possible return values.

## Remarks

See **Remarks** for [ID3D12Device::CreatePlacedResource](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createplacedresource_public).

## Requirements

**Header:** d3d12\_xs.h\
**Library:** d3d12\_xs.lib\
**Supported Platforms**: XBOX Series consoles

## See Also

[CreateCommittedResource](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createcommittedresource_public)

[CreateReservedResource](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createreservedresource_public)

[ID3D12Device10](/reference/graphics/d3d12/interfaces/id3d12device10/id3d12device10_public)

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


## Related topics

- [CreateReservedResource2 (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device10/methods/id3d12device10_createreservedresource2_public.md)
- [CreateHeap1 (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device4/methods/id3d12device4_createheap1_public.md)
- [CreateReservedResource1 (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device4/methods/id3d12device4_createreservedresource1_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)
