blob: 0f5f1942662885ae1082d2d88a6c7b4651a63b73 [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +01001/*
Michalis Spyrou9e9cbaf2018-03-15 14:41:34 +00002 * Copyright (c) 2017-2018 ARM Limited.
Anthony Barbier7068f992017-10-26 15:23:08 +01003 *
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_GCTENSOR_H__
26#define __ARM_COMPUTE_GCTENSOR_H__
27
28#include "arm_compute/core/GLES_COMPUTE/IGCTensor.h"
29#include "arm_compute/runtime/GLES_COMPUTE/GCTensorAllocator.h"
30
31namespace arm_compute
32{
33class ITensorAllocator;
34class ITensorInfo;
35
36/** Interface for OpenGL ES tensor */
37class GCTensor : public IGCTensor
38{
39public:
40 /** Default constructor */
41 GCTensor();
42
43 /** Prevent instances of this class from being copied (As this class contains pointers). */
44 GCTensor(const GCTensor &) = delete;
45
46 /** Prevent instances of this class from being copy assigned (As this class contains pointers). */
47 GCTensor &operator=(const GCTensor &) = delete;
48
49 /** Allow instances of this class to be moved */
50 GCTensor(GCTensor &&) = default;
51
52 /** Allow instances of this class to be moved */
53 GCTensor &operator=(GCTensor &&) = default;
54
55 /** Virtual destructor */
56 virtual ~GCTensor() = default;
57
58 /** Return a pointer to the tensor's allocator
59 *
60 * @return A pointer to the tensor's allocator
61 */
62 ITensorAllocator *allocator();
63
64 /** Enqueue a map operation of the allocated buffer on the given queue.
65 *
66 * @param[in] blocking (Optional) If true, then the mapping will be ready to use by the time
67 * this method returns, else it is the caller's responsibility
68 * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer.
69 *
70 * @return The mapping address.
71 */
72 void map(bool blocking = true);
73
74 /** Enqueue an unmap operation of the allocated and mapped buffer on the given queue.
75 *
76 * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before
77 * the memory is accessed by the device.
78 *
79 */
80 void unmap();
81
82 // Inherited methods overridden:
83 TensorInfo *info() const override;
84 TensorInfo *info() override;
85 uint8_t *buffer() const override;
86 GLuint gc_buffer() const override;
87
88protected:
89 // Inherited methods overridden:
90 uint8_t *do_map(bool blocking) override;
91 void do_unmap() override;
92
93private:
Michalis Spyrou9e9cbaf2018-03-15 14:41:34 +000094 mutable GCTensorAllocator _allocator; /**< Instance of the OpenGL ES tensor allocator */
Anthony Barbier7068f992017-10-26 15:23:08 +010095};
96
97using GCImage = GCTensor;
98}
99
100#endif /*__ARM_COMPUTE_GCTENSOR_H__ */