2 * Copyright © 2017 Broadcom
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include "util/u_format.h"
25 #include "vc5_context.h"
26 #include "vc5_tiling.h"
27 #include "broadcom/common/v3d_macros.h"
28 #include "broadcom/cle/v3dx_pack.h"
30 #define PIPE_CLEAR_COLOR_BUFFERS (PIPE_CLEAR_COLOR0 | \
35 #define PIPE_FIRST_COLOR_BUFFER_BIT (ffs(PIPE_CLEAR_COLOR0) - 1)
38 load_general(struct vc5_cl
*cl
, struct pipe_surface
*psurf
, int buffer
)
40 struct vc5_surface
*surf
= vc5_surface(psurf
);
41 bool separate_stencil
= surf
->separate_stencil
&& buffer
== STENCIL
;
42 if (separate_stencil
) {
43 psurf
= surf
->separate_stencil
;
44 surf
= vc5_surface(psurf
);
47 struct vc5_resource
*rsc
= vc5_resource(psurf
->texture
);
49 cl_emit(cl
, LOAD_TILE_BUFFER_GENERAL
, load
) {
50 load
.buffer_to_load
= buffer
;
51 load
.address
= cl_address(rsc
->bo
, surf
->offset
);
54 load
.memory_format
= surf
->tiling
;
56 load
.input_image_format
= V3D_OUTPUT_IMAGE_FORMAT_S8
;
58 load
.input_image_format
= surf
->format
;
60 if (surf
->tiling
== VC5_TILING_UIF_NO_XOR
||
61 surf
->tiling
== VC5_TILING_UIF_XOR
) {
62 load
.height_in_ub_or_stride
=
63 surf
->padded_height_of_output_image_in_uif_blocks
;
64 } else if (surf
->tiling
== VC5_TILING_RASTER
) {
65 struct vc5_resource_slice
*slice
=
66 &rsc
->slices
[psurf
->u
.tex
.level
];
67 load
.height_in_ub_or_stride
= slice
->stride
;
71 #else /* V3D_VERSION < 40 */
73 load
.padded_height_of_output_image_in_uif_blocks
=
74 surf
->padded_height_of_output_image_in_uif_blocks
;
75 #endif /* V3D_VERSION < 40 */
80 store_general(struct vc5_job
*job
,
81 struct vc5_cl
*cl
, struct pipe_surface
*psurf
, int buffer
,
82 int pipe_bit
, bool last_store
, bool general_color_clear
)
84 struct vc5_surface
*surf
= vc5_surface(psurf
);
85 bool separate_stencil
= surf
->separate_stencil
&& buffer
== STENCIL
;
86 if (separate_stencil
) {
87 psurf
= surf
->separate_stencil
;
88 surf
= vc5_surface(psurf
);
91 struct vc5_resource
*rsc
= vc5_resource(psurf
->texture
);
95 cl_emit(cl
, STORE_TILE_BUFFER_GENERAL
, store
) {
96 store
.buffer_to_store
= buffer
;
97 store
.address
= cl_address(rsc
->bo
, surf
->offset
);
100 store
.clear_buffer_being_stored
=
101 ((job
->cleared
& pipe_bit
) &&
102 (general_color_clear
||
103 !(pipe_bit
& PIPE_CLEAR_COLOR_BUFFERS
)));
105 if (separate_stencil
)
106 store
.output_image_format
= V3D_OUTPUT_IMAGE_FORMAT_S8
;
108 store
.output_image_format
= surf
->format
;
110 store
.memory_format
= surf
->tiling
;
112 if (surf
->tiling
== VC5_TILING_UIF_NO_XOR
||
113 surf
->tiling
== VC5_TILING_UIF_XOR
) {
114 store
.height_in_ub_or_stride
=
115 surf
->padded_height_of_output_image_in_uif_blocks
;
116 } else if (surf
->tiling
== VC5_TILING_RASTER
) {
117 struct vc5_resource_slice
*slice
=
118 &rsc
->slices
[psurf
->u
.tex
.level
];
119 store
.height_in_ub_or_stride
= slice
->stride
;
121 #else /* V3D_VERSION < 40 */
122 store
.raw_mode
= true;
124 store
.disable_colour_buffers_clear_on_write
= true;
125 store
.disable_z_buffer_clear_on_write
= true;
126 store
.disable_stencil_buffer_clear_on_write
= true;
128 store
.disable_colour_buffers_clear_on_write
=
129 !(((pipe_bit
& PIPE_CLEAR_COLOR_BUFFERS
) &&
130 general_color_clear
&&
131 (job
->cleared
& pipe_bit
)));
132 store
.disable_z_buffer_clear_on_write
=
133 !(job
->cleared
& PIPE_CLEAR_DEPTH
);
134 store
.disable_stencil_buffer_clear_on_write
=
135 !(job
->cleared
& PIPE_CLEAR_STENCIL
);
137 store
.padded_height_of_output_image_in_uif_blocks
=
138 surf
->padded_height_of_output_image_in_uif_blocks
;
139 #endif /* V3D_VERSION < 40 */
144 zs_buffer_from_pipe_bits(int pipe_clear_bits
)
146 switch (pipe_clear_bits
& PIPE_CLEAR_DEPTHSTENCIL
) {
147 case PIPE_CLEAR_DEPTHSTENCIL
:
149 case PIPE_CLEAR_DEPTH
:
151 case PIPE_CLEAR_STENCIL
:
158 /* The HW queues up the load until the tile coordinates show up, but can only
159 * track one at a time. If we need to do more than one load, then we need to
160 * flush out the previous load by emitting the tile coordinates and doing a
164 flush_last_load(struct vc5_cl
*cl
)
166 if (V3D_VERSION
>= 40)
169 cl_emit(cl
, TILE_COORDINATES_IMPLICIT
, coords
);
170 cl_emit(cl
, STORE_TILE_BUFFER_GENERAL
, store
) {
171 store
.buffer_to_store
= NONE
;
176 vc5_rcl_emit_loads(struct vc5_job
*job
, struct vc5_cl
*cl
)
178 uint32_t read_but_not_cleared
= job
->resolve
& ~job
->cleared
;
180 for (int i
= 0; i
< VC5_MAX_DRAW_BUFFERS
; i
++) {
181 uint32_t bit
= PIPE_CLEAR_COLOR0
<< i
;
182 if (!(read_but_not_cleared
& bit
))
185 struct pipe_surface
*psurf
= job
->cbufs
[i
];
186 if (!psurf
|| (V3D_VERSION
< 40 &&
187 psurf
->texture
->nr_samples
<= 1)) {
191 load_general(cl
, psurf
, RENDER_TARGET_0
+ i
);
192 read_but_not_cleared
&= ~bit
;
194 if (read_but_not_cleared
)
198 if (read_but_not_cleared
& PIPE_CLEAR_DEPTHSTENCIL
&&
199 (V3D_VERSION
>= 40 ||
200 (job
->zsbuf
&& job
->zsbuf
->texture
->nr_samples
> 1))) {
201 load_general(cl
, job
->zsbuf
,
202 zs_buffer_from_pipe_bits(read_but_not_cleared
));
203 read_but_not_cleared
&= ~PIPE_CLEAR_DEPTHSTENCIL
;
204 if (read_but_not_cleared
)
205 cl_emit(cl
, TILE_COORDINATES_IMPLICIT
, coords
);
209 /* The initial reload will be queued until we get the
212 if (read_but_not_cleared
) {
213 cl_emit(cl
, RELOAD_TILE_COLOUR_BUFFER
, load
) {
214 load
.disable_colour_buffer_load
=
215 (~read_but_not_cleared
&
216 PIPE_CLEAR_COLOR_BUFFERS
) >>
217 PIPE_FIRST_COLOR_BUFFER_BIT
;
219 read_but_not_cleared
& PIPE_CLEAR_DEPTH
;
220 load
.enable_stencil_load
=
221 read_but_not_cleared
& PIPE_CLEAR_STENCIL
;
224 #else /* V3D_VERSION >= 40 */
225 assert(!read_but_not_cleared
);
226 cl_emit(cl
, END_OF_LOADS
, end
);
231 vc5_rcl_emit_stores(struct vc5_job
*job
, struct vc5_cl
*cl
)
233 MAYBE_UNUSED
bool needs_color_clear
= job
->cleared
& PIPE_CLEAR_COLOR_BUFFERS
;
234 MAYBE_UNUSED
bool needs_z_clear
= job
->cleared
& PIPE_CLEAR_DEPTH
;
235 MAYBE_UNUSED
bool needs_s_clear
= job
->cleared
& PIPE_CLEAR_STENCIL
;
237 /* For clearing color in a TLB general on V3D 3.3:
239 * - NONE buffer store clears all TLB color buffers.
240 * - color buffer store clears just the TLB color buffer being stored.
241 * - Z/S buffers store may not clear the TLB color buffer.
243 * And on V3D 4.1, we only have one flag for "clear the buffer being
244 * stored" in the general packet, and a separate packet to clear all
247 * As a result, we only bother flagging TLB color clears in a general
248 * packet when we don't have to emit a separate packet to clear all
251 bool general_color_clear
= (needs_color_clear
&&
252 (job
->cleared
& PIPE_CLEAR_COLOR_BUFFERS
) ==
253 (job
->resolve
& PIPE_CLEAR_COLOR_BUFFERS
));
255 uint32_t stores_pending
= job
->resolve
;
257 /* For V3D 4.1, use general stores for all TLB stores.
259 * For V3D 3.3, we only use general stores to do raw stores for any
260 * MSAA surfaces. These output UIF tiled images where each 4x MSAA
261 * pixel is a 2x2 quad, and the format will be that of the
262 * internal_type/internal_bpp, rather than the format from GL's
263 * perspective. Non-MSAA surfaces will use
264 * STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED.
266 for (int i
= 0; i
< VC5_MAX_DRAW_BUFFERS
; i
++) {
267 uint32_t bit
= PIPE_CLEAR_COLOR0
<< i
;
268 if (!(job
->resolve
& bit
))
271 struct pipe_surface
*psurf
= job
->cbufs
[i
];
273 (V3D_VERSION
< 40 && psurf
->texture
->nr_samples
<= 1)) {
277 stores_pending
&= ~bit
;
278 store_general(job
, cl
, psurf
, RENDER_TARGET_0
+ i
, bit
,
279 !stores_pending
, general_color_clear
);
280 if (V3D_VERSION
< 40 && stores_pending
)
281 cl_emit(cl
, TILE_COORDINATES_IMPLICIT
, coords
);
284 if (job
->resolve
& PIPE_CLEAR_DEPTHSTENCIL
&& job
->zsbuf
&&
285 !(V3D_VERSION
< 40 && job
->zsbuf
->texture
->nr_samples
<= 1)) {
286 stores_pending
&= ~PIPE_CLEAR_DEPTHSTENCIL
;
288 struct vc5_resource
*rsc
= vc5_resource(job
->zsbuf
->texture
);
289 if (rsc
->separate_stencil
) {
290 if (job
->resolve
& PIPE_CLEAR_DEPTH
) {
291 store_general(job
, cl
, job
->zsbuf
, Z
,
294 general_color_clear
);
296 if (job
->resolve
& PIPE_CLEAR_STENCIL
) {
297 store_general(job
, cl
, job
->zsbuf
, STENCIL
,
300 general_color_clear
);
303 store_general(job
, cl
, job
->zsbuf
,
304 zs_buffer_from_pipe_bits(job
->resolve
),
305 job
->resolve
& PIPE_CLEAR_DEPTHSTENCIL
,
306 !stores_pending
, general_color_clear
);
309 if (V3D_VERSION
< 40 && stores_pending
)
310 cl_emit(cl
, TILE_COORDINATES_IMPLICIT
, coords
);
313 if (stores_pending
) {
315 cl_emit(cl
, STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED
, store
) {
317 store
.disable_color_buffer_write
=
319 PIPE_FIRST_COLOR_BUFFER_BIT
) & 0xf;
320 store
.enable_z_write
= stores_pending
& PIPE_CLEAR_DEPTH
;
321 store
.enable_stencil_write
= stores_pending
& PIPE_CLEAR_STENCIL
;
323 /* Note that when set this will clear all of the color
326 store
.disable_colour_buffers_clear_on_write
=
328 store
.disable_z_buffer_clear_on_write
=
330 store
.disable_stencil_buffer_clear_on_write
=
333 #else /* V3D_VERSION >= 40 */
334 unreachable("All color buffers should have been stored.");
335 #endif /* V3D_VERSION >= 40 */
336 } else if (needs_color_clear
&& !general_color_clear
) {
337 /* If we didn't do our color clears in the general packet,
338 * then emit a packet to clear all the TLB color buffers now.
341 cl_emit(cl
, STORE_TILE_BUFFER_GENERAL
, store
) {
342 store
.buffer_to_store
= NONE
;
344 #else /* V3D_VERSION >= 40 */
345 cl_emit(cl
, CLEAR_TILE_BUFFERS
, clear
) {
346 clear
.clear_all_render_targets
= true;
348 #endif /* V3D_VERSION >= 40 */
353 vc5_rcl_emit_generic_per_tile_list(struct vc5_job
*job
, int last_cbuf
)
355 /* Emit the generic list in our indirect state -- the rcl will just
356 * have pointers into it.
358 struct vc5_cl
*cl
= &job
->indirect
;
359 vc5_cl_ensure_space(cl
, 200, 1);
360 struct vc5_cl_reloc tile_list_start
= cl_get_address(cl
);
362 if (V3D_VERSION
>= 40) {
363 /* V3D 4.x only requires a single tile coordinates, and
364 * END_OF_LOADS switches us between loading and rendering.
366 cl_emit(cl
, TILE_COORDINATES_IMPLICIT
, coords
);
369 vc5_rcl_emit_loads(job
, cl
);
371 if (V3D_VERSION
< 40) {
372 /* Tile Coordinates triggers the last reload and sets where
373 * the stores go. There must be one per store packet.
375 cl_emit(cl
, TILE_COORDINATES_IMPLICIT
, coords
);
378 /* The binner starts out writing tiles assuming that the initial mode
379 * is triangles, so make sure that's the case.
381 cl_emit(cl
, PRIMITIVE_LIST_FORMAT
, fmt
) {
382 fmt
.data_type
= LIST_INDEXED
;
383 fmt
.primitive_type
= LIST_TRIANGLES
;
386 cl_emit(cl
, BRANCH_TO_IMPLICIT_TILE_LIST
, branch
);
388 vc5_rcl_emit_stores(job
, cl
);
390 #if V3D_VERSION >= 40
391 cl_emit(cl
, END_OF_TILE_MARKER
, end
);
394 cl_emit(cl
, RETURN_FROM_SUB_LIST
, ret
);
396 cl_emit(&job
->rcl
, START_ADDRESS_OF_GENERIC_TILE_LIST
, branch
) {
397 branch
.start
= tile_list_start
;
398 branch
.end
= cl_get_address(cl
);
402 #if V3D_VERSION >= 40
404 v3d_setup_render_target(struct vc5_job
*job
, int cbuf
,
405 uint32_t *rt_bpp
, uint32_t *rt_type
, uint32_t *rt_clamp
)
407 if (!job
->cbufs
[cbuf
])
410 struct vc5_surface
*surf
= vc5_surface(job
->cbufs
[cbuf
]);
411 *rt_bpp
= surf
->internal_bpp
;
412 *rt_type
= surf
->internal_type
;
413 *rt_clamp
= V3D_RENDER_TARGET_CLAMP_NONE
;
416 #else /* V3D_VERSION < 40 */
419 v3d_emit_z_stencil_config(struct vc5_job
*job
, struct vc5_surface
*surf
,
420 struct vc5_resource
*rsc
, bool is_separate_stencil
)
422 cl_emit(&job
->rcl
, TILE_RENDERING_MODE_CONFIGURATION_Z_STENCIL_CONFIG
, zs
) {
423 zs
.address
= cl_address(rsc
->bo
, surf
->offset
);
425 if (!is_separate_stencil
) {
426 zs
.internal_type
= surf
->internal_type
;
427 zs
.output_image_format
= surf
->format
;
429 zs
.z_stencil_id
= 1; /* Separate stencil */
432 zs
.padded_height_of_output_image_in_uif_blocks
=
433 surf
->padded_height_of_output_image_in_uif_blocks
;
435 assert(surf
->tiling
!= VC5_TILING_RASTER
);
436 zs
.memory_format
= surf
->tiling
;
439 if (job
->resolve
& (is_separate_stencil
?
441 PIPE_CLEAR_DEPTHSTENCIL
)) {
445 #endif /* V3D_VERSION < 40 */
447 #define div_round_up(a, b) (((a) + (b) - 1) / b)
450 v3dX(emit_rcl
)(struct vc5_job
*job
)
452 /* The RCL list should be empty. */
453 assert(!job
->rcl
.bo
);
455 vc5_cl_ensure_space_with_branch(&job
->rcl
, 200 + 256 *
456 cl_packet_length(SUPERTILE_COORDINATES
));
457 job
->submit
.rcl_start
= job
->rcl
.bo
->offset
;
458 vc5_job_add_bo(job
, job
->rcl
.bo
);
461 for (int i
= 0; i
< VC5_MAX_DRAW_BUFFERS
; i
++) {
466 /* Comon config must be the first TILE_RENDERING_MODE_CONFIGURATION
467 * and Z_STENCIL_CLEAR_VALUES must be last. The ones in between are
468 * optional updates to the previous HW state.
470 cl_emit(&job
->rcl
, TILE_RENDERING_MODE_CONFIGURATION_COMMON_CONFIGURATION
,
473 config
.enable_z_store
= job
->resolve
& PIPE_CLEAR_DEPTH
;
474 config
.enable_stencil_store
= job
->resolve
& PIPE_CLEAR_STENCIL
;
475 #else /* V3D_VERSION >= 40 */
477 struct vc5_surface
*surf
= vc5_surface(job
->zsbuf
);
478 config
.internal_depth_type
= surf
->internal_type
;
480 #endif /* V3D_VERSION >= 40 */
482 /* XXX: Early D/S clear */
484 config
.early_z_disable
= !job
->uses_early_z
;
486 config
.image_width_pixels
= job
->draw_width
;
487 config
.image_height_pixels
= job
->draw_height
;
489 config
.number_of_render_targets_minus_1
=
490 MAX2(nr_cbufs
, 1) - 1;
492 config
.multisample_mode_4x
= job
->msaa
;
494 config
.maximum_bpp_of_all_render_targets
= job
->internal_bpp
;
497 for (int i
= 0; i
< nr_cbufs
; i
++) {
498 struct pipe_surface
*psurf
= job
->cbufs
[i
];
501 struct vc5_surface
*surf
= vc5_surface(psurf
);
502 struct vc5_resource
*rsc
= vc5_resource(psurf
->texture
);
504 MAYBE_UNUSED
uint32_t config_pad
= 0;
505 uint32_t clear_pad
= 0;
507 /* XXX: Set the pad for raster. */
508 if (surf
->tiling
== VC5_TILING_UIF_NO_XOR
||
509 surf
->tiling
== VC5_TILING_UIF_XOR
) {
510 int uif_block_height
= vc5_utile_height(rsc
->cpp
) * 2;
511 uint32_t implicit_padded_height
= (align(job
->draw_height
, uif_block_height
) /
513 if (surf
->padded_height_of_output_image_in_uif_blocks
-
514 implicit_padded_height
< 15) {
515 config_pad
= (surf
->padded_height_of_output_image_in_uif_blocks
-
516 implicit_padded_height
);
519 clear_pad
= surf
->padded_height_of_output_image_in_uif_blocks
;
524 cl_emit(&job
->rcl
, TILE_RENDERING_MODE_CONFIGURATION_RENDER_TARGET_CONFIG
, rt
) {
525 rt
.address
= cl_address(rsc
->bo
, surf
->offset
);
526 rt
.internal_type
= surf
->internal_type
;
527 rt
.output_image_format
= surf
->format
;
528 rt
.memory_format
= surf
->tiling
;
529 rt
.internal_bpp
= surf
->internal_bpp
;
530 rt
.render_target_number
= i
;
533 if (job
->resolve
& PIPE_CLEAR_COLOR0
<< i
)
536 #endif /* V3D_VERSION < 40 */
538 cl_emit(&job
->rcl
, TILE_RENDERING_MODE_CONFIGURATION_CLEAR_COLORS_PART1
,
540 clear
.clear_color_low_32_bits
= job
->clear_color
[i
][0];
541 clear
.clear_color_next_24_bits
= job
->clear_color
[i
][1] & 0xffffff;
542 clear
.render_target_number
= i
;
545 if (surf
->internal_bpp
>= V3D_INTERNAL_BPP_64
) {
546 cl_emit(&job
->rcl
, TILE_RENDERING_MODE_CONFIGURATION_CLEAR_COLORS_PART2
,
548 clear
.clear_color_mid_low_32_bits
=
549 ((job
->clear_color
[i
][1] >> 24) |
550 (job
->clear_color
[i
][2] << 8));
551 clear
.clear_color_mid_high_24_bits
=
552 ((job
->clear_color
[i
][2] >> 24) |
553 ((job
->clear_color
[i
][3] & 0xffff) << 8));
554 clear
.render_target_number
= i
;
558 if (surf
->internal_bpp
>= V3D_INTERNAL_BPP_128
|| clear_pad
) {
559 cl_emit(&job
->rcl
, TILE_RENDERING_MODE_CONFIGURATION_CLEAR_COLORS_PART3
,
561 clear
.uif_padded_height_in_uif_blocks
= clear_pad
;
562 clear
.clear_color_high_16_bits
= job
->clear_color
[i
][3] >> 16;
563 clear
.render_target_number
= i
;
568 #if V3D_VERSION >= 40
569 cl_emit(&job
->rcl
, TILE_RENDERING_MODE_CONFIGURATION_RENDER_TARGET_CONFIG
, rt
) {
570 v3d_setup_render_target(job
, 0,
571 &rt
.render_target_0_internal_bpp
,
572 &rt
.render_target_0_internal_type
,
573 &rt
.render_target_0_clamp
);
574 v3d_setup_render_target(job
, 1,
575 &rt
.render_target_1_internal_bpp
,
576 &rt
.render_target_1_internal_type
,
577 &rt
.render_target_1_clamp
);
578 v3d_setup_render_target(job
, 2,
579 &rt
.render_target_2_internal_bpp
,
580 &rt
.render_target_2_internal_type
,
581 &rt
.render_target_2_clamp
);
582 v3d_setup_render_target(job
, 3,
583 &rt
.render_target_3_internal_bpp
,
584 &rt
.render_target_3_internal_type
,
585 &rt
.render_target_3_clamp
);
590 /* TODO: Don't bother emitting if we don't load/clear Z/S. */
592 struct pipe_surface
*psurf
= job
->zsbuf
;
593 struct vc5_surface
*surf
= vc5_surface(psurf
);
594 struct vc5_resource
*rsc
= vc5_resource(psurf
->texture
);
596 v3d_emit_z_stencil_config(job
, surf
, rsc
, false);
598 /* Emit the separate stencil packet if we have a resource for
599 * it. The HW will only load/store this buffer if the
600 * Z/Stencil config doesn't have stencil in its format.
602 if (surf
->separate_stencil
) {
603 v3d_emit_z_stencil_config(job
,
604 vc5_surface(surf
->separate_stencil
),
605 rsc
->separate_stencil
, true);
608 #endif /* V3D_VERSION < 40 */
610 /* Ends rendering mode config. */
611 cl_emit(&job
->rcl
, TILE_RENDERING_MODE_CONFIGURATION_Z_STENCIL_CLEAR_VALUES
,
613 clear
.z_clear_value
= job
->clear_z
;
614 clear
.stencil_vg_mask_clear_value
= job
->clear_s
;
617 /* Always set initial block size before the first branch, which needs
618 * to match the value from binning mode config.
620 cl_emit(&job
->rcl
, TILE_LIST_INITIAL_BLOCK_SIZE
, init
) {
621 init
.use_auto_chained_tile_lists
= true;
622 init
.size_of_first_block_in_chained_tile_lists
=
623 TILE_ALLOCATION_BLOCK_SIZE_64B
;
626 uint32_t supertile_w
= 1, supertile_h
= 1;
628 /* If doing multicore binning, we would need to initialize each core's
631 cl_emit(&job
->rcl
, MULTICORE_RENDERING_TILE_LIST_SET_BASE
, list
) {
632 list
.address
= cl_address(job
->tile_alloc
, 0);
635 cl_emit(&job
->rcl
, MULTICORE_RENDERING_SUPERTILE_CONFIGURATION
, config
) {
636 uint32_t frame_w_in_supertiles
, frame_h_in_supertiles
;
637 const uint32_t max_supertiles
= 256;
639 /* Size up our supertiles until we get under the limit. */
641 frame_w_in_supertiles
= div_round_up(job
->draw_tiles_x
,
643 frame_h_in_supertiles
= div_round_up(job
->draw_tiles_y
,
645 if (frame_w_in_supertiles
* frame_h_in_supertiles
<
650 if (supertile_w
< supertile_h
)
656 config
.total_frame_width_in_tiles
= job
->draw_tiles_x
;
657 config
.total_frame_height_in_tiles
= job
->draw_tiles_y
;
659 config
.supertile_width_in_tiles_minus_1
= supertile_w
- 1;
660 config
.supertile_height_in_tiles_minus_1
= supertile_h
- 1;
662 config
.total_frame_width_in_supertiles
= frame_w_in_supertiles
;
663 config
.total_frame_height_in_supertiles
= frame_h_in_supertiles
;
666 /* Start by clearing the tile buffer. */
667 cl_emit(&job
->rcl
, TILE_COORDINATES
, coords
) {
668 coords
.tile_column_number
= 0;
669 coords
.tile_row_number
= 0;
673 cl_emit(&job
->rcl
, STORE_TILE_BUFFER_GENERAL
, store
) {
674 store
.buffer_to_store
= NONE
;
677 cl_emit(&job
->rcl
, END_OF_LOADS
, end
);
678 cl_emit(&job
->rcl
, STORE_TILE_BUFFER_GENERAL
, store
) {
679 store
.buffer_to_store
= NONE
;
681 cl_emit(&job
->rcl
, CLEAR_TILE_BUFFERS
, clear
) {
682 clear
.clear_z_stencil_buffer
= true;
683 clear
.clear_all_render_targets
= true;
685 cl_emit(&job
->rcl
, END_OF_TILE_MARKER
, end
);
688 cl_emit(&job
->rcl
, FLUSH_VCD_CACHE
, flush
);
690 vc5_rcl_emit_generic_per_tile_list(job
, nr_cbufs
- 1);
692 cl_emit(&job
->rcl
, WAIT_ON_SEMAPHORE
, sem
);
694 /* XXX: Use Morton order */
695 uint32_t supertile_w_in_pixels
= job
->tile_width
* supertile_w
;
696 uint32_t supertile_h_in_pixels
= job
->tile_height
* supertile_h
;
697 uint32_t min_x_supertile
= job
->draw_min_x
/ supertile_w_in_pixels
;
698 uint32_t min_y_supertile
= job
->draw_min_y
/ supertile_h_in_pixels
;
699 uint32_t max_x_supertile
= (job
->draw_max_x
- 1) / supertile_w_in_pixels
;
700 uint32_t max_y_supertile
= (job
->draw_max_y
- 1) / supertile_h_in_pixels
;
702 for (int y
= min_y_supertile
; y
<= max_y_supertile
; y
++) {
703 for (int x
= min_x_supertile
; x
<= max_x_supertile
; x
++) {
704 cl_emit(&job
->rcl
, SUPERTILE_COORDINATES
, coords
) {
705 coords
.column_number_in_supertiles
= x
;
706 coords
.row_number_in_supertiles
= y
;
711 cl_emit(&job
->rcl
, END_OF_RENDERING
, end
);