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

# SetPredication

> 렌더링 조건자를 설정합니다.

렌더링 조건자를 설정합니다.

## 구문

```cpp theme={null}
void SetPredication(
    ID3D12Resource  pBuffer,
    UINT64 AlignedBufferOffset,
    D3D12_PREDICATION_OP Operation
)
```

### 매개 변수

*pBuffer \[in, optional]*\
형식: ID3D12Resource \*

[ID3D12Resource](/reference/graphics/d3d12_xs/interfaces/ID3D12Resource/id3d12resource_xs)로서의 버퍼이며, [**D3D12\_RESOURCE\_STATE\_PREDICATION**](/reference/graphics/d3d12_x/enums/d3d12_resource_states) 또는 [**D3D21\_RESOURCE\_STATE\_INDIRECT\_ARGUMENT**](/reference/graphics/d3d12_x/enums/d3d12_resource_states) 상태(두 값은 동일하며 명확성을 위해 별칭으로 제공됨)여야 하고, 조건 적용을 비활성화하려면 **NULL**입니다.

*AlignedBufferOffset \[in]*\
형식: UINT64

UINT64 형태의 정렬된 버퍼 오프셋입니다.

*Operation \[in]*\
형식: D3D12\_PREDICATION\_OP

D3D12\_PREDICATION\_OP\_EQUAL\_ZERO 또는 D3D12\_PREDICATION\_OP\_NOT\_EQUAL\_ZERO와 같은 [D3D12\_PREDICATION\_OP](/reference/graphics/d3d12/enums/d3d12_predication_op_public)을 지정합니다.

### 반환 값

형식: void

없음.

## 설명

이 메서드를 사용하여 조건자의 결과 조건 데이터가 지정된 연산과 같은 경우 이후 렌더링 및 리소스 조작 명령이 실제로 수행되지 않음을 나타냅니다.

Direct3D 11과 달리, Direct3D 12에서는 조건 적용 상태가 직접 명령 목록에 상속되지 않으며 조건 적용은 항상 준수됩니다(조건 적용 힌트가 없음).
모든 직접 명령 목록은 조건 적용이 비활성화된 상태로 시작합니다.
번들은 조건 적용 상태를 상속합니다.
동일한 조건자를 여러 번 바인딩하는 것은 유효합니다.

잘못된 API 호출은 [Close](/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_close_public)에서 오류를 반환하거나,
[ID3D12CommandQueue::ExecuteCommandLists](/reference/graphics/d3d12_x/interfaces/id3d12commandqueue/methods/id3d12commandqueue_executecommandlists)에서 명령 목록을 삭제하고 장치를 제거합니다.

런타임 유효성 검사가 실패할 때마다 디버그 레이어에서 오류를 발생시킵니다.

자세한 내용은 [조건 적용](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/predication)을 참조하세요.

#### 예제

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

```cpp theme={null}
// Fill the command list with all the render commands and dependent state.
void D3D12PredicationQueries::PopulateCommandList()
{
// 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_commandAllocators[m_frameIndex]->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_commandAllocators[m_frameIndex].Get(), m_pipelineState.Get()));

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

ID3D12DescriptorHeap* ppHeaps[] = { m_cbvHeap.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(dsvHandle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);

// Draw the quads and perform the occlusion query.
{
CD3DX12_GPU_DESCRIPTOR_HANDLE cbvFarQuad(m_cbvHeap->GetGPUDescriptorHandleForHeapStart(), m_frameIndex * CbvCountPerFrame, m_cbvSrvDescriptorSize);
CD3DX12_GPU_DESCRIPTOR_HANDLE cbvNearQuad(cbvFarQuad, m_cbvSrvDescriptorSize);

m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
m_commandList->IASetVertexBuffers(0, 1, &m_vertexBufferView);

// Draw the far quad conditionally based on the result of the occlusion query
// from the previous frame.
m_commandList->SetGraphicsRootDescriptorTable(0, cbvFarQuad);
m_commandList->SetPredication(m_queryResult.Get(), 0, D3D12_PREDICATION_OP_EQUAL_ZERO);
m_commandList->DrawInstanced(4, 1, 0, 0);

// Disable predication and always draw the near quad.
m_commandList->SetPredication(nullptr, 0, D3D12_PREDICATION_OP_EQUAL_ZERO);
m_commandList->SetGraphicsRootDescriptorTable(0, cbvNearQuad);
m_commandList->DrawInstanced(4, 1, 4, 0);

// Run the occlusion query with the bounding box quad.
m_commandList->SetGraphicsRootDescriptorTable(0, cbvFarQuad);
m_commandList->SetPipelineState(m_queryState.Get());
m_commandList->BeginQuery(m_queryHeap.Get(), D3D12_QUERY_TYPE_BINARY_OCCLUSION, 0);
m_commandList->DrawInstanced(4, 1, 8, 0);
m_commandList->EndQuery(m_queryHeap.Get(), D3D12_QUERY_TYPE_BINARY_OCCLUSION, 0);

// Resolve the occlusion query and store the results in the query result buffer
// to be used on the subsequent frame.
m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_queryResult.Get(), D3D12_RESOURCE_STATE_PREDICATION, D3D12_RESOURCE_STATE_COPY_DEST));
m_commandList->ResolveQueryData(m_queryHeap.Get(), D3D12_QUERY_TYPE_BINARY_OCCLUSION, 0, 1, m_queryResult.Get(), 0);
m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_queryResult.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PREDICATION));
}

// 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());
}

```

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

<div class="code" />

## 요구 사항

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

## 함께 보기

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

[조건 적용 쿼리 연습](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/predication-queries)


## Related topics

- [D3D12_PREDICATION_OP](/ko/reference/graphics/d3d12/enums/d3d12_predication_op_public.md)
- [BeginQuery](/ko/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_beginquery_public.md)
- [EndQuery](/ko/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_endquery_public.md)
- [ID3D12QueryHeap](/ko/reference/graphics/d3d12/interfaces/id3d12queryheap/id3d12queryheap_public.md)
- [CreateQueryHeap](/ko/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createqueryheap_public.md)
