Hash :
41b817f3
Author :
Date :
2021-05-31T17:38:43
CL: Add buffer enqueue commands Add buffer enqueue commands to front end and pass-through back end. Bug: angleproject:6015 Change-Id: I936530d31903e395550e4540339ebec2e6702e65 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2928425 Commit-Queue: John Plate <jplate@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.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 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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
//
// 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.
//
// CLCommandQueue.h: Defines the cl::CommandQueue class, which can be used to queue a set of OpenCL
// operations.
#ifndef LIBANGLE_CLCOMMANDQUEUE_H_
#define LIBANGLE_CLCOMMANDQUEUE_H_
#include "libANGLE/CLObject.h"
#include "libANGLE/renderer/CLCommandQueueImpl.h"
#include <limits>
namespace cl
{
class CommandQueue final : public _cl_command_queue, public Object
{
public:
// Front end entry functions, only called from OpenCL entry points
cl_int getInfo(CommandQueueInfo name,
size_t valueSize,
void *value,
size_t *valueSizeRet) const;
cl_int setProperty(CommandQueueProperties properties,
cl_bool enable,
cl_command_queue_properties *oldProperties);
cl_int enqueueReadBuffer(cl_mem buffer,
cl_bool blockingRead,
size_t offset,
size_t size,
void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int enqueueWriteBuffer(cl_mem buffer,
cl_bool blockingWrite,
size_t offset,
size_t size,
const void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int enqueueReadBufferRect(cl_mem buffer,
cl_bool blockingRead,
const size_t *bufferOrigin,
const size_t *hostOrigin,
const size_t *region,
size_t bufferRowPitch,
size_t bufferSlicePitch,
size_t hostRowPitch,
size_t hostSlicePitch,
void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int enqueueWriteBufferRect(cl_mem buffer,
cl_bool blockingWrite,
const size_t *bufferOrigin,
const size_t *hostOrigin,
const size_t *region,
size_t bufferRowPitch,
size_t bufferSlicePitch,
size_t hostRowPitch,
size_t hostSlicePitch,
const void *ptr,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int enqueueCopyBuffer(cl_mem srcBuffer,
cl_mem dstBuffer,
size_t srcOffset,
size_t dstOffset,
size_t size,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int enqueueCopyBufferRect(cl_mem srcBuffer,
cl_mem dstBuffer,
const size_t *srcOrigin,
const size_t *dstOrigin,
const size_t *region,
size_t srcRowPitch,
size_t srcSlicePitch,
size_t dstRowPitch,
size_t dstSlicePitch,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
cl_int enqueueFillBuffer(cl_mem buffer,
const void *pattern,
size_t patternSize,
size_t offset,
size_t size,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event);
void *enqueueMapBuffer(cl_mem buffer,
cl_bool blockingMap,
MapFlags mapFlags,
size_t offset,
size_t size,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event,
cl_int &errorCode);
public:
using PropArray = std::vector<cl_queue_properties>;
static constexpr cl_uint kNoSize = std::numeric_limits<cl_uint>::max();
~CommandQueue() override;
Context &getContext();
const Context &getContext() const;
const Device &getDevice() const;
CommandQueueProperties getProperties() const;
bool isOnHost() const;
bool isOnDevice() const;
bool hasSize() const;
cl_uint getSize() const;
template <typename T = rx::CLCommandQueueImpl>
T &getImpl() const;
private:
CommandQueue(Context &context,
Device &device,
PropArray &&propArray,
CommandQueueProperties properties,
cl_uint size,
cl_int &errorCode);
CommandQueue(Context &context,
Device &device,
CommandQueueProperties properties,
cl_int &errorCode);
const ContextPtr mContext;
const DevicePtr mDevice;
const PropArray mPropArray;
CommandQueueProperties mProperties;
const cl_uint mSize = kNoSize;
const rx::CLCommandQueueImpl::Ptr mImpl;
friend class Object;
};
inline Context &CommandQueue::getContext()
{
return *mContext;
}
inline const Context &CommandQueue::getContext() const
{
return *mContext;
}
inline const Device &CommandQueue::getDevice() const
{
return *mDevice;
}
inline CommandQueueProperties CommandQueue::getProperties() const
{
return mProperties;
}
inline bool CommandQueue::isOnHost() const
{
return mProperties.isNotSet(CL_QUEUE_ON_DEVICE);
}
inline bool CommandQueue::isOnDevice() const
{
return mProperties.isSet(CL_QUEUE_ON_DEVICE);
}
inline bool CommandQueue::hasSize() const
{
return mSize != kNoSize;
}
inline cl_uint CommandQueue::getSize() const
{
return mSize;
}
template <typename T>
inline T &CommandQueue::getImpl() const
{
return static_cast<T &>(*mImpl);
}
} // namespace cl
#endif // LIBANGLE_CLCOMMANDQUEUE_H_