aco/ngg: fix division-by-zero in assertion

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7576>
This commit is contained in:
Rhys Perry 2020-11-12 14:32:57 +00:00 committed by Marge Bot
parent 37a2c9ace6
commit 4eac442217
2 changed files with 28 additions and 1 deletions

View file

@ -416,7 +416,8 @@ void setup_gs_variables(isel_context *ctx, nir_shader *nir)
ctx->program->config->lds_size = (total_lds_bytes + ctx->program->lds_alloc_granule - 1) / ctx->program->lds_alloc_granule;
/* Make sure we have enough room for emitted GS vertices */
assert((ngg_emit_bytes % (ctx->ngg_gs_emit_vtx_bytes * nir->info.gs.vertices_out)) == 0);
if (nir->info.gs.vertices_out)
assert((ngg_emit_bytes % (ctx->ngg_gs_emit_vtx_bytes * nir->info.gs.vertices_out)) == 0);
/* See if the number of vertices and primitives are compile-time known */
nir_gs_count_vertices_and_primitives(nir, ctx->ngg_gs_const_vtxcnt, ctx->ngg_gs_const_prmcnt, 4u);

View file

@ -107,3 +107,29 @@ BEGIN_TEST(isel.gs.no_outputs)
fprintf(output, "success\n");
}
END_TEST
BEGIN_TEST(isel.gs.no_verts)
for (unsigned i = GFX8; i <= GFX10; i++) {
if (!set_variant((chip_class)i))
continue;
QoShaderModuleCreateInfo vs = qoShaderModuleCreateInfoGLSL(VERTEX,
void main() {}
);
QoShaderModuleCreateInfo gs = qoShaderModuleCreateInfoGLSL(GEOMETRY,
layout(points) in;
layout(points, max_vertices = 0) out;
void main() {}
);
PipelineBuilder pbld(get_vk_device((chip_class)i));
pbld.add_stage(VK_SHADER_STAGE_VERTEX_BIT, vs);
pbld.add_stage(VK_SHADER_STAGE_GEOMETRY_BIT, gs);
pbld.create_pipeline();
//! success
fprintf(output, "success\n");
}
END_TEST