Commit c2fd3388 by John Plate Committed by Commit Bot

CL: Add front end object references to back end objects

Add front end object references to back end objects, which requires a significant amount of refactoring, because the back end objects have to be constructed during the construction of the front end objects, so that the references can be passed to the back end objects, which then can be passed to the front end member initialization. That would have been easier with inheritance than with PImpl. Bug: angleproject:5904 Change-Id: Ib58e6a698e76987bdd63cd8088f923424d6c622b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2897249 Commit-Queue: John Plate <jplate@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent a7ae63e4
......@@ -42,9 +42,6 @@ struct Dispatch
constexpr const cl_icd_dispatch &getDispatch() { return *mDispatch; }
protected:
bool isCompatible(void *ptr) const { return ptr == &mDispatch; }
private:
// This has to be the first member to be OpenCL ICD compatible
const cl_icd_dispatch *const mDispatch;
......
......@@ -78,21 +78,22 @@ cl_int Context::getInfo(ContextInfo name, size_t valueSize, void *value, size_t
bool Context::IsValid(const _cl_context *context)
{
const Platform::PtrList &platforms = Platform::GetPlatforms();
return std::find_if(platforms.cbegin(), platforms.cend(), [=](const Platform::Ptr &platform) {
return std::find_if(platforms.cbegin(), platforms.cend(), [=](const PlatformPtr &platform) {
return platform->hasContext(context);
}) != platforms.cend();
}
Context::Context(Platform &platform,
PropArray &&properties,
Device::RefList &&devices,
DeviceRefList &&devices,
ContextErrorCB notify,
void *userData,
bool userSync,
cl_int *errcodeRet)
: _cl_context(platform.getDispatch()),
mPlatform(platform),
mImpl(platform.createContext(devices, ErrorCallback, this, userSync, errcodeRet)),
mImpl(
platform.mImpl->createContext(*this, devices, ErrorCallback, this, userSync, errcodeRet)),
mProperties(std::move(properties)),
mDevices(std::move(devices)),
mNotify(notify),
......@@ -108,10 +109,14 @@ Context::Context(Platform &platform,
cl_int *errcodeRet)
: _cl_context(platform.getDispatch()),
mPlatform(platform),
mImpl(platform.mImpl
->createContextFromType(deviceType, ErrorCallback, this, userSync, errcodeRet)),
mImpl(platform.mImpl->createContextFromType(*this,
deviceType,
ErrorCallback,
this,
userSync,
errcodeRet)),
mProperties(std::move(properties)),
mDevices(mImpl ? platform.mapDevices(mImpl->getDevices()) : Device::RefList{}),
mDevices(mImpl ? mImpl->getDevices() : DeviceRefList{}),
mNotify(notify),
mUserData(userData)
{}
......
......@@ -21,8 +21,7 @@ namespace cl
class Context final : public _cl_context, public Object
{
public:
using Ptr = std::unique_ptr<Context>;
using PtrList = std::list<Ptr>;
using PtrList = std::list<ContextPtr>;
using RefPtr = RefPointer<Context>;
using PropArray = std::vector<cl_context_properties>;
......@@ -40,7 +39,7 @@ class Context final : public _cl_context, public Object
private:
Context(Platform &platform,
PropArray &&properties,
Device::RefList &&devices,
DeviceRefList &&devices,
ContextErrorCB notify,
void *userData,
bool userSync,
......@@ -62,7 +61,7 @@ class Context final : public _cl_context, public Object
Platform &mPlatform;
const rx::CLContextImpl::Ptr mImpl;
const PropArray mProperties;
const Device::RefList mDevices;
const DeviceRefList mDevices;
const ContextErrorCB mNotify;
void *const mUserData;
......
......@@ -273,7 +273,7 @@ cl_int Device::getInfo(DeviceInfo name, size_t valueSize, void *value, size_t *v
// Handle all mapped values
case DeviceInfo::Platform:
valPointer = &mPlatform;
valPointer = static_cast<cl_platform_id>(&mPlatform);
copyValue = &valPointer;
copySize = sizeof(valPointer);
break;
......@@ -282,8 +282,9 @@ cl_int Device::getInfo(DeviceInfo name, size_t valueSize, void *value, size_t *v
{
return CL_INVALID_VALUE;
}
copyValue = &mParent;
copySize = sizeof(mParent);
valPointer = static_cast<cl_device_id>(mParent.get());
copyValue = &valPointer;
copySize = sizeof(valPointer);
break;
case DeviceInfo::ReferenceCount:
if (mInfo.mVersion < CL_MAKE_VERSION(1, 2, 0))
......@@ -323,67 +324,49 @@ cl_int Device::getInfo(DeviceInfo name, size_t valueSize, void *value, size_t *v
cl_int Device::createSubDevices(const cl_device_partition_property *properties,
cl_uint numDevices,
cl_device_id *devices,
cl_device_id *subDevices,
cl_uint *numDevicesRet)
{
if (devices == nullptr)
if (subDevices == nullptr)
{
numDevices = 0u;
}
rx::CLDeviceImpl::PtrList ptrList;
const cl_int result = mImpl->createSubDevices(properties, numDevices, ptrList, numDevicesRet);
DevicePtrList subDeviceList;
const cl_int result =
mImpl->createSubDevices(*this, properties, numDevices, subDeviceList, numDevicesRet);
if (result == CL_SUCCESS)
{
while (!ptrList.empty())
{
rx::CLDeviceImpl::Info info = ptrList.front()->createInfo();
if (!info.isValid())
for (const DevicePtr &subDevice : subDeviceList)
{
return CL_INVALID_VALUE;
}
mSubDevices.emplace_back(
new Device(mPlatform, this, std::move(ptrList.front()), std::move(info)));
ptrList.pop_front();
*devices++ = mSubDevices.back().get();
*subDevices++ = subDevice.get();
}
mSubDevices.splice(mSubDevices.cend(), std::move(subDeviceList));
}
return result;
}
Device::PtrList Device::CreateDevices(Platform &platform, rx::CLDeviceImpl::PtrList &&implList)
DevicePtr Device::CreateDevice(Platform &platform,
DeviceRefPtr &&parent,
const CreateImplFunc &createImplFunc)
{
PtrList devices;
while (!implList.empty())
{
rx::CLDeviceImpl::Info info = implList.front()->createInfo();
if (!info.isValid())
{
return Device::PtrList{};
}
devices.emplace_back(
new Device(platform, nullptr, std::move(implList.front()), std::move(info)));
implList.pop_front();
}
return devices;
DevicePtr device(new Device(platform, std::move(parent), createImplFunc));
return device->mInfo.isValid() ? std::move(device) : DevicePtr{};
}
bool Device::IsValid(const _cl_device_id *device)
{
const Platform::PtrList &platforms = Platform::GetPlatforms();
return std::find_if(platforms.cbegin(), platforms.cend(), [=](const Platform::Ptr &platform) {
return std::find_if(platforms.cbegin(), platforms.cend(), [=](const PlatformPtr &platform) {
return platform->hasDevice(device);
}) != platforms.cend();
}
Device::Device(Platform &platform,
Device *parent,
rx::CLDeviceImpl::Ptr &&impl,
rx::CLDeviceImpl::Info &&info)
Device::Device(Platform &platform, DeviceRefPtr &&parent, const CreateImplFunc &createImplFunc)
: _cl_device_id(platform.getDispatch()),
mPlatform(platform),
mParent(parent),
mImpl(std::move(impl)),
mInfo(std::move(info))
mParent(std::move(parent)),
mImpl(createImplFunc(*this)),
mInfo(mImpl->createInfo())
{}
void Device::destroySubDevice(Device *device)
......@@ -396,7 +379,6 @@ void Device::destroySubDevice(Device *device)
if (deviceIt != mSubDevices.cend())
{
mSubDevices.erase(deviceIt);
release();
}
else
{
......
......@@ -10,24 +10,24 @@
#define LIBANGLE_CLDEVICE_H_
#include "libANGLE/CLObject.h"
#include "libANGLE/CLRefPointer.h"
#include "libANGLE/renderer/CLDeviceImpl.h"
#include <functional>
namespace cl
{
class Device final : public _cl_device_id, public Object
{
public:
using Ptr = std::unique_ptr<Device>;
using PtrList = std::list<Ptr>;
using RefPtr = RefPointer<Device>;
using RefList = std::vector<RefPtr>;
using CreateImplFunc = std::function<rx::CLDeviceImpl::Ptr(const cl::Device &)>;
~Device();
Platform &getPlatform() const noexcept;
bool isRoot() const noexcept;
rx::CLDeviceImpl &getImpl() const;
const rx::CLDeviceImpl::Info &getInfo() const;
bool hasSubDevice(const _cl_device_id *device) const;
void retain() noexcept;
......@@ -38,28 +38,27 @@ class Device final : public _cl_device_id, public Object
cl_int createSubDevices(const cl_device_partition_property *properties,
cl_uint numDevices,
cl_device_id *devices,
cl_device_id *subDevices,
cl_uint *numDevicesRet);
static PtrList CreateDevices(Platform &platform, rx::CLDeviceImpl::PtrList &&implList);
static DevicePtr CreateDevice(Platform &platform,
DeviceRefPtr &&parent,
const CreateImplFunc &createImplFunc);
static bool IsValid(const _cl_device_id *device);
static bool IsValidType(cl_device_type type);
private:
Device(Platform &platform,
Device *parent,
rx::CLDeviceImpl::Ptr &&impl,
rx::CLDeviceImpl::Info &&info);
Device(Platform &platform, DeviceRefPtr &&parent, const CreateImplFunc &createImplFunc);
void destroySubDevice(Device *device);
Platform &mPlatform;
Device *const mParent;
const DeviceRefPtr mParent;
const rx::CLDeviceImpl::Ptr mImpl;
const rx::CLDeviceImpl::Info mInfo;
PtrList mSubDevices;
DevicePtrList mSubDevices;
friend class Platform;
};
......@@ -71,12 +70,22 @@ inline Platform &Device::getPlatform() const noexcept
inline bool Device::isRoot() const noexcept
{
return mParent == nullptr;
return !mParent;
}
inline rx::CLDeviceImpl &Device::getImpl() const
{
return *mImpl;
}
inline const rx::CLDeviceImpl::Info &Device::getInfo() const
{
return mInfo;
}
inline bool Device::hasSubDevice(const _cl_device_id *device) const
{
return std::find_if(mSubDevices.cbegin(), mSubDevices.cend(), [=](const Device::Ptr &ptr) {
return std::find_if(mSubDevices.cbegin(), mSubDevices.cend(), [=](const DevicePtr &ptr) {
return ptr.get() == device || ptr->hasSubDevice(device);
}) != mSubDevices.cend();
}
......
......@@ -18,7 +18,6 @@ namespace cl
class Object
{
public:
// This class cannot be virtual as its derived classes need to have standard layout
Object() = default;
~Object()
......
......@@ -67,32 +67,6 @@ Platform::~Platform()
removeRef();
}
Device::RefList Platform::mapDevices(const rx::CLDeviceImpl::List &deviceImplList) const
{
Device::RefList devices;
for (rx::CLDeviceImpl *impl : deviceImplList)
{
auto it = mDevices.cbegin();
while (it != mDevices.cend() && (*it)->mImpl.get() != impl)
{
++it;
}
if (it != mDevices.cend())
{
devices.emplace_back(it->get());
}
else
{
ERR() << "Device not found in platform list";
}
}
if (devices.size() != deviceImplList.size())
{
devices.clear();
}
return devices;
}
cl_int Platform::getInfo(PlatformInfo name, size_t valueSize, void *value, size_t *valueSizeRet)
{
const void *copyValue = nullptr;
......@@ -177,7 +151,7 @@ cl_int Platform::getDeviceIDs(cl_device_type deviceType,
cl_uint *numDevices) const
{
cl_uint found = 0u;
for (const Device::Ptr &device : mDevices)
for (const DevicePtr &device : mDevices)
{
cl_device_type type = 0u;
if (device->getInfoULong(DeviceInfo::Type, &type) == CL_SUCCESS &&
......@@ -197,6 +171,15 @@ cl_int Platform::getDeviceIDs(cl_device_type deviceType,
return found == 0u ? CL_DEVICE_NOT_FOUND : CL_SUCCESS;
}
void Platform::CreatePlatform(const cl_icd_dispatch &dispatch, const CreateImplFunc &createImplFunc)
{
PlatformPtr platform(new Platform(dispatch, createImplFunc));
if (platform->mInfo.isValid() && !platform->mDevices.empty())
{
GetList().emplace_back(std::move(platform));
}
}
cl_int Platform::GetPlatformIDs(cl_uint num_entries,
cl_platform_id *platforms,
cl_uint *num_platforms)
......@@ -229,7 +212,7 @@ cl_context Platform::CreateContext(const cl_context_properties *properties,
bool userSync = false;
Context::PropArray propArray = ParseContextProperties(properties, platform, userSync);
ASSERT(platform != nullptr);
Device::RefList refDevices;
DeviceRefList refDevices;
while (numDevices-- != 0u)
{
refDevices.emplace_back(static_cast<Device *>(*devices++));
......@@ -267,38 +250,12 @@ cl_context Platform::CreateContextFromType(const cl_context_properties *properti
return platform->mContexts.back().get();
}
void Platform::CreatePlatform(const cl_icd_dispatch &dispatch,
rx::CLPlatformImpl::InitData &initData)
{
Ptr platform(new Platform(dispatch, initData));
if (!platform->mDevices.empty())
{
GetList().emplace_back(std::move(platform));
}
}
Platform::Platform(const cl_icd_dispatch &dispatch, rx::CLPlatformImpl::InitData &initData)
Platform::Platform(const cl_icd_dispatch &dispatch, const CreateImplFunc &createImplFunc)
: _cl_platform_id(dispatch),
mImpl(std::move(std::get<0>(initData))),
mInfo(std::move(std::get<1>(initData))),
mDevices(Device::CreateDevices(*this, std::move(std::get<2>(initData))))
{
ASSERT(isCompatible(this));
}
rx::CLContextImpl::Ptr Platform::createContext(const Device::RefList &devices,
ContextErrorCB notify,
void *userData,
bool userSync,
cl_int *errcodeRet)
{
rx::CLDeviceImpl::List deviceImplList;
for (const Device::RefPtr &device : devices)
{
deviceImplList.emplace_back(device->mImpl.get());
}
return mImpl->createContext(std::move(deviceImplList), notify, userData, userSync, errcodeRet);
}
mImpl(createImplFunc(*this)),
mInfo(mImpl->createInfo()),
mDevices(mImpl->createDevices(*this))
{}
void Platform::destroyContext(Context *context)
{
......
......@@ -15,21 +15,22 @@
#include "anglebase/no_destructor.h"
#include <functional>
namespace cl
{
class Platform final : public _cl_platform_id, public Object
{
public:
using Ptr = std::unique_ptr<Platform>;
using PtrList = std::list<Ptr>;
using PtrList = std::list<PlatformPtr>;
using CreateImplFunc = std::function<rx::CLPlatformImpl::Ptr(const cl::Platform &)>;
~Platform();
const rx::CLPlatformImpl::Info &getInfo() const;
bool hasDevice(const _cl_device_id *device) const;
const Device::PtrList &getDevices() const;
Device::RefList mapDevices(const rx::CLDeviceImpl::List &deviceImplList) const;
const DevicePtrList &getDevices() const;
bool hasContext(const _cl_context *context) const;
cl_int getInfo(PlatformInfo name, size_t valueSize, void *value, size_t *valueSizeRet);
......@@ -39,6 +40,9 @@ class Platform final : public _cl_platform_id, public Object
cl_device_id *devices,
cl_uint *numDevices) const;
static void CreatePlatform(const cl_icd_dispatch &dispatch,
const CreateImplFunc &createImplFunc);
static cl_int GetPlatformIDs(cl_uint num_entries,
cl_platform_id *platforms,
cl_uint *num_platforms);
......@@ -56,26 +60,16 @@ class Platform final : public _cl_platform_id, public Object
void *userData,
cl_int *errcodeRet);
static void CreatePlatform(const cl_icd_dispatch &dispatch,
rx::CLPlatformImpl::InitData &initData);
static const PtrList &GetPlatforms();
static Platform *GetDefault();
static Platform *CastOrDefault(cl_platform_id platform);
static bool IsValid(const _cl_platform_id *platform);
static bool IsValidOrDefault(const _cl_platform_id *platform);
static constexpr const char *GetVendor();
private:
Platform(const cl_icd_dispatch &dispatch, rx::CLPlatformImpl::InitData &initData);
rx::CLContextImpl::Ptr createContext(const Device::RefList &devices,
ContextErrorCB notify,
void *userData,
bool userSync,
cl_int *errcodeRet);
Platform(const cl_icd_dispatch &dispatch, const CreateImplFunc &createImplFunc);
void destroyContext(Context *context);
......@@ -83,7 +77,7 @@ class Platform final : public _cl_platform_id, public Object
const rx::CLPlatformImpl::Ptr mImpl;
const rx::CLPlatformImpl::Info mInfo;
const Device::PtrList mDevices;
const DevicePtrList mDevices;
Context::PtrList mContexts;
......@@ -93,21 +87,26 @@ class Platform final : public _cl_platform_id, public Object
friend class Context;
};
inline const rx::CLPlatformImpl::Info &Platform::getInfo() const
{
return mInfo;
}
inline bool Platform::hasDevice(const _cl_device_id *device) const
{
return std::find_if(mDevices.cbegin(), mDevices.cend(), [=](const Device::Ptr &ptr) {
return std::find_if(mDevices.cbegin(), mDevices.cend(), [=](const DevicePtr &ptr) {
return ptr.get() == device || ptr->hasSubDevice(device);
}) != mDevices.cend();
}
inline const Device::PtrList &Platform::getDevices() const
inline const DevicePtrList &Platform::getDevices() const
{
return mDevices;
}
inline bool Platform::hasContext(const _cl_context *context) const
{
return std::find_if(mContexts.cbegin(), mContexts.cend(), [=](const Context::Ptr &ptr) {
return std::find_if(mContexts.cbegin(), mContexts.cend(), [=](const ContextPtr &ptr) {
return ptr.get() == context;
}) != mContexts.cend();
}
......@@ -136,8 +135,9 @@ inline Platform *Platform::CastOrDefault(cl_platform_id platform)
inline bool Platform::IsValid(const _cl_platform_id *platform)
{
const PtrList &platforms = GetPlatforms();
return std::find_if(platforms.cbegin(), platforms.cend(),
[=](const Ptr &ptr) { return ptr.get() == platform; }) != platforms.cend();
return std::find_if(platforms.cbegin(), platforms.cend(), [=](const PlatformPtr &ptr) {
return ptr.get() == platform;
}) != platforms.cend();
}
// Our CL implementation defines that a nullptr value chooses the platform that we provide as
......
......@@ -8,9 +8,6 @@
#ifndef LIBANGLE_CLREFPOINTER_H_
#define LIBANGLE_CLREFPOINTER_H_
#include "libANGLE/CLtypes.h"
#include "libANGLE/Debug.h"
#include <algorithm>
namespace cl
......
......@@ -8,7 +8,7 @@
#ifndef LIBANGLE_CLTYPES_H_
#define LIBANGLE_CLTYPES_H_
#include "angle_cl.h"
#include "libANGLE/CLRefPointer.h"
#include "common/PackedCLEnums_autogen.h"
......@@ -22,6 +22,7 @@
namespace cl
{
class CommandQueue;
class Context;
class Device;
......@@ -32,6 +33,22 @@ class Object;
class Platform;
class Program;
class Sampler;
using CommandQueuePtr = std::unique_ptr<CommandQueue>;
using ContextPtr = std::unique_ptr<Context>;
using DevicePtr = std::unique_ptr<Device>;
using EventPtr = std::unique_ptr<Event>;
using KernelPtr = std::unique_ptr<Kernel>;
using MemoryPtr = std::unique_ptr<Memory>;
using ObjectPtr = std::unique_ptr<Object>;
using PlatformPtr = std::unique_ptr<Platform>;
using ProgramPtr = std::unique_ptr<Program>;
using SamplerPtr = std::unique_ptr<Sampler>;
using DevicePtrList = std::list<DevicePtr>;
using DeviceRefPtr = RefPointer<Device>;
using DeviceRefList = std::vector<DeviceRefPtr>;
} // namespace cl
#endif // LIBANGLE_CLTYPES_H_
......@@ -7,28 +7,11 @@
#include "libANGLE/renderer/CLContextImpl.h"
#include "libANGLE/renderer/CLPlatformImpl.h"
#include "libANGLE/Debug.h"
namespace rx
{
CLContextImpl::CLContextImpl(CLPlatformImpl &platform, CLDeviceImpl::List &&devices)
: mPlatform(platform), mDevices(std::move(devices))
{}
CLContextImpl::CLContextImpl(const cl::Context &context) : mContext(context) {}
CLContextImpl::~CLContextImpl()
{
auto it = std::find(mPlatform.mContexts.cbegin(), mPlatform.mContexts.cend(), this);
if (it != mPlatform.mContexts.cend())
{
mPlatform.mContexts.erase(it);
}
else
{
ERR() << "Context not in platform's list";
}
}
CLContextImpl::~CLContextImpl() = default;
} // namespace rx
......@@ -17,29 +17,16 @@ class CLContextImpl : angle::NonCopyable
{
public:
using Ptr = std::unique_ptr<CLContextImpl>;
using List = std::list<CLContextImpl *>;
CLContextImpl(CLPlatformImpl &platform, CLDeviceImpl::List &&devices);
CLContextImpl(const cl::Context &context);
virtual ~CLContextImpl();
template <typename T>
T &getPlatform() const
{
return static_cast<T &>(mPlatform);
}
const CLDeviceImpl::List &getDevices() const;
virtual cl::DeviceRefList getDevices() const = 0;
protected:
CLPlatformImpl &mPlatform;
const CLDeviceImpl::List mDevices;
const cl::Context &mContext;
};
inline const CLDeviceImpl::List &CLContextImpl::getDevices() const
{
return mDevices;
}
} // namespace rx
#endif // LIBANGLE_RENDERER_CLCONTEXTIMPL_H_
......@@ -20,24 +20,8 @@ CLDeviceImpl::Info::Info(Info &&) = default;
CLDeviceImpl::Info &CLDeviceImpl::Info::operator=(Info &&) = default;
CLDeviceImpl::CLDeviceImpl(CLPlatformImpl &platform, CLDeviceImpl *parent)
: mPlatform(platform), mParent(parent)
{}
CLDeviceImpl::CLDeviceImpl(const cl::Device &device) : mDevice(device) {}
CLDeviceImpl::~CLDeviceImpl()
{
if (mParent != nullptr)
{
auto it = std::find(mParent->mSubDevices.cbegin(), mParent->mSubDevices.cend(), this);
if (it != mParent->mSubDevices.cend())
{
mParent->mSubDevices.erase(it);
}
else
{
ERR() << "Sub-device not in parent's list";
}
}
}
CLDeviceImpl::~CLDeviceImpl() = default;
} // namespace rx
......@@ -16,6 +16,8 @@ namespace rx
class CLDeviceImpl : angle::NonCopyable
{
public:
using Ptr = std::unique_ptr<CLDeviceImpl>;
struct Info
{
Info();
......@@ -41,19 +43,9 @@ class CLDeviceImpl : angle::NonCopyable
std::vector<cl_device_partition_property> mPartitionType;
};
using Ptr = std::unique_ptr<CLDeviceImpl>;
using PtrList = std::list<Ptr>;
using List = std::list<CLDeviceImpl *>;
CLDeviceImpl(CLPlatformImpl &platform, CLDeviceImpl *parent);
CLDeviceImpl(const cl::Device &device);
virtual ~CLDeviceImpl();
template <typename T>
T &getPlatform() const
{
return static_cast<T &>(mPlatform);
}
virtual Info createInfo() const = 0;
virtual cl_int getInfoUInt(cl::DeviceInfo name, cl_uint *value) const = 0;
......@@ -62,16 +54,14 @@ class CLDeviceImpl : angle::NonCopyable
virtual cl_int getInfoStringLength(cl::DeviceInfo name, size_t *value) const = 0;
virtual cl_int getInfoString(cl::DeviceInfo name, size_t size, char *value) const = 0;
virtual cl_int createSubDevices(const cl_device_partition_property *properties,
virtual cl_int createSubDevices(cl::Device &device,
const cl_device_partition_property *properties,
cl_uint numDevices,
PtrList &implList,
cl::DevicePtrList &subDeviceList,
cl_uint *numDevicesRet) = 0;
protected:
CLPlatformImpl &mPlatform;
CLDeviceImpl *const mParent;
List mSubDevices;
const cl::Device &mDevice;
};
} // namespace rx
......
......@@ -18,7 +18,7 @@ CLPlatformImpl::Info::Info(Info &&) = default;
CLPlatformImpl::Info &CLPlatformImpl::Info::operator=(Info &&) = default;
CLPlatformImpl::CLPlatformImpl(CLDeviceImpl::List &&devices) : mDevices(std::move(devices)) {}
CLPlatformImpl::CLPlatformImpl(const cl::Platform &platform) : mPlatform(platform) {}
CLPlatformImpl::~CLPlatformImpl() = default;
......
......@@ -19,6 +19,8 @@ namespace rx
class CLPlatformImpl : angle::NonCopyable
{
public:
using Ptr = std::unique_ptr<CLPlatformImpl>;
struct Info
{
Info();
......@@ -41,40 +43,31 @@ class CLPlatformImpl : angle::NonCopyable
cl_ulong mHostTimerRes = 0u;
};
using Ptr = std::unique_ptr<CLPlatformImpl>;
using InitData = std::tuple<Ptr, Info, CLDeviceImpl::PtrList>;
using InitList = std::list<InitData>;
explicit CLPlatformImpl(CLDeviceImpl::List &&devices);
explicit CLPlatformImpl(const cl::Platform &platform);
virtual ~CLPlatformImpl();
const CLDeviceImpl::List &getDevices() const;
// For initialization only
virtual Info createInfo() const = 0;
virtual cl::DevicePtrList createDevices(cl::Platform &platform) const = 0;
virtual CLContextImpl::Ptr createContext(CLDeviceImpl::List &&devices,
virtual CLContextImpl::Ptr createContext(const cl::Context &context,
const cl::DeviceRefList &devices,
cl::ContextErrorCB notify,
void *userData,
bool userSync,
cl_int *errcodeRet) = 0;
virtual CLContextImpl::Ptr createContextFromType(cl_device_type deviceType,
virtual CLContextImpl::Ptr createContextFromType(const cl::Context &context,
cl_device_type deviceType,
cl::ContextErrorCB notify,
void *userData,
bool userSync,
cl_int *errcodeRet) = 0;
protected:
const CLDeviceImpl::List mDevices;
CLContextImpl::List mContexts;
friend class CLContextImpl;
const cl::Platform &mPlatform;
};
inline const CLDeviceImpl::List &CLPlatformImpl::getDevices() const
{
return mDevices;
}
} // namespace rx
#endif // LIBANGLE_RENDERER_CLPLATFORMIMPL_H_
......@@ -7,23 +7,66 @@
#include "libANGLE/renderer/cl/CLContextCL.h"
#include "libANGLE/renderer/cl/CLPlatformCL.h"
#include "libANGLE/renderer/cl/CLDeviceCL.h"
#include "libANGLE/CLContext.h"
#include "libANGLE/CLDevice.h"
#include "libANGLE/CLPlatform.h"
#include "libANGLE/Debug.h"
namespace rx
{
CLContextCL::CLContextCL(CLPlatformCL &platform, CLDeviceImpl::List &&devices, cl_context context)
: CLContextImpl(platform, std::move(devices)), mContext(context)
CLContextCL::CLContextCL(const cl::Context &context, cl_context native)
: CLContextImpl(context), mNative(native)
{}
CLContextCL::~CLContextCL()
{
if (mContext->getDispatch().clReleaseContext(mContext) != CL_SUCCESS)
if (mNative->getDispatch().clReleaseContext(mNative) != CL_SUCCESS)
{
ERR() << "Error while releasing CL context";
}
}
cl::DeviceRefList CLContextCL::getDevices() const
{
size_t valueSize = 0u;
cl_int result = mNative->getDispatch().clGetContextInfo(mNative, CL_CONTEXT_DEVICES, 0u,
nullptr, &valueSize);
if (result == CL_SUCCESS && (valueSize % sizeof(cl_device_id)) == 0u)
{
std::vector<cl_device_id> nativeDevices(valueSize / sizeof(cl_device_id), nullptr);
result = mNative->getDispatch().clGetContextInfo(mNative, CL_CONTEXT_DEVICES, valueSize,
nativeDevices.data(), nullptr);
if (result == CL_SUCCESS)
{
const cl::DevicePtrList &platformDevices = mContext.getPlatform().getDevices();
cl::DeviceRefList devices;
for (cl_device_id nativeDevice : nativeDevices)
{
auto it = platformDevices.cbegin();
while (it != platformDevices.cend() &&
static_cast<CLDeviceCL &>((*it)->getImpl()).getNative() != nativeDevice)
{
++it;
}
if (it != platformDevices.cend())
{
devices.emplace_back(it->get());
}
else
{
ERR() << "Device not found in platform list";
return cl::DeviceRefList{};
}
}
return devices;
}
}
ERR() << "Error fetching devices from CL context, code: " << result;
return cl::DeviceRefList{};
}
} // namespace rx
......@@ -18,11 +18,13 @@ namespace rx
class CLContextCL : public CLContextImpl
{
public:
CLContextCL(CLPlatformCL &platform, CLDeviceImpl::List &&devices, cl_context context);
CLContextCL(const cl::Context &context, cl_context native);
~CLContextCL() override;
cl::DeviceRefList getDevices() const override;
private:
const cl_context mContext;
const cl_context mNative;
};
} // namespace rx
......
......@@ -10,6 +10,7 @@
#include "libANGLE/renderer/cl/CLPlatformCL.h"
#include "libANGLE/renderer/cl/cl_util.h"
#include "libANGLE/CLDevice.h"
#include "libANGLE/Debug.h"
namespace rx
......@@ -45,8 +46,7 @@ bool GetDeviceInfo(cl_device_id device, cl::DeviceInfo name, std::vector<T> &vec
CLDeviceCL::~CLDeviceCL()
{
if (mVersion >= CL_MAKE_VERSION(1, 2, 0) &&
mDevice->getDispatch().clReleaseDevice(mDevice) != CL_SUCCESS)
if (!mDevice.isRoot() && mNative->getDispatch().clReleaseDevice(mNative) != CL_SUCCESS)
{
ERR() << "Error while releasing CL device";
}
......@@ -55,17 +55,26 @@ CLDeviceCL::~CLDeviceCL()
CLDeviceImpl::Info CLDeviceCL::createInfo() const
{
Info info;
info.mVersion = mVersion;
std::vector<char> valString;
if (!GetDeviceInfo(mDevice, cl::DeviceInfo::Extensions, valString))
if (!GetDeviceInfo(mNative, cl::DeviceInfo::Version, valString))
{
return Info{};
}
info.mVersion = ExtractCLVersion(valString.data());
if (info.mVersion == 0u)
{
return Info{};
}
if (!GetDeviceInfo(mNative, cl::DeviceInfo::Extensions, valString))
{
return Info{};
}
info.mExtensions.assign(valString.data());
RemoveUnsupportedCLExtensions(info.mExtensions);
if (!GetDeviceInfo(mDevice, cl::DeviceInfo::MaxWorkItemSizes, info.mMaxWorkItemSizes))
if (!GetDeviceInfo(mNative, cl::DeviceInfo::MaxWorkItemSizes, info.mMaxWorkItemSizes))
{
return Info{};
}
......@@ -80,21 +89,21 @@ CLDeviceImpl::Info CLDeviceCL::createInfo() const
return Info{};
}
if (mVersion >= CL_MAKE_VERSION(1, 2, 0) &&
(!GetDeviceInfo(mDevice, cl::DeviceInfo::PartitionProperties, info.mPartitionProperties) ||
!GetDeviceInfo(mDevice, cl::DeviceInfo::PartitionType, info.mPartitionType)))
if (info.mVersion >= CL_MAKE_VERSION(1, 2, 0) &&
(!GetDeviceInfo(mNative, cl::DeviceInfo::PartitionProperties, info.mPartitionProperties) ||
!GetDeviceInfo(mNative, cl::DeviceInfo::PartitionType, info.mPartitionType)))
{
return Info{};
}
if (mVersion >= CL_MAKE_VERSION(3, 0, 0) &&
(!GetDeviceInfo(mDevice, cl::DeviceInfo::ILsWithVersion, info.mILsWithVersion) ||
!GetDeviceInfo(mDevice, cl::DeviceInfo::BuiltInKernelsWithVersion,
if (info.mVersion >= CL_MAKE_VERSION(3, 0, 0) &&
(!GetDeviceInfo(mNative, cl::DeviceInfo::ILsWithVersion, info.mILsWithVersion) ||
!GetDeviceInfo(mNative, cl::DeviceInfo::BuiltInKernelsWithVersion,
info.mBuiltInKernelsWithVersion) ||
!GetDeviceInfo(mDevice, cl::DeviceInfo::OpenCL_C_AllVersions,
!GetDeviceInfo(mNative, cl::DeviceInfo::OpenCL_C_AllVersions,
info.mOpenCL_C_AllVersions) ||
!GetDeviceInfo(mDevice, cl::DeviceInfo::OpenCL_C_Features, info.mOpenCL_C_Features) ||
!GetDeviceInfo(mDevice, cl::DeviceInfo::ExtensionsWithVersion,
!GetDeviceInfo(mNative, cl::DeviceInfo::OpenCL_C_Features, info.mOpenCL_C_Features) ||
!GetDeviceInfo(mNative, cl::DeviceInfo::ExtensionsWithVersion,
info.mExtensionsWithVersion)))
{
return Info{};
......@@ -106,93 +115,69 @@ CLDeviceImpl::Info CLDeviceCL::createInfo() const
cl_int CLDeviceCL::getInfoUInt(cl::DeviceInfo name, cl_uint *value) const
{
return mDevice->getDispatch().clGetDeviceInfo(mDevice, cl::ToCLenum(name), sizeof(*value),
return mNative->getDispatch().clGetDeviceInfo(mNative, cl::ToCLenum(name), sizeof(*value),
value, nullptr);
}
cl_int CLDeviceCL::getInfoULong(cl::DeviceInfo name, cl_ulong *value) const
{
return mDevice->getDispatch().clGetDeviceInfo(mDevice, cl::ToCLenum(name), sizeof(*value),
return mNative->getDispatch().clGetDeviceInfo(mNative, cl::ToCLenum(name), sizeof(*value),
value, nullptr);
}
cl_int CLDeviceCL::getInfoSizeT(cl::DeviceInfo name, size_t *value) const
{
return mDevice->getDispatch().clGetDeviceInfo(mDevice, cl::ToCLenum(name), sizeof(*value),
return mNative->getDispatch().clGetDeviceInfo(mNative, cl::ToCLenum(name), sizeof(*value),
value, nullptr);
}
cl_int CLDeviceCL::getInfoStringLength(cl::DeviceInfo name, size_t *value) const
{
return mDevice->getDispatch().clGetDeviceInfo(mDevice, cl::ToCLenum(name), 0u, nullptr, value);
return mNative->getDispatch().clGetDeviceInfo(mNative, cl::ToCLenum(name), 0u, nullptr, value);
}
cl_int CLDeviceCL::getInfoString(cl::DeviceInfo name, size_t size, char *value) const
{
return mDevice->getDispatch().clGetDeviceInfo(mDevice, cl::ToCLenum(name), size, value,
return mNative->getDispatch().clGetDeviceInfo(mNative, cl::ToCLenum(name), size, value,
nullptr);
}
cl_int CLDeviceCL::createSubDevices(const cl_device_partition_property *properties,
cl_int CLDeviceCL::createSubDevices(cl::Device &device,
const cl_device_partition_property *properties,
cl_uint numDevices,
PtrList &implList,
cl::DevicePtrList &subDeviceList,
cl_uint *numDevicesRet)
{
if (mVersion < CL_MAKE_VERSION(1, 2, 0))
{
return CL_INVALID_VALUE;
}
if (numDevices == 0u)
{
return mDevice->getDispatch().clCreateSubDevices(mDevice, properties, 0u, nullptr,
return mNative->getDispatch().clCreateSubDevices(mNative, properties, 0u, nullptr,
numDevicesRet);
}
std::vector<cl_device_id> devices(numDevices, nullptr);
const cl_int result = mDevice->getDispatch().clCreateSubDevices(mDevice, properties, numDevices,
devices.data(), nullptr);
std::vector<cl_device_id> nativeSubDevices(numDevices, nullptr);
const cl_int result = mNative->getDispatch().clCreateSubDevices(
mNative, properties, numDevices, nativeSubDevices.data(), nullptr);
if (result == CL_SUCCESS)
{
for (cl_device_id device : devices)
for (cl_device_id nativeSubDevice : nativeSubDevices)
{
implList.emplace_back(CLDeviceCL::Create(getPlatform<CLPlatformCL>(), this, device));
if (!implList.back())
const cl::Device::CreateImplFunc createImplFunc = [&](const cl::Device &device) {
return Ptr(new CLDeviceCL(device, nativeSubDevice));
};
subDeviceList.emplace_back(cl::Device::CreateDevice(
device.getPlatform(), cl::DeviceRefPtr(&device), createImplFunc));
if (!subDeviceList.back())
{
implList.clear();
subDeviceList.clear();
return CL_INVALID_VALUE;
}
mSubDevices.emplace_back(implList.back().get());
}
}
return result;
}
CLDeviceCL *CLDeviceCL::Create(CLPlatformCL &platform, CLDeviceCL *parent, cl_device_id device)
{
size_t valueSize = 0u;
if (device->getDispatch().clGetDeviceInfo(device, CL_DEVICE_VERSION, 0u, nullptr, &valueSize) ==
CL_SUCCESS)
{
std::vector<char> valString(valueSize, '\0');
if (device->getDispatch().clGetDeviceInfo(device, CL_DEVICE_VERSION, valueSize,
valString.data(), nullptr) == CL_SUCCESS)
{
const cl_version version = ExtractCLVersion(valString.data());
if (version != 0u)
{
return new CLDeviceCL(platform, parent, device, version);
}
}
}
ERR() << "Failed to query version for device";
return nullptr;
}
CLDeviceCL::CLDeviceCL(CLPlatformCL &platform,
CLDeviceCL *parent,
cl_device_id device,
cl_version version)
: CLDeviceImpl(platform, parent), mDevice(device), mVersion(version)
CLDeviceCL::CLDeviceCL(const cl::Device &device, cl_device_id native)
: CLDeviceImpl(device), mNative(native)
{}
} // namespace rx
......@@ -30,23 +30,23 @@ class CLDeviceCL : public CLDeviceImpl
cl_int getInfoStringLength(cl::DeviceInfo name, size_t *value) const override;
cl_int getInfoString(cl::DeviceInfo name, size_t size, char *value) const override;
cl_int createSubDevices(const cl_device_partition_property *properties,
cl_int createSubDevices(cl::Device &device,
const cl_device_partition_property *properties,
cl_uint numDevices,
PtrList &implList,
cl::DevicePtrList &subDeviceList,
cl_uint *numDevicesRet) override;
static CLDeviceCL *Create(CLPlatformCL &platform, CLDeviceCL *parent, cl_device_id device);
private:
CLDeviceCL(CLPlatformCL &platform, CLDeviceCL *parent, cl_device_id device, cl_version version);
CLDeviceCL(const cl::Device &device, cl_device_id native);
const cl_device_id mNative;
const cl_device_id mDevice;
const cl_version mVersion;
friend class CLPlatformCL;
};
inline cl_device_id CLDeviceCL::getNative()
{
return mDevice;
return mNative;
}
} // namespace rx
......
......@@ -20,34 +20,36 @@ class CLPlatformCL : public CLPlatformImpl
cl_platform_id getNative();
CLContextImpl::Ptr createContext(CLDeviceImpl::List &&deviceImplList,
Info createInfo() const override;
cl::DevicePtrList createDevices(cl::Platform &platform) const override;
CLContextImpl::Ptr createContext(const cl::Context &context,
const cl::DeviceRefList &devices,
cl::ContextErrorCB notify,
void *userData,
bool userSync,
cl_int *errcodeRet) override;
CLContextImpl::Ptr createContextFromType(cl_device_type deviceType,
CLContextImpl::Ptr createContextFromType(const cl::Context &context,
cl_device_type deviceType,
cl::ContextErrorCB notify,
void *userData,
bool userSync,
cl_int *errcodeRet) override;
static InitList GetPlatforms(bool isIcd);
static void Initialize(const cl_icd_dispatch &dispatch, bool isIcd);
private:
CLPlatformCL(cl_platform_id platform, cl_version version, CLDeviceImpl::PtrList &devices);
static Info GetInfo(cl_platform_id platform);
CLPlatformCL(const cl::Platform &platform, cl_platform_id native);
const cl_platform_id mPlatform;
const cl_version mVersion;
const cl_platform_id mNative;
friend class CLContextCL;
};
inline cl_platform_id CLPlatformCL::getNative()
{
return mPlatform;
return mNative;
}
} // namespace rx
......
......@@ -7,14 +7,10 @@
#include "libANGLE/renderer/vulkan/CLContextVk.h"
#include "libANGLE/renderer/vulkan/CLPlatformVk.h"
namespace rx
{
CLContextVk::CLContextVk(CLPlatformVk &platform, CLDeviceImpl::List &&devices)
: CLContextImpl(platform, std::move(devices))
{}
CLContextVk::CLContextVk(const cl::Context &context) : CLContextImpl(context) {}
CLContextVk::~CLContextVk() = default;
......
......@@ -18,7 +18,7 @@ namespace rx
class CLContextVk : public CLContextImpl
{
public:
CLContextVk(CLPlatformVk &platform, CLDeviceImpl::List &&devices);
CLContextVk(const cl::Context &context);
~CLContextVk() override;
};
......
......@@ -12,8 +12,7 @@
namespace rx
{
CLDeviceVk::CLDeviceVk(CLPlatformVk &platform, CLDeviceVk *parent) : CLDeviceImpl(platform, parent)
{}
CLDeviceVk::CLDeviceVk(const cl::Device &device) : CLDeviceImpl(device) {}
CLDeviceVk::~CLDeviceVk() = default;
......@@ -48,9 +47,10 @@ cl_int CLDeviceVk::getInfoString(cl::DeviceInfo name, size_t size, char *value)
return CL_INVALID_VALUE;
}
cl_int CLDeviceVk::createSubDevices(const cl_device_partition_property *properties,
cl_int CLDeviceVk::createSubDevices(cl::Device &device,
const cl_device_partition_property *properties,
cl_uint numDevices,
PtrList &deviceImplList,
cl::DevicePtrList &subDeviceList,
cl_uint *numDevicesRet)
{
return CL_INVALID_VALUE;
......
......@@ -18,7 +18,7 @@ namespace rx
class CLDeviceVk : public CLDeviceImpl
{
public:
CLDeviceVk(CLPlatformVk &platform, CLDeviceVk *parent);
explicit CLDeviceVk(const cl::Device &device);
~CLDeviceVk() override;
Info createInfo() const override;
......@@ -29,9 +29,10 @@ class CLDeviceVk : public CLDeviceImpl
cl_int getInfoStringLength(cl::DeviceInfo name, size_t *value) const override;
cl_int getInfoString(cl::DeviceInfo name, size_t size, char *value) const override;
cl_int createSubDevices(const cl_device_partition_property *properties,
cl_int createSubDevices(cl::Device &device,
const cl_device_partition_property *properties,
cl_uint numDevices,
PtrList &deviceImplList,
cl::DevicePtrList &subDeviceList,
cl_uint *numDevicesRet) override;
};
......
......@@ -9,6 +9,8 @@
#include "libANGLE/renderer/vulkan/CLDeviceVk.h"
#include "libANGLE/CLPlatform.h"
#include "anglebase/no_destructor.h"
#include "common/angle_version.h"
......@@ -17,6 +19,7 @@ namespace rx
namespace
{
std::string CreateExtensionString(const NameVersionVector &extList)
{
std::string extensions;
......@@ -32,17 +35,43 @@ std::string CreateExtensionString(const NameVersionVector &extList)
return extensions;
}
CLDeviceImpl::List CreateDevices(CLPlatformVk &platform, CLDeviceImpl::PtrList &implList)
{
implList.emplace_back(new CLDeviceVk(platform, nullptr));
return CLDeviceImpl::List(1u, implList.back().get());
}
} // namespace
CLPlatformVk::~CLPlatformVk() = default;
CLContextImpl::Ptr CLPlatformVk::createContext(CLDeviceImpl::List &&deviceImplList,
CLPlatformImpl::Info CLPlatformVk::createInfo() const
{
NameVersionVector extList = {
cl_name_version{CL_MAKE_VERSION(1, 0, 0), "cl_khr_icd"},
cl_name_version{CL_MAKE_VERSION(1, 0, 0), "cl_khr_extended_versioning"}};
Info info;
info.mProfile.assign("FULL_PROFILE");
info.mVersionStr.assign(GetVersionString());
info.mVersion = GetVersion();
info.mName.assign("ANGLE Vulkan");
info.mExtensions.assign(CreateExtensionString(extList));
info.mExtensionsWithVersion = std::move(extList);
info.mHostTimerRes = 0u;
return info;
}
cl::DevicePtrList CLPlatformVk::createDevices(cl::Platform &platform) const
{
cl::DevicePtrList devices;
const cl::Device::CreateImplFunc createImplFunc = [](const cl::Device &device) {
return CLDeviceVk::Ptr(new CLDeviceVk(device));
};
devices.emplace_back(cl::Device::CreateDevice(platform, nullptr, createImplFunc));
if (!devices.back())
{
devices.clear();
}
return devices;
}
CLContextImpl::Ptr CLPlatformVk::createContext(const cl::Context &context,
const cl::DeviceRefList &devices,
cl::ContextErrorCB notify,
void *userData,
bool userSync,
......@@ -52,7 +81,8 @@ CLContextImpl::Ptr CLPlatformVk::createContext(CLDeviceImpl::List &&deviceImplLi
return contextImpl;
}
CLContextImpl::Ptr CLPlatformVk::createContextFromType(cl_device_type deviceType,
CLContextImpl::Ptr CLPlatformVk::createContextFromType(const cl::Context &context,
cl_device_type deviceType,
cl::ContextErrorCB notify,
void *userData,
bool userSync,
......@@ -62,32 +92,12 @@ CLContextImpl::Ptr CLPlatformVk::createContextFromType(cl_device_type deviceType
return contextImpl;
}
CLPlatformVk::InitList CLPlatformVk::GetPlatforms()
void CLPlatformVk::Initialize(const cl_icd_dispatch &dispatch)
{
NameVersionVector extList = {
cl_name_version{CL_MAKE_VERSION(1, 0, 0), "cl_khr_icd"},
cl_name_version{CL_MAKE_VERSION(1, 0, 0), "cl_khr_extended_versioning"}};
Info info;
info.mProfile.assign("FULL_PROFILE");
info.mVersionStr.assign(GetVersionString());
info.mVersion = GetVersion();
info.mName.assign("ANGLE Vulkan");
info.mExtensions.assign(CreateExtensionString(extList));
info.mExtensionsWithVersion = std::move(extList);
info.mHostTimerRes = 0u;
InitList initList;
if (info.isValid())
{
CLDeviceImpl::PtrList devices;
Ptr platform(new CLPlatformVk(devices));
if (!devices.empty())
{
initList.emplace_back(std::move(platform), std::move(info), std::move(devices));
}
}
return initList;
const cl::Platform::CreateImplFunc createImplFunc = [](const cl::Platform &platform) {
return Ptr(new CLPlatformVk(platform));
};
cl::Platform::CreatePlatform(dispatch, createImplFunc);
}
const std::string &CLPlatformVk::GetVersionString()
......@@ -98,8 +108,6 @@ const std::string &CLPlatformVk::GetVersionString()
return *sVersion;
}
CLPlatformVk::CLPlatformVk(CLDeviceImpl::PtrList &devices)
: CLPlatformImpl(CreateDevices(*this, devices))
{}
CLPlatformVk::CLPlatformVk(const cl::Platform &platform) : CLPlatformImpl(platform) {}
} // namespace rx
......@@ -10,8 +10,6 @@
#include "libANGLE/renderer/CLPlatformImpl.h"
#include <string>
namespace rx
{
......@@ -20,24 +18,30 @@ class CLPlatformVk : public CLPlatformImpl
public:
~CLPlatformVk() override;
CLContextImpl::Ptr createContext(CLDeviceImpl::List &&deviceImplList,
Info createInfo() const override;
cl::DevicePtrList createDevices(cl::Platform &platform) const override;
CLContextImpl::Ptr createContext(const cl::Context &context,
const cl::DeviceRefList &devices,
cl::ContextErrorCB notify,
void *userData,
bool userSync,
cl_int *errcodeRet) override;
CLContextImpl::Ptr createContextFromType(cl_device_type deviceType,
CLContextImpl::Ptr createContextFromType(const cl::Context &context,
cl_device_type deviceType,
cl::ContextErrorCB notify,
void *userData,
bool userSync,
cl_int *errcodeRet) override;
static InitList GetPlatforms();
static void Initialize(const cl_icd_dispatch &dispatch);
static constexpr cl_version GetVersion();
static const std::string &GetVersionString();
private:
explicit CLPlatformVk(CLDeviceImpl::PtrList &devices);
explicit CLPlatformVk(const cl::Platform &platform);
};
constexpr cl_version CLPlatformVk::GetVersion()
......
......@@ -9,8 +9,6 @@
#include "libGLESv2/cl_dispatch_table.h"
#include "libANGLE/CLPlatform.h"
#ifdef ANGLE_ENABLE_CL_PASSTHROUGH
# include "libANGLE/renderer/cl/CLPlatformCL.h"
#endif
......@@ -31,21 +29,11 @@ void InitBackEnds(bool isIcd)
initialized = true;
#ifdef ANGLE_ENABLE_CL_PASSTHROUGH
rx::CLPlatformImpl::InitList initListCL = rx::CLPlatformCL::GetPlatforms(isIcd);
while (!initListCL.empty())
{
Platform::CreatePlatform(gCLIcdDispatchTable, initListCL.front());
initListCL.pop_front();
}
rx::CLPlatformCL::Initialize(gCLIcdDispatchTable, isIcd);
#endif
#ifdef ANGLE_ENABLE_VULKAN
rx::CLPlatformImpl::InitList initListVk = rx::CLPlatformVk::GetPlatforms();
while (!initListVk.empty())
{
Platform::CreatePlatform(gCLIcdDispatchTable, initListVk.front());
initListVk.pop_front();
}
rx::CLPlatformVk::Initialize(gCLIcdDispatchTable);
#endif
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment