blob: ab4e57e0cee22bcbecf3e983e26eb5dc9b5f89d9 [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +01001/*
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#ifndef __ARM_COMPUTE_IGCTENSOR_H__
25#define __ARM_COMPUTE_IGCTENSOR_H__
26
27#include "arm_compute/core/GLES_COMPUTE/OpenGLES.h"
28#include "arm_compute/core/ITensor.h"
29
30#include <cstdint>
31
32namespace arm_compute
33{
34/** Interface for GLES Compute tensor */
35class IGCTensor : public ITensor
36{
37public:
38 /** Default constructor. */
39 IGCTensor();
40
41 /** Prevent instances of this class from being copied (As this class contains pointers). */
42 IGCTensor(const IGCTensor &) = delete;
43
44 /** Prevent instances of this class from being copy assigned (As this class contains pointers). */
45 IGCTensor &operator=(const IGCTensor &) = delete;
46
47 /** Allow instances of this class to be moved */
48 IGCTensor(IGCTensor &&) = default;
49
50 /** Allow instances of this class to be moved */
51 IGCTensor &operator=(IGCTensor &&) = default;
52
53 /** Virtual destructor */
54 virtual ~IGCTensor() = default;
55
56 /** Map on an allocated buffer.
57 *
58 * @param[in] blocking (Optional) If true, then the mapping will be ready to use by the time
59 * this method returns, else it is the caller's responsibility
60 * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer.
61 */
62 void map(bool blocking = true);
63 /** Unmap an allocated and mapped buffer.
64 */
65 void unmap();
66 /** Clear the contents of the tensor synchronously.
67 */
68 void clear();
69
70 // Inherited methods overridden:
71 uint8_t *buffer() const override;
72 /** Interface to be implemented by the child class to return the tensor's gles compute buffer id.
73 *
74 * @return A SSBO buffer id.
75 */
76 virtual GLuint gc_buffer() const = 0;
77
78protected:
79 /** Method to be implemented by the child class to map the SSBO.
80 *
81 * @param[in] blocking If true, then the mapping will be ready to use by the time
82 * this method returns, else it is the caller's responsibility
83 * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer.
84 */
85 virtual uint8_t *do_map(bool blocking) = 0;
86 /** Method to be implemented by the child class to unmap the SSBO.
87 *
88 * @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
89 * the memory is accessed by the device.
90 */
91 virtual void do_unmap() = 0;
92
93private:
94 uint8_t *_mapping;
95};
96
97using IGCImage = IGCTensor;
98}
99#endif /*__ARM_COMPUTE_IGCTENSOR_H__ */