From 4eac4422175164643d4e2ab8cf0f859fb6d02cb0 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 12 Nov 2020 14:32:57 +0000 Subject: [PATCH] aco/ngg: fix division-by-zero in assertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rhys Perry Reviewed-by: Timur Kristóf Reviewed-by: Samuel Pitoiset Part-of: --- .../aco_instruction_selection_setup.cpp | 3 ++- src/amd/compiler/tests/test_isel.cpp | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_instruction_selection_setup.cpp b/src/amd/compiler/aco_instruction_selection_setup.cpp index fb17618dad6..008db0a68e9 100644 --- a/src/amd/compiler/aco_instruction_selection_setup.cpp +++ b/src/amd/compiler/aco_instruction_selection_setup.cpp @@ -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); diff --git a/src/amd/compiler/tests/test_isel.cpp b/src/amd/compiler/tests/test_isel.cpp index 4de4ac3d692..83daf37b8d9 100644 --- a/src/amd/compiler/tests/test_isel.cpp +++ b/src/amd/compiler/tests/test_isel.cpp @@ -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