context/llpcCompiler.cpp
Context* Compiler::AcquireContext() const
{
    Context* pFreeContext = nullptr;

    MutexGuard lock(m_contextPoolMutex);

    // Try to find a free context from pool first
    for (auto pContext : *m_pContextPool)
    {
        GfxIpVersion gfxIpVersion = pContext->GetGfxIpVersion();

        if ((pContext->IsInUse()   == false) &&
            (gfxIpVersion.major    == m_gfxIp.major) &&
            (gfxIpVersion.minor    == m_gfxIp.minor) &&
            (gfxIpVersion.stepping == m_gfxIp.stepping))
        {
            pFreeContext = pContext;
            pFreeContext->SetInUse(true);
            break;
        }
    }

    if (pFreeContext == nullptr)
    {
        // Create a new one if we fail to find an available one
        pFreeContext = new Context(m_gfxIp, &m_gpuWorkarounds);
        pFreeContext->SetInUse(true);
        m_pContextPool->push_back(pFreeContext);
    }

    LLPC_ASSERT(pFreeContext != nullptr);
    return pFreeContext;
}
// =====================================================================================================================
// Acquires a free context from context pool.
Acquires a free context from context pool.
Acquires a free context from context pool .
Context* Compiler::AcquireContext() const
{
    Context* pFreeContext = nullptr;
    MutexGuard lock(m_contextPoolMutex);
    for (auto pContext : *m_pContextPool)
    {
        GfxIpVersion gfxIpVersion = pContext->GetGfxIpVersion();
        if ((pContext->IsInUse()   == false) &&
            (gfxIpVersion.major    == m_gfxIp.major) &&
            (gfxIpVersion.minor    == m_gfxIp.minor) &&
            (gfxIpVersion.stepping == m_gfxIp.stepping))
        {
            pFreeContext = pContext;
            pFreeContext->SetInUse(true);
            break;
        }
    }
    if (pFreeContext == nullptr)
    {
        pFreeContext = new Context(m_gfxIp, &m_gpuWorkarounds);
        pFreeContext->SetInUse(true);
        m_pContextPool->push_back(pFreeContext);
    }
    LLPC_ASSERT(pFreeContext != nullptr);
    return pFreeContext;
}
Context * Compiler :: AcquireContext ( ) const { Context * pFreeContext = nullptr ; MutexGuard lock ( m_contextPoolMutex ) ; for ( auto pContext : * m_pContextPool ) { GfxIpVersion gfxIpVersion = pContext -> GetGfxIpVersion ( ) ; if ( ( pContext -> IsInUse ( ) == false ) && ( gfxIpVersion . major == m_gfxIp . major ) && ( gfxIpVersion . minor == m_gfxIp . minor ) && ( gfxIpVersion . stepping == m_gfxIp . stepping ) ) { pFreeContext = pContext ; pFreeContext -> SetInUse ( true ) ; break ; } } if ( pFreeContext == nullptr ) { pFreeContext = new Context ( m_gfxIp , & m_gpuWorkarounds ) ; pFreeContext -> SetInUse ( true ) ; m_pContextPool -> push_back ( pFreeContext ) ; } LLPC_ASSERT ( pFreeContext != nullptr ) ; return pFreeContext ; }
Acquires a free context from context pool.
Acquires a free context from context pool .
// Try to find a free context from pool first // Create a new one if we fail to find an available one