diff options
author | Jonathan Marek <[email protected]> | 2020-07-02 11:53:33 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-07-04 03:33:43 +0000 |
commit | 19f3c79c7ed4e68d37771489f52bd94a2d032fa6 (patch) | |
tree | 6beb7e002c5429b698c7e9e9cc6ec78728f6533c /src/freedreno/vulkan | |
parent | 395511d16915297b39d11f6d7ede0e0274d390c9 (diff) |
turnip: fix tess param bo size calculation
ir3 already calculates the stride in the tess param bo, so use that instead
of a incorrect calculation. The calculation of per_vertex_output_size /
per_patch_output_size is wrong because it counts dwords instead of bytes,
and what it counts for per_vertex_output_size is a per-patch size because
the glsl type is already an array of # vertex/patch elements.
Signed-off-by: Jonathan Marek <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5743>
Diffstat (limited to 'src/freedreno/vulkan')
-rw-r--r-- | src/freedreno/vulkan/tu_cmd_buffer.c | 28 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_pipeline.c | 25 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_private.h | 3 |
3 files changed, 13 insertions, 43 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 4effbba572a..62751ba4ccb 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -2808,21 +2808,17 @@ get_tess_param_bo_size(const struct tu_pipeline *pipeline, { /* TODO: For indirect draws, we can't compute the BO size ahead of time. * Still not sure what to do here, so just allocate a reasonably large - * BO and hope for the best for now. - * (maxTessellationControlPerVertexOutputComponents * 2048 vertices + - * maxTessellationControlPerPatchOutputComponents * 512 patches) */ - if (!draw_count) { - return ((128 * 2048) + (128 * 512)) * 4; - } + * BO and hope for the best for now. */ + if (!draw_count) + draw_count = 2048; - /* For each patch, adreno lays out the tess param BO in memory as: - * (v_input[0][0])...(v_input[i][j])(p_input[0])...(p_input[k]). - * where i = # vertices per patch, j = # per-vertex outputs, and - * k = # per-patch outputs.*/ + /* the tess param BO is pipeline->tess.param_stride bytes per patch, + * which includes both the per-vertex outputs and per-patch outputs + * build_primitive_map in ir3 calculates this stride + */ uint32_t verts_per_patch = pipeline->ia.primtype - DI_PT_PATCHES0; uint32_t num_patches = draw_count / verts_per_patch; - return draw_count * pipeline->tess.per_vertex_output_size + - pipeline->tess.per_patch_output_size * num_patches; + return num_patches * pipeline->tess.param_stride; } static uint64_t @@ -2831,11 +2827,9 @@ get_tess_factor_bo_size(const struct tu_pipeline *pipeline, { /* TODO: For indirect draws, we can't compute the BO size ahead of time. * Still not sure what to do here, so just allocate a reasonably large - * BO and hope for the best for now. - * (quad factor stride * 512 patches) */ - if (!draw_count) { - return (28 * 512) * 4; - } + * BO and hope for the best for now. */ + if (!draw_count) + draw_count = 2048; /* Each distinct patch gets its own tess factor output. */ uint32_t verts_per_patch = pipeline->ia.primtype - DI_PT_PATCHES0; diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index e43fc34f32b..965aa34209f 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -2028,30 +2028,6 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder, builder->binning_variant = variant; - if (builder->shaders[MESA_SHADER_TESS_CTRL]) { - struct ir3_shader *hs = - builder->shaders[MESA_SHADER_TESS_CTRL]->ir3_shader; - assert(hs->type != MESA_SHADER_NONE); - - /* Calculate and store the per-vertex and per-patch HS-output sizes. */ - uint32_t per_vertex_output_size = 0; - uint32_t per_patch_output_size = 0; - nir_foreach_variable (output, &hs->nir->outputs) { - switch (output->data.location) { - case VARYING_SLOT_TESS_LEVEL_OUTER: - case VARYING_SLOT_TESS_LEVEL_INNER: - continue; - } - uint32_t size = glsl_count_attribute_slots(output->type, false) * 4; - if (output->data.patch) - per_patch_output_size += size; - else - per_vertex_output_size += size; - } - pipeline->tess.per_vertex_output_size = per_vertex_output_size; - pipeline->tess.per_patch_output_size = per_patch_output_size; - } - return VK_SUCCESS; } @@ -2200,6 +2176,7 @@ tu_pipeline_builder_parse_tessellation(struct tu_pipeline_builder *builder, domain_info->domainOrigin == VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT; const struct ir3_shader_variant *hs = builder->variants[MESA_SHADER_TESS_CTRL]; const struct ir3_shader_variant *ds = builder->variants[MESA_SHADER_TESS_EVAL]; + pipeline->tess.param_stride = hs->output_size * 4; pipeline->tess.hs_bo_regid = hs->const_state->offsets.primitive_param + 1; pipeline->tess.ds_bo_regid = ds->const_state->offsets.primitive_param + 1; } diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 3287edf8a22..c91c86c3949 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1076,8 +1076,7 @@ struct tu_pipeline struct { uint32_t patch_type; - uint32_t per_vertex_output_size; - uint32_t per_patch_output_size; + uint32_t param_stride; uint32_t hs_bo_regid; uint32_t ds_bo_regid; bool upper_left_domain_origin; |