v3d: support rendering to multi-layered framebuffers
[mesa.git] / src / gallium / drivers / v3d / v3d_context.h
1 /*
2 * Copyright © 2014-2017 Broadcom
3 * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
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
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
25 #ifndef VC5_CONTEXT_H
26 #define VC5_CONTEXT_H
27
28 #ifdef V3D_VERSION
29 #include "broadcom/common/v3d_macros.h"
30 #endif
31
32 #include <stdio.h>
33
34 #include "pipe/p_context.h"
35 #include "pipe/p_state.h"
36 #include "util/bitset.h"
37 #include "util/slab.h"
38 #include "xf86drm.h"
39 #include "drm-uapi/v3d_drm.h"
40 #include "v3d_screen.h"
41 #include "broadcom/common/v3d_limits.h"
42
43 struct v3d_job;
44 struct v3d_bo;
45 void v3d_job_add_bo(struct v3d_job *job, struct v3d_bo *bo);
46
47 #include "v3d_bufmgr.h"
48 #include "v3d_resource.h"
49 #include "v3d_cl.h"
50
51 #ifdef USE_V3D_SIMULATOR
52 #define using_v3d_simulator true
53 #else
54 #define using_v3d_simulator false
55 #endif
56
57 #define VC5_DIRTY_BLEND (1ull << 0)
58 #define VC5_DIRTY_RASTERIZER (1ull << 1)
59 #define VC5_DIRTY_ZSA (1ull << 2)
60 #define VC5_DIRTY_COMPTEX (1ull << 3)
61 #define VC5_DIRTY_VERTTEX (1ull << 4)
62 #define VC5_DIRTY_GEOMTEX (1ull << 5)
63 #define VC5_DIRTY_FRAGTEX (1ull << 6)
64
65 #define VC5_DIRTY_SHADER_IMAGE (1ull << 9)
66 #define VC5_DIRTY_BLEND_COLOR (1ull << 10)
67 #define VC5_DIRTY_STENCIL_REF (1ull << 11)
68 #define VC5_DIRTY_SAMPLE_STATE (1ull << 12)
69 #define VC5_DIRTY_FRAMEBUFFER (1ull << 13)
70 #define VC5_DIRTY_STIPPLE (1ull << 14)
71 #define VC5_DIRTY_VIEWPORT (1ull << 15)
72 #define VC5_DIRTY_CONSTBUF (1ull << 16)
73 #define VC5_DIRTY_VTXSTATE (1ull << 17)
74 #define VC5_DIRTY_VTXBUF (1ull << 18)
75 #define VC5_DIRTY_SCISSOR (1ull << 19)
76 #define VC5_DIRTY_FLAT_SHADE_FLAGS (1ull << 20)
77 #define VC5_DIRTY_PRIM_MODE (1ull << 21)
78 #define VC5_DIRTY_CLIP (1ull << 22)
79 #define VC5_DIRTY_UNCOMPILED_CS (1ull << 23)
80 #define VC5_DIRTY_UNCOMPILED_VS (1ull << 24)
81 #define VC5_DIRTY_UNCOMPILED_GS (1ull << 25)
82 #define VC5_DIRTY_UNCOMPILED_FS (1ull << 26)
83
84 #define VC5_DIRTY_COMPILED_CS (1ull << 29)
85 #define VC5_DIRTY_COMPILED_VS (1ull << 30)
86 #define VC5_DIRTY_COMPILED_GS_BIN (1ULL << 31)
87 #define VC5_DIRTY_COMPILED_GS (1ULL << 32)
88 #define VC5_DIRTY_COMPILED_FS (1ull << 33)
89
90 #define VC5_DIRTY_FS_INPUTS (1ull << 38)
91 #define VC5_DIRTY_GS_INPUTS (1ull << 39)
92 #define VC5_DIRTY_STREAMOUT (1ull << 40)
93 #define VC5_DIRTY_OQ (1ull << 41)
94 #define VC5_DIRTY_CENTROID_FLAGS (1ull << 42)
95 #define VC5_DIRTY_NOPERSPECTIVE_FLAGS (1ull << 43)
96 #define VC5_DIRTY_SSBO (1ull << 44)
97
98 #define VC5_MAX_FS_INPUTS 64
99
100 enum v3d_sampler_state_variant {
101 V3D_SAMPLER_STATE_BORDER_0,
102 V3D_SAMPLER_STATE_F16,
103 V3D_SAMPLER_STATE_F16_UNORM,
104 V3D_SAMPLER_STATE_F16_SNORM,
105 V3D_SAMPLER_STATE_F16_BGRA,
106 V3D_SAMPLER_STATE_F16_BGRA_UNORM,
107 V3D_SAMPLER_STATE_F16_BGRA_SNORM,
108 V3D_SAMPLER_STATE_F16_A,
109 V3D_SAMPLER_STATE_F16_A_SNORM,
110 V3D_SAMPLER_STATE_F16_A_UNORM,
111 V3D_SAMPLER_STATE_F16_LA,
112 V3D_SAMPLER_STATE_F16_LA_UNORM,
113 V3D_SAMPLER_STATE_F16_LA_SNORM,
114 V3D_SAMPLER_STATE_32,
115 V3D_SAMPLER_STATE_32_UNORM,
116 V3D_SAMPLER_STATE_32_SNORM,
117 V3D_SAMPLER_STATE_32_A,
118 V3D_SAMPLER_STATE_32_A_UNORM,
119 V3D_SAMPLER_STATE_32_A_SNORM,
120 V3D_SAMPLER_STATE_1010102U,
121 V3D_SAMPLER_STATE_16U,
122 V3D_SAMPLER_STATE_16I,
123 V3D_SAMPLER_STATE_8I,
124 V3D_SAMPLER_STATE_8U,
125
126 V3D_SAMPLER_STATE_VARIANT_COUNT,
127 };
128
129 enum v3d_flush_cond {
130 /* Flush job unless we are flushing for transform feedback, where we
131 * handle flushing in the driver via the 'Wait for TF' packet.
132 */
133 V3D_FLUSH_DEFAULT,
134 /* Always flush the job, even for cases where we would normally not
135 * do it, such as transform feedback.
136 */
137 V3D_FLUSH_ALWAYS,
138 /* Flush job if it is not the current FBO job. This is intended to
139 * skip automatic flushes of the current job for resources that we
140 * expect to be externally synchronized by the application using
141 * glMemoryBarrier(), such as SSBOs and shader images.
142 */
143 V3D_FLUSH_NOT_CURRENT_JOB,
144 };
145
146 struct v3d_sampler_view {
147 struct pipe_sampler_view base;
148 uint32_t p0;
149 uint32_t p1;
150 /* Precomputed swizzles to pass in to the shader key. */
151 uint8_t swizzle[4];
152
153 uint8_t texture_shader_state[32];
154 /* V3D 4.x: Texture state struct. */
155 struct v3d_bo *bo;
156
157 enum v3d_sampler_state_variant sampler_variant;
158
159 /* Actual texture to be read by this sampler view. May be different
160 * from base.texture in the case of having a shadow tiled copy of a
161 * raster texture.
162 */
163 struct pipe_resource *texture;
164 };
165
166 struct v3d_sampler_state {
167 struct pipe_sampler_state base;
168 uint32_t p0;
169 uint32_t p1;
170
171 /* V3D 3.x: Packed texture state. */
172 uint8_t texture_shader_state[32];
173 /* V3D 4.x: Sampler state struct. */
174 struct pipe_resource *sampler_state;
175 uint32_t sampler_state_offset[V3D_SAMPLER_STATE_VARIANT_COUNT];
176
177 bool border_color_variants;
178 };
179
180 struct v3d_texture_stateobj {
181 struct pipe_sampler_view *textures[V3D_MAX_TEXTURE_SAMPLERS];
182 unsigned num_textures;
183 struct pipe_sampler_state *samplers[V3D_MAX_TEXTURE_SAMPLERS];
184 unsigned num_samplers;
185 struct v3d_cl_reloc texture_state[V3D_MAX_TEXTURE_SAMPLERS];
186 };
187
188 struct v3d_shader_uniform_info {
189 enum quniform_contents *contents;
190 uint32_t *data;
191 uint32_t count;
192 };
193
194 struct v3d_uncompiled_shader {
195 /** A name for this program, so you can track it in shader-db output. */
196 uint32_t program_id;
197 /** How many variants of this program were compiled, for shader-db. */
198 uint32_t compiled_variant_count;
199 struct pipe_shader_state base;
200 uint32_t num_tf_outputs;
201 struct v3d_varying_slot *tf_outputs;
202 uint16_t tf_specs[16];
203 uint16_t tf_specs_psiz[16];
204 uint32_t num_tf_specs;
205 };
206
207 struct v3d_compiled_shader {
208 struct pipe_resource *resource;
209 uint32_t offset;
210
211 union {
212 struct v3d_prog_data *base;
213 struct v3d_vs_prog_data *vs;
214 struct v3d_gs_prog_data *gs;
215 struct v3d_fs_prog_data *fs;
216 struct v3d_compute_prog_data *compute;
217 } prog_data;
218
219 /**
220 * VC5_DIRTY_* flags that, when set in v3d->dirty, mean that the
221 * uniforms have to be rewritten (and therefore the shader state
222 * reemitted).
223 */
224 uint64_t uniform_dirty_bits;
225 };
226
227 struct v3d_program_stateobj {
228 struct v3d_uncompiled_shader *bind_vs, *bind_gs, *bind_fs, *bind_compute;
229 struct v3d_compiled_shader *cs, *vs, *gs_bin, *gs, *fs, *compute;
230
231 struct hash_table *cache[MESA_SHADER_STAGES];
232
233 struct v3d_bo *spill_bo;
234 int spill_size_per_thread;
235 };
236
237 struct v3d_constbuf_stateobj {
238 struct pipe_constant_buffer cb[PIPE_MAX_CONSTANT_BUFFERS];
239 uint32_t enabled_mask;
240 uint32_t dirty_mask;
241 };
242
243 struct v3d_vertexbuf_stateobj {
244 struct pipe_vertex_buffer vb[PIPE_MAX_ATTRIBS];
245 unsigned count;
246 uint32_t enabled_mask;
247 uint32_t dirty_mask;
248 };
249
250 struct v3d_vertex_stateobj {
251 struct pipe_vertex_element pipe[V3D_MAX_VS_INPUTS / 4];
252 unsigned num_elements;
253
254 uint8_t attrs[16 * (V3D_MAX_VS_INPUTS / 4)];
255 struct pipe_resource *defaults;
256 uint32_t defaults_offset;
257 };
258
259 struct v3d_stream_output_target {
260 struct pipe_stream_output_target base;
261 /* Number of transform feedback vertices written to this target */
262 uint32_t recorded_vertex_count;
263 };
264
265 struct v3d_streamout_stateobj {
266 struct pipe_stream_output_target *targets[PIPE_MAX_SO_BUFFERS];
267 /* Number of vertices we've written into the buffer so far. */
268 uint32_t offsets[PIPE_MAX_SO_BUFFERS];
269 unsigned num_targets;
270 };
271
272 struct v3d_ssbo_stateobj {
273 struct pipe_shader_buffer sb[PIPE_MAX_SHADER_BUFFERS];
274 uint32_t enabled_mask;
275 };
276
277 /* Hash table key for v3d->jobs */
278 struct v3d_job_key {
279 struct pipe_surface *cbufs[4];
280 struct pipe_surface *zsbuf;
281 };
282
283 enum v3d_ez_state {
284 VC5_EZ_UNDECIDED = 0,
285 VC5_EZ_GT_GE,
286 VC5_EZ_LT_LE,
287 VC5_EZ_DISABLED,
288 };
289
290 struct v3d_image_view {
291 struct pipe_image_view base;
292 /* V3D 4.x texture shader state struct */
293 struct pipe_resource *tex_state;
294 uint32_t tex_state_offset;
295 };
296
297 struct v3d_shaderimg_stateobj {
298 struct v3d_image_view si[PIPE_MAX_SHADER_IMAGES];
299 uint32_t enabled_mask;
300 };
301
302 /**
303 * A complete bin/render job.
304 *
305 * This is all of the state necessary to submit a bin/render to the kernel.
306 * We want to be able to have multiple in progress at a time, so that we don't
307 * need to flush an existing CL just to switch to rendering to a new render
308 * target (which would mean reading back from the old render target when
309 * starting to render to it again).
310 */
311 struct v3d_job {
312 struct v3d_context *v3d;
313 struct v3d_cl bcl;
314 struct v3d_cl rcl;
315 struct v3d_cl indirect;
316 struct v3d_bo *tile_alloc;
317 struct v3d_bo *tile_state;
318
319 struct drm_v3d_submit_cl submit;
320
321 /**
322 * Set of all BOs referenced by the job. This will be used for making
323 * the list of BOs that the kernel will need to have paged in to
324 * execute our job.
325 */
326 struct set *bos;
327
328 /** Sum of the sizes of the BOs referenced by the job. */
329 uint32_t referenced_size;
330
331 struct set *write_prscs;
332 struct set *tf_write_prscs;
333
334 /* Size of the submit.bo_handles array. */
335 uint32_t bo_handles_size;
336
337 /** @{ Surfaces to submit rendering for. */
338 struct pipe_surface *cbufs[4];
339 struct pipe_surface *zsbuf;
340 /** @} */
341 /** @{
342 * Bounding box of the scissor across all queued drawing.
343 *
344 * Note that the max values are exclusive.
345 */
346 uint32_t draw_min_x;
347 uint32_t draw_min_y;
348 uint32_t draw_max_x;
349 uint32_t draw_max_y;
350 /** @} */
351 /** @{
352 * Width/height of the color framebuffer being rendered to,
353 * for VC5_TILE_RENDERING_MODE_CONFIG.
354 */
355 uint32_t draw_width;
356 uint32_t draw_height;
357 uint32_t num_layers;
358
359 /** @} */
360 /** @{ Tile information, depending on MSAA and float color buffer. */
361 uint32_t draw_tiles_x; /** @< Number of tiles wide for framebuffer. */
362 uint32_t draw_tiles_y; /** @< Number of tiles high for framebuffer. */
363
364 uint32_t tile_width; /** @< Width of a tile. */
365 uint32_t tile_height; /** @< Height of a tile. */
366 /** maximum internal_bpp of all color render targets. */
367 uint32_t internal_bpp;
368
369 /** Whether the current rendering is in a 4X MSAA tile buffer. */
370 bool msaa;
371 /** @} */
372
373 /* Bitmask of PIPE_CLEAR_* of buffers that were cleared before the
374 * first rendering.
375 */
376 uint32_t clear;
377 /* Bitmask of PIPE_CLEAR_* of buffers that have been read by a draw
378 * call without having been cleared first.
379 */
380 uint32_t load;
381 /* Bitmask of PIPE_CLEAR_* of buffers that have been rendered to
382 * (either clears or draws) and should be stored.
383 */
384 uint32_t store;
385 uint32_t clear_color[4][4];
386 float clear_z;
387 uint8_t clear_s;
388
389 /**
390 * Set if some drawing (triangles, blits, or just a glClear()) has
391 * been done to the FBO, meaning that we need to
392 * DRM_IOCTL_VC5_SUBMIT_CL.
393 */
394 bool needs_flush;
395
396 /* Set if any shader has dirtied cachelines in the TMU that need to be
397 * flushed before job end.
398 */
399 bool tmu_dirty_rcl;
400
401 /**
402 * Set if a packet enabling TF has been emitted in the job (V3D 4.x).
403 */
404 bool tf_enabled;
405
406 /**
407 * Current EZ state for drawing. Updated at the start of draw after
408 * we've decided on the shader being rendered.
409 */
410 enum v3d_ez_state ez_state;
411 /**
412 * The first EZ state that was used for drawing with a decided EZ
413 * direction (so either UNDECIDED, GT, or LT).
414 */
415 enum v3d_ez_state first_ez_state;
416
417 /**
418 * Number of draw calls (not counting full buffer clears) queued in
419 * the current job.
420 */
421 uint32_t draw_calls_queued;
422
423 /**
424 * Number of draw calls (not counting full buffer clears) queued in
425 * the current job during active transform feedback.
426 */
427 uint32_t tf_draw_calls_queued;
428
429 struct v3d_job_key key;
430 };
431
432 struct v3d_context {
433 struct pipe_context base;
434
435 int fd;
436 struct v3d_screen *screen;
437
438 /** The 3D rendering job for the currently bound FBO. */
439 struct v3d_job *job;
440
441 /* Map from struct v3d_job_key to the job for that FBO.
442 */
443 struct hash_table *jobs;
444
445 /**
446 * Map from v3d_resource to a job writing to that resource.
447 *
448 * Primarily for flushing jobs rendering to textures that are now
449 * being read from.
450 */
451 struct hash_table *write_jobs;
452
453 struct slab_child_pool transfer_pool;
454 struct blitter_context *blitter;
455
456 /** bitfield of VC5_DIRTY_* */
457 uint64_t dirty;
458
459 struct primconvert_context *primconvert;
460
461 uint32_t next_uncompiled_program_id;
462 uint64_t next_compiled_program_id;
463
464 struct v3d_compiler_state *compiler_state;
465
466 uint8_t prim_mode;
467
468 /** Maximum index buffer valid for the current shader_rec. */
469 uint32_t max_index;
470
471 /** Sync object that our RCL or TFU job will update as its out_sync. */
472 uint32_t out_sync;
473
474 /* Stream uploader used by gallium internals. This could also be used
475 * by driver internals, but we tend to use the v3d_cl.h interfaces
476 * instead.
477 */
478 struct u_upload_mgr *uploader;
479 /* State uploader used inside the driver. This is for packing bits of
480 * long-term state inside buffers, since the kernel interfaces
481 * allocate a page at a time.
482 */
483 struct u_upload_mgr *state_uploader;
484
485 /** @{ Current pipeline state objects */
486 struct pipe_scissor_state scissor;
487 struct v3d_blend_state *blend;
488 struct v3d_rasterizer_state *rasterizer;
489 struct v3d_depth_stencil_alpha_state *zsa;
490
491 struct v3d_program_stateobj prog;
492 uint32_t compute_num_workgroups[3];
493 struct v3d_bo *compute_shared_memory;
494
495 struct v3d_vertex_stateobj *vtx;
496
497 struct {
498 struct pipe_blend_color f;
499 uint16_t hf[4];
500 } blend_color;
501 struct pipe_stencil_ref stencil_ref;
502 unsigned sample_mask;
503 struct pipe_framebuffer_state framebuffer;
504
505 /* Per render target, whether we should swap the R and B fields in the
506 * shader's color output and in blending. If render targets disagree
507 * on the R/B swap and use the constant color, then we would need to
508 * fall back to in-shader blending.
509 */
510 uint8_t swap_color_rb;
511
512 /* Per render target, whether we should treat the dst alpha values as
513 * one in blending.
514 *
515 * For RGBX formats, the tile buffer's alpha channel will be
516 * undefined.
517 */
518 uint8_t blend_dst_alpha_one;
519
520 bool active_queries;
521
522 uint32_t tf_prims_generated;
523 uint32_t prims_generated;
524
525 struct pipe_poly_stipple stipple;
526 struct pipe_clip_state clip;
527 struct pipe_viewport_state viewport;
528 struct v3d_ssbo_stateobj ssbo[PIPE_SHADER_TYPES];
529 struct v3d_shaderimg_stateobj shaderimg[PIPE_SHADER_TYPES];
530 struct v3d_constbuf_stateobj constbuf[PIPE_SHADER_TYPES];
531 struct v3d_texture_stateobj tex[PIPE_SHADER_TYPES];
532 struct v3d_vertexbuf_stateobj vertexbuf;
533 struct v3d_streamout_stateobj streamout;
534 struct v3d_bo *current_oq;
535 struct pipe_resource *prim_counts;
536 uint32_t prim_counts_offset;
537 struct pipe_debug_callback debug;
538 /** @} */
539 };
540
541 struct v3d_rasterizer_state {
542 struct pipe_rasterizer_state base;
543
544 float point_size;
545
546 uint8_t depth_offset[9];
547 uint8_t depth_offset_z16[9];
548 };
549
550 struct v3d_depth_stencil_alpha_state {
551 struct pipe_depth_stencil_alpha_state base;
552
553 enum v3d_ez_state ez_state;
554
555 uint8_t stencil_front[6];
556 uint8_t stencil_back[6];
557 };
558
559 struct v3d_blend_state {
560 struct pipe_blend_state base;
561
562 /* Per-RT mask of whether blending is enabled. */
563 uint8_t blend_enables;
564 };
565
566 #define perf_debug(...) do { \
567 if (unlikely(V3D_DEBUG & V3D_DEBUG_PERF)) \
568 fprintf(stderr, __VA_ARGS__); \
569 if (unlikely(v3d->debug.debug_message)) \
570 pipe_debug_message(&v3d->debug, PERF_INFO, __VA_ARGS__); \
571 } while (0)
572
573 #define foreach_bit(b, mask) \
574 for (uint32_t _m = (mask), b; _m && ({(b) = u_bit_scan(&_m); 1;});)
575
576 static inline struct v3d_context *
577 v3d_context(struct pipe_context *pcontext)
578 {
579 return (struct v3d_context *)pcontext;
580 }
581
582 static inline struct v3d_sampler_view *
583 v3d_sampler_view(struct pipe_sampler_view *psview)
584 {
585 return (struct v3d_sampler_view *)psview;
586 }
587
588 static inline struct v3d_sampler_state *
589 v3d_sampler_state(struct pipe_sampler_state *psampler)
590 {
591 return (struct v3d_sampler_state *)psampler;
592 }
593
594 static inline struct v3d_stream_output_target *
595 v3d_stream_output_target(struct pipe_stream_output_target *ptarget)
596 {
597 return (struct v3d_stream_output_target *)ptarget;
598 }
599
600 static inline uint32_t
601 v3d_stream_output_target_get_vertex_count(struct pipe_stream_output_target *ptarget)
602 {
603 return v3d_stream_output_target(ptarget)->recorded_vertex_count;
604 }
605
606 struct pipe_context *v3d_context_create(struct pipe_screen *pscreen,
607 void *priv, unsigned flags);
608 void v3d_program_init(struct pipe_context *pctx);
609 void v3d_program_fini(struct pipe_context *pctx);
610 void v3d_query_init(struct pipe_context *pctx);
611
612 void v3d_simulator_init(struct v3d_screen *screen);
613 void v3d_simulator_destroy(struct v3d_screen *screen);
614 uint32_t v3d_simulator_get_spill(uint32_t spill_size);
615 int v3d_simulator_ioctl(int fd, unsigned long request, void *arg);
616 void v3d_simulator_open_from_handle(int fd, int handle, uint32_t size);
617
618 static inline int
619 v3d_ioctl(int fd, unsigned long request, void *arg)
620 {
621 if (using_v3d_simulator)
622 return v3d_simulator_ioctl(fd, request, arg);
623 else
624 return drmIoctl(fd, request, arg);
625 }
626
627 static inline bool
628 v3d_transform_feedback_enabled(struct v3d_context *v3d)
629 {
630 return (v3d->prog.bind_vs->num_tf_specs != 0 ||
631 (v3d->prog.bind_gs && v3d->prog.bind_gs->num_tf_specs != 0)) &&
632 v3d->active_queries;
633 }
634
635 void v3d_set_shader_uniform_dirty_flags(struct v3d_compiled_shader *shader);
636 struct v3d_cl_reloc v3d_write_uniforms(struct v3d_context *v3d,
637 struct v3d_job *job,
638 struct v3d_compiled_shader *shader,
639 enum pipe_shader_type stage);
640
641 void v3d_flush(struct pipe_context *pctx);
642 void v3d_job_init(struct v3d_context *v3d);
643 struct v3d_job *v3d_job_create(struct v3d_context *v3d);
644 void v3d_job_free(struct v3d_context *v3d, struct v3d_job *job);
645 struct v3d_job *v3d_get_job(struct v3d_context *v3d,
646 struct pipe_surface **cbufs,
647 struct pipe_surface *zsbuf);
648 struct v3d_job *v3d_get_job_for_fbo(struct v3d_context *v3d);
649 void v3d_job_add_bo(struct v3d_job *job, struct v3d_bo *bo);
650 void v3d_job_add_write_resource(struct v3d_job *job, struct pipe_resource *prsc);
651 void v3d_job_add_tf_write_resource(struct v3d_job *job, struct pipe_resource *prsc);
652 void v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job);
653 void v3d_flush_jobs_using_bo(struct v3d_context *v3d, struct v3d_bo *bo);
654 void v3d_flush_jobs_writing_resource(struct v3d_context *v3d,
655 struct pipe_resource *prsc,
656 enum v3d_flush_cond flush_cond);
657 void v3d_flush_jobs_reading_resource(struct v3d_context *v3d,
658 struct pipe_resource *prsc,
659 enum v3d_flush_cond flush_cond);
660 void v3d_update_compiled_shaders(struct v3d_context *v3d, uint8_t prim_mode);
661 void v3d_update_compiled_cs(struct v3d_context *v3d);
662
663 bool v3d_rt_format_supported(const struct v3d_device_info *devinfo,
664 enum pipe_format f);
665 bool v3d_tex_format_supported(const struct v3d_device_info *devinfo,
666 enum pipe_format f);
667 uint8_t v3d_get_rt_format(const struct v3d_device_info *devinfo, enum pipe_format f);
668 uint8_t v3d_get_tex_format(const struct v3d_device_info *devinfo, enum pipe_format f);
669 uint8_t v3d_get_tex_return_size(const struct v3d_device_info *devinfo,
670 enum pipe_format f,
671 enum pipe_tex_compare compare);
672 uint8_t v3d_get_tex_return_channels(const struct v3d_device_info *devinfo,
673 enum pipe_format f);
674 const uint8_t *v3d_get_format_swizzle(const struct v3d_device_info *devinfo,
675 enum pipe_format f);
676 void v3d_get_internal_type_bpp_for_output_format(const struct v3d_device_info *devinfo,
677 uint32_t format,
678 uint32_t *type,
679 uint32_t *bpp);
680 bool v3d_tfu_supports_tex_format(const struct v3d_device_info *devinfo,
681 uint32_t tex_format);
682
683 void v3d_init_query_functions(struct v3d_context *v3d);
684 void v3d_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info);
685 void v3d_blitter_save(struct v3d_context *v3d);
686 bool v3d_generate_mipmap(struct pipe_context *pctx,
687 struct pipe_resource *prsc,
688 enum pipe_format format,
689 unsigned int base_level,
690 unsigned int last_level,
691 unsigned int first_layer,
692 unsigned int last_layer);
693
694 struct v3d_fence *v3d_fence_create(struct v3d_context *v3d);
695
696 void v3d_tf_update_counters(struct v3d_context *v3d);
697
698 #ifdef v3dX
699 # include "v3dx_context.h"
700 #else
701 # define v3dX(x) v3d33_##x
702 # include "v3dx_context.h"
703 # undef v3dX
704
705 # define v3dX(x) v3d41_##x
706 # include "v3dx_context.h"
707 # undef v3dX
708 #endif
709
710 #endif /* VC5_CONTEXT_H */