diff options
author | Iago Toral Quiroga <[email protected]> | 2019-11-07 15:40:45 +0100 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2019-12-16 08:42:37 +0100 |
commit | 76fc8c8bb1979122af40ed143fed726050b293b9 (patch) | |
tree | 363c8c26f993acde5450ef65d14b4ad12c97d003 /src/broadcom | |
parent | 76f4c83815a005f37b58c54d51ca6c4982546e54 (diff) |
v3d: compute appropriate VPM memory configuration for geometry shader workloads
Geometry shaders can output many vertices and thus have higher VPM memory
pressure as a result. It is possible that too wide geometry shader dispatches
exceed the maximum available VPM output allocated, in which case we need
to reduce the dispatch width until we can fit the VPM memory requirements.
Supported dispatch widths for geometry shaders are 16, 8, 4, 1.
There is a limit in the number of VPM output sectors that can be used by a
geometry shader that we can meet by lowering the dispatch width at compile
time, however, at draw time we need to revisit this number and, together with
other elements that can contribute to total VPM memory requirements, decide
on a configuration that can fit the program into the available VPM memory.
Ideally, we also want to aim for not using more than half of the available
memory so we that we can run a pair of bin and render programs in parallel.
v2: fixed language in comment and typo in commit log. (Alejandro)
Reviewed-by: Alejandro PiƱeiro <[email protected]>
Diffstat (limited to 'src/broadcom')
-rw-r--r-- | src/broadcom/compiler/v3d_compiler.h | 7 | ||||
-rw-r--r-- | src/broadcom/compiler/vir.c | 18 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h index a5b4748aaf0..4249c181bf1 100644 --- a/src/broadcom/compiler/v3d_compiler.h +++ b/src/broadcom/compiler/v3d_compiler.h @@ -716,6 +716,13 @@ struct v3d_gs_prog_data { /* Total number of components written, for the shader state record. */ uint32_t vpm_output_size; + /* Maximum SIMD dispatch width to not exceed VPM output size limits + * in the geometry shader. Notice that the final dispatch width has to + * be decided at draw time and could be lower based on the VPM pressure + * added by other shader stages. + */ + uint8_t simd_width; + /* Output primitive type */ uint8_t out_prim_type; diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index 4f88b86a5d2..34f7773f066 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -680,6 +680,24 @@ v3d_gs_set_prog_data(struct v3d_compile *c, /* Output segment size is in sectors (8 rows of 32 bits per channel) */ prog_data->vpm_output_size = align(c->vpm_output_size, 8) / 8; + /* Compute SIMD dispatch width and update VPM output size accordingly + * to ensure we can fit our program in memory. Available widths are + * 16, 8, 4, 1. + * + * Notice that at draw time we will have to consider VPM memory + * requirements from other stages and choose a smaller dispatch + * width if needed to fit the program in VPM memory. + */ + prog_data->simd_width = 16; + while ((prog_data->simd_width > 1 && prog_data->vpm_output_size > 16) || + prog_data->simd_width == 2) { + prog_data->simd_width >>= 1; + prog_data->vpm_output_size = + align(prog_data->vpm_output_size, 2) / 2; + } + assert(prog_data->vpm_output_size <= 16); + assert(prog_data->simd_width != 2); + prog_data->out_prim_type = c->s->info.gs.output_primitive; prog_data->num_invocations = c->s->info.gs.invocations; } |