Hash :
2d1bb3e1
Author :
Date :
2024-04-15T00:58:07
CL: Replace Spinlock with angle::SimpleMutex Bug: angleproject:8667 Change-Id: I9b53da920ea743d77c76793522cef826ecc62813 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5446559 Reviewed-by: Austin Annestrand <a.annestrand@samsung.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
//
// 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.
//
// CLDevice.h: Defines the cl::Device class, which provides information about OpenCL device
// configurations.
#ifndef LIBANGLE_CLDEVICE_H_
#define LIBANGLE_CLDEVICE_H_
#include "libANGLE/CLObject.h"
#include "libANGLE/renderer/CLDeviceImpl.h"
#include "common/SynchronizedValue.h"
#include <functional>
namespace cl
{
class Device final : public _cl_device_id, public Object
{
public:
// Front end entry functions, only called from OpenCL entry points
angle::Result getInfo(DeviceInfo name,
size_t valueSize,
void *value,
size_t *valueSizeRet) const;
angle::Result createSubDevices(const cl_device_partition_property *properties,
cl_uint numDevices,
cl_device_id *subDevices,
cl_uint *numDevicesRet);
public:
~Device() override;
Platform &getPlatform() noexcept;
const Platform &getPlatform() const noexcept;
bool isRoot() const noexcept;
const rx::CLDeviceImpl::Info &getInfo() const;
cl_version getVersion() const;
bool isVersionOrNewer(cl_uint major, cl_uint minor) const;
template <typename T = rx::CLDeviceImpl>
T &getImpl() const;
bool supportsBuiltInKernel(const std::string &name) const;
bool supportsNativeImageDimensions(const cl_image_desc &desc) const;
bool supportsImageDimensions(const ImageDescriptor &desc) const;
static bool IsValidType(DeviceType type);
private:
Device(Platform &platform,
Device *parent,
DeviceType type,
const rx::CLDeviceImpl::CreateFunc &createFunc);
Platform &mPlatform;
const DevicePtr mParent;
const rx::CLDeviceImpl::Ptr mImpl;
const rx::CLDeviceImpl::Info mInfo;
angle::SynchronizedValue<CommandQueue *> mDefaultCommandQueue = nullptr;
friend class CommandQueue;
friend class Platform;
};
inline Platform &Device::getPlatform() noexcept
{
return mPlatform;
}
inline const Platform &Device::getPlatform() const noexcept
{
return mPlatform;
}
inline bool Device::isRoot() const noexcept
{
return mParent == nullptr;
}
inline const rx::CLDeviceImpl::Info &Device::getInfo() const
{
return mInfo;
}
inline cl_version Device::getVersion() const
{
return mInfo.version;
}
inline bool Device::isVersionOrNewer(cl_uint major, cl_uint minor) const
{
return mInfo.version >= CL_MAKE_VERSION(major, minor, 0u);
}
template <typename T>
inline T &Device::getImpl() const
{
return static_cast<T &>(*mImpl);
}
inline bool Device::IsValidType(DeviceType type)
{
return type.get() <= CL_DEVICE_TYPE_CUSTOM || type == CL_DEVICE_TYPE_ALL;
}
} // namespace cl
#endif // LIBANGLE_CLDEVICE_H_