llvmpipe: add grid launch
[mesa.git] / src / gallium / drivers / panfrost / pan_allocate.h
1 /*
2 * © Copyright 2017-2018 Alyssa Rosenzweig
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 */
24
25 #ifndef __PAN_ALLOCATE_H__
26 #define __PAN_ALLOCATE_H__
27
28 #include <unistd.h>
29 #include <sys/mman.h>
30 #include <stdbool.h>
31
32 #include <panfrost-misc.h>
33
34 #include "util/list.h"
35
36 struct panfrost_context;
37
38 /* Represents a fat pointer for GPU-mapped memory, returned from the transient
39 * allocator and not used for much else */
40
41 struct panfrost_transfer {
42 uint8_t *cpu;
43 mali_ptr gpu;
44 };
45
46 struct panfrost_bo {
47 /* Must be first for casting */
48 struct list_head link;
49
50 struct pipe_reference reference;
51
52 /* Mapping for the entire object (all levels) */
53 uint8_t *cpu;
54
55 /* GPU address for the object */
56 mali_ptr gpu;
57
58 /* Size of all entire trees */
59 size_t size;
60
61 int gem_handle;
62
63 uint32_t flags;
64 };
65
66 struct panfrost_memory {
67 /* Backing for the slab in memory */
68 struct panfrost_bo *bo;
69 int stack_bottom;
70 };
71
72 struct panfrost_transfer
73 panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz);
74
75 mali_ptr
76 panfrost_upload_transient(struct panfrost_context *ctx, const void *data, size_t sz);
77
78 static inline mali_ptr
79 panfrost_reserve(struct panfrost_memory *mem, size_t sz)
80 {
81 mem->stack_bottom += sz;
82 return mem->bo->gpu + (mem->stack_bottom - sz);
83 }
84
85 #endif /* __PAN_ALLOCATE_H__ */