Hash :
8ef76b6a
Author :
Date :
2025-08-04T12:34:17
CL/Vulkan: cl_khr_external_memory extension (pt.2)
- Make this extension visible if Vulkan implementation support
features supportsExternalMemoryFd and/or
supportsExternalMemoryDmaBuf
- Implemented APIs clEnqueueAcquireExternalMemObjectsKHR and
clEnqueueReleaseExternalMemObjectsKHR
- Updated clCreateBufferWithProperties to handle external memory
file descriptor.
Bug: angleproject:378017028
Change-Id: I1751982c8e9b2cd07b7e251cc54db5dcd1bcda20
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6843980
Commit-Queue: Austin Annestrand <a.annestrand@samsung.com>
Reviewed-by: 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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
//
// 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.
//
// CLPlatform.h: Defines the cl::Platform class, which provides information about platform-specific
// OpenCL features.
#ifndef LIBANGLE_CLPLATFORM_H_
#define LIBANGLE_CLPLATFORM_H_
#include "libANGLE/CLObject.h"
#include "libANGLE/Context.h"
#include "common/WorkerThread.h"
#include "libANGLE/renderer/CLPlatformImpl.h"
#include "anglebase/no_destructor.h"
namespace cl
{
class Platform final : public _cl_platform_id, public Object
{
public:
// Front end entry functions, only called from OpenCL entry points
static void Initialize(const cl_icd_dispatch &dispatch,
rx::CLPlatformImpl::CreateFuncs &&createFuncs);
static Platform *GetDefault();
static Platform *CastOrDefault(cl_platform_id platform);
static bool IsValidOrDefault(const _cl_platform_id *platform);
static angle::Result GetPlatformIDs(cl_uint numEntries,
cl_platform_id *platforms,
cl_uint *numPlatforms);
angle::Result getInfo(PlatformInfo name,
size_t valueSize,
void *value,
size_t *valueSizeRet) const;
angle::Result getDeviceIDs(DeviceType deviceType,
cl_uint numEntries,
cl_device_id *devices,
cl_uint *numDevices) const;
bool hasDeviceType(DeviceType) const;
static cl_context CreateContext(const cl_context_properties *properties,
cl_uint numDevices,
const cl_device_id *devices,
ContextErrorCB notify,
void *userData);
static cl_context CreateContextFromType(const cl_context_properties *properties,
DeviceType deviceType,
ContextErrorCB notify,
void *userData);
angle::Result unloadCompiler();
public:
~Platform() override;
const rx::CLPlatformImpl::Info &getInfo() const;
cl_version getVersion() const;
bool isVersionOrNewer(cl_uint major, cl_uint minor) const;
const DevicePtrs &getDevices() const;
template <typename T = rx::CLPlatformImpl>
T &getImpl() const;
static const PlatformPtrs &GetPlatforms();
static constexpr const char *GetVendor();
const std::shared_ptr<angle::WorkerThreadPool> &getMultiThreadPool() const;
angle::FrameCaptureShared *getFrameCaptureShared();
private:
explicit Platform(const rx::CLPlatformImpl::CreateFunc &createFunc);
DevicePtrs createDevices(rx::CLDeviceImpl::CreateDatas &&createDatas);
static PlatformPtrs &GetPointers();
const rx::CLPlatformImpl::Ptr mImpl;
const DevicePtrs mDevices;
const rx::CLPlatformImpl::Info mInfo;
std::shared_ptr<angle::WorkerThreadPool> mMultiThreadPool;
static constexpr char kVendor[] = "ANGLE";
static constexpr char kIcdSuffix[] = "ANGLE";
static angle::FrameCaptureShared *mFrameCaptureShared;
};
inline Platform *Platform::GetDefault()
{
return GetPlatforms().empty() ? nullptr : GetPlatforms().front().get();
}
inline Platform *Platform::CastOrDefault(cl_platform_id platform)
{
return platform != nullptr ? &platform->cast<Platform>() : GetDefault();
}
// Our CL implementation defines that a nullptr value chooses the platform that we provide as
// default, so this function returns true for a nullptr value if a default platform exists.
inline bool Platform::IsValidOrDefault(const _cl_platform_id *platform)
{
return platform != nullptr ? IsValid(platform) : GetDefault() != nullptr;
}
inline const rx::CLPlatformImpl::Info &Platform::getInfo() const
{
return mInfo;
}
inline cl_version Platform::getVersion() const
{
return mInfo.version;
}
inline bool Platform::isVersionOrNewer(cl_uint major, cl_uint minor) const
{
return mInfo.version >= CL_MAKE_VERSION(major, minor, 0u);
}
inline const DevicePtrs &Platform::getDevices() const
{
return mDevices;
}
template <typename T>
inline T &Platform::getImpl() const
{
return static_cast<T &>(*mImpl);
}
inline const PlatformPtrs &Platform::GetPlatforms()
{
return GetPointers();
}
constexpr const char *Platform::GetVendor()
{
return kVendor;
}
inline const std::shared_ptr<angle::WorkerThreadPool> &Platform::getMultiThreadPool() const
{
return mMultiThreadPool;
}
inline PlatformPtrs &Platform::GetPointers()
{
static angle::base::NoDestructor<PlatformPtrs> sPointers;
return *sPointers;
}
} // namespace cl
#endif // LIBANGLE_CLPLATFORM_H_