[Mesa-dev] [PATCH] radeonsi: fix an off-by-one error in the bounds check for max_vertices

Marek Olšák maraeo at gmail.com
Wed Dec 7 21:34:16 UTC 2016


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Tue, Dec 6, 2016 at 9:06 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> 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 at lists.freedesktop.org
> --
> One more thing I noticed on top of all the other GS changes...
> ---
>  src/gallium/drivers/radeonsi/si_shader.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
> index dee2a17..749823d 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -5181,21 +5181,21 @@ static void si_llvm_emit_vertex(
>                                        "");
>
>         /* If this thread has already emitted the declared maximum number of
>          * vertices, skip the write: excessive vertex emissions are not
>          * supposed to have any effect.
>          *
>          * If the shader has no writes to memory, kill it instead. This skips
>          * 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), "");
>
>         bool use_kill = !info->writes_memory;
>         if (use_kill) {
>                 kill = lp_build_select(&bld_base->base, can_emit,
>                                        lp_build_const_float(gallivm, 1.0f),
>                                        lp_build_const_float(gallivm, -1.0f));
>
>                 lp_build_intrinsic(gallivm->builder, "llvm.AMDGPU.kill",
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list