1 //
2 // Copyright 2021 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // CLCommandQueueCL.h: Defines the class interface for CLCommandQueueCL,
7 // implementing CLCommandQueueImpl.
8 
9 #ifndef LIBANGLE_RENDERER_CL_CLCOMMANDQUEUECL_H_
10 #define LIBANGLE_RENDERER_CL_CLCOMMANDQUEUECL_H_
11 
12 #include "libANGLE/renderer/CLCommandQueueImpl.h"
13 
14 namespace rx
15 {
16 
17 class CLCommandQueueCL : public CLCommandQueueImpl
18 {
19   public:
20     CLCommandQueueCL(const cl::CommandQueue &commandQueue, cl_command_queue native);
21     ~CLCommandQueueCL() override;
22 
23     cl_command_queue getNative() const;
24 
25     cl_int setProperty(cl::CommandQueueProperties properties, cl_bool enable) override;
26 
27     cl_int enqueueReadBuffer(const cl::Buffer &buffer,
28                              bool blocking,
29                              size_t offset,
30                              size_t size,
31                              void *ptr,
32                              const cl::EventPtrs &waitEvents,
33                              CLEventImpl::CreateFunc *eventCreateFunc) override;
34 
35     cl_int enqueueWriteBuffer(const cl::Buffer &buffer,
36                               bool blocking,
37                               size_t offset,
38                               size_t size,
39                               const void *ptr,
40                               const cl::EventPtrs &waitEvents,
41                               CLEventImpl::CreateFunc *eventCreateFunc) override;
42 
43     cl_int enqueueReadBufferRect(const cl::Buffer &buffer,
44                                  bool blocking,
45                                  const size_t bufferOrigin[3],
46                                  const size_t hostOrigin[3],
47                                  const size_t region[3],
48                                  size_t bufferRowPitch,
49                                  size_t bufferSlicePitch,
50                                  size_t hostRowPitch,
51                                  size_t hostSlicePitch,
52                                  void *ptr,
53                                  const cl::EventPtrs &waitEvents,
54                                  CLEventImpl::CreateFunc *eventCreateFunc) override;
55 
56     cl_int enqueueWriteBufferRect(const cl::Buffer &buffer,
57                                   bool blocking,
58                                   const size_t bufferOrigin[3],
59                                   const size_t hostOrigin[3],
60                                   const size_t region[3],
61                                   size_t bufferRowPitch,
62                                   size_t bufferSlicePitch,
63                                   size_t hostRowPitch,
64                                   size_t hostSlicePitch,
65                                   const void *ptr,
66                                   const cl::EventPtrs &waitEvents,
67                                   CLEventImpl::CreateFunc *eventCreateFunc) override;
68 
69     cl_int enqueueCopyBuffer(const cl::Buffer &srcBuffer,
70                              const cl::Buffer &dstBuffer,
71                              size_t srcOffset,
72                              size_t dstOffset,
73                              size_t size,
74                              const cl::EventPtrs &waitEvents,
75                              CLEventImpl::CreateFunc *eventCreateFunc) override;
76 
77     cl_int enqueueCopyBufferRect(const cl::Buffer &srcBuffer,
78                                  const cl::Buffer &dstBuffer,
79                                  const size_t srcOrigin[3],
80                                  const size_t dstOrigin[3],
81                                  const size_t region[3],
82                                  size_t srcRowPitch,
83                                  size_t srcSlicePitch,
84                                  size_t dstRowPitch,
85                                  size_t dstSlicePitch,
86                                  const cl::EventPtrs &waitEvents,
87                                  CLEventImpl::CreateFunc *eventCreateFunc) override;
88 
89     cl_int enqueueFillBuffer(const cl::Buffer &buffer,
90                              const void *pattern,
91                              size_t patternSize,
92                              size_t offset,
93                              size_t size,
94                              const cl::EventPtrs &waitEvents,
95                              CLEventImpl::CreateFunc *eventCreateFunc) override;
96 
97     void *enqueueMapBuffer(const cl::Buffer &buffer,
98                            bool blocking,
99                            cl::MapFlags mapFlags,
100                            size_t offset,
101                            size_t size,
102                            const cl::EventPtrs &waitEvents,
103                            CLEventImpl::CreateFunc *eventCreateFunc,
104                            cl_int &errorCode) override;
105 
106     cl_int enqueueReadImage(const cl::Image &image,
107                             bool blocking,
108                             const size_t origin[3],
109                             const size_t region[3],
110                             size_t rowPitch,
111                             size_t slicePitch,
112                             void *ptr,
113                             const cl::EventPtrs &waitEvents,
114                             CLEventImpl::CreateFunc *eventCreateFunc) override;
115 
116     cl_int enqueueWriteImage(const cl::Image &image,
117                              bool blocking,
118                              const size_t origin[3],
119                              const size_t region[3],
120                              size_t inputRowPitch,
121                              size_t inputSlicePitch,
122                              const void *ptr,
123                              const cl::EventPtrs &waitEvents,
124                              CLEventImpl::CreateFunc *eventCreateFunc) override;
125 
126     cl_int enqueueCopyImage(const cl::Image &srcImage,
127                             const cl::Image &dstImage,
128                             const size_t srcOrigin[3],
129                             const size_t dstOrigin[3],
130                             const size_t region[3],
131                             const cl::EventPtrs &waitEvents,
132                             CLEventImpl::CreateFunc *eventCreateFunc) override;
133 
134     cl_int enqueueFillImage(const cl::Image &image,
135                             const void *fillColor,
136                             const size_t origin[3],
137                             const size_t region[3],
138                             const cl::EventPtrs &waitEvents,
139                             CLEventImpl::CreateFunc *eventCreateFunc) override;
140 
141     cl_int enqueueCopyImageToBuffer(const cl::Image &srcImage,
142                                     const cl::Buffer &dstBuffer,
143                                     const size_t srcOrigin[3],
144                                     const size_t region[3],
145                                     size_t dstOffset,
146                                     const cl::EventPtrs &waitEvents,
147                                     CLEventImpl::CreateFunc *eventCreateFunc) override;
148 
149     cl_int enqueueCopyBufferToImage(const cl::Buffer &srcBuffer,
150                                     const cl::Image &dstImage,
151                                     size_t srcOffset,
152                                     const size_t dstOrigin[3],
153                                     const size_t region[3],
154                                     const cl::EventPtrs &waitEvents,
155                                     CLEventImpl::CreateFunc *eventCreateFunc) override;
156 
157     void *enqueueMapImage(const cl::Image &image,
158                           bool blocking,
159                           cl::MapFlags mapFlags,
160                           const size_t origin[3],
161                           const size_t region[3],
162                           size_t *imageRowPitch,
163                           size_t *imageSlicePitch,
164                           const cl::EventPtrs &waitEvents,
165                           CLEventImpl::CreateFunc *eventCreateFunc,
166                           cl_int &errorCode) override;
167 
168     cl_int enqueueUnmapMemObject(const cl::Memory &memory,
169                                  void *mappedPtr,
170                                  const cl::EventPtrs &waitEvents,
171                                  CLEventImpl::CreateFunc *eventCreateFunc) override;
172 
173     cl_int enqueueMigrateMemObjects(const cl::MemoryPtrs &memObjects,
174                                     cl::MemMigrationFlags flags,
175                                     const cl::EventPtrs &waitEvents,
176                                     CLEventImpl::CreateFunc *eventCreateFunc) override;
177 
178     cl_int enqueueNDRangeKernel(const cl::Kernel &kernel,
179                                 cl_uint workDim,
180                                 const size_t *globalWorkOffset,
181                                 const size_t *globalWorkSize,
182                                 const size_t *localWorkSize,
183                                 const cl::EventPtrs &waitEvents,
184                                 CLEventImpl::CreateFunc *eventCreateFunc) override;
185 
186     cl_int enqueueTask(const cl::Kernel &kernel,
187                        const cl::EventPtrs &waitEvents,
188                        CLEventImpl::CreateFunc *eventCreateFunc) override;
189 
190     cl_int enqueueNativeKernel(cl::UserFunc userFunc,
191                                void *args,
192                                size_t cbArgs,
193                                const cl::BufferPtrs &buffers,
194                                const std::vector<size_t> bufferPtrOffsets,
195                                const cl::EventPtrs &waitEvents,
196                                CLEventImpl::CreateFunc *eventCreateFunc) override;
197 
198     cl_int enqueueMarkerWithWaitList(const cl::EventPtrs &waitEvents,
199                                      CLEventImpl::CreateFunc *eventCreateFunc) override;
200 
201     cl_int enqueueMarker(CLEventImpl::CreateFunc &eventCreateFunc) override;
202 
203     cl_int enqueueWaitForEvents(const cl::EventPtrs &events) override;
204 
205     cl_int enqueueBarrierWithWaitList(const cl::EventPtrs &waitEvents,
206                                       CLEventImpl::CreateFunc *eventCreateFunc) override;
207 
208     cl_int enqueueBarrier() override;
209 
210     cl_int flush() override;
211     cl_int finish() override;
212 
213   private:
214     const cl_command_queue mNative;
215 };
216 
getNative()217 inline cl_command_queue CLCommandQueueCL::getNative() const
218 {
219     return mNative;
220 }
221 
222 }  // namespace rx
223 
224 #endif  // LIBANGLE_RENDERER_CL_CLCOMMANDQUEUECL_H_
225