ID3D12GraphicsCommandList::ResolveQueryData 메서드(d3d12.h)

쿼리에서 데이터를 추출합니다. ResolveQueryData는 모든 힙 형식(기본, 업로드 및 다시 읽기)에 작동합니다.

구문

void ResolveQueryData(
  [in] ID3D12QueryHeap  *pQueryHeap,
  [in] D3D12_QUERY_TYPE Type,
  [in] UINT             StartIndex,
  [in] UINT             NumQueries,
  [in] ID3D12Resource   *pDestinationBuffer,
  [in] UINT64           AlignedDestinationBufferOffset
);

매개 변수

[in] pQueryHeap

형식: ID3D12QueryHeap*

resolve 쿼리를 포함하는 ID3D12QueryHeap을 지정합니다.

[in] Type

형식: D3D12_QUERY_TYPE

쿼리 유형( D3D12_QUERY_TYPE 멤버 중 하나를 지정합니다.

[in] StartIndex

형식: UINT

resolve 첫 번째 쿼리의 인덱스를 지정합니다.

[in] NumQueries

형식: UINT

resolve 쿼리 수를 지정합니다.

[in] pDestinationBuffer

형식: ID3D12Resource*

상태 D3D12_RESOURCE_STATE_COPY_DEST 있어야 하는 ID3D12Resource 대상 버퍼를 지정합니다.

[in] AlignedDestinationBufferOffset

형식: UINT64

대상 버퍼에 대한 맞춤 오프셋을 지정합니다. 8바이트의 배수여야 합니다.

반환 값

없음

설명

ResolveQueryData 는 쿼리 데이터를 대상 버퍼에 쓰는 일괄 처리된 작업을 수행합니다. 쿼리 데이터는 대상 버퍼 및 매개 변수에 연속적으로 기록됩니다.

ResolveQueryData 는 애플리케이션 불투명 쿼리 힙의 애플리케이션 불투명 쿼리 데이터를 애플리케이션에서 사용할 수 있는 어댑터 중립적 값으로 바꿉니다. 완료되지 않은 힙 내에서 쿼리를 확인합니다( ID3D12GraphicsCommandList::BeginQuery 가 호출되었지만 ID3D12GraphicsCommandList::EndQuery가 호출되지 않음) 또는 초기화되지 않은 쿼리는 정의되지 않은 동작을 초래하며 디바이스 중단 또는 제거가 발생할 수 있습니다. 디버그 계층은 애플리케이션이 불완전하거나 초기화되지 않은 쿼리를 해결한 것을 감지하면 오류를 내보낸다.

참고

드라이버가 확인되지 않은 쿼리 내에 GPUVA 또는 기타 데이터를 내부적으로 저장할 수 있으므로 불완전하거나 초기화되지 않은 쿼리를 해결하는 것은 정의되지 않은 동작입니다. 따라서 초기화되지 않은 데이터에 대해 이러한 쿼리를 resolve 시도하면 페이지 오류 또는 디바이스 중단이 발생할 수 있습니다. 이전 버전의 디버그 계층은 이 동작의 유효성을 검사하지 않았습니다.

이진 폐색 쿼리는 쿼리당 64비트 쓰기 가장 중요한 비트는 0(개체가 완전히 폐색됨) 또는 1(개체의 샘플이 1개 이상 그려졌을 것임)입니다. 나머지 비트는 0입니다. 폐색 쿼리는 쿼리당 64비트 쓰기 값은 테스트를 통과한 샘플 수입니다. 타임스탬프 쿼리는 쿼리당 64비트(각 명령 큐 빈도와 비교해야 하는 틱 값)를 씁니다( 타이밍 참조).

파이프라인 통계 쿼리는 쿼리당 D3D12_QUERY_DATA_PIPELINE_STATISTICS 구조를 작성합니다. 모든 스트림아웃 통계 쿼리는 쿼리당 D3D12_QUERY_DATA_SO_STATISTICS 구조를 작성합니다.

코어 런타임은 다음의 유효성을 검사합니다.

  • StartIndexNumQueries 는 범위 내에 있습니다.
  • AlignedDestinationBufferOffset 은 8바이트의 배수입니다.
  • DestinationBuffer 는 버퍼입니다.
  • 기록된 데이터는 출력 버퍼를 오버플로하지 않습니다.
  • 쿼리 형식은 명령 목록 형식에서 지원되어야 합니다.
  • 쿼리 형식은 쿼리 힙에서 지원되어야 합니다.

대상 버퍼가 D3D12_RESOURCE_STATE_COPY_DEST 상태가 아니거나 확인 중인 쿼리에 ID3D12GraphicsCommandList::EndQuery 가 호출되지 않은 경우 디버그 계층에서 경고가 발생합니다.

예제

D3D12PredicationQueries 샘플은 다음과 같이 ID3D12GraphicsCommandList::ResolveQueryData를 사용합니다.

// 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 참조의 예제 코드를 참조하세요.

요구 사항

요구 사항
대상 플랫폼 Windows
헤더 d3d12.h
라이브러리 D3d12.lib
DLL D3d12.dll

추가 정보

ID3D12GraphicsCommandList