Hash :
ffbcd15e
Author :
Date :
2025-01-06T16:07:02
CL: Update event creation routines Move backend construction after frontend construction completes. This avoids potential undefined behavior if backend construction tries to access members of half-constructed frontend object. Add virtual onEventCreate routine for any actions that need to be performed after cmd event has been created. Additionally, this also fixes incorrect timestamp values when queue profiling is enabled for the VK backend. This was due to a missed event association to the cmd queue. Bug: angleproject:377942756 Change-Id: I0a2f0390cc04f94143d1801ad71e06f63785f3ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6149055 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Austin Annestrand <a.annestrand@samsung.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Gowtham Tammana <g.tammana@samsung.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 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.
//
// CLEvent.h: Defines the cl::Event class, which can be used to track the execution status of an
// OpenCL command.
#ifndef LIBANGLE_CLEVENT_H_
#define LIBANGLE_CLEVENT_H_
#include "libANGLE/CLObject.h"
#include "libANGLE/renderer/CLEventImpl.h"
#include "common/SynchronizedValue.h"
#include <array>
namespace cl
{
class Event final : public _cl_event, public Object
{
public:
// Front end entry functions, only called from OpenCL entry points
angle::Result setUserEventStatus(cl_int executionStatus);
angle::Result getInfo(EventInfo name,
size_t valueSize,
void *value,
size_t *valueSizeRet) const;
angle::Result setCallback(cl_int commandExecCallbackType, EventCB pfnNotify, void *userData);
angle::Result getProfilingInfo(ProfilingInfo name,
size_t valueSize,
void *value,
size_t *valueSizeRet);
public:
~Event() override;
Context &getContext();
const Context &getContext() const;
const CommandQueuePtr &getCommandQueue() const;
cl_command_type getCommandType() const;
bool wasStatusChanged() const;
template <typename T = rx::CLEventImpl>
T &getImpl() const;
void callback(cl_int commandStatus);
angle::Result initBackend(const rx::CLEventImpl::CreateFunc &createFunc);
bool isUserEvent() const { return mCommandType == CL_COMMAND_USER; }
static EventPtrs Cast(cl_uint numEvents, const cl_event *eventList);
private:
using CallbackData = std::pair<EventCB, void *>;
using Callbacks = std::vector<CallbackData>;
Event(Context &context);
Event(CommandQueue &queue, cl_command_type commandType);
const ContextPtr mContext;
const CommandQueuePtr mCommandQueue;
const cl_command_type mCommandType;
rx::CLEventImpl::Ptr mImpl;
bool mStatusWasChanged = false;
// Create separate storage for each possible callback type.
static_assert(CL_COMPLETE == 0 && CL_RUNNING == 1 && CL_SUBMITTED == 2,
"OpenCL command execution status values are not as assumed");
angle::SynchronizedValue<std::array<Callbacks, 3u>> mCallbacks;
friend class Object;
};
inline Context &Event::getContext()
{
return *mContext;
}
inline const Context &Event::getContext() const
{
return *mContext;
}
inline const CommandQueuePtr &Event::getCommandQueue() const
{
return mCommandQueue;
}
inline cl_command_type Event::getCommandType() const
{
return mCommandType;
}
inline bool Event::wasStatusChanged() const
{
return mStatusWasChanged;
}
template <typename T>
inline T &Event::getImpl() const
{
return static_cast<T &>(*mImpl);
}
} // namespace cl
#endif // LIBANGLE_CLEVENT_H_