radeonsi: fix an off-by-one error in the bounds check for max_vertices
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 6 Dec 2016 20:03:03 +0000 (21:03 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 12 Dec 2016 08:04:13 +0000 (09:04 +0100)
The spec actually says that calling EmitStreamVertex is undefined when
you exceed max_vertices. But we do need to avoid trampling over memory
outside the GSVS ring.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_shader.c

index 8827643caef98ba0a050b905c5a01db0971a6781..9ee1190b9e96d59366c2a24adafad961fd144e58 100644 (file)
@@ -5281,7 +5281,7 @@ static void si_llvm_emit_vertex(
         * further memory loads and may allow LLVM to skip to the end
         * altogether.
         */
-       can_emit = LLVMBuildICmp(gallivm->builder, LLVMIntULE, gs_next_vertex,
+       can_emit = LLVMBuildICmp(gallivm->builder, LLVMIntULT, gs_next_vertex,
                                 lp_build_const_int32(gallivm,
                                                      shader->selector->gs_max_out_vertices), "");