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

# ExecuteBundle

> Executa um pacote.

Executa um pacote.

## Sintaxe

```cpp theme={null}
void ExecuteBundle(
    ID3D12GraphicsCommandList  pCommandList
)
```

### Parâmetros

*pCommandList \[in]*\
Tipo: ID3D12GraphicsCommandList \*

Especifica a [ID3D12GraphicsCommandList](/pt-BR/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs) que determina o pacote a ser executado.

### Valor retornado

Tipo: void

Nenhum.

## Comentários

Os pacotes herdam todo o estado da lista de comandos pai na qual **ExecuteBundle** é chamado, exceto o objeto de estado do pipeline e a topologia primitiva.
Todo o estado definido em um pacote afetará o estado da lista de comandos pai.
Observe que **ExecuteBundle** não é uma operação predicada.

<h3><a id="Runtime_validation" /><a id="runtime_validation" /><a id="RUNTIME_VALIDATION" />Validação do runtime</h3>
O runtime validará se o "chamado" é um pacote e se o "chamador" é uma lista de comandos direta. O runtime também validará se o pacote foi fechado. Se o contrato for violado, o runtime descartará a chamada silenciosamente.
Uma falha de validação fará com que [Close](/pt-BR/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_close_public) retorne E\_INVALIDARG.

<h3><a id="Debug_layer" /><a id="debug_layer" /><a id="DEBUG_LAYER" />Camada de depuração</h3>
A camada de depuração emitirá um aviso nos mesmos casos em que o runtime falhará.
A camada de depuração emitirá um aviso se um predicado estiver definido quando [ExecuteCommandList](/pt-BR/reference/graphics/d3d12_x/interfaces/id3d12commandqueue/methods/id3d12commandqueue_executecommandlists) for chamado.
Além disso, a camada de depuração emitirá um erro se detectar que algum recurso referenciado pela lista de comandos foi destruído.

A camada de depuração também validará se o alocador de comandos associado ao pacote não foi redefinido desde que [Close](/pt-BR/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_close_public) foi chamado na lista de comandos. Essa validação ocorre no momento de **ExecuteBundle** e quando a lista de comandos pai é executada em uma fila de comandos.

#### Exemplos

A amostra [D3D12Bundles](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) usa **ID3D12GraphicsCommandList::ExecuteBundle** da seguinte maneira:

```cpp theme={null}
void D3D12Bundles::PopulateCommandList(FrameResource* pFrameResource)
{
// Command list allocators can only be reset when the associated
// command lists have finished execution on the GPU; apps should use
// fences to determine GPU execution progress.
ThrowIfFailed(m_pCurrentFrameResource->m_commandAllocator->Reset());

// However, when ExecuteCommandList() is called on a particular command
// list, that command list can then be reset at any time and must be before
// re-recording.
ThrowIfFailed(m_commandList->Reset(m_pCurrentFrameResource->m_commandAllocator.Get(), m_pipelineState1.Get()));

// Set necessary state.
m_commandList->SetGraphicsRootSignature(m_rootSignature.Get());

ID3D12DescriptorHeap* ppHeaps[] = { m_cbvSrvHeap.Get(), m_samplerHeap.Get() };
m_commandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps);

m_commandList->RSSetViewports(1, &m_viewport);
m_commandList->RSSetScissorRects(1, &m_scissorRect);

// Indicate that the back buffer will be used as a render target.
m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));

CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart(), m_frameIndex, m_rtvDescriptorSize);
CD3DX12_CPU_DESCRIPTOR_HANDLE dsvHandle(m_dsvHeap->GetCPUDescriptorHandleForHeapStart());
m_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, &dsvHandle);

// Record commands.
const float clearColor[] = { 0.0f, 0.2f, 0.4f, 1.0f };
m_commandList->ClearRenderTargetView(rtvHandle, clearColor, 0, nullptr);
m_commandList->ClearDepthStencilView(m_dsvHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);

if (UseBundles)
{
// Execute the prebuilt bundle.
m_commandList->ExecuteBundle(pFrameResource->m_bundle.Get());
}
else
{
// Populate a new command list.
pFrameResource->PopulateCommandList(m_commandList.Get(), m_pipelineState1.Get(), m_pipelineState2.Get(), m_currentFrameResourceIndex, m_numIndices, &m_indexBufferView,
&m_vertexBufferView, m_cbvSrvHeap.Get(), m_cbvSrvDescriptorSize, m_samplerHeap.Get(), m_rootSignature.Get());
}

// Indicate that the back buffer will now be used to present.
m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));

ThrowIfFailed(m_commandList->Close());
}

```

Confira [Código de exemplo na referência do D3D12](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code).

<div class="code" />

## Requisitos

**Cabeçalho:** d3d12\_xs.h ou d3d12\_x.h\
**Biblioteca:** d3d12\_xs.lib ou d3d12\_x.lib\
**Plataformas com suporte**: consoles XBOX Series e família XBOX One

## Confira também

[ID3D12GraphicsCommandList](/pt-BR/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs)


## Related topics

- [Execute Inventory Operations](/api-reference/inventory/execute-inventory-operations.md)
- [Visão geral do Economy v2](/pt-BR/services/playfab/economy-monetization/economy-v2/overview.md)
- [Execute Function](/api-reference/server-side-cloud-script/execute-function.md)
- [Configurar a autenticação do PlayFab usando Facebook e Unity](/pt-BR/services/playfab/identity/player-identity/platform-specific-authentication/facebook-unity.md)
- [Como configurar um bundle de pré-venda](/pt-BR/publishing/game-publishing/how-to/how-to-create-preorder-visible-bundle.md)
