Exemplo n.º 1
0
//-----------------------------------------------------------------------------
/// Handler used after the real runtime implementation of an API call has been invoked.
/// \param pNewAPIEntry The new APIEntry created for the API call invocation.
/// \param pWrappedCmdBuf The interface pointer used to invoke the API call.
/// \param inFuncId The FuncId corresponding to the API call being traced.
//-----------------------------------------------------------------------------
void VktFrameProfilerLayer::PostCall(VktAPIEntry* pNewAPIEntry, FuncId inFuncId, VktWrappedCmdBuf* pWrappedCmdBuf)
{
    // Wait and gather results
    if (pWrappedCmdBuf->IsProfilingEnabled() && ShouldProfileFunction(inFuncId))
    {
        osThreadId threadId = osGetCurrentThreadId();
        SampleInfo* pSampleInfo = GetSampleInfoForThread(threadId);

        if (pSampleInfo != nullptr)
        {
            if (pSampleInfo->mbBeginSampleSuccessful == true)
            {
                ProfilerResultCode endResult = pWrappedCmdBuf->EndCmdMeasurement();

                if (endResult == PROFILER_SUCCESS)
                {
                    pNewAPIEntry->m_sampleId = pSampleInfo->mSampleId;
                    StoreProfilerResult(pNewAPIEntry);
                }
                else
                {
                    Log(logERROR, "Failed EndCmdMeasurement. CmdBuf='0x%p' SampleId='%d'\n", pWrappedCmdBuf->AppHandle(), pSampleInfo->mSampleId);
                }
            }
            else
            {
                Log(logERROR, "Didn't call EndMeasurement because BeginMeasurement wasn't successful.\n");
            }
        }
        else
        {
            Log(logERROR, "Didn't call EndSample because there was no SampleInfo for Thread %d\n", threadId);
        }
    }
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
/// Handler used after the real runtime implementation of an API call has been invoked.
/// \param inNewAPIEntry The new APIEntry created for the API call invocation.
/// \param inWrappedInterface The interface pointer used to invoke the API call.
/// \param inFunctionId The FuncId corresponding to the API call being traced.
//-----------------------------------------------------------------------------
void DX12FrameProfilerLayer::PostCall(DX12APIEntry* inNewAPIEntry, IUnknown* inWrappedInterface, FuncId inFunctionId)
{
    Wrapped_ID3D12GraphicsCommandListCustom* pWrappedGraphicsCommandListCustom = static_cast<Wrapped_ID3D12GraphicsCommandListCustom*>(inWrappedInterface);

    // Wait and gather results
    if (pWrappedGraphicsCommandListCustom->IsProfilingEnabled() && ShouldProfileFunction(inFunctionId))
    {
        Wrapped_ID3D12GraphicsCommandList* pWrappedGraphicsCommandList = static_cast<Wrapped_ID3D12GraphicsCommandList*>(inWrappedInterface);

        osThreadId threadId = osGetCurrentThreadId();

        Wrapped_ID3D12CommandList* pCmdList = static_cast<Wrapped_ID3D12CommandList*>(inWrappedInterface);

        if (CommandListSupportsTimestamping(pCmdList) == true)
        {
            SampleInfo* pSampleInfo = GetSampleInfoForThread(threadId);

            if (pSampleInfo != nullptr)
            {
                if (pSampleInfo->mbBeginSampleSuccessful == true)
                {
                    Wrapped_ID3D12GraphicsCommandListCustom* pCmdListCustom = static_cast<Wrapped_ID3D12GraphicsCommandListCustom*>(inWrappedInterface);

                    ProfilerResultCode endResult = pCmdListCustom->EndCmdMeasurement();

                    if (endResult == PROFILER_SUCCESS)
                    {
                        inNewAPIEntry->mSampleId = pSampleInfo->mSampleId;
                        StoreProfilerResult(inNewAPIEntry);
                    }
                    else
                    {
                        Log(logERROR, "Failed EndCmdMeasurement. CmdList='0x%p' SampleId='%d'\n", pWrappedGraphicsCommandList->mRealGraphicsCommandList, pSampleInfo->mSampleId);
                    }
                }
                else
                {
                    Log(logERROR, "Didn't call EndMeasurement because BeginMeasurement wasn't successful.\n");
                }
            }
            else
            {
                Log(logERROR, "Didn't call EndSample because there was no SampleInfo for Thread %d\n", threadId);
            }
        }
        else
        {
            Log(logERROR, "Failed to find or create SampleInfo instance for Thread %d\n", threadId);
        }
    }
}