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"
39 #include "pandecode/decode.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
;
69 fence
= rzalloc(NULL
, struct panfrost_batch_fence
);
71 pipe_reference_init(&fence
->reference
, 1);
72 fence
->ctx
= batch
->ctx
;
74 ret
= drmSyncobjCreate(pan_device(batch
->ctx
->base
.screen
)->fd
, 0,
82 panfrost_free_batch_fence(struct panfrost_batch_fence
*fence
)
84 drmSyncobjDestroy(pan_device(fence
->ctx
->base
.screen
)->fd
,
90 panfrost_batch_fence_unreference(struct panfrost_batch_fence
*fence
)
92 if (pipe_reference(&fence
->reference
, NULL
))
93 panfrost_free_batch_fence(fence
);
97 panfrost_batch_fence_reference(struct panfrost_batch_fence
*fence
)
99 pipe_reference(NULL
, &fence
->reference
);
102 static struct panfrost_batch
*
103 panfrost_create_batch(struct panfrost_context
*ctx
,
104 const struct pipe_framebuffer_state
*key
)
106 struct panfrost_batch
*batch
= rzalloc(ctx
, struct panfrost_batch
);
110 batch
->bos
= _mesa_hash_table_create(batch
, _mesa_hash_pointer
,
111 _mesa_key_pointer_equal
);
113 batch
->minx
= batch
->miny
= ~0;
114 batch
->maxx
= batch
->maxy
= 0;
116 batch
->out_sync
= panfrost_create_batch_fence(batch
);
117 util_copy_framebuffer_state(&batch
->key
, key
);
119 batch
->pool
= panfrost_create_pool(batch
, pan_device(ctx
->base
.screen
));
125 panfrost_freeze_batch(struct panfrost_batch
*batch
)
127 struct panfrost_context
*ctx
= batch
->ctx
;
128 struct hash_entry
*entry
;
130 /* Remove the entry in the FBO -> batch hash table if the batch
131 * matches. This way, next draws/clears targeting this FBO will trigger
132 * the creation of a new batch.
134 entry
= _mesa_hash_table_search(ctx
->batches
, &batch
->key
);
135 if (entry
&& entry
->data
== batch
)
136 _mesa_hash_table_remove(ctx
->batches
, entry
);
138 /* If this is the bound batch, the panfrost_context parameters are
139 * relevant so submitting it invalidates those parameters, but if it's
140 * not bound, the context parameters are for some other batch so we
141 * can't invalidate them.
143 if (ctx
->batch
== batch
) {
144 panfrost_invalidate_frame(ctx
);
149 #ifdef PAN_BATCH_DEBUG
150 static bool panfrost_batch_is_frozen(struct panfrost_batch
*batch
)
152 struct panfrost_context
*ctx
= batch
->ctx
;
153 struct hash_entry
*entry
;
155 entry
= _mesa_hash_table_search(ctx
->batches
, &batch
->key
);
156 if (entry
&& entry
->data
== batch
)
159 if (ctx
->batch
== batch
)
167 panfrost_free_batch(struct panfrost_batch
*batch
)
172 #ifdef PAN_BATCH_DEBUG
173 assert(panfrost_batch_is_frozen(batch
));
176 hash_table_foreach(batch
->bos
, entry
)
177 panfrost_bo_unreference((struct panfrost_bo
*)entry
->key
);
179 hash_table_foreach(batch
->pool
.bos
, entry
)
180 panfrost_bo_unreference((struct panfrost_bo
*)entry
->key
);
182 util_dynarray_foreach(&batch
->dependencies
,
183 struct panfrost_batch_fence
*, dep
) {
184 panfrost_batch_fence_unreference(*dep
);
187 /* The out_sync fence lifetime is different from the the batch one
188 * since other batches might want to wait on a fence of already
189 * submitted/signaled batch. All we need to do here is make sure the
190 * fence does not point to an invalid batch, which the core will
191 * interpret as 'batch is already submitted'.
193 batch
->out_sync
->batch
= NULL
;
194 panfrost_batch_fence_unreference(batch
->out_sync
);
196 util_unreference_framebuffer_state(&batch
->key
);
200 #ifdef PAN_BATCH_DEBUG
202 panfrost_dep_graph_contains_batch(struct panfrost_batch
*root
,
203 struct panfrost_batch
*batch
)
208 util_dynarray_foreach(&root
->dependencies
,
209 struct panfrost_batch_fence
*, dep
) {
210 if ((*dep
)->batch
== batch
||
211 panfrost_dep_graph_contains_batch((*dep
)->batch
, batch
))
220 panfrost_batch_add_dep(struct panfrost_batch
*batch
,
221 struct panfrost_batch_fence
*newdep
)
223 if (batch
== newdep
->batch
)
226 /* We might want to turn ->dependencies into a set if the number of
227 * deps turns out to be big enough to make this 'is dep already there'
228 * search inefficient.
230 util_dynarray_foreach(&batch
->dependencies
,
231 struct panfrost_batch_fence
*, dep
) {
236 #ifdef PAN_BATCH_DEBUG
237 /* Make sure the dependency graph is acyclic. */
238 assert(!panfrost_dep_graph_contains_batch(newdep
->batch
, batch
));
241 panfrost_batch_fence_reference(newdep
);
242 util_dynarray_append(&batch
->dependencies
,
243 struct panfrost_batch_fence
*, newdep
);
245 /* We now have a batch depending on us, let's make sure new draw/clear
246 * calls targeting the same FBO use a new batch object.
249 panfrost_freeze_batch(newdep
->batch
);
252 static struct panfrost_batch
*
253 panfrost_get_batch(struct panfrost_context
*ctx
,
254 const struct pipe_framebuffer_state
*key
)
256 /* Lookup the job first */
257 struct hash_entry
*entry
= _mesa_hash_table_search(ctx
->batches
, key
);
262 /* Otherwise, let's create a job */
264 struct panfrost_batch
*batch
= panfrost_create_batch(ctx
, key
);
266 /* Save the created job */
267 _mesa_hash_table_insert(ctx
->batches
, &batch
->key
, batch
);
272 /* Get the job corresponding to the FBO we're currently rendering into */
274 struct panfrost_batch
*
275 panfrost_get_batch_for_fbo(struct panfrost_context
*ctx
)
277 /* If we're wallpapering, we special case to workaround
280 if (ctx
->wallpaper_batch
)
281 return ctx
->wallpaper_batch
;
283 /* If we already began rendering, use that */
286 assert(util_framebuffer_state_equal(&ctx
->batch
->key
,
287 &ctx
->pipe_framebuffer
));
291 /* If not, look up the job */
292 struct panfrost_batch
*batch
= panfrost_get_batch(ctx
,
293 &ctx
->pipe_framebuffer
);
295 /* Set this job as the current FBO job. Will be reset when updating the
296 * FB state and when submitting or releasing a job.
302 struct panfrost_batch
*
303 panfrost_get_fresh_batch_for_fbo(struct panfrost_context
*ctx
)
305 struct panfrost_batch
*batch
;
307 batch
= panfrost_get_batch(ctx
, &ctx
->pipe_framebuffer
);
309 /* The batch has no draw/clear queued, let's return it directly.
310 * Note that it's perfectly fine to re-use a batch with an
311 * existing clear, we'll just update it with the new clear request.
313 if (!batch
->scoreboard
.first_job
)
316 /* Otherwise, we need to freeze the existing one and instantiate a new
319 panfrost_freeze_batch(batch
);
320 return panfrost_get_batch(ctx
, &ctx
->pipe_framebuffer
);
324 panfrost_batch_fence_is_signaled(struct panfrost_batch_fence
*fence
)
329 /* Batch has not been submitted yet. */
333 int ret
= drmSyncobjWait(pan_device(fence
->ctx
->base
.screen
)->fd
,
334 &fence
->syncobj
, 1, 0, 0, NULL
);
336 /* Cache whether the fence was signaled */
337 fence
->signaled
= ret
>= 0;
338 return fence
->signaled
;
342 panfrost_bo_access_gc_fences(struct panfrost_context
*ctx
,
343 struct panfrost_bo_access
*access
,
344 const struct panfrost_bo
*bo
)
346 if (access
->writer
&& panfrost_batch_fence_is_signaled(access
->writer
)) {
347 panfrost_batch_fence_unreference(access
->writer
);
348 access
->writer
= NULL
;
351 struct panfrost_batch_fence
**readers_array
= util_dynarray_begin(&access
->readers
);
352 struct panfrost_batch_fence
**new_readers
= readers_array
;
354 util_dynarray_foreach(&access
->readers
, struct panfrost_batch_fence
*,
359 if (panfrost_batch_fence_is_signaled(*reader
)) {
360 panfrost_batch_fence_unreference(*reader
);
363 /* Build a new array of only unsignaled fences in-place */
364 *(new_readers
++) = *reader
;
368 if (!util_dynarray_resize(&access
->readers
, struct panfrost_batch_fence
*,
369 new_readers
- readers_array
) &&
370 new_readers
!= readers_array
)
371 unreachable("Invalid dynarray access->readers");
374 /* Collect signaled fences to keep the kernel-side syncobj-map small. The
375 * idea is to collect those signaled fences at the end of each flush_all
376 * call. This function is likely to collect only fences from previous
377 * batch flushes not the one that have just have just been submitted and
378 * are probably still in flight when we trigger the garbage collection.
379 * Anyway, we need to do this garbage collection at some point if we don't
380 * want the BO access map to keep invalid entries around and retain
384 panfrost_gc_fences(struct panfrost_context
*ctx
)
386 hash_table_foreach(ctx
->accessed_bos
, entry
) {
387 struct panfrost_bo_access
*access
= entry
->data
;
390 panfrost_bo_access_gc_fences(ctx
, access
, entry
->key
);
391 if (!util_dynarray_num_elements(&access
->readers
,
392 struct panfrost_batch_fence
*) &&
395 _mesa_hash_table_remove(ctx
->accessed_bos
, entry
);
400 #ifdef PAN_BATCH_DEBUG
402 panfrost_batch_in_readers(struct panfrost_batch
*batch
,
403 struct panfrost_bo_access
*access
)
405 util_dynarray_foreach(&access
->readers
, struct panfrost_batch_fence
*,
407 if (*reader
&& (*reader
)->batch
== batch
)
416 panfrost_batch_update_bo_access(struct panfrost_batch
*batch
,
417 struct panfrost_bo
*bo
, bool writes
,
418 bool already_accessed
)
420 struct panfrost_context
*ctx
= batch
->ctx
;
421 struct panfrost_bo_access
*access
;
422 bool old_writes
= false;
423 struct hash_entry
*entry
;
425 entry
= _mesa_hash_table_search(ctx
->accessed_bos
, bo
);
426 access
= entry
? entry
->data
: NULL
;
428 old_writes
= access
->writer
!= NULL
;
430 access
= rzalloc(ctx
, struct panfrost_bo_access
);
431 util_dynarray_init(&access
->readers
, access
);
432 _mesa_hash_table_insert(ctx
->accessed_bos
, bo
, access
);
433 /* We are the first to access this BO, let's initialize
434 * old_writes to our own access type in that case.
441 if (writes
&& !old_writes
) {
442 /* Previous access was a read and we want to write this BO.
443 * We first need to add explicit deps between our batch and
444 * the previous readers.
446 util_dynarray_foreach(&access
->readers
,
447 struct panfrost_batch_fence
*, reader
) {
448 /* We were already reading the BO, no need to add a dep
449 * on ourself (the acyclic check would complain about
452 if (!(*reader
) || (*reader
)->batch
== batch
)
455 panfrost_batch_add_dep(batch
, *reader
);
457 panfrost_batch_fence_reference(batch
->out_sync
);
460 panfrost_batch_fence_unreference(access
->writer
);
462 /* We now are the new writer. */
463 access
->writer
= batch
->out_sync
;
465 /* Release the previous readers and reset the readers array. */
466 util_dynarray_foreach(&access
->readers
,
467 struct panfrost_batch_fence
*,
471 panfrost_batch_fence_unreference(*reader
);
474 util_dynarray_clear(&access
->readers
);
475 } else if (writes
&& old_writes
) {
476 /* First check if we were the previous writer, in that case
477 * there's nothing to do. Otherwise we need to add a
478 * dependency between the new writer and the old one.
480 if (access
->writer
!= batch
->out_sync
) {
481 if (access
->writer
) {
482 panfrost_batch_add_dep(batch
, access
->writer
);
483 panfrost_batch_fence_unreference(access
->writer
);
485 panfrost_batch_fence_reference(batch
->out_sync
);
486 access
->writer
= batch
->out_sync
;
488 } else if (!writes
&& old_writes
) {
489 /* First check if we were the previous writer, in that case
490 * we want to keep the access type unchanged, as a write is
491 * more constraining than a read.
493 if (access
->writer
!= batch
->out_sync
) {
494 /* Add a dependency on the previous writer. */
495 panfrost_batch_add_dep(batch
, access
->writer
);
497 /* The previous access was a write, there's no reason
498 * to have entries in the readers array.
500 assert(!util_dynarray_num_elements(&access
->readers
,
501 struct panfrost_batch_fence
*));
503 /* Add ourselves to the readers array. */
504 panfrost_batch_fence_reference(batch
->out_sync
);
505 util_dynarray_append(&access
->readers
,
506 struct panfrost_batch_fence
*,
508 access
->writer
= NULL
;
511 /* We already accessed this BO before, so we should already be
512 * in the reader array.
514 #ifdef PAN_BATCH_DEBUG
515 if (already_accessed
) {
516 assert(panfrost_batch_in_readers(batch
, access
));
521 /* Previous access was a read and we want to read this BO.
522 * Add ourselves to the readers array and add a dependency on
523 * the previous writer if any.
525 panfrost_batch_fence_reference(batch
->out_sync
);
526 util_dynarray_append(&access
->readers
,
527 struct panfrost_batch_fence
*,
531 panfrost_batch_add_dep(batch
, access
->writer
);
536 panfrost_batch_add_bo(struct panfrost_batch
*batch
, struct panfrost_bo
*bo
,
542 struct hash_entry
*entry
;
543 uint32_t old_flags
= 0;
545 entry
= _mesa_hash_table_search(batch
->bos
, bo
);
547 entry
= _mesa_hash_table_insert(batch
->bos
, bo
,
548 (void *)(uintptr_t)flags
);
549 panfrost_bo_reference(bo
);
551 old_flags
= (uintptr_t)entry
->data
;
553 /* All batches have to agree on the shared flag. */
554 assert((old_flags
& PAN_BO_ACCESS_SHARED
) ==
555 (flags
& PAN_BO_ACCESS_SHARED
));
560 if (old_flags
== flags
)
564 entry
->data
= (void *)(uintptr_t)flags
;
566 /* If this is not a shared BO, we don't really care about dependency
569 if (!(flags
& PAN_BO_ACCESS_SHARED
))
572 /* All dependencies should have been flushed before we execute the
573 * wallpaper draw, so it should be harmless to skip the
574 * update_bo_access() call.
576 if (batch
== batch
->ctx
->wallpaper_batch
)
579 assert(flags
& PAN_BO_ACCESS_RW
);
580 panfrost_batch_update_bo_access(batch
, bo
, flags
& PAN_BO_ACCESS_WRITE
,
585 panfrost_batch_add_resource_bos(struct panfrost_batch
*batch
,
586 struct panfrost_resource
*rsrc
,
589 panfrost_batch_add_bo(batch
, rsrc
->bo
, flags
);
591 for (unsigned i
= 0; i
< MAX_MIP_LEVELS
; i
++)
592 if (rsrc
->slices
[i
].checksum_bo
)
593 panfrost_batch_add_bo(batch
, rsrc
->slices
[i
].checksum_bo
, flags
);
595 if (rsrc
->separate_stencil
)
596 panfrost_batch_add_bo(batch
, rsrc
->separate_stencil
->bo
, flags
);
599 void panfrost_batch_add_fbo_bos(struct panfrost_batch
*batch
)
601 uint32_t flags
= PAN_BO_ACCESS_SHARED
| PAN_BO_ACCESS_WRITE
|
602 PAN_BO_ACCESS_VERTEX_TILER
|
603 PAN_BO_ACCESS_FRAGMENT
;
605 for (unsigned i
= 0; i
< batch
->key
.nr_cbufs
; ++i
) {
606 struct panfrost_resource
*rsrc
= pan_resource(batch
->key
.cbufs
[i
]->texture
);
607 panfrost_batch_add_resource_bos(batch
, rsrc
, flags
);
610 if (batch
->key
.zsbuf
) {
611 struct panfrost_resource
*rsrc
= pan_resource(batch
->key
.zsbuf
->texture
);
612 panfrost_batch_add_resource_bos(batch
, rsrc
, flags
);
617 panfrost_batch_create_bo(struct panfrost_batch
*batch
, size_t size
,
618 uint32_t create_flags
, uint32_t access_flags
)
620 struct panfrost_bo
*bo
;
622 bo
= panfrost_bo_create(pan_device(batch
->ctx
->base
.screen
), size
,
624 panfrost_batch_add_bo(batch
, bo
, access_flags
);
626 /* panfrost_batch_add_bo() has retained a reference and
627 * panfrost_bo_create() initialize the refcnt to 1, so let's
628 * unreference the BO here so it gets released when the batch is
629 * destroyed (unless it's retained by someone else in the meantime).
631 panfrost_bo_unreference(bo
);
635 /* Returns the polygon list's GPU address if available, or otherwise allocates
636 * the polygon list. It's perfectly fast to use allocate/free BO directly,
637 * since we'll hit the BO cache and this is one-per-batch anyway. */
640 panfrost_batch_get_polygon_list(struct panfrost_batch
*batch
, unsigned size
)
642 if (batch
->polygon_list
) {
643 assert(batch
->polygon_list
->size
>= size
);
645 /* Create the BO as invisible, as there's no reason to map */
646 size
= util_next_power_of_two(size
);
648 batch
->polygon_list
= panfrost_batch_create_bo(batch
, size
,
650 PAN_BO_ACCESS_PRIVATE
|
652 PAN_BO_ACCESS_VERTEX_TILER
|
653 PAN_BO_ACCESS_FRAGMENT
);
656 return batch
->polygon_list
->gpu
;
660 panfrost_batch_get_scratchpad(struct panfrost_batch
*batch
,
662 unsigned thread_tls_alloc
,
665 unsigned size
= panfrost_get_total_stack_size(shift
,
669 if (batch
->scratchpad
) {
670 assert(batch
->scratchpad
->size
>= size
);
672 batch
->scratchpad
= panfrost_batch_create_bo(batch
, size
,
674 PAN_BO_ACCESS_PRIVATE
|
676 PAN_BO_ACCESS_VERTEX_TILER
|
677 PAN_BO_ACCESS_FRAGMENT
);
680 return batch
->scratchpad
;
684 panfrost_batch_get_shared_memory(struct panfrost_batch
*batch
,
686 unsigned workgroup_count
)
688 if (batch
->shared_memory
) {
689 assert(batch
->shared_memory
->size
>= size
);
691 batch
->shared_memory
= panfrost_batch_create_bo(batch
, size
,
693 PAN_BO_ACCESS_PRIVATE
|
695 PAN_BO_ACCESS_VERTEX_TILER
);
698 return batch
->shared_memory
;
702 panfrost_batch_get_tiler_heap(struct panfrost_batch
*batch
)
704 if (batch
->tiler_heap
)
705 return batch
->tiler_heap
;
707 batch
->tiler_heap
= panfrost_batch_create_bo(batch
, 4096 * 4096,
710 PAN_BO_ACCESS_PRIVATE
|
712 PAN_BO_ACCESS_VERTEX_TILER
|
713 PAN_BO_ACCESS_FRAGMENT
);
714 assert(batch
->tiler_heap
);
715 return batch
->tiler_heap
;
719 panfrost_batch_get_tiler_meta(struct panfrost_batch
*batch
, unsigned vertex_count
)
724 if (batch
->tiler_meta
)
725 return batch
->tiler_meta
;
727 struct panfrost_bo
*tiler_heap
;
728 tiler_heap
= panfrost_batch_get_tiler_heap(batch
);
730 struct bifrost_tiler_heap_meta tiler_heap_meta
= {
731 .heap_size
= tiler_heap
->size
,
732 .tiler_heap_start
= tiler_heap
->gpu
,
733 .tiler_heap_free
= tiler_heap
->gpu
,
734 .tiler_heap_end
= tiler_heap
->gpu
+ tiler_heap
->size
,
736 .unk7e007e
= 0x7e007e,
739 struct bifrost_tiler_meta tiler_meta
= {
740 .hierarchy_mask
= 0x28,
742 .width
= MALI_POSITIVE(batch
->key
.width
),
743 .height
= MALI_POSITIVE(batch
->key
.height
),
744 .tiler_heap_meta
= panfrost_pool_upload(&batch
->pool
, &tiler_heap_meta
, sizeof(tiler_heap_meta
)),
747 batch
->tiler_meta
= panfrost_pool_upload(&batch
->pool
, &tiler_meta
, sizeof(tiler_meta
));
748 return batch
->tiler_meta
;
752 panfrost_batch_get_tiler_dummy(struct panfrost_batch
*batch
)
754 struct panfrost_device
*dev
= pan_device(batch
->ctx
->base
.screen
);
756 uint32_t create_flags
= 0;
758 if (batch
->tiler_dummy
)
759 return batch
->tiler_dummy
;
761 if (!(dev
->quirks
& MIDGARD_NO_HIER_TILING
))
762 create_flags
= PAN_BO_INVISIBLE
;
764 batch
->tiler_dummy
= panfrost_batch_create_bo(batch
, 4096,
766 PAN_BO_ACCESS_PRIVATE
|
768 PAN_BO_ACCESS_VERTEX_TILER
|
769 PAN_BO_ACCESS_FRAGMENT
);
770 assert(batch
->tiler_dummy
);
771 return batch
->tiler_dummy
;
775 panfrost_batch_reserve_framebuffer(struct panfrost_batch
*batch
)
777 struct panfrost_device
*dev
= pan_device(batch
->ctx
->base
.screen
);
779 /* If we haven't, reserve space for the framebuffer */
781 if (!batch
->framebuffer
.gpu
) {
782 unsigned size
= (dev
->quirks
& MIDGARD_SFBD
) ?
783 sizeof(struct mali_single_framebuffer
) :
784 sizeof(struct mali_framebuffer
);
786 batch
->framebuffer
= panfrost_pool_alloc(&batch
->pool
, size
);
788 /* Tag the pointer */
789 if (!(dev
->quirks
& MIDGARD_SFBD
))
790 batch
->framebuffer
.gpu
|= MALI_MFBD
;
793 return batch
->framebuffer
.gpu
;
799 panfrost_load_surface(struct panfrost_batch
*batch
, struct pipe_surface
*surf
, unsigned loc
)
804 struct panfrost_resource
*rsrc
= pan_resource(surf
->texture
);
805 unsigned level
= surf
->u
.tex
.level
;
807 if (!rsrc
->slices
[level
].initialized
)
810 if (!rsrc
->damage
.inverted_len
)
813 /* Clamp the rendering area to the damage extent. The
814 * KHR_partial_update() spec states that trying to render outside of
815 * the damage region is "undefined behavior", so we should be safe.
817 unsigned damage_width
= (rsrc
->damage
.extent
.maxx
- rsrc
->damage
.extent
.minx
);
818 unsigned damage_height
= (rsrc
->damage
.extent
.maxy
- rsrc
->damage
.extent
.miny
);
820 if (damage_width
&& damage_height
) {
821 panfrost_batch_intersection_scissor(batch
,
822 rsrc
->damage
.extent
.minx
,
823 rsrc
->damage
.extent
.miny
,
824 rsrc
->damage
.extent
.maxx
,
825 rsrc
->damage
.extent
.maxy
);
828 /* XXX: Native blits on Bifrost */
829 if (batch
->pool
.dev
->quirks
& IS_BIFROST
) {
830 if (loc
!= FRAG_RESULT_DATA0
)
833 /* XXX: why align on *twice* the tile length? */
834 batch
->minx
= batch
->minx
& ~((MALI_TILE_LENGTH
* 2) - 1);
835 batch
->miny
= batch
->miny
& ~((MALI_TILE_LENGTH
* 2) - 1);
836 batch
->maxx
= MIN2(ALIGN_POT(batch
->maxx
, MALI_TILE_LENGTH
* 2),
838 batch
->maxy
= MIN2(ALIGN_POT(batch
->maxy
, MALI_TILE_LENGTH
* 2),
841 struct pipe_box rect
;
842 batch
->ctx
->wallpaper_batch
= batch
;
843 u_box_2d(batch
->minx
, batch
->miny
, batch
->maxx
- batch
->minx
,
844 batch
->maxy
- batch
->miny
, &rect
);
845 panfrost_blit_wallpaper(batch
->ctx
, &rect
);
846 batch
->ctx
->wallpaper_batch
= NULL
;
850 enum pipe_format format
= rsrc
->base
.format
;
852 if (loc
== FRAG_RESULT_DEPTH
) {
853 if (!util_format_has_depth(util_format_description(format
)))
856 format
= util_format_get_depth_only(format
);
857 } else if (loc
== FRAG_RESULT_STENCIL
) {
858 if (!util_format_has_stencil(util_format_description(format
)))
861 if (rsrc
->separate_stencil
) {
862 rsrc
= rsrc
->separate_stencil
;
863 format
= rsrc
->base
.format
;
866 format
= util_format_stencil_only(format
);
869 enum mali_texture_type type
=
870 panfrost_translate_texture_type(rsrc
->base
.target
);
872 unsigned nr_samples
= surf
->nr_samples
;
875 nr_samples
= surf
->texture
->nr_samples
;
877 struct pan_image img
= {
878 .width0
= rsrc
->base
.width0
,
879 .height0
= rsrc
->base
.height0
,
880 .depth0
= rsrc
->base
.depth0
,
883 .layout
= rsrc
->layout
,
884 .array_size
= rsrc
->base
.array_size
,
885 .first_level
= level
,
887 .first_layer
= surf
->u
.tex
.first_layer
,
888 .last_layer
= surf
->u
.tex
.last_layer
,
889 .nr_samples
= nr_samples
,
890 .cubemap_stride
= rsrc
->cubemap_stride
,
892 .slices
= rsrc
->slices
895 mali_ptr blend_shader
= 0;
897 if (loc
>= FRAG_RESULT_DATA0
&& !panfrost_can_fixed_blend(rsrc
->base
.format
)) {
898 struct panfrost_blend_shader
*b
=
899 panfrost_get_blend_shader(batch
->ctx
, &batch
->ctx
->blit_blend
, rsrc
->base
.format
, loc
- FRAG_RESULT_DATA0
);
901 struct panfrost_bo
*bo
= panfrost_batch_create_bo(batch
, b
->size
,
903 PAN_BO_ACCESS_PRIVATE
|
905 PAN_BO_ACCESS_FRAGMENT
);
907 memcpy(bo
->cpu
, b
->buffer
, b
->size
);
908 assert(b
->work_count
<= 4);
910 blend_shader
= bo
->gpu
| b
->first_tag
;
913 struct panfrost_transfer transfer
= panfrost_pool_alloc(&batch
->pool
,
914 4 * 4 * 6 * rsrc
->damage
.inverted_len
);
916 for (unsigned i
= 0; i
< rsrc
->damage
.inverted_len
; ++i
) {
917 float *o
= (float *) (transfer
.cpu
+ (4 * 4 * 6 * i
));
918 struct pan_rect r
= rsrc
->damage
.inverted_rects
[i
];
921 r
.minx
, rsrc
->base
.height0
- r
.miny
, 0.0, 1.0,
922 r
.maxx
, rsrc
->base
.height0
- r
.miny
, 0.0, 1.0,
923 r
.minx
, rsrc
->base
.height0
- r
.maxy
, 0.0, 1.0,
925 r
.maxx
, rsrc
->base
.height0
- r
.miny
, 0.0, 1.0,
926 r
.minx
, rsrc
->base
.height0
- r
.maxy
, 0.0, 1.0,
927 r
.maxx
, rsrc
->base
.height0
- r
.maxy
, 0.0, 1.0,
930 assert(sizeof(rect
) == 4 * 4 * 6);
931 memcpy(o
, rect
, sizeof(rect
));
934 panfrost_load_midg(&batch
->pool
, &batch
->scoreboard
,
936 batch
->framebuffer
.gpu
, transfer
.gpu
,
937 rsrc
->damage
.inverted_len
* 6,
940 panfrost_batch_add_bo(batch
, batch
->pool
.dev
->blit_shaders
.bo
,
941 PAN_BO_ACCESS_SHARED
| PAN_BO_ACCESS_READ
| PAN_BO_ACCESS_FRAGMENT
);
945 panfrost_batch_draw_wallpaper(struct panfrost_batch
*batch
)
947 panfrost_batch_reserve_framebuffer(batch
);
949 /* Assume combined. If either depth or stencil is written, they will
950 * both be written so we need to be careful for reloading */
952 unsigned draws
= batch
->draws
;
954 if (draws
& PIPE_CLEAR_DEPTHSTENCIL
)
955 draws
|= PIPE_CLEAR_DEPTHSTENCIL
;
957 /* Mask of buffers which need reload since they are not cleared and
958 * they are drawn. (If they are cleared, reload is useless; if they are
959 * not drawn and also not cleared, we can generally omit the attachment
960 * at the framebuffer descriptor level */
962 unsigned reload
= ~batch
->clear
& draws
;
964 for (unsigned i
= 0; i
< batch
->key
.nr_cbufs
; ++i
) {
965 if (reload
& (PIPE_CLEAR_COLOR0
<< i
))
966 panfrost_load_surface(batch
, batch
->key
.cbufs
[i
], FRAG_RESULT_DATA0
+ i
);
969 if (reload
& PIPE_CLEAR_DEPTH
)
970 panfrost_load_surface(batch
, batch
->key
.zsbuf
, FRAG_RESULT_DEPTH
);
972 if (reload
& PIPE_CLEAR_STENCIL
)
973 panfrost_load_surface(batch
, batch
->key
.zsbuf
, FRAG_RESULT_STENCIL
);
977 panfrost_batch_record_bo(struct hash_entry
*entry
, unsigned *bo_handles
, unsigned idx
)
979 struct panfrost_bo
*bo
= (struct panfrost_bo
*)entry
->key
;
980 uint32_t flags
= (uintptr_t)entry
->data
;
982 assert(bo
->gem_handle
> 0);
983 bo_handles
[idx
] = bo
->gem_handle
;
985 /* Update the BO access flags so that panfrost_bo_wait() knows
986 * about all pending accesses.
987 * We only keep the READ/WRITE info since this is all the BO
988 * wait logic cares about.
989 * We also preserve existing flags as this batch might not
990 * be the first one to access the BO.
992 bo
->gpu_access
|= flags
& (PAN_BO_ACCESS_RW
);
996 panfrost_batch_submit_ioctl(struct panfrost_batch
*batch
,
997 mali_ptr first_job_desc
,
1000 struct panfrost_context
*ctx
= batch
->ctx
;
1001 struct pipe_context
*gallium
= (struct pipe_context
*) ctx
;
1002 struct panfrost_device
*dev
= pan_device(gallium
->screen
);
1003 struct drm_panfrost_submit submit
= {0,};
1004 uint32_t *bo_handles
;
1007 submit
.out_sync
= batch
->out_sync
->syncobj
;
1008 submit
.jc
= first_job_desc
;
1009 submit
.requirements
= reqs
;
1011 bo_handles
= calloc(batch
->pool
.bos
->entries
+ batch
->bos
->entries
, sizeof(*bo_handles
));
1014 hash_table_foreach(batch
->bos
, entry
)
1015 panfrost_batch_record_bo(entry
, bo_handles
, submit
.bo_handle_count
++);
1017 hash_table_foreach(batch
->pool
.bos
, entry
)
1018 panfrost_batch_record_bo(entry
, bo_handles
, submit
.bo_handle_count
++);
1020 submit
.bo_handles
= (u64
) (uintptr_t) bo_handles
;
1021 ret
= drmIoctl(dev
->fd
, DRM_IOCTL_PANFROST_SUBMIT
, &submit
);
1025 if (dev
->debug
& PAN_DBG_MSGS
)
1026 fprintf(stderr
, "Error submitting: %m\n");
1031 /* Trace the job if we're doing that */
1032 if (dev
->debug
& (PAN_DBG_TRACE
| PAN_DBG_SYNC
)) {
1033 /* Wait so we can get errors reported back */
1034 drmSyncobjWait(dev
->fd
, &batch
->out_sync
->syncobj
, 1,
1035 INT64_MAX
, 0, NULL
);
1037 /* Trace gets priority over sync */
1038 bool minimal
= !(dev
->debug
& PAN_DBG_TRACE
);
1039 pandecode_jc(submit
.jc
, dev
->quirks
& IS_BIFROST
, dev
->gpu_id
, minimal
);
1046 panfrost_batch_submit_jobs(struct panfrost_batch
*batch
)
1048 bool has_draws
= batch
->scoreboard
.first_job
;
1052 ret
= panfrost_batch_submit_ioctl(batch
, batch
->scoreboard
.first_job
, 0);
1056 if (batch
->scoreboard
.tiler_dep
|| batch
->clear
) {
1057 /* Whether we program the fragment job for draws or not depends
1058 * on whether there is any *tiler* activity (so fragment
1059 * shaders). If there are draws but entirely RASTERIZER_DISCARD
1060 * (say, for transform feedback), we want a fragment job that
1061 * *only* clears, since otherwise the tiler structures will be
1062 * uninitialized leading to faults (or state leaks) */
1064 mali_ptr fragjob
= panfrost_fragment_job(batch
,
1065 batch
->scoreboard
.tiler_dep
!= 0);
1066 ret
= panfrost_batch_submit_ioctl(batch
, fragjob
, PANFROST_JD_REQ_FS
);
1074 panfrost_batch_submit(struct panfrost_batch
*batch
)
1077 struct panfrost_device
*dev
= pan_device(batch
->ctx
->base
.screen
);
1079 /* Submit the dependencies first. */
1080 util_dynarray_foreach(&batch
->dependencies
,
1081 struct panfrost_batch_fence
*, dep
) {
1083 panfrost_batch_submit((*dep
)->batch
);
1088 /* Nothing to do! */
1089 if (!batch
->scoreboard
.first_job
&& !batch
->clear
) {
1090 /* Mark the fence as signaled so the fence logic does not try
1093 batch
->out_sync
->signaled
= true;
1097 panfrost_batch_draw_wallpaper(batch
);
1099 /* Now that all draws are in, we can finally prepare the
1100 * FBD for the batch */
1102 if (batch
->framebuffer
.gpu
&& batch
->scoreboard
.first_job
) {
1103 struct panfrost_context
*ctx
= batch
->ctx
;
1104 struct pipe_context
*gallium
= (struct pipe_context
*) ctx
;
1105 struct panfrost_device
*dev
= pan_device(gallium
->screen
);
1107 if (dev
->quirks
& MIDGARD_SFBD
)
1108 panfrost_attach_sfbd(batch
, ~0);
1110 panfrost_attach_mfbd(batch
, ~0);
1113 mali_ptr polygon_list
= panfrost_batch_get_polygon_list(batch
,
1114 MALI_TILER_MINIMUM_HEADER_SIZE
);
1116 panfrost_scoreboard_initialize_tiler(&batch
->pool
, &batch
->scoreboard
, polygon_list
);
1118 ret
= panfrost_batch_submit_jobs(batch
);
1120 if (ret
&& dev
->debug
& PAN_DBG_MSGS
)
1121 fprintf(stderr
, "panfrost_batch_submit failed: %d\n", ret
);
1123 /* We must reset the damage info of our render targets here even
1124 * though a damage reset normally happens when the DRI layer swaps
1125 * buffers. That's because there can be implicit flushes the GL
1126 * app is not aware of, and those might impact the damage region: if
1127 * part of the damaged portion is drawn during those implicit flushes,
1128 * you have to reload those areas before next draws are pushed, and
1129 * since the driver can't easily know what's been modified by the draws
1130 * it flushed, the easiest solution is to reload everything.
1132 for (unsigned i
= 0; i
< batch
->key
.nr_cbufs
; i
++) {
1133 if (!batch
->key
.cbufs
[i
])
1136 panfrost_resource_set_damage_region(NULL
,
1137 batch
->key
.cbufs
[i
]->texture
, 0, NULL
);
1141 panfrost_freeze_batch(batch
);
1142 panfrost_free_batch(batch
);
1146 panfrost_flush_all_batches(struct panfrost_context
*ctx
)
1148 hash_table_foreach(ctx
->batches
, hentry
) {
1149 struct panfrost_batch
*batch
= hentry
->data
;
1152 panfrost_batch_submit(batch
);
1155 assert(!ctx
->batches
->entries
);
1157 /* Collect batch fences before returning */
1158 panfrost_gc_fences(ctx
);
1162 panfrost_pending_batches_access_bo(struct panfrost_context
*ctx
,
1163 const struct panfrost_bo
*bo
)
1165 struct panfrost_bo_access
*access
;
1166 struct hash_entry
*hentry
;
1168 hentry
= _mesa_hash_table_search(ctx
->accessed_bos
, bo
);
1169 access
= hentry
? hentry
->data
: NULL
;
1173 if (access
->writer
&& access
->writer
->batch
)
1176 util_dynarray_foreach(&access
->readers
, struct panfrost_batch_fence
*,
1178 if (*reader
&& (*reader
)->batch
)
1185 /* We always flush writers. We might also need to flush readers */
1188 panfrost_flush_batches_accessing_bo(struct panfrost_context
*ctx
,
1189 struct panfrost_bo
*bo
,
1192 struct panfrost_bo_access
*access
;
1193 struct hash_entry
*hentry
;
1195 hentry
= _mesa_hash_table_search(ctx
->accessed_bos
, bo
);
1196 access
= hentry
? hentry
->data
: NULL
;
1200 if (access
->writer
&& access
->writer
->batch
)
1201 panfrost_batch_submit(access
->writer
->batch
);
1206 util_dynarray_foreach(&access
->readers
, struct panfrost_batch_fence
*,
1208 if (*reader
&& (*reader
)->batch
)
1209 panfrost_batch_submit((*reader
)->batch
);
1214 panfrost_batch_set_requirements(struct panfrost_batch
*batch
)
1216 struct panfrost_context
*ctx
= batch
->ctx
;
1218 if (ctx
->rasterizer
&& ctx
->rasterizer
->base
.multisample
)
1219 batch
->requirements
|= PAN_REQ_MSAA
;
1221 if (ctx
->depth_stencil
&& ctx
->depth_stencil
->depth
.writemask
) {
1222 batch
->requirements
|= PAN_REQ_DEPTH_WRITE
;
1223 batch
->draws
|= PIPE_CLEAR_DEPTH
;
1226 if (ctx
->depth_stencil
&& ctx
->depth_stencil
->stencil
[0].enabled
)
1227 batch
->draws
|= PIPE_CLEAR_STENCIL
;
1231 panfrost_batch_adjust_stack_size(struct panfrost_batch
*batch
)
1233 struct panfrost_context
*ctx
= batch
->ctx
;
1235 for (unsigned i
= 0; i
< PIPE_SHADER_TYPES
; ++i
) {
1236 struct panfrost_shader_state
*ss
;
1238 ss
= panfrost_get_shader_state(ctx
, i
);
1242 batch
->stack_size
= MAX2(batch
->stack_size
, ss
->stack_size
);
1246 /* Helper to smear a 32-bit color across 128-bit components */
1249 pan_pack_color_32(uint32_t *packed
, uint32_t v
)
1251 for (unsigned i
= 0; i
< 4; ++i
)
1256 pan_pack_color_64(uint32_t *packed
, uint32_t lo
, uint32_t hi
)
1258 for (unsigned i
= 0; i
< 4; i
+= 2) {
1265 pan_pack_color(uint32_t *packed
, const union pipe_color_union
*color
, enum pipe_format format
)
1267 /* Alpha magicked to 1.0 if there is no alpha */
1269 bool has_alpha
= util_format_has_alpha(format
);
1270 float clear_alpha
= has_alpha
? color
->f
[3] : 1.0f
;
1272 /* Packed color depends on the framebuffer format */
1274 const struct util_format_description
*desc
=
1275 util_format_description(format
);
1277 if (util_format_is_rgba8_variant(desc
) && desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_SRGB
) {
1278 pan_pack_color_32(packed
,
1279 ((uint32_t) float_to_ubyte(clear_alpha
) << 24) |
1280 ((uint32_t) float_to_ubyte(color
->f
[2]) << 16) |
1281 ((uint32_t) float_to_ubyte(color
->f
[1]) << 8) |
1282 ((uint32_t) float_to_ubyte(color
->f
[0]) << 0));
1283 } else if (format
== PIPE_FORMAT_B5G6R5_UNORM
) {
1284 /* First, we convert the components to R5, G6, B5 separately */
1285 unsigned r5
= _mesa_roundevenf(SATURATE(color
->f
[0]) * 31.0);
1286 unsigned g6
= _mesa_roundevenf(SATURATE(color
->f
[1]) * 63.0);
1287 unsigned b5
= _mesa_roundevenf(SATURATE(color
->f
[2]) * 31.0);
1289 /* Then we pack into a sparse u32. TODO: Why these shifts? */
1290 pan_pack_color_32(packed
, (b5
<< 25) | (g6
<< 14) | (r5
<< 5));
1291 } else if (format
== PIPE_FORMAT_B4G4R4A4_UNORM
) {
1292 /* Convert to 4-bits */
1293 unsigned r4
= _mesa_roundevenf(SATURATE(color
->f
[0]) * 15.0);
1294 unsigned g4
= _mesa_roundevenf(SATURATE(color
->f
[1]) * 15.0);
1295 unsigned b4
= _mesa_roundevenf(SATURATE(color
->f
[2]) * 15.0);
1296 unsigned a4
= _mesa_roundevenf(SATURATE(clear_alpha
) * 15.0);
1298 /* Pack on *byte* intervals */
1299 pan_pack_color_32(packed
, (a4
<< 28) | (b4
<< 20) | (g4
<< 12) | (r4
<< 4));
1300 } else if (format
== PIPE_FORMAT_B5G5R5A1_UNORM
) {
1301 /* Scale as expected but shift oddly */
1302 unsigned r5
= _mesa_roundevenf(SATURATE(color
->f
[0]) * 31.0);
1303 unsigned g5
= _mesa_roundevenf(SATURATE(color
->f
[1]) * 31.0);
1304 unsigned b5
= _mesa_roundevenf(SATURATE(color
->f
[2]) * 31.0);
1305 unsigned a1
= _mesa_roundevenf(SATURATE(clear_alpha
) * 1.0);
1307 pan_pack_color_32(packed
, (a1
<< 31) | (b5
<< 25) | (g5
<< 15) | (r5
<< 5));
1309 /* Otherwise, it's generic subject to replication */
1311 union util_color out
= { 0 };
1312 unsigned size
= util_format_get_blocksize(format
);
1314 util_pack_color(color
->f
, format
, &out
);
1317 unsigned b
= out
.ui
[0];
1318 unsigned s
= b
| (b
<< 8);
1319 pan_pack_color_32(packed
, s
| (s
<< 16));
1320 } else if (size
== 2)
1321 pan_pack_color_32(packed
, out
.ui
[0] | (out
.ui
[0] << 16));
1322 else if (size
== 3 || size
== 4)
1323 pan_pack_color_32(packed
, out
.ui
[0]);
1325 pan_pack_color_64(packed
, out
.ui
[0], out
.ui
[1] | (out
.ui
[1] << 16)); /* RGB16F -- RGBB */
1327 pan_pack_color_64(packed
, out
.ui
[0], out
.ui
[1]);
1328 else if (size
== 16)
1329 memcpy(packed
, out
.ui
, 16);
1331 unreachable("Unknown generic format size packing clear colour");
1336 panfrost_batch_clear(struct panfrost_batch
*batch
,
1338 const union pipe_color_union
*color
,
1339 double depth
, unsigned stencil
)
1341 struct panfrost_context
*ctx
= batch
->ctx
;
1343 if (buffers
& PIPE_CLEAR_COLOR
) {
1344 for (unsigned i
= 0; i
< PIPE_MAX_COLOR_BUFS
; ++i
) {
1345 if (!(buffers
& (PIPE_CLEAR_COLOR0
<< i
)))
1348 enum pipe_format format
= ctx
->pipe_framebuffer
.cbufs
[i
]->format
;
1349 pan_pack_color(batch
->clear_color
[i
], color
, format
);
1353 if (buffers
& PIPE_CLEAR_DEPTH
) {
1354 batch
->clear_depth
= depth
;
1357 if (buffers
& PIPE_CLEAR_STENCIL
) {
1358 batch
->clear_stencil
= stencil
;
1361 batch
->clear
|= buffers
;
1363 /* Clearing affects the entire framebuffer (by definition -- this is
1364 * the Gallium clear callback, which clears the whole framebuffer. If
1365 * the scissor test were enabled from the GL side, the gallium frontend
1366 * would emit a quad instead and we wouldn't go down this code path) */
1368 panfrost_batch_union_scissor(batch
, 0, 0,
1369 ctx
->pipe_framebuffer
.width
,
1370 ctx
->pipe_framebuffer
.height
);
1374 panfrost_batch_compare(const void *a
, const void *b
)
1376 return util_framebuffer_state_equal(a
, b
);
1380 panfrost_batch_hash(const void *key
)
1382 return _mesa_hash_data(key
, sizeof(struct pipe_framebuffer_state
));
1385 /* Given a new bounding rectangle (scissor), let the job cover the union of the
1386 * new and old bounding rectangles */
1389 panfrost_batch_union_scissor(struct panfrost_batch
*batch
,
1390 unsigned minx
, unsigned miny
,
1391 unsigned maxx
, unsigned maxy
)
1393 batch
->minx
= MIN2(batch
->minx
, minx
);
1394 batch
->miny
= MIN2(batch
->miny
, miny
);
1395 batch
->maxx
= MAX2(batch
->maxx
, maxx
);
1396 batch
->maxy
= MAX2(batch
->maxy
, maxy
);
1400 panfrost_batch_intersection_scissor(struct panfrost_batch
*batch
,
1401 unsigned minx
, unsigned miny
,
1402 unsigned maxx
, unsigned maxy
)
1404 batch
->minx
= MAX2(batch
->minx
, minx
);
1405 batch
->miny
= MAX2(batch
->miny
, miny
);
1406 batch
->maxx
= MIN2(batch
->maxx
, maxx
);
1407 batch
->maxy
= MIN2(batch
->maxy
, maxy
);
1410 /* Are we currently rendering to the dev (rather than an FBO)? */
1413 panfrost_batch_is_scanout(struct panfrost_batch
*batch
)
1415 /* If there is no color buffer, it's an FBO */
1416 if (batch
->key
.nr_cbufs
!= 1)
1419 /* If we're too early that no framebuffer was sent, it's scanout */
1420 if (!batch
->key
.cbufs
[0])
1423 return batch
->key
.cbufs
[0]->texture
->bind
& PIPE_BIND_DISPLAY_TARGET
||
1424 batch
->key
.cbufs
[0]->texture
->bind
& PIPE_BIND_SCANOUT
||
1425 batch
->key
.cbufs
[0]->texture
->bind
& PIPE_BIND_SHARED
;
1429 panfrost_batch_init(struct panfrost_context
*ctx
)
1431 ctx
->batches
= _mesa_hash_table_create(ctx
,
1432 panfrost_batch_hash
,
1433 panfrost_batch_compare
);
1434 ctx
->accessed_bos
= _mesa_hash_table_create(ctx
, _mesa_hash_pointer
,
1435 _mesa_key_pointer_equal
);