Hash :
05fb2272
Author :
Date :
2021-04-27T19:31:31
Add support for OpenCL ICD Loader Bug: angleproject:5908 Change-Id: Idafc0d15b69f9a21f2ab5e48c4c34f0dc0e0ee96 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2854598 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: John Plate <jplate@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
//
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// dispatch.cpp: Implements a function to fetch the ANGLE OpenCL dispatch table.
#include "libOpenCL/dispatch.h"
#include "anglebase/no_destructor.h"
#include "common/system_utils.h"
#include <iostream>
#include <memory>
namespace cl
{
namespace
{
std::unique_ptr<angle::Library> &EntryPointsLib()
{
static angle::base::NoDestructor<std::unique_ptr<angle::Library>> sEntryPointsLib;
return *sEntryPointsLib;
}
} // anonymous namespace
cl_icd_dispatch &GetDispatch()
{
static cl_icd_dispatch *sDispatch = nullptr;
if (sDispatch == nullptr)
{
EntryPointsLib().reset(
angle::OpenSharedLibrary(ANGLE_GLESV2_LIBRARY_NAME, angle::SearchType::ApplicationDir));
if (EntryPointsLib())
{
sDispatch = reinterpret_cast<cl_icd_dispatch *>(
EntryPointsLib()->getSymbol("gCLIcdDispatchTable"));
if (sDispatch == nullptr)
{
std::cerr << "Error loading CL dispatch table." << std::endl;
}
}
else
{
std::cerr << "Error opening GLESv2 library." << std::endl;
}
}
return *sDispatch;
}
} // namespace cl