2 * Copyright (C) 2019 Alyssa Rosenzweig
3 * Copyright (C) 2014-2017 Broadcom
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:
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
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 FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 #include "drm-uapi/panfrost_drm.h"
31 #include "pan_context.h"
32 #include "util/hash_table.h"
33 #include "util/ralloc.h"
34 #include "util/format/u_format.h"
35 #include "util/u_pack_color.h"
36 #include "util/rounding.h"
38 #include "pan_blending.h"
40 #include "panfrost-quirks.h"
42 /* panfrost_bo_access is here to help us keep track of batch accesses to BOs
43 * and build a proper dependency graph such that batches can be pipelined for
44 * better GPU utilization.
46 * Each accessed BO has a corresponding entry in the ->accessed_bos hash table.
47 * A BO is either being written or read at any time (see if writer != NULL).
48 * When the last access is a write, the batch writing the BO might have read
49 * dependencies (readers that have not been executed yet and want to read the
50 * previous BO content), and when the last access is a read, all readers might
51 * depend on another batch to push its results to memory. That's what the
52 * readers/writers keep track off.
53 * There can only be one writer at any given time, if a new batch wants to
54 * write to the same BO, a dependency will be added between the new writer and
55 * the old writer (at the batch level), and panfrost_bo_access->writer will be
56 * updated to point to the new writer.
58 struct panfrost_bo_access
{
59 struct util_dynarray readers
;
60 struct panfrost_batch_fence
*writer
;
63 static struct panfrost_batch_fence
*
64 panfrost_create_batch_fence(struct panfrost_batch
*batch
)
66 struct panfrost_batch_fence
*fence
;
68 fence
= rzalloc(NULL
, struct panfrost_batch_fence
);
70 pipe_reference_init(&fence
->reference
, 1);
77 panfrost_free_batch_fence(struct panfrost_batch_fence
*fence
)
83 panfrost_batch_fence_unreference(struct panfrost_batch_fence
*fence
)
85 if (pipe_reference(&fence
->reference
, NULL
))
86 panfrost_free_batch_fence(fence
);
90 panfrost_batch_fence_reference(struct panfrost_batch_fence
*fence
)
92 pipe_reference(NULL
, &fence
->reference
);
95 static struct panfrost_batch
*
96 panfrost_create_batch(struct panfrost_context
*ctx
,
97 const struct pipe_framebuffer_state
*key
)
99 struct panfrost_batch
*batch
= rzalloc(ctx
, struct panfrost_batch
);
103 batch
->bos
= _mesa_hash_table_create(batch
, _mesa_hash_pointer
,
104 _mesa_key_pointer_equal
);
106 batch
->minx
= batch
->miny
= ~0;
107 batch
->maxx
= batch
->maxy
= 0;
109 batch
->out_sync
= panfrost_create_batch_fence(batch
);
110 util_copy_framebuffer_state(&batch
->key
, key
);
112 batch
->pool
= panfrost_create_pool(batch
, pan_device(ctx
->base
.screen
));
118 panfrost_freeze_batch(struct panfrost_batch
*batch
)
120 struct panfrost_context
*ctx
= batch
->ctx
;
121 struct hash_entry
*entry
;
123 /* Remove the entry in the FBO -> batch hash table if the batch
124 * matches. This way, next draws/clears targeting this FBO will trigger
125 * the creation of a new batch.
127 entry
= _mesa_hash_table_search(ctx
->batches
, &batch
->key
);
128 if (entry
&& entry
->data
== batch
)
129 _mesa_hash_table_remove(ctx
->batches
, entry
);
131 /* If this is the bound batch, the panfrost_context parameters are
132 * relevant so submitting it invalidates those parameters, but if it's
133 * not bound, the context parameters are for some other batch so we
134 * can't invalidate them.
136 if (ctx
->batch
== batch
) {
137 panfrost_invalidate_frame(ctx
);
142 #ifdef PAN_BATCH_DEBUG
143 static bool panfrost_batch_is_frozen(struct panfrost_batch
*batch
)
145 struct panfrost_context
*ctx
= batch
->ctx
;
146 struct hash_entry
*entry
;
148 entry
= _mesa_hash_table_search(ctx
->batches
, &batch
->key
);
149 if (entry
&& entry
->data
== batch
)
152 if (ctx
->batch
== batch
)
160 panfrost_free_batch(struct panfrost_batch
*batch
)
165 #ifdef PAN_BATCH_DEBUG
166 assert(panfrost_batch_is_frozen(batch
));
169 hash_table_foreach(batch
->bos
, entry
)
170 panfrost_bo_unreference((struct panfrost_bo
*)entry
->key
);
172 hash_table_foreach(batch
->pool
.bos
, entry
)
173 panfrost_bo_unreference((struct panfrost_bo
*)entry
->key
);
175 util_dynarray_foreach(&batch
->dependencies
,
176 struct panfrost_batch_fence
*, dep
) {
177 panfrost_batch_fence_unreference(*dep
);
180 /* The out_sync fence lifetime is different from the the batch one
181 * since other batches might want to wait on a fence of already
182 * submitted/signaled batch. All we need to do here is make sure the
183 * fence does not point to an invalid batch, which the core will
184 * interpret as 'batch is already submitted'.
186 batch
->out_sync
->batch
= NULL
;
187 panfrost_batch_fence_unreference(batch
->out_sync
);
189 util_unreference_framebuffer_state(&batch
->key
);
193 #ifdef PAN_BATCH_DEBUG
195 panfrost_dep_graph_contains_batch(struct panfrost_batch
*root
,
196 struct panfrost_batch
*batch
)
201 util_dynarray_foreach(&root
->dependencies
,
202 struct panfrost_batch_fence
*, dep
) {
203 if ((*dep
)->batch
== batch
||
204 panfrost_dep_graph_contains_batch((*dep
)->batch
, batch
))
213 panfrost_batch_add_dep(struct panfrost_batch
*batch
,
214 struct panfrost_batch_fence
*newdep
)
216 if (batch
== newdep
->batch
)
219 /* We might want to turn ->dependencies into a set if the number of
220 * deps turns out to be big enough to make this 'is dep already there'
221 * search inefficient.
223 util_dynarray_foreach(&batch
->dependencies
,
224 struct panfrost_batch_fence
*, dep
) {
229 #ifdef PAN_BATCH_DEBUG
230 /* Make sure the dependency graph is acyclic. */
231 assert(!panfrost_dep_graph_contains_batch(newdep
->batch
, batch
));
234 panfrost_batch_fence_reference(newdep
);
235 util_dynarray_append(&batch
->dependencies
,
236 struct panfrost_batch_fence
*, newdep
);
238 /* We now have a batch depending on us, let's make sure new draw/clear
239 * calls targeting the same FBO use a new batch object.
242 panfrost_freeze_batch(newdep
->batch
);
245 static struct panfrost_batch
*
246 panfrost_get_batch(struct panfrost_context
*ctx
,
247 const struct pipe_framebuffer_state
*key
)
249 /* Lookup the job first */
250 struct hash_entry
*entry
= _mesa_hash_table_search(ctx
->batches
, key
);
255 /* Otherwise, let's create a job */
257 struct panfrost_batch
*batch
= panfrost_create_batch(ctx
, key
);
259 /* Save the created job */
260 _mesa_hash_table_insert(ctx
->batches
, &batch
->key
, batch
);
265 /* Get the job corresponding to the FBO we're currently rendering into */
267 struct panfrost_batch
*
268 panfrost_get_batch_for_fbo(struct panfrost_context
*ctx
)
270 /* If we're wallpapering, we special case to workaround
273 if (ctx
->wallpaper_batch
)
274 return ctx
->wallpaper_batch
;
276 /* If we already began rendering, use that */
279 assert(util_framebuffer_state_equal(&ctx
->batch
->key
,
280 &ctx
->pipe_framebuffer
));
284 /* If not, look up the job */
285 struct panfrost_batch
*batch
= panfrost_get_batch(ctx
,
286 &ctx
->pipe_framebuffer
);
288 /* Set this job as the current FBO job. Will be reset when updating the
289 * FB state and when submitting or releasing a job.
295 struct panfrost_batch
*
296 panfrost_get_fresh_batch_for_fbo(struct panfrost_context
*ctx
)
298 struct panfrost_batch
*batch
;
300 batch
= panfrost_get_batch(ctx
, &ctx
->pipe_framebuffer
);
302 /* The batch has no draw/clear queued, let's return it directly.
303 * Note that it's perfectly fine to re-use a batch with an
304 * existing clear, we'll just update it with the new clear request.
306 if (!batch
->scoreboard
.first_job
)
309 /* Otherwise, we need to freeze the existing one and instantiate a new
312 panfrost_freeze_batch(batch
);
313 return panfrost_get_batch(ctx
, &ctx
->pipe_framebuffer
);
317 panfrost_bo_access_gc_fences(struct panfrost_context
*ctx
,
318 struct panfrost_bo_access
*access
,
319 const struct panfrost_bo
*bo
)
321 if (access
->writer
) {
322 panfrost_batch_fence_unreference(access
->writer
);
323 access
->writer
= NULL
;
326 struct panfrost_batch_fence
**readers_array
= util_dynarray_begin(&access
->readers
);
327 struct panfrost_batch_fence
**new_readers
= readers_array
;
329 util_dynarray_foreach(&access
->readers
, struct panfrost_batch_fence
*,
334 panfrost_batch_fence_unreference(*reader
);
338 if (!util_dynarray_resize(&access
->readers
, struct panfrost_batch_fence
*,
339 new_readers
- readers_array
) &&
340 new_readers
!= readers_array
)
341 unreachable("Invalid dynarray access->readers");
344 /* Collect signaled fences to keep the kernel-side syncobj-map small. The
345 * idea is to collect those signaled fences at the end of each flush_all
346 * call. This function is likely to collect only fences from previous
347 * batch flushes not the one that have just have just been submitted and
348 * are probably still in flight when we trigger the garbage collection.
349 * Anyway, we need to do this garbage collection at some point if we don't
350 * want the BO access map to keep invalid entries around and retain
354 panfrost_gc_fences(struct panfrost_context
*ctx
)
356 hash_table_foreach(ctx
->accessed_bos
, entry
) {
357 struct panfrost_bo_access
*access
= entry
->data
;
360 panfrost_bo_access_gc_fences(ctx
, access
, entry
->key
);
361 if (!util_dynarray_num_elements(&access
->readers
,
362 struct panfrost_batch_fence
*) &&
365 _mesa_hash_table_remove(ctx
->accessed_bos
, entry
);
370 #ifdef PAN_BATCH_DEBUG
372 panfrost_batch_in_readers(struct panfrost_batch
*batch
,
373 struct panfrost_bo_access
*access
)
375 util_dynarray_foreach(&access
->readers
, struct panfrost_batch_fence
*,
377 if (*reader
&& (*reader
)->batch
== batch
)
386 panfrost_batch_update_bo_access(struct panfrost_batch
*batch
,
387 struct panfrost_bo
*bo
, bool writes
,
388 bool already_accessed
)
390 struct panfrost_context
*ctx
= batch
->ctx
;
391 struct panfrost_bo_access
*access
;
392 bool old_writes
= false;
393 struct hash_entry
*entry
;
395 entry
= _mesa_hash_table_search(ctx
->accessed_bos
, bo
);
396 access
= entry
? entry
->data
: NULL
;
398 old_writes
= access
->writer
!= NULL
;
400 access
= rzalloc(ctx
, struct panfrost_bo_access
);
401 util_dynarray_init(&access
->readers
, access
);
402 _mesa_hash_table_insert(ctx
->accessed_bos
, bo
, access
);
403 /* We are the first to access this BO, let's initialize
404 * old_writes to our own access type in that case.
411 if (writes
&& !old_writes
) {
412 /* Previous access was a read and we want to write this BO.
413 * We first need to add explicit deps between our batch and
414 * the previous readers.
416 util_dynarray_foreach(&access
->readers
,
417 struct panfrost_batch_fence
*, reader
) {
418 /* We were already reading the BO, no need to add a dep
419 * on ourself (the acyclic check would complain about
422 if (!(*reader
) || (*reader
)->batch
== batch
)
425 panfrost_batch_add_dep(batch
, *reader
);
427 panfrost_batch_fence_reference(batch
->out_sync
);
430 panfrost_batch_fence_unreference(access
->writer
);
432 /* We now are the new writer. */
433 access
->writer
= batch
->out_sync
;
435 /* Release the previous readers and reset the readers array. */
436 util_dynarray_foreach(&access
->readers
,
437 struct panfrost_batch_fence
*,
441 panfrost_batch_fence_unreference(*reader
);
444 util_dynarray_clear(&access
->readers
);
445 } else if (writes
&& old_writes
) {
446 /* First check if we were the previous writer, in that case
447 * there's nothing to do. Otherwise we need to add a
448 * dependency between the new writer and the old one.
450 if (access
->writer
!= batch
->out_sync
) {
451 if (access
->writer
) {
452 panfrost_batch_add_dep(batch
, access
->writer
);
453 panfrost_batch_fence_unreference(access
->writer
);
455 panfrost_batch_fence_reference(batch
->out_sync
);
456 access
->writer
= batch
->out_sync
;
458 } else if (!writes
&& old_writes
) {
459 /* First check if we were the previous writer, in that case
460 * we want to keep the access type unchanged, as a write is
461 * more constraining than a read.
463 if (access
->writer
!= batch
->out_sync
) {
464 /* Add a dependency on the previous writer. */
465 panfrost_batch_add_dep(batch
, access
->writer
);
467 /* The previous access was a write, there's no reason
468 * to have entries in the readers array.
470 assert(!util_dynarray_num_elements(&access
->readers
,
471 struct panfrost_batch_fence
*));
473 /* Add ourselves to the readers array. */
474 panfrost_batch_fence_reference(batch
->out_sync
);
475 util_dynarray_append(&access
->readers
,
476 struct panfrost_batch_fence
*,
478 access
->writer
= NULL
;
481 /* We already accessed this BO before, so we should already be
482 * in the reader array.
484 #ifdef PAN_BATCH_DEBUG
485 if (already_accessed
) {
486 assert(panfrost_batch_in_readers(batch
, access
));
491 /* Previous access was a read and we want to read this BO.
492 * Add ourselves to the readers array and add a dependency on
493 * the previous writer if any.
495 panfrost_batch_fence_reference(batch
->out_sync
);
496 util_dynarray_append(&access
->readers
,
497 struct panfrost_batch_fence
*,
501 panfrost_batch_add_dep(batch
, access
->writer
);
506 panfrost_batch_add_bo(struct panfrost_batch
*batch
, struct panfrost_bo
*bo
,
512 struct hash_entry
*entry
;
513 uint32_t old_flags
= 0;
515 entry
= _mesa_hash_table_search(batch
->bos
, bo
);
517 entry
= _mesa_hash_table_insert(batch
->bos
, bo
,
518 (void *)(uintptr_t)flags
);
519 panfrost_bo_reference(bo
);
521 old_flags
= (uintptr_t)entry
->data
;
523 /* All batches have to agree on the shared flag. */
524 assert((old_flags
& PAN_BO_ACCESS_SHARED
) ==
525 (flags
& PAN_BO_ACCESS_SHARED
));
530 if (old_flags
== flags
)
534 entry
->data
= (void *)(uintptr_t)flags
;
536 /* If this is not a shared BO, we don't really care about dependency
539 if (!(flags
& PAN_BO_ACCESS_SHARED
))
542 /* All dependencies should have been flushed before we execute the
543 * wallpaper draw, so it should be harmless to skip the
544 * update_bo_access() call.
546 if (batch
== batch
->ctx
->wallpaper_batch
)
549 assert(flags
& PAN_BO_ACCESS_RW
);
550 panfrost_batch_update_bo_access(batch
, bo
, flags
& PAN_BO_ACCESS_WRITE
,
555 panfrost_batch_add_resource_bos(struct panfrost_batch
*batch
,
556 struct panfrost_resource
*rsrc
,
559 panfrost_batch_add_bo(batch
, rsrc
->bo
, flags
);
561 for (unsigned i
= 0; i
< MAX_MIP_LEVELS
; i
++)
562 if (rsrc
->slices
[i
].checksum_bo
)
563 panfrost_batch_add_bo(batch
, rsrc
->slices
[i
].checksum_bo
, flags
);
565 if (rsrc
->separate_stencil
)
566 panfrost_batch_add_bo(batch
, rsrc
->separate_stencil
->bo
, flags
);
569 void panfrost_batch_add_fbo_bos(struct panfrost_batch
*batch
)
571 uint32_t flags
= PAN_BO_ACCESS_SHARED
| PAN_BO_ACCESS_WRITE
|
572 PAN_BO_ACCESS_VERTEX_TILER
|
573 PAN_BO_ACCESS_FRAGMENT
;
575 for (unsigned i
= 0; i
< batch
->key
.nr_cbufs
; ++i
) {
576 struct panfrost_resource
*rsrc
= pan_resource(batch
->key
.cbufs
[i
]->texture
);
577 panfrost_batch_add_resource_bos(batch
, rsrc
, flags
);
580 if (batch
->key
.zsbuf
) {
581 struct panfrost_resource
*rsrc
= pan_resource(batch
->key
.zsbuf
->texture
);
582 panfrost_batch_add_resource_bos(batch
, rsrc
, flags
);
587 panfrost_batch_create_bo(struct panfrost_batch
*batch
, size_t size
,
588 uint32_t create_flags
, uint32_t access_flags
)
590 struct panfrost_bo
*bo
;
592 bo
= panfrost_bo_create(pan_device(batch
->ctx
->base
.screen
), size
,
594 panfrost_batch_add_bo(batch
, bo
, access_flags
);
596 /* panfrost_batch_add_bo() has retained a reference and
597 * panfrost_bo_create() initialize the refcnt to 1, so let's
598 * unreference the BO here so it gets released when the batch is
599 * destroyed (unless it's retained by someone else in the meantime).
601 panfrost_bo_unreference(bo
);
605 /* Returns the polygon list's GPU address if available, or otherwise allocates
606 * the polygon list. It's perfectly fast to use allocate/free BO directly,
607 * since we'll hit the BO cache and this is one-per-batch anyway. */
610 panfrost_batch_get_polygon_list(struct panfrost_batch
*batch
, unsigned size
)
612 if (batch
->polygon_list
) {
613 assert(batch
->polygon_list
->size
>= size
);
615 /* Create the BO as invisible, as there's no reason to map */
616 size
= util_next_power_of_two(size
);
618 batch
->polygon_list
= panfrost_batch_create_bo(batch
, size
,
620 PAN_BO_ACCESS_PRIVATE
|
622 PAN_BO_ACCESS_VERTEX_TILER
|
623 PAN_BO_ACCESS_FRAGMENT
);
626 return batch
->polygon_list
->gpu
;
630 panfrost_batch_get_scratchpad(struct panfrost_batch
*batch
,
632 unsigned thread_tls_alloc
,
635 unsigned size
= panfrost_get_total_stack_size(shift
,
639 if (batch
->scratchpad
) {
640 assert(batch
->scratchpad
->size
>= size
);
642 batch
->scratchpad
= panfrost_batch_create_bo(batch
, size
,
644 PAN_BO_ACCESS_PRIVATE
|
646 PAN_BO_ACCESS_VERTEX_TILER
|
647 PAN_BO_ACCESS_FRAGMENT
);
650 return batch
->scratchpad
;
654 panfrost_batch_get_shared_memory(struct panfrost_batch
*batch
,
656 unsigned workgroup_count
)
658 if (batch
->shared_memory
) {
659 assert(batch
->shared_memory
->size
>= size
);
661 batch
->shared_memory
= panfrost_batch_create_bo(batch
, size
,
663 PAN_BO_ACCESS_PRIVATE
|
665 PAN_BO_ACCESS_VERTEX_TILER
);
668 return batch
->shared_memory
;
672 panfrost_batch_get_tiler_heap(struct panfrost_batch
*batch
)
674 if (batch
->tiler_heap
)
675 return batch
->tiler_heap
;
677 batch
->tiler_heap
= panfrost_batch_create_bo(batch
, 4096 * 4096,
680 PAN_BO_ACCESS_PRIVATE
|
682 PAN_BO_ACCESS_VERTEX_TILER
|
683 PAN_BO_ACCESS_FRAGMENT
);
684 assert(batch
->tiler_heap
);
685 return batch
->tiler_heap
;
689 panfrost_batch_get_tiler_meta(struct panfrost_batch
*batch
, unsigned vertex_count
)
694 if (batch
->tiler_meta
)
695 return batch
->tiler_meta
;
697 struct panfrost_bo
*tiler_heap
;
698 tiler_heap
= panfrost_batch_get_tiler_heap(batch
);
700 struct bifrost_tiler_heap_meta tiler_heap_meta
= {
701 .heap_size
= tiler_heap
->size
,
702 .tiler_heap_start
= tiler_heap
->gpu
,
703 .tiler_heap_free
= tiler_heap
->gpu
,
704 .tiler_heap_end
= tiler_heap
->gpu
+ tiler_heap
->size
,
706 .unk7e007e
= 0x7e007e,
709 struct bifrost_tiler_meta tiler_meta
= {
710 .hierarchy_mask
= 0x28,
712 .width
= MALI_POSITIVE(batch
->key
.width
),
713 .height
= MALI_POSITIVE(batch
->key
.height
),
714 .tiler_heap_meta
= panfrost_pool_upload(&batch
->pool
, &tiler_heap_meta
, sizeof(tiler_heap_meta
)),
717 batch
->tiler_meta
= panfrost_pool_upload(&batch
->pool
, &tiler_meta
, sizeof(tiler_meta
));
718 return batch
->tiler_meta
;
722 panfrost_batch_get_tiler_dummy(struct panfrost_batch
*batch
)
724 struct panfrost_device
*dev
= pan_device(batch
->ctx
->base
.screen
);
726 uint32_t create_flags
= 0;
728 if (batch
->tiler_dummy
)
729 return batch
->tiler_dummy
;
731 if (!(dev
->quirks
& MIDGARD_NO_HIER_TILING
))
732 create_flags
= PAN_BO_INVISIBLE
;
734 batch
->tiler_dummy
= panfrost_batch_create_bo(batch
, 4096,
736 PAN_BO_ACCESS_PRIVATE
|
738 PAN_BO_ACCESS_VERTEX_TILER
|
739 PAN_BO_ACCESS_FRAGMENT
);
740 assert(batch
->tiler_dummy
);
741 return batch
->tiler_dummy
;
745 panfrost_batch_reserve_framebuffer(struct panfrost_batch
*batch
)
747 struct panfrost_device
*dev
= pan_device(batch
->ctx
->base
.screen
);
749 /* If we haven't, reserve space for the framebuffer */
751 if (!batch
->framebuffer
.gpu
) {
752 unsigned size
= (dev
->quirks
& MIDGARD_SFBD
) ?
753 sizeof(struct mali_single_framebuffer
) :
754 sizeof(struct mali_framebuffer
);
756 batch
->framebuffer
= panfrost_pool_alloc(&batch
->pool
, size
);
758 /* Tag the pointer */
759 if (!(dev
->quirks
& MIDGARD_SFBD
))
760 batch
->framebuffer
.gpu
|= MALI_MFBD
;
763 return batch
->framebuffer
.gpu
;
769 panfrost_load_surface(struct panfrost_batch
*batch
, struct pipe_surface
*surf
, unsigned loc
)
774 struct panfrost_resource
*rsrc
= pan_resource(surf
->texture
);
775 unsigned level
= surf
->u
.tex
.level
;
777 if (!rsrc
->slices
[level
].initialized
)
780 if (!rsrc
->damage
.inverted_len
)
783 /* Clamp the rendering area to the damage extent. The
784 * KHR_partial_update() spec states that trying to render outside of
785 * the damage region is "undefined behavior", so we should be safe.
787 unsigned damage_width
= (rsrc
->damage
.extent
.maxx
- rsrc
->damage
.extent
.minx
);
788 unsigned damage_height
= (rsrc
->damage
.extent
.maxy
- rsrc
->damage
.extent
.miny
);
790 if (damage_width
&& damage_height
) {
791 panfrost_batch_intersection_scissor(batch
,
792 rsrc
->damage
.extent
.minx
,
793 rsrc
->damage
.extent
.miny
,
794 rsrc
->damage
.extent
.maxx
,
795 rsrc
->damage
.extent
.maxy
);
798 /* XXX: Native blits on Bifrost */
799 if (batch
->pool
.dev
->quirks
& IS_BIFROST
) {
800 if (loc
!= FRAG_RESULT_DATA0
)
803 /* XXX: why align on *twice* the tile length? */
804 batch
->minx
= batch
->minx
& ~((MALI_TILE_LENGTH
* 2) - 1);
805 batch
->miny
= batch
->miny
& ~((MALI_TILE_LENGTH
* 2) - 1);
806 batch
->maxx
= MIN2(ALIGN_POT(batch
->maxx
, MALI_TILE_LENGTH
* 2),
808 batch
->maxy
= MIN2(ALIGN_POT(batch
->maxy
, MALI_TILE_LENGTH
* 2),
811 struct pipe_box rect
;
812 batch
->ctx
->wallpaper_batch
= batch
;
813 u_box_2d(batch
->minx
, batch
->miny
, batch
->maxx
- batch
->minx
,
814 batch
->maxy
- batch
->miny
, &rect
);
815 panfrost_blit_wallpaper(batch
->ctx
, &rect
);
816 batch
->ctx
->wallpaper_batch
= NULL
;
820 enum pipe_format format
= rsrc
->base
.format
;
822 if (loc
== FRAG_RESULT_DEPTH
) {
823 if (!util_format_has_depth(util_format_description(format
)))
826 format
= util_format_get_depth_only(format
);
827 } else if (loc
== FRAG_RESULT_STENCIL
) {
828 if (!util_format_has_stencil(util_format_description(format
)))
831 if (rsrc
->separate_stencil
) {
832 rsrc
= rsrc
->separate_stencil
;
833 format
= rsrc
->base
.format
;
836 format
= util_format_stencil_only(format
);
839 enum mali_texture_type type
=
840 panfrost_translate_texture_type(rsrc
->base
.target
);
842 struct pan_image img
= {
843 .width0
= rsrc
->base
.width0
,
844 .height0
= rsrc
->base
.height0
,
845 .depth0
= rsrc
->base
.depth0
,
848 .layout
= rsrc
->layout
,
849 .array_size
= rsrc
->base
.array_size
,
850 .first_level
= level
,
852 .first_layer
= surf
->u
.tex
.first_layer
,
853 .last_layer
= surf
->u
.tex
.last_layer
,
854 .nr_samples
= rsrc
->base
.nr_samples
,
855 .cubemap_stride
= rsrc
->cubemap_stride
,
857 .slices
= rsrc
->slices
860 mali_ptr blend_shader
= 0;
862 if (loc
>= FRAG_RESULT_DATA0
&& !panfrost_can_fixed_blend(rsrc
->base
.format
)) {
863 struct panfrost_blend_shader
*b
=
864 panfrost_get_blend_shader(batch
->ctx
, &batch
->ctx
->blit_blend
, rsrc
->base
.format
, loc
- FRAG_RESULT_DATA0
);
866 struct panfrost_bo
*bo
= panfrost_batch_create_bo(batch
, b
->size
,
868 PAN_BO_ACCESS_PRIVATE
|
870 PAN_BO_ACCESS_FRAGMENT
);
872 memcpy(bo
->cpu
, b
->buffer
, b
->size
);
873 assert(b
->work_count
<= 4);
875 blend_shader
= bo
->gpu
| b
->first_tag
;
878 struct panfrost_transfer transfer
= panfrost_pool_alloc(&batch
->pool
,
879 4 * 4 * 6 * rsrc
->damage
.inverted_len
);
881 for (unsigned i
= 0; i
< rsrc
->damage
.inverted_len
; ++i
) {
882 float *o
= (float *) (transfer
.cpu
+ (4 * 4 * 6 * i
));
883 struct pan_rect r
= rsrc
->damage
.inverted_rects
[i
];
886 r
.minx
, rsrc
->base
.height0
- r
.miny
, 0.0, 1.0,
887 r
.maxx
, rsrc
->base
.height0
- r
.miny
, 0.0, 1.0,
888 r
.minx
, rsrc
->base
.height0
- r
.maxy
, 0.0, 1.0,
890 r
.maxx
, rsrc
->base
.height0
- r
.miny
, 0.0, 1.0,
891 r
.minx
, rsrc
->base
.height0
- r
.maxy
, 0.0, 1.0,
892 r
.maxx
, rsrc
->base
.height0
- r
.maxy
, 0.0, 1.0,
895 assert(sizeof(rect
) == 4 * 4 * 6);
896 memcpy(o
, rect
, sizeof(rect
));
899 panfrost_load_midg(&batch
->pool
, &batch
->scoreboard
,
901 batch
->framebuffer
.gpu
, transfer
.gpu
,
902 rsrc
->damage
.inverted_len
* 6,
905 panfrost_batch_add_bo(batch
, batch
->pool
.dev
->blit_shaders
.bo
,
906 PAN_BO_ACCESS_SHARED
| PAN_BO_ACCESS_READ
| PAN_BO_ACCESS_FRAGMENT
);
910 panfrost_batch_draw_wallpaper(struct panfrost_batch
*batch
)
912 panfrost_batch_reserve_framebuffer(batch
);
914 /* Assume combined. If either depth or stencil is written, they will
915 * both be written so we need to be careful for reloading */
917 unsigned draws
= batch
->draws
;
919 if (draws
& PIPE_CLEAR_DEPTHSTENCIL
)
920 draws
|= PIPE_CLEAR_DEPTHSTENCIL
;
922 /* Mask of buffers which need reload since they are not cleared and
923 * they are drawn. (If they are cleared, reload is useless; if they are
924 * not drawn and also not cleared, we can generally omit the attachment
925 * at the framebuffer descriptor level */
927 unsigned reload
= ~batch
->clear
& draws
;
929 for (unsigned i
= 0; i
< batch
->key
.nr_cbufs
; ++i
) {
930 if (reload
& (PIPE_CLEAR_COLOR0
<< i
))
931 panfrost_load_surface(batch
, batch
->key
.cbufs
[i
], FRAG_RESULT_DATA0
+ i
);
934 if (reload
& PIPE_CLEAR_DEPTH
)
935 panfrost_load_surface(batch
, batch
->key
.zsbuf
, FRAG_RESULT_DEPTH
);
937 if (reload
& PIPE_CLEAR_STENCIL
)
938 panfrost_load_surface(batch
, batch
->key
.zsbuf
, FRAG_RESULT_STENCIL
);
942 panfrost_batch_record_bo(struct hash_entry
*entry
, unsigned *bo_handles
, unsigned idx
)
944 struct panfrost_bo
*bo
= (struct panfrost_bo
*)entry
->key
;
945 uint32_t flags
= (uintptr_t)entry
->data
;
947 assert(bo
->gem_handle
> 0);
948 bo_handles
[idx
] = bo
->gem_handle
;
950 /* Update the BO access flags so that panfrost_bo_wait() knows
951 * about all pending accesses.
952 * We only keep the READ/WRITE info since this is all the BO
953 * wait logic cares about.
954 * We also preserve existing flags as this batch might not
955 * be the first one to access the BO.
957 bo
->gpu_access
|= flags
& (PAN_BO_ACCESS_RW
);
961 panfrost_batch_submit_ioctl(struct panfrost_batch
*batch
,
962 mali_ptr first_job_desc
,
966 struct panfrost_context
*ctx
= batch
->ctx
;
967 struct pipe_context
*gallium
= (struct pipe_context
*) ctx
;
968 struct panfrost_device
*dev
= pan_device(gallium
->screen
);
969 struct drm_panfrost_submit submit
= {0,};
970 uint32_t *bo_handles
;
973 /* If we trace, we always need a syncobj, so make one of our own if we
974 * weren't given one to use. Remember that we did so, so we can free it
975 * after we're done but preventing double-frees if we were given a
978 bool our_sync
= false;
980 if (!out_sync
&& dev
->debug
& (PAN_DBG_TRACE
| PAN_DBG_SYNC
)) {
981 drmSyncobjCreate(dev
->fd
, 0, &out_sync
);
985 submit
.out_sync
= out_sync
;
986 submit
.jc
= first_job_desc
;
987 submit
.requirements
= reqs
;
989 bo_handles
= calloc(batch
->pool
.bos
->entries
+ batch
->bos
->entries
, sizeof(*bo_handles
));
992 hash_table_foreach(batch
->bos
, entry
)
993 panfrost_batch_record_bo(entry
, bo_handles
, submit
.bo_handle_count
++);
995 hash_table_foreach(batch
->pool
.bos
, entry
)
996 panfrost_batch_record_bo(entry
, bo_handles
, submit
.bo_handle_count
++);
998 submit
.bo_handles
= (u64
) (uintptr_t) bo_handles
;
999 ret
= drmIoctl(dev
->fd
, DRM_IOCTL_PANFROST_SUBMIT
, &submit
);
1003 if (dev
->debug
& PAN_DBG_MSGS
)
1004 fprintf(stderr
, "Error submitting: %m\n");
1009 /* Trace the job if we're doing that */
1010 if (dev
->debug
& (PAN_DBG_TRACE
| PAN_DBG_SYNC
)) {
1011 /* Wait so we can get errors reported back */
1012 drmSyncobjWait(dev
->fd
, &out_sync
, 1,
1013 INT64_MAX
, 0, NULL
);
1015 /* Trace gets priority over sync */
1016 bool minimal
= !(dev
->debug
& PAN_DBG_TRACE
);
1017 pandecode_jc(submit
.jc
, dev
->quirks
& IS_BIFROST
, dev
->gpu_id
, minimal
);
1020 /* Cleanup if we created the syncobj */
1022 drmSyncobjDestroy(dev
->fd
, out_sync
);
1027 /* Submit both vertex/tiler and fragment jobs for a batch, possibly with an
1028 * outsync corresponding to the later of the two (since there will be an
1029 * implicit dep between them) */
1032 panfrost_batch_submit_jobs(struct panfrost_batch
*batch
, uint32_t out_sync
)
1034 bool has_draws
= batch
->scoreboard
.first_job
;
1035 bool has_frag
= batch
->scoreboard
.tiler_dep
|| batch
->clear
;
1039 ret
= panfrost_batch_submit_ioctl(batch
, batch
->scoreboard
.first_job
,
1040 0, has_frag
? 0 : out_sync
);
1045 /* Whether we program the fragment job for draws or not depends
1046 * on whether there is any *tiler* activity (so fragment
1047 * shaders). If there are draws but entirely RASTERIZER_DISCARD
1048 * (say, for transform feedback), we want a fragment job that
1049 * *only* clears, since otherwise the tiler structures will be
1050 * uninitialized leading to faults (or state leaks) */
1052 mali_ptr fragjob
= panfrost_fragment_job(batch
,
1053 batch
->scoreboard
.tiler_dep
!= 0);
1054 ret
= panfrost_batch_submit_ioctl(batch
, fragjob
,
1055 PANFROST_JD_REQ_FS
, out_sync
);
1063 panfrost_batch_submit(struct panfrost_batch
*batch
, uint32_t out_sync
)
1066 struct panfrost_device
*dev
= pan_device(batch
->ctx
->base
.screen
);
1068 /* Submit the dependencies first. Don't pass along the out_sync since
1069 * they are guaranteed to terminate sooner */
1070 util_dynarray_foreach(&batch
->dependencies
,
1071 struct panfrost_batch_fence
*, dep
) {
1073 panfrost_batch_submit((*dep
)->batch
, 0);
1078 /* Nothing to do! */
1079 if (!batch
->scoreboard
.first_job
&& !batch
->clear
) {
1081 drmSyncobjSignal(dev
->fd
, &out_sync
, 1);
1085 panfrost_batch_draw_wallpaper(batch
);
1087 /* Now that all draws are in, we can finally prepare the
1088 * FBD for the batch */
1090 if (batch
->framebuffer
.gpu
&& batch
->scoreboard
.first_job
) {
1091 struct panfrost_context
*ctx
= batch
->ctx
;
1092 struct pipe_context
*gallium
= (struct pipe_context
*) ctx
;
1093 struct panfrost_device
*dev
= pan_device(gallium
->screen
);
1095 if (dev
->quirks
& MIDGARD_SFBD
)
1096 panfrost_attach_sfbd(batch
, ~0);
1098 panfrost_attach_mfbd(batch
, ~0);
1101 mali_ptr polygon_list
= panfrost_batch_get_polygon_list(batch
,
1102 MALI_TILER_MINIMUM_HEADER_SIZE
);
1104 panfrost_scoreboard_initialize_tiler(&batch
->pool
, &batch
->scoreboard
, polygon_list
);
1106 ret
= panfrost_batch_submit_jobs(batch
, out_sync
);
1108 if (ret
&& dev
->debug
& PAN_DBG_MSGS
)
1109 fprintf(stderr
, "panfrost_batch_submit failed: %d\n", ret
);
1111 /* We must reset the damage info of our render targets here even
1112 * though a damage reset normally happens when the DRI layer swaps
1113 * buffers. That's because there can be implicit flushes the GL
1114 * app is not aware of, and those might impact the damage region: if
1115 * part of the damaged portion is drawn during those implicit flushes,
1116 * you have to reload those areas before next draws are pushed, and
1117 * since the driver can't easily know what's been modified by the draws
1118 * it flushed, the easiest solution is to reload everything.
1120 for (unsigned i
= 0; i
< batch
->key
.nr_cbufs
; i
++) {
1121 if (!batch
->key
.cbufs
[i
])
1124 panfrost_resource_set_damage_region(NULL
,
1125 batch
->key
.cbufs
[i
]->texture
, 0, NULL
);
1129 panfrost_freeze_batch(batch
);
1130 panfrost_free_batch(batch
);
1133 /* Submit all batches, applying the out_sync to the currently bound batch */
1136 panfrost_flush_all_batches(struct panfrost_context
*ctx
, uint32_t out_sync
)
1138 struct panfrost_batch
*batch
= panfrost_get_batch_for_fbo(ctx
);
1139 panfrost_batch_submit(batch
, out_sync
);
1141 hash_table_foreach(ctx
->batches
, hentry
) {
1142 struct panfrost_batch
*batch
= hentry
->data
;
1145 panfrost_batch_submit(batch
, 0);
1148 assert(!ctx
->batches
->entries
);
1150 /* Collect batch fences before returning */
1151 panfrost_gc_fences(ctx
);
1155 panfrost_pending_batches_access_bo(struct panfrost_context
*ctx
,
1156 const struct panfrost_bo
*bo
)
1158 struct panfrost_bo_access
*access
;
1159 struct hash_entry
*hentry
;
1161 hentry
= _mesa_hash_table_search(ctx
->accessed_bos
, bo
);
1162 access
= hentry
? hentry
->data
: NULL
;
1166 if (access
->writer
&& access
->writer
->batch
)
1169 util_dynarray_foreach(&access
->readers
, struct panfrost_batch_fence
*,
1171 if (*reader
&& (*reader
)->batch
)
1178 /* We always flush writers. We might also need to flush readers */
1181 panfrost_flush_batches_accessing_bo(struct panfrost_context
*ctx
,
1182 struct panfrost_bo
*bo
,
1185 struct panfrost_bo_access
*access
;
1186 struct hash_entry
*hentry
;
1188 hentry
= _mesa_hash_table_search(ctx
->accessed_bos
, bo
);
1189 access
= hentry
? hentry
->data
: NULL
;
1193 if (access
->writer
&& access
->writer
->batch
)
1194 panfrost_batch_submit(access
->writer
->batch
, 0);
1199 util_dynarray_foreach(&access
->readers
, struct panfrost_batch_fence
*,
1201 if (*reader
&& (*reader
)->batch
)
1202 panfrost_batch_submit((*reader
)->batch
, 0);
1207 panfrost_batch_set_requirements(struct panfrost_batch
*batch
)
1209 struct panfrost_context
*ctx
= batch
->ctx
;
1211 if (ctx
->rasterizer
&& ctx
->rasterizer
->base
.multisample
)
1212 batch
->requirements
|= PAN_REQ_MSAA
;
1214 if (ctx
->depth_stencil
&& ctx
->depth_stencil
->depth
.writemask
) {
1215 batch
->requirements
|= PAN_REQ_DEPTH_WRITE
;
1216 batch
->draws
|= PIPE_CLEAR_DEPTH
;
1219 if (ctx
->depth_stencil
&& ctx
->depth_stencil
->stencil
[0].enabled
)
1220 batch
->draws
|= PIPE_CLEAR_STENCIL
;
1224 panfrost_batch_adjust_stack_size(struct panfrost_batch
*batch
)
1226 struct panfrost_context
*ctx
= batch
->ctx
;
1228 for (unsigned i
= 0; i
< PIPE_SHADER_TYPES
; ++i
) {
1229 struct panfrost_shader_state
*ss
;
1231 ss
= panfrost_get_shader_state(ctx
, i
);
1235 batch
->stack_size
= MAX2(batch
->stack_size
, ss
->stack_size
);
1239 /* Helper to smear a 32-bit color across 128-bit components */
1242 pan_pack_color_32(uint32_t *packed
, uint32_t v
)
1244 for (unsigned i
= 0; i
< 4; ++i
)
1249 pan_pack_color_64(uint32_t *packed
, uint32_t lo
, uint32_t hi
)
1251 for (unsigned i
= 0; i
< 4; i
+= 2) {
1258 pan_pack_color(uint32_t *packed
, const union pipe_color_union
*color
, enum pipe_format format
)
1260 /* Alpha magicked to 1.0 if there is no alpha */
1262 bool has_alpha
= util_format_has_alpha(format
);
1263 float clear_alpha
= has_alpha
? color
->f
[3] : 1.0f
;
1265 /* Packed color depends on the framebuffer format */
1267 const struct util_format_description
*desc
=
1268 util_format_description(format
);
1270 if (util_format_is_rgba8_variant(desc
) && desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_SRGB
) {
1271 pan_pack_color_32(packed
,
1272 ((uint32_t) float_to_ubyte(clear_alpha
) << 24) |
1273 ((uint32_t) float_to_ubyte(color
->f
[2]) << 16) |
1274 ((uint32_t) float_to_ubyte(color
->f
[1]) << 8) |
1275 ((uint32_t) float_to_ubyte(color
->f
[0]) << 0));
1276 } else if (format
== PIPE_FORMAT_B5G6R5_UNORM
) {
1277 /* First, we convert the components to R5, G6, B5 separately */
1278 unsigned r5
= _mesa_roundevenf(SATURATE(color
->f
[0]) * 31.0);
1279 unsigned g6
= _mesa_roundevenf(SATURATE(color
->f
[1]) * 63.0);
1280 unsigned b5
= _mesa_roundevenf(SATURATE(color
->f
[2]) * 31.0);
1282 /* Then we pack into a sparse u32. TODO: Why these shifts? */
1283 pan_pack_color_32(packed
, (b5
<< 25) | (g6
<< 14) | (r5
<< 5));
1284 } else if (format
== PIPE_FORMAT_B4G4R4A4_UNORM
) {
1285 /* Convert to 4-bits */
1286 unsigned r4
= _mesa_roundevenf(SATURATE(color
->f
[0]) * 15.0);
1287 unsigned g4
= _mesa_roundevenf(SATURATE(color
->f
[1]) * 15.0);
1288 unsigned b4
= _mesa_roundevenf(SATURATE(color
->f
[2]) * 15.0);
1289 unsigned a4
= _mesa_roundevenf(SATURATE(clear_alpha
) * 15.0);
1291 /* Pack on *byte* intervals */
1292 pan_pack_color_32(packed
, (a4
<< 28) | (b4
<< 20) | (g4
<< 12) | (r4
<< 4));
1293 } else if (format
== PIPE_FORMAT_B5G5R5A1_UNORM
) {
1294 /* Scale as expected but shift oddly */
1295 unsigned r5
= _mesa_roundevenf(SATURATE(color
->f
[0]) * 31.0);
1296 unsigned g5
= _mesa_roundevenf(SATURATE(color
->f
[1]) * 31.0);
1297 unsigned b5
= _mesa_roundevenf(SATURATE(color
->f
[2]) * 31.0);
1298 unsigned a1
= _mesa_roundevenf(SATURATE(clear_alpha
) * 1.0);
1300 pan_pack_color_32(packed
, (a1
<< 31) | (b5
<< 25) | (g5
<< 15) | (r5
<< 5));
1302 /* Otherwise, it's generic subject to replication */
1304 union util_color out
= { 0 };
1305 unsigned size
= util_format_get_blocksize(format
);
1307 util_pack_color(color
->f
, format
, &out
);
1310 unsigned b
= out
.ui
[0];
1311 unsigned s
= b
| (b
<< 8);
1312 pan_pack_color_32(packed
, s
| (s
<< 16));
1313 } else if (size
== 2)
1314 pan_pack_color_32(packed
, out
.ui
[0] | (out
.ui
[0] << 16));
1315 else if (size
== 3 || size
== 4)
1316 pan_pack_color_32(packed
, out
.ui
[0]);
1318 pan_pack_color_64(packed
, out
.ui
[0], out
.ui
[1] | (out
.ui
[1] << 16)); /* RGB16F -- RGBB */
1320 pan_pack_color_64(packed
, out
.ui
[0], out
.ui
[1]);
1321 else if (size
== 16)
1322 memcpy(packed
, out
.ui
, 16);
1324 unreachable("Unknown generic format size packing clear colour");
1329 panfrost_batch_clear(struct panfrost_batch
*batch
,
1331 const union pipe_color_union
*color
,
1332 double depth
, unsigned stencil
)
1334 struct panfrost_context
*ctx
= batch
->ctx
;
1336 if (buffers
& PIPE_CLEAR_COLOR
) {
1337 for (unsigned i
= 0; i
< PIPE_MAX_COLOR_BUFS
; ++i
) {
1338 if (!(buffers
& (PIPE_CLEAR_COLOR0
<< i
)))
1341 enum pipe_format format
= ctx
->pipe_framebuffer
.cbufs
[i
]->format
;
1342 pan_pack_color(batch
->clear_color
[i
], color
, format
);
1346 if (buffers
& PIPE_CLEAR_DEPTH
) {
1347 batch
->clear_depth
= depth
;
1350 if (buffers
& PIPE_CLEAR_STENCIL
) {
1351 batch
->clear_stencil
= stencil
;
1354 batch
->clear
|= buffers
;
1356 /* Clearing affects the entire framebuffer (by definition -- this is
1357 * the Gallium clear callback, which clears the whole framebuffer. If
1358 * the scissor test were enabled from the GL side, the gallium frontend
1359 * would emit a quad instead and we wouldn't go down this code path) */
1361 panfrost_batch_union_scissor(batch
, 0, 0,
1362 ctx
->pipe_framebuffer
.width
,
1363 ctx
->pipe_framebuffer
.height
);
1367 panfrost_batch_compare(const void *a
, const void *b
)
1369 return util_framebuffer_state_equal(a
, b
);
1373 panfrost_batch_hash(const void *key
)
1375 return _mesa_hash_data(key
, sizeof(struct pipe_framebuffer_state
));
1378 /* Given a new bounding rectangle (scissor), let the job cover the union of the
1379 * new and old bounding rectangles */
1382 panfrost_batch_union_scissor(struct panfrost_batch
*batch
,
1383 unsigned minx
, unsigned miny
,
1384 unsigned maxx
, unsigned maxy
)
1386 batch
->minx
= MIN2(batch
->minx
, minx
);
1387 batch
->miny
= MIN2(batch
->miny
, miny
);
1388 batch
->maxx
= MAX2(batch
->maxx
, maxx
);
1389 batch
->maxy
= MAX2(batch
->maxy
, maxy
);
1393 panfrost_batch_intersection_scissor(struct panfrost_batch
*batch
,
1394 unsigned minx
, unsigned miny
,
1395 unsigned maxx
, unsigned maxy
)
1397 batch
->minx
= MAX2(batch
->minx
, minx
);
1398 batch
->miny
= MAX2(batch
->miny
, miny
);
1399 batch
->maxx
= MIN2(batch
->maxx
, maxx
);
1400 batch
->maxy
= MIN2(batch
->maxy
, maxy
);
1403 /* Are we currently rendering to the dev (rather than an FBO)? */
1406 panfrost_batch_is_scanout(struct panfrost_batch
*batch
)
1408 /* If there is no color buffer, it's an FBO */
1409 if (batch
->key
.nr_cbufs
!= 1)
1412 /* If we're too early that no framebuffer was sent, it's scanout */
1413 if (!batch
->key
.cbufs
[0])
1416 return batch
->key
.cbufs
[0]->texture
->bind
& PIPE_BIND_DISPLAY_TARGET
||
1417 batch
->key
.cbufs
[0]->texture
->bind
& PIPE_BIND_SCANOUT
||
1418 batch
->key
.cbufs
[0]->texture
->bind
& PIPE_BIND_SHARED
;
1422 panfrost_batch_init(struct panfrost_context
*ctx
)
1424 ctx
->batches
= _mesa_hash_table_create(ctx
,
1425 panfrost_batch_hash
,
1426 panfrost_batch_compare
);
1427 ctx
->accessed_bos
= _mesa_hash_table_create(ctx
, _mesa_hash_pointer
,
1428 _mesa_key_pointer_equal
);