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

# CopyTiles

> Copies tiles from buffer to tiled resource or vice versa. (ID3D12GraphicsCommandList.CopyTiles)

Copies tiles from buffer to tiled resource or vice versa.

## Syntax

```cpp theme={null}
void CopyTiles(
    ID3D12Resource  pTiledResource,
    const D3D12_TILED_RESOURCE_COORDINATE  pTileRegionStartCoordinate,
    const D3D12_TILE_REGION_SIZE  pTileRegionSize,
    ID3D12Resource  pBuffer,
    UINT64 BufferStartOffsetInBytes,
    D3D12_TILE_COPY_FLAGS Flags
)
```

### Parameters

*pTiledResource \[in]*\
Type: ID3D12Resource \*

A pointer to a tiled resource.

*pTileRegionStartCoordinate \[in]*\
Type: const D3D12\_TILED\_RESOURCE\_COORDINATE \*

A pointer to a
[D3D12\_TILED\_RESOURCE\_COORDINATE](/reference/graphics/d3d12/structs/d3d12_tiled_resource_coordinate_public) structure that describes the starting coordinates of the tiled resource.

*pTileRegionSize \[in]*\
Type: const D3D12\_TILE\_REGION\_SIZE \*

A pointer to a [D3D12\_TILE\_REGION\_SIZE](/reference/graphics/d3d12/structs/d3d12_tile_region_size_public) structure that describes the size of the tiled region.

*pBuffer \[in]*\
Type: ID3D12Resource \*

A pointer to an [ID3D12Resource](/reference/graphics/d3d12_xs/interfaces/ID3D12Resource/id3d12resource_xs) that represents a default, dynamic, or staging buffer.

*BufferStartOffsetInBytes*\
Type: UINT64

The offset in bytes into the buffer at <i>pBuffer</i> to start the operation.

*Flags*\
Type: D3D12\_TILE\_COPY\_FLAGS

A combination of [D3D12\_TILE\_COPY\_FLAGS](/reference/graphics/d3d12/enums/d3d12_tile_copy_flags_public)-typed values that are combined by using a bitwise OR operation and that identifies how to copy tiles.

### Return value

Type: void

None.

## Remarks

**CopyTiles** drops write operations to
unmapped areas and handles read operations from unmapped areas
(except on Tier\_1 tiled resources,
where reading and writing unmapped areas is invalid - refer to [D3D12\_TILED\_RESOURCES\_TIER](/reference/graphics/d3d12/enums/d3d12_tiled_resources_tier_public)).

If a copy operation involves writing to the same memory location multiple times because multiple locations in the
destination resource are mapped to the same tile memory, the resulting write operations to multi-mapped tiles are
non-deterministic and non-repeatable; that is, accesses to the tile memory happen in whatever order the hardware
happens to execute the copy operation.

The tiles involved in the copy operation can't include tiles that contain packed mipmaps or results of the copy
operation are undefined. To transfer data to and from mipmaps that the hardware packs into the one-or-more tiles that constitute the packed mips, you must
use the standard (that is, non-tile specific) copy APIs
like [CopyTextureRegion](/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_copytextureregion_public).

**CopyTiles** does copy data in a slightly different pattern than the standard copy methods.

The memory layout of the tiles in the non-tiled buffer resource side of the copy operation is linear in memory within 64 KB tiles, which the hardware and driver swizzle and de-swizzle per tile as appropriate when they transfer to and from a tiled resource. For multisample antialiasing (MSAA) surfaces, the hardware and driver traverse each pixel's samples in sample-index order before they move to the next pixel. For tiles that are partially filled on the right side (for a surface that has a width not a multiple of tile width in pixels), the pitch and stride to move down a row is the full size in bytes of the number pixels that would fit across the tile if the tile was full. So, there can be a gap between each row of pixels in memory. Mipmaps that are smaller than a tile are not packed together in the linear layout, which might seem to be a waste of memory space, but as mentioned you can't use **CopyTiles** to copy to mipmaps that the hardware packs together. You can just use generic copy APIs, like [CopyTextureRegion](/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_copytextureregion_public), to copy small mipmaps individually.

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

[ID3D12GraphicsCommandList](/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs)

[Tiled resources](https://learn.microsoft.com/en-us/windows/desktop/direct3d11/tiled-resources)
