[Mesa-dev] [Mesa-stable] [PATCH] i965: Fix gl_InvocationID in dual object GS where invocations == 1.

Anuj Phogat anuj.phogat at gmail.com
Mon Oct 17 21:04:16 UTC 2016


On Fri, Oct 14, 2016 at 8:08 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> dEQP-GLES31.functional.geometry_shading.instanced.geometry_1_invocations
> draws using a geometry shader that specifies
>
>    layout(points, invocations = 1) in;
>
> and then uses gl_InvocationID.  According to the Haswell PRM, the
> "GS Instance ID 0" (and 1) thread payload fields are undefined in
> dual object mode:
>
>    "If 'dispatch mode' is DUAL_OBJECT this field is not valid."
>
> But there's no point in using them - if there's only one invocation,
> the ID will be 0.  So just load a constant.
>
> Cc: mesa-stable at lists.freedesktop.org
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
> index c5886d4..59c7d21 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
> @@ -59,7 +59,10 @@ vec4_gs_visitor::make_reg_for_system_value(int location)
>     switch (location) {
>     case SYSTEM_VALUE_INVOCATION_ID:
>        this->current_annotation = "initialize gl_InvocationID";
> -      emit(GS_OPCODE_GET_INSTANCE_ID, *reg);
> +      if (gs_prog_data->invocations > 1)
> +         emit(GS_OPCODE_GET_INSTANCE_ID, *reg);
> +      else
> +         emit(MOV(*reg, brw_imm_ud(0)));
>        break;
>     default:
>        unreachable("not reached");
> --
> 2.10.0
>
> _______________________________________________
> mesa-stable mailing list
> mesa-stable at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-stable

LGTM. Verified the recommendation in PRM:
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list