Path: blob/main_old/src/libGLESv2/entry_points_cl_utils.cpp
1693 views
//1// Copyright 2021 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// entry_points_cl_utils.cpp: These helpers are used in CL entry point routines.67#include "libGLESv2/entry_points_cl_utils.h"89#include "libGLESv2/cl_dispatch_table.h"1011#include "libANGLE/CLPlatform.h"12#ifdef ANGLE_ENABLE_CL_PASSTHROUGH13# include "libANGLE/renderer/cl/CLPlatformCL.h"14#endif15#ifdef ANGLE_ENABLE_VULKAN16# include "libANGLE/renderer/vulkan/CLPlatformVk.h"17#endif1819#include "anglebase/no_destructor.h"2021#include <mutex>2223namespace cl24{2526void InitBackEnds(bool isIcd)27{28enum struct State29{30Uninitialized,31Initializing,32Initialized33};34static State sState = State::Uninitialized;3536// Fast thread-unsafe check first37if (sState == State::Initialized)38{39return;40}4142static angle::base::NoDestructor<std::recursive_mutex> sMutex;43std::lock_guard<std::recursive_mutex> lock(*sMutex);4445// Thread-safe check, return if initialized46// or if already initializing (re-entry from CL pass-through back end)47if (sState != State::Uninitialized)48{49return;50}5152sState = State::Initializing;5354rx::CLPlatformImpl::CreateFuncs createFuncs;55#ifdef ANGLE_ENABLE_CL_PASSTHROUGH56rx::CLPlatformCL::Initialize(createFuncs, isIcd);57#endif58#ifdef ANGLE_ENABLE_VULKAN59rx::CLPlatformVk::Initialize(createFuncs);60#endif61Platform::Initialize(gCLIcdDispatchTable, std::move(createFuncs));6263sState = State::Initialized;64}6566} // namespace cl676869