• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
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  * Authors:
24  *    Rob Clark <robclark@freedesktop.org>
25  */
26 
27 #ifndef FREEDRENO_GMEM_H_
28 #define FREEDRENO_GMEM_H_
29 
30 #include "pipe/p_state.h"
31 #include "util/list.h"
32 
33 #include "freedreno_util.h"
34 
35 BEGINC;
36 
37 /* per-pipe configuration for hw binning: */
38 struct fd_vsc_pipe {
39    uint8_t x, y, w, h; /* VSC_PIPE[p].CONFIG */
40 };
41 
42 /* per-tile configuration for hw binning: */
43 struct fd_tile {
44    uint8_t p; /* index into vsc_pipe[]s */
45    uint8_t n; /* slot within pipe */
46    uint16_t bin_w, bin_h;
47    uint16_t xoff, yoff;
48 };
49 
50 struct fd_gmem_stateobj {
51    struct pipe_reference reference;
52    struct fd_screen *screen;
53    void *key;
54 
55    uint32_t cbuf_base[MAX_RENDER_TARGETS];
56    uint32_t zsbuf_base[2];
57    uint8_t cbuf_cpp[MAX_RENDER_TARGETS];
58    uint8_t zsbuf_cpp[2];
59    uint16_t bin_h, nbins_y;
60    uint16_t bin_w, nbins_x;
61    uint16_t minx, miny;
62    uint16_t width, height;
63    uint16_t maxpw, maxph; /* maximum pipe width/height */
64    uint8_t num_vsc_pipes; /* number of pipes for a20x */
65 
66    struct fd_vsc_pipe vsc_pipe[32];
67    struct fd_tile *tile;
68 
69    struct list_head node;
70 };
71 
72 void __fd_gmem_destroy(struct fd_gmem_stateobj *gmem);
73 
74 static inline void
fd_gmem_reference(struct fd_gmem_stateobj ** ptr,struct fd_gmem_stateobj * gmem)75 fd_gmem_reference(struct fd_gmem_stateobj **ptr, struct fd_gmem_stateobj *gmem)
76 {
77    struct fd_gmem_stateobj *old_gmem = *ptr;
78 
79    if (pipe_reference(&(*ptr)->reference, &gmem->reference))
80       __fd_gmem_destroy(old_gmem);
81 
82    *ptr = gmem;
83 }
84 
85 struct fd_gmem_cache {
86    struct hash_table *ht;
87    struct list_head lru;
88 };
89 
90 struct fd_batch;
91 
92 void fd_gmem_render_tiles(struct fd_batch *batch) assert_dt;
93 unsigned fd_gmem_estimate_bins_per_pipe(struct fd_batch *batch);
94 bool fd_gmem_needs_restore(struct fd_batch *batch, const struct fd_tile *tile,
95                            uint32_t buffers);
96 
97 struct pipe_screen;
98 void fd_gmem_screen_init(struct pipe_screen *pscreen);
99 void fd_gmem_screen_fini(struct pipe_screen *pscreen);
100 
101 ENDC;
102 
103 #endif /* FREEDRENO_GMEM_H_ */
104