1 /*
2 * Copyright © 2012 Rob Clark <[email protected]>
3 * SPDX-License-Identifier: MIT
4 *
5 * Authors:
6 * Rob Clark <[email protected]>
7 */
8
9 #ifndef FREEDRENO_GMEM_H_
10 #define FREEDRENO_GMEM_H_
11
12 #include "pipe/p_state.h"
13 #include "util/list.h"
14
15 #include "freedreno_util.h"
16
17 BEGINC;
18
19 /* per-pipe configuration for hw binning: */
20 struct fd_vsc_pipe {
21 uint8_t x, y, w, h; /* VSC_PIPE[p].CONFIG */
22 };
23
24 /* per-tile configuration for hw binning: */
25 struct fd_tile {
26 uint8_t p; /* index into vsc_pipe[]s */
27 uint8_t n; /* slot within pipe */
28 uint16_t bin_w, bin_h;
29 uint16_t xoff, yoff;
30 };
31
32 struct fd_gmem_stateobj {
33 struct pipe_reference reference;
34 struct fd_screen *screen;
35 void *key;
36
37 uint32_t cbuf_base[MAX_RENDER_TARGETS];
38 uint32_t zsbuf_base[2];
39 uint8_t cbuf_cpp[MAX_RENDER_TARGETS];
40 uint8_t zsbuf_cpp[2];
41 uint16_t bin_h, nbins_y;
42 uint16_t bin_w, nbins_x;
43 uint16_t minx, miny;
44 uint16_t width, height;
45 uint16_t maxpw, maxph; /* maximum pipe width/height */
46 uint8_t num_vsc_pipes; /* number of pipes for a20x */
47
48 struct fd_vsc_pipe vsc_pipe[32];
49 struct fd_tile *tile;
50
51 struct list_head node;
52 };
53
54 void __fd_gmem_destroy(struct fd_gmem_stateobj *gmem);
55
56 static inline void
fd_gmem_reference(struct fd_gmem_stateobj ** ptr,struct fd_gmem_stateobj * gmem)57 fd_gmem_reference(struct fd_gmem_stateobj **ptr, struct fd_gmem_stateobj *gmem)
58 {
59 struct fd_gmem_stateobj *old_gmem = *ptr;
60
61 if (pipe_reference(&(*ptr)->reference, &gmem->reference))
62 __fd_gmem_destroy(old_gmem);
63
64 *ptr = gmem;
65 }
66
67 struct fd_gmem_cache {
68 struct hash_table *ht;
69 struct list_head lru;
70 };
71
72 struct fd_batch;
73
74 void fd_gmem_render_tiles(struct fd_batch *batch) assert_dt;
75 unsigned fd_gmem_estimate_bins_per_pipe(struct fd_batch *batch);
76 bool fd_gmem_needs_restore(struct fd_batch *batch, const struct fd_tile *tile,
77 uint32_t buffers);
78
79 struct pipe_screen;
80 void fd_gmem_screen_init(struct pipe_screen *pscreen);
81 void fd_gmem_screen_fini(struct pipe_screen *pscreen);
82
83 ENDC;
84
85 #endif /* FREEDRENO_GMEM_H_ */
86