panfrost: Stop passing screen around for BO operations
[mesa.git] / src / gallium / drivers / panfrost / pan_bo.h
1 /*
2 * © Copyright 2019 Alyssa Rosenzweig
3 * © Copyright 2019 Collabora, Ltd.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * 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
19 * THE 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
26 #ifndef __PAN_BO_H__
27 #define __PAN_BO_H__
28
29 #include <panfrost-misc.h>
30 #include "pipe/p_state.h"
31 #include "util/list.h"
32
33 struct panfrost_screen;
34
35 /* Flags for allocated memory */
36
37 /* This memory region is executable */
38 #define PAN_BO_EXECUTE (1 << 0)
39
40 /* This memory region should be lazily allocated and grow-on-page-fault. Must
41 * be used in conjunction with INVISIBLE */
42 #define PAN_BO_GROWABLE (1 << 1)
43
44 /* This memory region should not be mapped to the CPU */
45 #define PAN_BO_INVISIBLE (1 << 2)
46
47 /* This memory region will be used for varyings and needs to have the cache
48 * bits twiddled accordingly */
49 #define PAN_BO_COHERENT_LOCAL (1 << 3)
50
51 /* This region may not be used immediately and will not mmap on allocate
52 * (semantically distinct from INVISIBLE, which cannot never be mmaped) */
53 #define PAN_BO_DELAY_MMAP (1 << 4)
54
55 struct panfrost_bo {
56 /* Must be first for casting */
57 struct list_head link;
58
59 struct pipe_reference reference;
60
61 struct panfrost_screen *screen;
62
63 /* Mapping for the entire object (all levels) */
64 uint8_t *cpu;
65
66 /* GPU address for the object */
67 mali_ptr gpu;
68
69 /* Size of all entire trees */
70 size_t size;
71
72 int gem_handle;
73
74 uint32_t flags;
75 };
76
77 void
78 panfrost_bo_reference(struct panfrost_bo *bo);
79 void
80 panfrost_bo_unreference(struct panfrost_bo *bo);
81 struct panfrost_bo *
82 panfrost_bo_create(struct panfrost_screen *screen, size_t size,
83 uint32_t flags);
84 void
85 panfrost_bo_mmap(struct panfrost_bo *bo);
86 void
87 panfrost_bo_release(struct panfrost_bo *bo, bool cacheable);
88 struct panfrost_bo *
89 panfrost_bo_import(struct panfrost_screen *screen, int fd);
90 int
91 panfrost_bo_export(struct panfrost_bo *bo);
92 void
93 panfrost_bo_cache_evict_all(struct panfrost_screen *screen);
94
95 #endif /* __PAN_BO_H__ */