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

# CopyBufferRegion

> CopyBufferRegion (XBOX의 Direct3D 12) — 하나의 리소스에서 다른 리소스로 버퍼 영역을 복사합니다. XBOX 게임 개발을 위한 Direct3D 12 그래픽 API 참조입니다.

하나의 리소스에서 다른 리소스로 버퍼 영역을 복사합니다.

## 구문

```cpp theme={null}
void CopyBufferRegion(
    ID3D12Resource  pDstBuffer,
    UINT64 DstOffset,
    ID3D12Resource  pSrcBuffer,
    UINT64 SrcOffset,
    UINT64 NumBytes
)
```

### 매개 변수

*pDstBuffer \[in]*<br />형식: ID3D12Resource \*

대상 [ID3D12Resource](/reference/graphics/d3d12_xs/interfaces/ID3D12Resource/id3d12resource_xs)를 지정합니다.

*DstOffset*<br />형식: UINT64

대상 리소스에 대한 UINT64 오프셋(바이트 단위)을 지정합니다.

*pSrcBuffer \[in]*<br />형식: ID3D12Resource \*

원본 [ID3D12Resource](/reference/graphics/d3d12_xs/interfaces/ID3D12Resource/id3d12resource_xs)를 지정합니다.

*SrcOffset*<br />형식: UINT64

복사를 시작할 원본 리소스의 UINT64 오프셋(바이트 단위)을 지정합니다.

*NumBytes*<br />형식: UINT64

복사할 바이트 수를 지정합니다.

### 반환 값

형식: void

없음.

## 설명

전체 리소스를 복사할 때는 [CopyResource](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-copyresource) 메서드를 사용하는 것을 고려하고, 리소스의 영역을 복사할 때는 이 메서드를 사용하세요.

**CopyBufferRegion**은 동일한 힙 메모리에 별칭이 지정된 리소스를 초기화하는 데 사용할 수 있습니다. 자세한 내용은 [CreatePlacedResource](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createplacedresource_public)를 참조하세요.

#### 예제

[D3D12HelloTriangle](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) 샘플은 다음과 같이 **ID3D12GraphicsCommandList::CopyBufferRegion**을 사용합니다:

```cpp theme={null}
inline UINT64 UpdateSubresources(
_In_ ID3D12GraphicsCommandList* pCmdList,
_In_ ID3D12Resource* pDestinationResource,
_In_ ID3D12Resource* pIntermediate,
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources,
UINT64 RequiredSize,
_In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts,
_In_reads_(NumSubresources) const UINT* pNumRows,
_In_reads_(NumSubresources) const UINT64* pRowSizesInBytes,
_In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData)
{
// Minor validation
D3D12_RESOURCE_DESC IntermediateDesc = pIntermediate->GetDesc();
D3D12_RESOURCE_DESC DestinationDesc = pDestinationResource->GetDesc();
if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER ||
IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset ||
RequiredSize > (SIZE_T)-1 ||
(DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER &&
(FirstSubresource != 0 || NumSubresources != 1)))
{
return 0;
}

BYTE* pData;
HRESULT hr = pIntermediate->Map(0, NULL, reinterpret_cast<void**>(&pData));
if (FAILED(hr))
{
return 0;
}

for (UINT i = 0; i < NumSubresources; ++i)
{
if (pRowSizesInBytes[i] > (SIZE_T)-1) return 0;
D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, pLayouts[i].Footprint.RowPitch * pNumRows[i] };
MemcpySubresource(&DestData, &pSrcData[i], (SIZE_T)pRowSizesInBytes[i], pNumRows[i], pLayouts[i].Footprint.Depth);
}
pIntermediate->Unmap(0, NULL);

if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
{
CD3DX12_BOX SrcBox( UINT( pLayouts[0].Offset ), UINT( pLayouts[0].Offset + pLayouts[0].Footprint.Width ) );
pCmdList->CopyBufferRegion(
pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width);
}
else
{
for (UINT i = 0; i < NumSubresources; ++i)
{
CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource);
CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]);
pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr);
}
}
return RequiredSize;
}
```

[D3D12 참조의 예제 코드](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code)를 참조하세요.

<div class="code" />

## 요구 사항

**헤더:** d3d12\_xs.h 또는 d3d12\_x.h<br />**라이브러리:** d3d12\_xs.lib 또는 d3d12\_x.lib<br />**지원 플랫폼**: XBOX Series 콘솔 및 XBOX One 제품군

## 함께 보기

[CopyTextureRegion](/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_copytextureregion_public)

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


## Related topics

- [CreatePlacedResource](/ko/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createplacedresource_public.md)
- [D3D12_CROSS_NODE_SHARING_TIER](/ko/reference/graphics/d3d12/enums/d3d12_cross_node_sharing_tier_public.md)
- [CopyTiles](/ko/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_copytiles_public.md)
- [CopyTileMappings](/ko/reference/graphics/d3d12/interfaces/id3d12commandqueue/methods/id3d12commandqueue_copytilemappings_public.md)
- [Region](/ko/services/playfab/api-references/events/data-types/region.md)
