Debian Codegraph @

src/gallium/drivers/nouveau/nvc0/nvc0_screen.h

raw
1 #ifndef __NVC0_SCREEN_H__
2 #define __NVC0_SCREEN_H__
3
4 #include "nouveau_screen.h"
5 #include "nouveau_mm.h"
6 #include "nouveau_fence.h"
7 #include "nouveau_heap.h"
8
9 #include "nv_object.xml.h"
10
11 #include "nvc0/nvc0_winsys.h"
12 #include "nvc0/nvc0_stateobj.h"
13
14 #define NVC0_TIC_MAX_ENTRIES 2048
15 #define NVC0_TSC_MAX_ENTRIES 2048
16 #define NVE4_IMG_MAX_HANDLES 512
17
18 /* doesn't count driver-reserved slot */
19 #define NVC0_MAX_PIPE_CONSTBUFS 15
20 #define NVC0_MAX_CONST_BUFFERS 16
21 #define NVC0_MAX_CONSTBUF_SIZE 65536
22
23 #define NVC0_MAX_VIEWPORTS 16
24
25 #define NVC0_MAX_BUFFERS 32
26
27 #define NVC0_MAX_IMAGES 8
28
29 #define NVC0_MAX_WINDOW_RECTANGLES 8
30
31 struct nvc0_context;
32
33 struct nvc0_blitter;
34
35 struct nvc0_graph_state {
36 bool flushed;
37 bool rasterizer_discard;
38 bool early_z_forced;
39 bool prim_restart;
40 uint32_t instance_elts; /* bitmask of per-instance elements */
41 uint32_t instance_base;
42 uint32_t constant_vbos;
43 uint32_t constant_elts;
44 int32_t index_bias;
45 uint16_t scissor;
46 bool flatshade;
47 uint8_t patch_vertices;
48 uint8_t vbo_mode; /* 0 = normal, 1 = translate, 3 = translate, forced */
49 uint8_t num_vtxbufs;
50 uint8_t num_vtxelts;
51 uint8_t num_textures[6];
52 uint8_t num_samplers[6];
53 uint8_t tls_required; /* bitmask of shader types using l[] */
54 uint8_t clip_enable;
55 uint32_t clip_mode;
56 bool uniform_buffer_bound[6];
57 struct nvc0_transform_feedback_state *tfb;
58 bool seamless_cube_map;
59 bool post_depth_coverage;
60 };
61
62 struct nvc0_cb_binding {
63 uint64_t addr;
64 int size;
65 };
66
67 struct nvc0_screen {
68 struct nouveau_screen base;
69
70 struct nvc0_context *cur_ctx;
71 struct nvc0_graph_state save_state;
72 simple_mtx_t state_lock;
73
74 int num_occlusion_queries_active;
75
76 struct nouveau_bo *text;
77 struct nouveau_bo *uniform_bo;
78 struct nouveau_bo *tls;
79 struct nouveau_bo *txc; /* TIC (offset 0) and TSC (65536) */
80 struct nouveau_bo *poly_cache;
81
82 uint8_t gpc_count;
83 uint16_t mp_count;
84 uint16_t mp_count_compute; /* magic reg can make compute use fewer MPs */
85
86 struct nouveau_heap *text_heap;
87 struct nouveau_heap *lib_code; /* allocated from text_heap */
88
89 struct nvc0_blitter *blitter;
90
91 struct {
92 void **entries;
93 int next;
94 uint32_t lock[NVC0_TIC_MAX_ENTRIES / 32];
95 bool maxwell;
96 } tic;
97
98 struct {
99 void **entries;
100 int next;
101 uint32_t lock[NVC0_TSC_MAX_ENTRIES / 32];
102 } tsc;
103
104 struct {
105 struct pipe_image_view **entries;
106 int next;
107 } img;
108
109 struct {
110 struct nouveau_bo *bo;
111 uint32_t *map;
112 } fence;
113
114 struct {
115 struct nvc0_program *prog; /* compute state object to read MP counters */
116 struct nvc0_hw_sm_query *mp_counter[8]; /* counter to query allocation */
117 uint8_t num_hw_sm_active[2];
118 bool mp_counters_enabled;
119 } pm;
120
121 /* only maintained on Maxwell+ */
122 struct nvc0_cb_binding cb_bindings[5][NVC0_MAX_CONST_BUFFERS];
123
124 struct nouveau_object *eng3d; /* sqrt(1/2)|kepler> + sqrt(1/2)|fermi> */
125 struct nouveau_object *eng2d;
126 struct nouveau_object *m2mf;
127 struct nouveau_object *copy;
128 struct nouveau_object *compute;
129 struct nouveau_object *nvsw;
130 };
131
132 static inline struct nvc0_screen *
133 nvc0_screen(struct pipe_screen *screen)
134 {
135 return (struct nvc0_screen *)screen;
136 }
137
138 int nvc0_screen_get_driver_query_info(struct pipe_screen *, unsigned,
139 struct pipe_driver_query_info *);
140
141 int nvc0_screen_get_driver_query_group_info(struct pipe_screen *, unsigned,
142 struct pipe_driver_query_group_info *);
143
144 bool nvc0_blitter_create(struct nvc0_screen *);
145 void nvc0_blitter_destroy(struct nvc0_screen *);
146
147 void nvc0_screen_make_buffers_resident(struct nvc0_screen *);
148
149 int nvc0_screen_tic_alloc(struct nvc0_screen *, void *);
150 int nvc0_screen_tsc_alloc(struct nvc0_screen *, void *);
151
152 int nve4_screen_compute_setup(struct nvc0_screen *, struct nouveau_pushbuf *);
153 int nvc0_screen_compute_setup(struct nvc0_screen *, struct nouveau_pushbuf *);
154
155 int nvc0_screen_resize_text_area(struct nvc0_screen *, struct nouveau_pushbuf *, uint64_t);
156
157 // 3D Only
158 void nvc0_screen_bind_cb_3d(struct nvc0_screen *, struct nouveau_pushbuf *, bool *, int, int, int, uint64_t);
159
160 struct nvc0_format {
161 uint32_t rt;
162 struct {
163 unsigned format:7;
164 unsigned type_r:3;
165 unsigned type_g:3;
166 unsigned type_b:3;
167 unsigned type_a:3;
168 unsigned src_x:3;
169 unsigned src_y:3;
170 unsigned src_z:3;
171 unsigned src_w:3;
172 } tic;
173 uint32_t usage;
174 };
175
176 struct nvc0_vertex_format {
177 uint32_t vtx;
178 uint32_t usage;
179 };
180
181 extern const struct nvc0_format nvc0_format_table[];
182 extern const struct nvc0_vertex_format nvc0_vertex_format[];
183
184 static inline void
185 nvc0_screen_tic_unlock(struct nvc0_screen *screen, struct nv50_tic_entry *tic)
186 {
187 if (tic->bindless)
188 return;
189 if (tic->id >= 0)
190 screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
191 }
192
193 static inline void
194 nvc0_screen_tsc_unlock(struct nvc0_screen *screen, struct nv50_tsc_entry *tsc)
195 {
196 if (tsc->id >= 0)
197 screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
198 }
199
200 static inline void
201 nvc0_screen_tic_free(struct nvc0_screen *screen, struct nv50_tic_entry *tic)
202 {
203 if (tic->id >= 0) {
204 screen->tic.entries[tic->id] = NULL;
205 screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
206 }
207 }
208
209 static inline void
210 nvc0_screen_tsc_free(struct nvc0_screen *screen, struct nv50_tsc_entry *tsc)
211 {
212 if (tsc->id >= 0) {
213 screen->tsc.entries[tsc->id] = NULL;
214 screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
215 }
216 }
217
218 #endif