Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2017 ARM Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #ifndef __ARM_COMPUTE_GCSCHEDULER_H__ |
| 26 | #define __ARM_COMPUTE_GCSCHEDULER_H__ |
| 27 | |
| 28 | #include "arm_compute/core/GLES_COMPUTE/IGCKernel.h" |
| 29 | #include "arm_compute/core/Types.h" |
| 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | class IGCKernel; |
| 34 | |
| 35 | /** Provides global access to a OpenGL ES context and command queue. */ |
| 36 | class GCScheduler |
| 37 | { |
| 38 | private: |
| 39 | /** Constructor */ |
| 40 | GCScheduler(); |
| 41 | |
| 42 | public: |
| 43 | /** Access the scheduler singleton. |
| 44 | * |
| 45 | * @return The scheduler |
| 46 | */ |
| 47 | static GCScheduler &get(); |
| 48 | |
| 49 | /** Initialises the context and command queue used by the scheduler to default values |
| 50 | * and sets a default device and kernel path for the @ref GCKernelLibrary. |
| 51 | */ |
| 52 | void default_init(); |
| 53 | |
| 54 | /** Schedule the execution of the passed kernel if possible. |
| 55 | * |
| 56 | * @param[in] kernel Kernel to execute. |
| 57 | * @param[in] flush (Optional) Specifies if the command queue will be flushed after running the kernel. |
| 58 | */ |
| 59 | void enqueue(IGCKernel &kernel, bool flush = true); |
| 60 | |
| 61 | /** Initialises the display and context to be used by the scheduler. |
| 62 | * |
| 63 | * @param[in] dpy The EGL display connection |
| 64 | * @param[in] ctx The EGL rendering context |
| 65 | */ |
| 66 | void init(EGLDisplay dpy, EGLContext ctx); |
| 67 | |
| 68 | /** Blocks until all commands in the associated command queue have finished. */ |
| 69 | void sync(); |
| 70 | }; |
| 71 | } |
| 72 | |
| 73 | #endif /* __ARM_COMPUTE_GCSCHEDULER_H__ */ |