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/u_format.h"
35 #include "util/u_pack_color.h"
37 #include "pandecode/decode.h"
39 static struct panfrost_batch_fence
*
40 panfrost_create_batch_fence(struct panfrost_batch
*batch
)
42 struct panfrost_batch_fence
*fence
;
45 fence
= rzalloc(NULL
, struct panfrost_batch_fence
);
47 pipe_reference_init(&fence
->reference
, 1);
48 fence
->ctx
= batch
->ctx
;
50 ret
= drmSyncobjCreate(pan_screen(batch
->ctx
->base
.screen
)->fd
, 0,
58 panfrost_free_batch_fence(struct panfrost_batch_fence
*fence
)
60 drmSyncobjDestroy(pan_screen(fence
->ctx
->base
.screen
)->fd
,
66 panfrost_batch_fence_unreference(struct panfrost_batch_fence
*fence
)
68 if (pipe_reference(&fence
->reference
, NULL
))
69 panfrost_free_batch_fence(fence
);
73 panfrost_batch_fence_reference(struct panfrost_batch_fence
*fence
)
75 pipe_reference(NULL
, &fence
->reference
);
78 static struct panfrost_batch
*
79 panfrost_create_batch(struct panfrost_context
*ctx
,
80 const struct pipe_framebuffer_state
*key
)
82 struct panfrost_batch
*batch
= rzalloc(ctx
, struct panfrost_batch
);
86 batch
->bos
= _mesa_hash_table_create(batch
, _mesa_hash_pointer
,
87 _mesa_key_pointer_equal
);
89 batch
->minx
= batch
->miny
= ~0;
90 batch
->maxx
= batch
->maxy
= 0;
91 batch
->transient_offset
= 0;
93 util_dynarray_init(&batch
->headers
, batch
);
94 util_dynarray_init(&batch
->gpu_headers
, batch
);
95 batch
->out_sync
= panfrost_create_batch_fence(batch
);
96 util_copy_framebuffer_state(&batch
->key
, key
);
102 panfrost_free_batch(struct panfrost_batch
*batch
)
107 struct panfrost_context
*ctx
= batch
->ctx
;
109 hash_table_foreach(batch
->bos
, entry
)
110 panfrost_bo_unreference((struct panfrost_bo
*)entry
->key
);
112 _mesa_hash_table_remove_key(ctx
->batches
, &batch
->key
);
114 if (ctx
->batch
== batch
)
117 /* The out_sync fence lifetime is different from the the batch one
118 * since other batches might want to wait on a fence of already
119 * submitted/signaled batch. All we need to do here is make sure the
120 * fence does not point to an invalid batch, which the core will
121 * interpret as 'batch is already submitted'.
123 batch
->out_sync
->batch
= NULL
;
124 panfrost_batch_fence_unreference(batch
->out_sync
);
126 util_unreference_framebuffer_state(&batch
->key
);
130 static struct panfrost_batch
*
131 panfrost_get_batch(struct panfrost_context
*ctx
,
132 const struct pipe_framebuffer_state
*key
)
134 /* Lookup the job first */
135 struct hash_entry
*entry
= _mesa_hash_table_search(ctx
->batches
, key
);
140 /* Otherwise, let's create a job */
142 struct panfrost_batch
*batch
= panfrost_create_batch(ctx
, key
);
144 /* Save the created job */
145 _mesa_hash_table_insert(ctx
->batches
, &batch
->key
, batch
);
150 /* Get the job corresponding to the FBO we're currently rendering into */
152 struct panfrost_batch
*
153 panfrost_get_batch_for_fbo(struct panfrost_context
*ctx
)
155 /* If we're wallpapering, we special case to workaround
158 if (ctx
->wallpaper_batch
)
159 return ctx
->wallpaper_batch
;
161 /* If we already began rendering, use that */
164 assert(util_framebuffer_state_equal(&ctx
->batch
->key
,
165 &ctx
->pipe_framebuffer
));
169 /* If not, look up the job */
170 struct panfrost_batch
*batch
= panfrost_get_batch(ctx
,
171 &ctx
->pipe_framebuffer
);
173 /* Set this job as the current FBO job. Will be reset when updating the
174 * FB state and when submitting or releasing a job.
181 panfrost_batch_add_bo(struct panfrost_batch
*batch
, struct panfrost_bo
*bo
,
187 struct hash_entry
*entry
;
188 uint32_t old_flags
= 0;
190 entry
= _mesa_hash_table_search(batch
->bos
, bo
);
192 entry
= _mesa_hash_table_insert(batch
->bos
, bo
,
193 (void *)(uintptr_t)flags
);
194 panfrost_bo_reference(bo
);
196 old_flags
= (uintptr_t)entry
->data
;
201 if (old_flags
== flags
)
205 entry
->data
= (void *)(uintptr_t)flags
;
208 void panfrost_batch_add_fbo_bos(struct panfrost_batch
*batch
)
210 uint32_t flags
= PAN_BO_ACCESS_SHARED
| PAN_BO_ACCESS_WRITE
|
211 PAN_BO_ACCESS_VERTEX_TILER
|
212 PAN_BO_ACCESS_FRAGMENT
;
214 for (unsigned i
= 0; i
< batch
->key
.nr_cbufs
; ++i
) {
215 struct panfrost_resource
*rsrc
= pan_resource(batch
->key
.cbufs
[i
]->texture
);
216 panfrost_batch_add_bo(batch
, rsrc
->bo
, flags
);
219 if (batch
->key
.zsbuf
) {
220 struct panfrost_resource
*rsrc
= pan_resource(batch
->key
.zsbuf
->texture
);
221 panfrost_batch_add_bo(batch
, rsrc
->bo
, flags
);
226 panfrost_batch_create_bo(struct panfrost_batch
*batch
, size_t size
,
227 uint32_t create_flags
, uint32_t access_flags
)
229 struct panfrost_bo
*bo
;
231 bo
= panfrost_bo_create(pan_screen(batch
->ctx
->base
.screen
), size
,
233 panfrost_batch_add_bo(batch
, bo
, access_flags
);
235 /* panfrost_batch_add_bo() has retained a reference and
236 * panfrost_bo_create() initialize the refcnt to 1, so let's
237 * unreference the BO here so it gets released when the batch is
238 * destroyed (unless it's retained by someone else in the meantime).
240 panfrost_bo_unreference(bo
);
244 /* Returns the polygon list's GPU address if available, or otherwise allocates
245 * the polygon list. It's perfectly fast to use allocate/free BO directly,
246 * since we'll hit the BO cache and this is one-per-batch anyway. */
249 panfrost_batch_get_polygon_list(struct panfrost_batch
*batch
, unsigned size
)
251 if (batch
->polygon_list
) {
252 assert(batch
->polygon_list
->size
>= size
);
254 /* Create the BO as invisible, as there's no reason to map */
256 batch
->polygon_list
= panfrost_batch_create_bo(batch
, size
,
258 PAN_BO_ACCESS_PRIVATE
|
260 PAN_BO_ACCESS_VERTEX_TILER
|
261 PAN_BO_ACCESS_FRAGMENT
);
264 return batch
->polygon_list
->gpu
;
268 panfrost_batch_get_scratchpad(struct panfrost_batch
*batch
)
270 if (batch
->scratchpad
)
271 return batch
->scratchpad
;
273 batch
->scratchpad
= panfrost_batch_create_bo(batch
, 64 * 4 * 4096,
275 PAN_BO_ACCESS_PRIVATE
|
277 PAN_BO_ACCESS_VERTEX_TILER
|
278 PAN_BO_ACCESS_FRAGMENT
);
279 assert(batch
->scratchpad
);
280 return batch
->scratchpad
;
284 panfrost_batch_get_tiler_heap(struct panfrost_batch
*batch
)
286 if (batch
->tiler_heap
)
287 return batch
->tiler_heap
;
289 batch
->tiler_heap
= panfrost_batch_create_bo(batch
, 4096 * 4096,
292 PAN_BO_ACCESS_PRIVATE
|
294 PAN_BO_ACCESS_VERTEX_TILER
|
295 PAN_BO_ACCESS_FRAGMENT
);
296 assert(batch
->tiler_heap
);
297 return batch
->tiler_heap
;
301 panfrost_batch_get_tiler_dummy(struct panfrost_batch
*batch
)
303 if (batch
->tiler_dummy
)
304 return batch
->tiler_dummy
;
306 batch
->tiler_dummy
= panfrost_batch_create_bo(batch
, 4096,
308 PAN_BO_ACCESS_PRIVATE
|
310 PAN_BO_ACCESS_VERTEX_TILER
|
311 PAN_BO_ACCESS_FRAGMENT
);
312 assert(batch
->tiler_dummy
);
313 return batch
->tiler_dummy
;
317 panfrost_batch_draw_wallpaper(struct panfrost_batch
*batch
)
319 /* Nothing to reload? TODO: MRT wallpapers */
320 if (batch
->key
.cbufs
[0] == NULL
)
323 /* Check if the buffer has any content on it worth preserving */
325 struct pipe_surface
*surf
= batch
->key
.cbufs
[0];
326 struct panfrost_resource
*rsrc
= pan_resource(surf
->texture
);
327 unsigned level
= surf
->u
.tex
.level
;
329 if (!rsrc
->slices
[level
].initialized
)
332 batch
->ctx
->wallpaper_batch
= batch
;
334 /* Clamp the rendering area to the damage extent. The
335 * KHR_partial_update() spec states that trying to render outside of
336 * the damage region is "undefined behavior", so we should be safe.
338 unsigned damage_width
= (rsrc
->damage
.extent
.maxx
- rsrc
->damage
.extent
.minx
);
339 unsigned damage_height
= (rsrc
->damage
.extent
.maxy
- rsrc
->damage
.extent
.miny
);
341 if (damage_width
&& damage_height
) {
342 panfrost_batch_intersection_scissor(batch
,
343 rsrc
->damage
.extent
.minx
,
344 rsrc
->damage
.extent
.miny
,
345 rsrc
->damage
.extent
.maxx
,
346 rsrc
->damage
.extent
.maxy
);
349 /* FIXME: Looks like aligning on a tile is not enough, but
350 * aligning on twice the tile size seems to works. We don't
351 * know exactly what happens here but this deserves extra
352 * investigation to figure it out.
354 batch
->minx
= batch
->minx
& ~((MALI_TILE_LENGTH
* 2) - 1);
355 batch
->miny
= batch
->miny
& ~((MALI_TILE_LENGTH
* 2) - 1);
356 batch
->maxx
= MIN2(ALIGN_POT(batch
->maxx
, MALI_TILE_LENGTH
* 2),
358 batch
->maxy
= MIN2(ALIGN_POT(batch
->maxy
, MALI_TILE_LENGTH
* 2),
361 struct pipe_scissor_state damage
;
362 struct pipe_box rects
[4];
364 /* Clamp the damage box to the rendering area. */
365 damage
.minx
= MAX2(batch
->minx
, rsrc
->damage
.biggest_rect
.x
);
366 damage
.miny
= MAX2(batch
->miny
, rsrc
->damage
.biggest_rect
.y
);
367 damage
.maxx
= MIN2(batch
->maxx
,
368 rsrc
->damage
.biggest_rect
.x
+
369 rsrc
->damage
.biggest_rect
.width
);
370 damage
.maxy
= MIN2(batch
->maxy
,
371 rsrc
->damage
.biggest_rect
.y
+
372 rsrc
->damage
.biggest_rect
.height
);
374 /* One damage rectangle means we can end up with at most 4 reload
376 * 1: left region, only exists if damage.x > 0
377 * 2: right region, only exists if damage.x + damage.width < fb->width
378 * 3: top region, only exists if damage.y > 0. The intersection with
379 * the left and right regions are dropped
380 * 4: bottom region, only exists if damage.y + damage.height < fb->height.
381 * The intersection with the left and right regions are dropped
383 * ____________________________
390 * |_______|___________|______|
392 u_box_2d(batch
->minx
, batch
->miny
, damage
.minx
- batch
->minx
,
393 batch
->maxy
- batch
->miny
, &rects
[0]);
394 u_box_2d(damage
.maxx
, batch
->miny
, batch
->maxx
- damage
.maxx
,
395 batch
->maxy
- batch
->miny
, &rects
[1]);
396 u_box_2d(damage
.minx
, batch
->miny
, damage
.maxx
- damage
.minx
,
397 damage
.miny
- batch
->miny
, &rects
[2]);
398 u_box_2d(damage
.minx
, damage
.maxy
, damage
.maxx
- damage
.minx
,
399 batch
->maxy
- damage
.maxy
, &rects
[3]);
401 for (unsigned i
= 0; i
< 4; i
++) {
402 /* Width and height are always >= 0 even if width is declared as a
403 * signed integer: u_box_2d() helper takes unsigned args and
404 * panfrost_set_damage_region() is taking care of clamping
407 if (!rects
[i
].width
|| !rects
[i
].height
)
410 /* Blit the wallpaper in */
411 panfrost_blit_wallpaper(batch
->ctx
, &rects
[i
]);
413 batch
->ctx
->wallpaper_batch
= NULL
;
417 panfrost_batch_submit_ioctl(struct panfrost_batch
*batch
,
418 mali_ptr first_job_desc
,
421 struct panfrost_context
*ctx
= batch
->ctx
;
422 struct pipe_context
*gallium
= (struct pipe_context
*) ctx
;
423 struct panfrost_screen
*screen
= pan_screen(gallium
->screen
);
424 struct drm_panfrost_submit submit
= {0,};
425 uint32_t *bo_handles
;
428 submit
.in_syncs
= (u64
) (uintptr_t) &ctx
->out_sync
;
429 submit
.in_sync_count
= 1;
431 submit
.out_sync
= ctx
->out_sync
;
433 submit
.jc
= first_job_desc
;
434 submit
.requirements
= reqs
;
436 bo_handles
= calloc(batch
->bos
->entries
, sizeof(*bo_handles
));
439 hash_table_foreach(batch
->bos
, entry
) {
440 struct panfrost_bo
*bo
= (struct panfrost_bo
*)entry
->key
;
441 assert(bo
->gem_handle
> 0);
442 bo_handles
[submit
.bo_handle_count
++] = bo
->gem_handle
;
445 submit
.bo_handles
= (u64
) (uintptr_t) bo_handles
;
446 ret
= drmIoctl(screen
->fd
, DRM_IOCTL_PANFROST_SUBMIT
, &submit
);
449 fprintf(stderr
, "Error submitting: %m\n");
453 /* Trace the job if we're doing that */
454 if (pan_debug
& PAN_DBG_TRACE
) {
455 /* Wait so we can get errors reported back */
456 drmSyncobjWait(screen
->fd
, &ctx
->out_sync
, 1, INT64_MAX
, 0, NULL
);
457 pandecode_jc(submit
.jc
, FALSE
);
464 panfrost_batch_submit_jobs(struct panfrost_batch
*batch
)
466 bool has_draws
= batch
->first_job
.gpu
;
470 ret
= panfrost_batch_submit_ioctl(batch
, batch
->first_job
.gpu
, 0);
474 if (batch
->first_tiler
.gpu
|| batch
->clear
) {
475 mali_ptr fragjob
= panfrost_fragment_job(batch
, has_draws
);
477 ret
= panfrost_batch_submit_ioctl(batch
, fragjob
, PANFROST_JD_REQ_FS
);
485 panfrost_batch_submit(struct panfrost_batch
*batch
)
489 struct panfrost_context
*ctx
= batch
->ctx
;
493 if (!batch
->last_job
.gpu
&& !batch
->clear
) {
494 /* Mark the fence as signaled so the fence logic does not try
497 batch
->out_sync
->signaled
= true;
501 if (!batch
->clear
&& batch
->last_tiler
.gpu
)
502 panfrost_batch_draw_wallpaper(batch
);
504 panfrost_scoreboard_link_batch(batch
);
506 ret
= panfrost_batch_submit_jobs(batch
);
509 fprintf(stderr
, "panfrost_batch_submit failed: %d\n", ret
);
512 /* If this is the bound batch, the panfrost_context parameters are
513 * relevant so submitting it invalidates those paramaters, but if it's
514 * not bound, the context parameters are for some other batch so we
515 * can't invalidate them.
517 if (ctx
->batch
== batch
)
518 panfrost_invalidate_frame(ctx
);
520 /* The job has been submitted, let's invalidate the current FBO job
523 assert(!ctx
->batch
|| batch
== ctx
->batch
);
526 /* We always stall the pipeline for correct results since pipelined
527 * rendering is quite broken right now (to be fixed by the panfrost_job
528 * refactor, just take the perf hit for correctness)
530 drmSyncobjWait(pan_screen(ctx
->base
.screen
)->fd
, &ctx
->out_sync
, 1,
532 panfrost_free_batch(batch
);
536 panfrost_batch_set_requirements(struct panfrost_batch
*batch
)
538 struct panfrost_context
*ctx
= batch
->ctx
;
540 if (ctx
->rasterizer
&& ctx
->rasterizer
->base
.multisample
)
541 batch
->requirements
|= PAN_REQ_MSAA
;
543 if (ctx
->depth_stencil
&& ctx
->depth_stencil
->depth
.writemask
)
544 batch
->requirements
|= PAN_REQ_DEPTH_WRITE
;
547 /* Helper to smear a 32-bit color across 128-bit components */
550 pan_pack_color_32(uint32_t *packed
, uint32_t v
)
552 for (unsigned i
= 0; i
< 4; ++i
)
557 pan_pack_color_64(uint32_t *packed
, uint32_t lo
, uint32_t hi
)
559 for (unsigned i
= 0; i
< 4; i
+= 2) {
566 pan_pack_color(uint32_t *packed
, const union pipe_color_union
*color
, enum pipe_format format
)
568 /* Alpha magicked to 1.0 if there is no alpha */
570 bool has_alpha
= util_format_has_alpha(format
);
571 float clear_alpha
= has_alpha
? color
->f
[3] : 1.0f
;
573 /* Packed color depends on the framebuffer format */
575 const struct util_format_description
*desc
=
576 util_format_description(format
);
578 if (util_format_is_rgba8_variant(desc
)) {
579 pan_pack_color_32(packed
,
580 (float_to_ubyte(clear_alpha
) << 24) |
581 (float_to_ubyte(color
->f
[2]) << 16) |
582 (float_to_ubyte(color
->f
[1]) << 8) |
583 (float_to_ubyte(color
->f
[0]) << 0));
584 } else if (format
== PIPE_FORMAT_B5G6R5_UNORM
) {
585 /* First, we convert the components to R5, G6, B5 separately */
586 unsigned r5
= CLAMP(color
->f
[0], 0.0, 1.0) * 31.0;
587 unsigned g6
= CLAMP(color
->f
[1], 0.0, 1.0) * 63.0;
588 unsigned b5
= CLAMP(color
->f
[2], 0.0, 1.0) * 31.0;
590 /* Then we pack into a sparse u32. TODO: Why these shifts? */
591 pan_pack_color_32(packed
, (b5
<< 25) | (g6
<< 14) | (r5
<< 5));
592 } else if (format
== PIPE_FORMAT_B4G4R4A4_UNORM
) {
593 /* We scale the components against 0xF0 (=240.0), rather than 0xFF */
594 unsigned r4
= CLAMP(color
->f
[0], 0.0, 1.0) * 240.0;
595 unsigned g4
= CLAMP(color
->f
[1], 0.0, 1.0) * 240.0;
596 unsigned b4
= CLAMP(color
->f
[2], 0.0, 1.0) * 240.0;
597 unsigned a4
= CLAMP(clear_alpha
, 0.0, 1.0) * 240.0;
599 /* Pack on *byte* intervals */
600 pan_pack_color_32(packed
, (a4
<< 24) | (b4
<< 16) | (g4
<< 8) | r4
);
601 } else if (format
== PIPE_FORMAT_B5G5R5A1_UNORM
) {
602 /* Scale as expected but shift oddly */
603 unsigned r5
= round(CLAMP(color
->f
[0], 0.0, 1.0)) * 31.0;
604 unsigned g5
= round(CLAMP(color
->f
[1], 0.0, 1.0)) * 31.0;
605 unsigned b5
= round(CLAMP(color
->f
[2], 0.0, 1.0)) * 31.0;
606 unsigned a1
= round(CLAMP(clear_alpha
, 0.0, 1.0)) * 1.0;
608 pan_pack_color_32(packed
, (a1
<< 31) | (b5
<< 25) | (g5
<< 15) | (r5
<< 5));
610 /* Try Gallium's generic default path. Doesn't work for all
611 * formats but it's a good guess. */
613 union util_color out
;
615 if (util_format_is_pure_integer(format
)) {
616 memcpy(out
.ui
, color
->ui
, 16);
618 util_pack_color(color
->f
, format
, &out
);
621 unsigned size
= util_format_get_blocksize(format
);
624 unsigned b
= out
.ui
[0];
625 unsigned s
= b
| (b
<< 8);
626 pan_pack_color_32(packed
, s
| (s
<< 16));
627 } else if (size
== 2)
628 pan_pack_color_32(packed
, out
.ui
[0] | (out
.ui
[0] << 16));
630 pan_pack_color_32(packed
, out
.ui
[0]);
632 pan_pack_color_64(packed
, out
.ui
[0], out
.ui
[1]);
634 memcpy(packed
, out
.ui
, 16);
636 unreachable("Unknown generic format size packing clear colour");
641 panfrost_batch_clear(struct panfrost_batch
*batch
,
643 const union pipe_color_union
*color
,
644 double depth
, unsigned stencil
)
646 struct panfrost_context
*ctx
= batch
->ctx
;
648 if (buffers
& PIPE_CLEAR_COLOR
) {
649 for (unsigned i
= 0; i
< PIPE_MAX_COLOR_BUFS
; ++i
) {
650 if (!(buffers
& (PIPE_CLEAR_COLOR0
<< i
)))
653 enum pipe_format format
= ctx
->pipe_framebuffer
.cbufs
[i
]->format
;
654 pan_pack_color(batch
->clear_color
[i
], color
, format
);
658 if (buffers
& PIPE_CLEAR_DEPTH
) {
659 batch
->clear_depth
= depth
;
662 if (buffers
& PIPE_CLEAR_STENCIL
) {
663 batch
->clear_stencil
= stencil
;
666 batch
->clear
|= buffers
;
668 /* Clearing affects the entire framebuffer (by definition -- this is
669 * the Gallium clear callback, which clears the whole framebuffer. If
670 * the scissor test were enabled from the GL side, the state tracker
671 * would emit a quad instead and we wouldn't go down this code path) */
673 panfrost_batch_union_scissor(batch
, 0, 0,
674 ctx
->pipe_framebuffer
.width
,
675 ctx
->pipe_framebuffer
.height
);
679 panfrost_batch_compare(const void *a
, const void *b
)
681 return util_framebuffer_state_equal(a
, b
);
685 panfrost_batch_hash(const void *key
)
687 return _mesa_hash_data(key
, sizeof(struct pipe_framebuffer_state
));
690 /* Given a new bounding rectangle (scissor), let the job cover the union of the
691 * new and old bounding rectangles */
694 panfrost_batch_union_scissor(struct panfrost_batch
*batch
,
695 unsigned minx
, unsigned miny
,
696 unsigned maxx
, unsigned maxy
)
698 batch
->minx
= MIN2(batch
->minx
, minx
);
699 batch
->miny
= MIN2(batch
->miny
, miny
);
700 batch
->maxx
= MAX2(batch
->maxx
, maxx
);
701 batch
->maxy
= MAX2(batch
->maxy
, maxy
);
705 panfrost_batch_intersection_scissor(struct panfrost_batch
*batch
,
706 unsigned minx
, unsigned miny
,
707 unsigned maxx
, unsigned maxy
)
709 batch
->minx
= MAX2(batch
->minx
, minx
);
710 batch
->miny
= MAX2(batch
->miny
, miny
);
711 batch
->maxx
= MIN2(batch
->maxx
, maxx
);
712 batch
->maxy
= MIN2(batch
->maxy
, maxy
);
715 /* Are we currently rendering to the screen (rather than an FBO)? */
718 panfrost_batch_is_scanout(struct panfrost_batch
*batch
)
720 /* If there is no color buffer, it's an FBO */
721 if (batch
->key
.nr_cbufs
!= 1)
724 /* If we're too early that no framebuffer was sent, it's scanout */
725 if (!batch
->key
.cbufs
[0])
728 return batch
->key
.cbufs
[0]->texture
->bind
& PIPE_BIND_DISPLAY_TARGET
||
729 batch
->key
.cbufs
[0]->texture
->bind
& PIPE_BIND_SCANOUT
||
730 batch
->key
.cbufs
[0]->texture
->bind
& PIPE_BIND_SHARED
;
734 panfrost_batch_init(struct panfrost_context
*ctx
)
736 ctx
->batches
= _mesa_hash_table_create(ctx
,
738 panfrost_batch_compare
);