/**
***************************************************************************************************
*   DX12CmdListProfiler::SetupNewMeasurementGroup
*
*   @brief
*       Create a new query heap and memory pair for time stamping.
*
*   @return
*       S_OK if successful
***************************************************************************************************
*/
HRESULT DX12CmdListProfiler::SetupNewMeasurementGroup(ProfilerCmdListData& cmdListData)
{
    HRESULT result = S_OK;

    ProfilerMeasurementGroup measurementGroup = {};

    if (m_config.measurementTypeFlags & PROFILER_MEASUREMENT_TYPE_TIMESTAMPS)
    {
        result = CreateQueryBuffer(&measurementGroup.pTimestampBuffer,
                                   m_config.measurementsPerGroup * sizeof(ProfilerInterval));

        if (result == S_OK)
        {
            measurementGroup.pTimestampBuffer->SetName(L"Timestamp Buffer");

            D3D12_QUERY_HEAP_DESC queryHeapDesc;
            queryHeapDesc.Count    = m_config.measurementsPerGroup * 2;
            queryHeapDesc.NodeMask = 1;
            queryHeapDesc.Type     = D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
            result = m_pDevice->CreateQueryHeap(&queryHeapDesc, IID_PPV_ARGS(&measurementGroup.pTimestampQueryHeap));

            if (result == S_OK)
            {
                measurementGroup.pTimestampQueryHeap->SetName(L"Timestamp QueryHeap");
            }
        }
    }

    if (m_config.measurementTypeFlags & PROFILER_MEASUREMENT_TYPE_PIPE_STATS)
    {
        result = CreateQueryBuffer(&measurementGroup.pPipeStatsBuffer,
                                   m_config.measurementsPerGroup * sizeof(D3D12_QUERY_DATA_PIPELINE_STATISTICS));

        if (result == S_OK)
        {
            measurementGroup.pPipeStatsBuffer->SetName(L"PipeStats Buffer");

            D3D12_QUERY_HEAP_DESC queryHeapDesc;
            queryHeapDesc.Count    = m_config.measurementsPerGroup;
            queryHeapDesc.NodeMask = 1;
            queryHeapDesc.Type     = D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS;
            result = m_pDevice->CreateQueryHeap(&queryHeapDesc, IID_PPV_ARGS(&measurementGroup.pPipeStatsQueryHeap));

            if (result == S_OK)
            {
                measurementGroup.pPipeStatsQueryHeap->SetName(L"PipeStats QueryHeap");
            }
        }
    }

    if (result == S_OK)
    {
        cmdListData.measurementGroups.push_back(measurementGroup);
        cmdListData.pActiveMeasurementGroup = &cmdListData.measurementGroups.back();
    }

    return result;
}
Beispiel #2
0
//-----------------------------------------------------------------------------
/// Release collection of GPU resources.
/// \param gpuRes The set of GPU resources to release.
/// \returns The result code after attempting to release the incoming resources.
//-----------------------------------------------------------------------------
VkResult VktCmdBufProfiler::CreateGpuResourceGroup(ProfilerGpuResources& gpuRes)
{
    VkResult result = VK_INCOMPLETE;

    VkQueryPoolCreateInfo queryPoolCreateInfo = VkQueryPoolCreateInfo();
    queryPoolCreateInfo.sType      = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
    queryPoolCreateInfo.pNext      = nullptr;
    queryPoolCreateInfo.queryType  = VK_QUERY_TYPE_TIMESTAMP;
    queryPoolCreateInfo.queryCount = m_maxQueriesPerGroup;
    result = m_pDeviceDT->CreateQueryPool(m_config.device, &queryPoolCreateInfo, nullptr, &gpuRes.timestampQueryPool);

    if (result == VK_SUCCESS)
    {
        result = CreateQueryBuffer(
                     &gpuRes.timestampBuffer,
                     &gpuRes.timestampMem,
                     m_config.measurementsPerGroup * sizeof(ProfilerInterval));
    }

    return result;
}