1 /*
2 * Copyright © 2014-2017 Broadcom
3 *
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:
10 *
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
13 * Software.
14 *
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
21 * IN THE SOFTWARE.
22 */
23
24 /** @file v3dx_job.c
25 *
26 * V3D version-specific functions for submitting V3D render jobs to the
27 * kernel.
28 */
29
30 #include "v3d_context.h"
31 #include "broadcom/cle/v3dx_pack.h"
32 #include "broadcom/common/v3d_util.h"
33
v3dX(bcl_epilogue)34 void v3dX(bcl_epilogue)(struct v3d_context *v3d, struct v3d_job *job)
35 {
36 v3d_cl_ensure_space_with_branch(&job->bcl,
37 cl_packet_length(PRIMITIVE_COUNTS_FEEDBACK) +
38 cl_packet_length(TRANSFORM_FEEDBACK_SPECS) +
39 cl_packet_length(FLUSH));
40
41 if (job->tf_enabled || job->needs_primitives_generated) {
42 /* Write primitive counts to memory. */
43 assert(v3d->prim_counts);
44 struct v3d_resource *rsc =
45 v3d_resource(v3d->prim_counts);
46 cl_emit(&job->bcl, PRIMITIVE_COUNTS_FEEDBACK, counter) {
47 counter.address =
48 cl_address(rsc->bo,
49 v3d->prim_counts_offset);
50 counter.read_write_64byte = false;
51 counter.op = 0;
52 }
53 }
54
55 /* Disable TF at the end of the CL, so that the TF block
56 * cleans up and finishes before it gets reset by the next
57 * frame's tile binning mode cfg packet. (SWVC5-718).
58 */
59 if (job->tf_enabled) {
60 cl_emit(&job->bcl, TRANSFORM_FEEDBACK_SPECS, tfe) {
61 tfe.enable = false;
62 };
63 }
64
65 /* We just FLUSH here to tell the HW to cap the bin CLs with a
66 * return. Any remaining state changes won't be flushed to
67 * the bins first -- you would need FLUSH_ALL for that, but
68 * the HW for hasn't been validated
69 */
70 cl_emit(&job->bcl, FLUSH, flush);
71 }
72
73 void
v3dX(job_emit_enable_double_buffer)74 v3dX(job_emit_enable_double_buffer)(struct v3d_job *job)
75 {
76 assert(job->bcl_tile_binning_mode_ptr);
77 struct cl_packet_struct(TILE_BINNING_MODE_CFG) config = {
78 cl_packet_header(TILE_BINNING_MODE_CFG),
79 };
80
81 config.width_in_pixels = job->draw_width;
82 config.height_in_pixels = job->draw_height;
83 #if V3D_VERSION == 42
84 config.number_of_render_targets = MAX2(job->nr_cbufs, 1);
85 config.multisample_mode_4x = job->msaa;
86 config.double_buffer_in_non_ms_mode = job->double_buffer;
87 config.maximum_bpp_of_all_render_targets = job->internal_bpp;
88 #endif
89 #if V3D_VERSION >= 71
90 config.log2_tile_width = log2_tile_size(job->tile_desc.width);
91 config.log2_tile_height = log2_tile_size(job->tile_desc.height);
92 #endif
93
94 uint8_t *rewrite_addr = (uint8_t *)job->bcl_tile_binning_mode_ptr;
95 cl_packet_pack(TILE_BINNING_MODE_CFG)(NULL, rewrite_addr, &config);
96 }
97