panfrost: Add the shader BO to the batch in patch_shader_state()
[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 /* Some BOs shouldn't be returned back to the reuse BO cache, use this flag to
56 * let the BO logic know about this contraint. */
57 #define PAN_BO_DONT_REUSE (1 << 5)
58
59 struct panfrost_bo {
60 /* Must be first for casting */
61 struct list_head link;
62
63 struct pipe_reference reference;
64
65 struct panfrost_screen *screen;
66
67 /* Mapping for the entire object (all levels) */
68 uint8_t *cpu;
69
70 /* GPU address for the object */
71 mali_ptr gpu;
72
73 /* Size of all entire trees */
74 size_t size;
75
76 int gem_handle;
77
78 uint32_t flags;
79 };
80
81 void
82 panfrost_bo_reference(struct panfrost_bo *bo);
83 void
84 panfrost_bo_unreference(struct panfrost_bo *bo);
85 struct panfrost_bo *
86 panfrost_bo_create(struct panfrost_screen *screen, size_t size,
87 uint32_t flags);
88 void
89 panfrost_bo_mmap(struct panfrost_bo *bo);
90 struct panfrost_bo *
91 panfrost_bo_import(struct panfrost_screen *screen, int fd);
92 int
93 panfrost_bo_export(struct panfrost_bo *bo);
94 void
95 panfrost_bo_cache_evict_all(struct panfrost_screen *screen);
96
97 #endif /* __PAN_BO_H__ */