Hash :
ed7c31c7
Author :
Date :
2023-11-29T18:31:43
OpenCL: Replace error-passing APIs to use angle::Result Part 2 of Issue 8435: This part replaces existing error handling for all CL APIs that return CL objects to now use "angle::Result". Bug: angleproject:8435 Change-Id: I75e41c7cbb06220cabec7cc9f9cb5107a3b6bd6d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5075773 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@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
//
// 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.
//
// CLObject.h: Defines the cl::Object class, which is the base class of all ANGLE CL objects.
#ifndef LIBANGLE_CLOBJECT_H_
#define LIBANGLE_CLOBJECT_H_
#include "libANGLE/CLtypes.h"
#include "libANGLE/renderer/CLtypes.h"
#include <atomic>
namespace cl
{
class Object
{
public:
Object();
virtual ~Object();
cl_uint getRefCount() const noexcept { return mRefCount; }
void retain() noexcept { ++mRefCount; }
bool release()
{
if (mRefCount == 0u)
{
WARN() << "Unreferenced object without references";
return true;
}
return --mRefCount == 0u;
}
template <typename T, typename... Args>
static T *Create(Args &&...args)
{
T *object = new T(std::forward<Args>(args)...);
return object;
}
private:
std::atomic<cl_uint> mRefCount;
};
} // namespace cl
#endif // LIBANGLE_CLCONTEXT_H_