//-----------------------------------------------------------------------------
/// Called at present-time.
/// \param queue The queue we're using to present.
/// \param pPresentInfo Information about this present.
//-----------------------------------------------------------------------------
VkResult VktWrappedQueue::QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* pPresentInfo)
{
    VkResult result = QueuePresentKHR_ICD(queue, pPresentInfo);

    VktTraceAnalyzerLayer::Instance()->OnPresent(queue, pPresentInfo);

    QueueInfo queueInfo = {};
    queueInfo.physicalDevice = m_createInfo.physicalDevice;
    queueInfo.device         = m_createInfo.device;
    queueInfo.queue          = queue;
    VktFrameDebuggerLayer::Instance()->OnPresent(queueInfo);

    VktLayerManager::GetLayerManager()->EndFrame();

    // Get new requests sent to the server.
    GetPendingRequests();

    VktLayerManager::GetLayerManager()->BeginFrame();

    return result;
}
Example #2
0
//--------------------------------------------------------------------------
/// Begin the frame.
//--------------------------------------------------------------------------
void ModernAPILayerManager::BeginFrame()
{
    GetPendingRequests();

    if (mCmdSetSessionName.IsActive())
    {
        gtASCIIString sessionName = mCmdSetSessionName.GetValue();

        if (SessionManager::Instance()->SetSessionName(sessionName) == false)
        {
            mCmdSetSessionName.Send("Failed");
        }
        else
        {
            mCmdSetSessionName.Send("OK");
        }
    }

    if (mCmdSetProjectName.IsActive())
    {
        gtASCIIString projectName = mCmdSetProjectName.GetValue();

        if (SessionManager::Instance()->SetProjectName(projectName) == false)
        {
            mCmdSetProjectName.Send("Failed");
        }
        else
        {
            mCmdSetProjectName.Send("OK");
        }
    }

    // Check if we need to collect a trace for this currently-rendering frame.
    if (mbTraceTriggeredFromKeypress)
    {
        Log(logMESSAGE, "Keypress capture starting.\n");

        MultithreadedTraceAnalyzerLayer* traceAnalyzer = GetTraceAnalyzerLayer();

        if (traceAnalyzer != nullptr)
        {
            // Examine the layer stack to check for any enabled layers. If there are,
            // we won't be able to collect a trace successfully.
            if (m_EnabledLayers.empty())
            {
#if ENABLE_CLIENT_LOCKOUT_ON_KEYPRESS
                // Tell the GPUPerfServer to reject all incoming requests (it will send the stalled status return to all messages)
                SG_SET_BOOL(ForceRenderStallState, true);
#endif // ENABLE_CLIENT_LOCKOUT_ON_KEYPRESS

                // Since there aren't any layers enabled in the stack, we can proceed with pushing the Logger.
                if (!traceAnalyzer->IsEnabled())
                {
                    // Need to add the TraceAnalyzer layer to the stack.
                    PushLayer(*traceAnalyzer, &m_pushLayer);
                }

                // Enable trace collection for the next rendered frame.
                traceAnalyzer->EnableLinkedTraceCollection();
            }
            else
            {
                // The LayerManager's "enabled layer stack" wasn't empty, meaning the client was in the middle of an operation.
                // Dump a message to the log, and forget that a keypress trace was requested.
                Log(logMESSAGE, "Layer stack is non-empty. Not going to push the Logger for Keypress Capture.\n");
                mbTraceTriggeredFromKeypress = false;
            }
        }
    }

    if (mCmdFrameCaptureWithSave.IsActive())
    {
        // Extract the capture mode argument from the capture mode string
        m_captureType = (CaptureType)mCmdFrameCaptureWithSave.GetCaptureType();
        m_captureCount = mCmdFrameCaptureWithSave.GetCaptureCount();

        if (m_captureCount == 0)
        {
            Log(logERROR, "ModernAPILayerManager::BeginFrame - m_captureCount is 0, forcing it to 1.\n");
            m_captureCount = 1;
        }

        // Exclude Frame Capture
        if (m_captureType > 0 && m_captureType < 4)
        {
            // Now I need to make sure that the MultithreadedTraceAnalyzerLayer is on the stack.
            MultithreadedTraceAnalyzerLayer* traceAnalyzer = GetTraceAnalyzerLayer();
            traceAnalyzer->EnableLinkedTraceCollection();

            // enable objectInspector writing to disk
            ObjectDatabaseProcessor* objectDatabase = GetObjectDatabaseProcessor();
            objectDatabase->EnableObjectDatabaseCollection();
        }
    }

    // Call into the base class to deal with basic layer management.
    LayerManager::BeginFrame();
}