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