[Mesa-dev] [PATCH 0/9] Fix shader_draw_parameters CTS tests

Neil Roberts nroberts at igalia.com
Fri Nov 10 18:08:28 UTC 2017


Just to note, I made some Piglit patches to verify this new behaviour
too:

https://patchwork.freedesktop.org/series/33626/

This might make testing a little easier if someone wants to implement
the behaviour for other drivers too.

- Neil

Antia Puentes <apuentes at igalia.com> writes:

> Hi,
>
> the series sets gl_BaseVertex to zero for gl*DrawArrays* in i965.
> Previously, its value was the value passed as <first> in the non-indexed
> draw call. This was convinient because the gl_VertexID was calculated as
> gl_VertexIDBaseZero + gl_BaseVertex.
>
> However, as gl_BaseVertex must be zero for non-indexed draw calls, this
> calculation is broken.
>
> Apart from setting the basevertex to zero in i965, the following patches add
> a new VS system value which will contain <first> or <basevertex> as needed
> to make the gl_VertexID calculation right.
>
>
> The relevant bits of the OpenGL 4.6 specification involved here are:
>
> * 11.1.3.9 Shader Inputs
>
> "gl_BaseVertex holds the integer value passed to the baseVertex parameter to the
> command that resulted in the current shader invocation. In the case where the
> command has no baseVertex parameter, the value of gl_BaseVertex is zero."
>
> "gl_VertexID holds the integer index i implicitly passed by DrawArrays or
> one of the other drawing commands defined in section 10.4."
>
> * 10.4. Drawing Commands Using Vertex Arrays:
>
>   - Page 352:
> "The index of any element transferred to the GL by DrawArraysOneInstance is
> referred to as its vertex ID, and may be read by a vertex shader as gl_VertexID.
> The vertex ID of the ith element transferred is first + i."
>
>   - Page 355:
> "The index of any element transferred to the GL by DrawElementsOneInstance is
> referred to as its vertex ID, and may be read by a vertex shader as gl_VertexID.
> The vertex ID of the ith element transferred is the sum of basevertex and the
> value stored in the currently bound element array buffer at offset indices + i."
>
> Regards,
> Antia.
>
> Antia Puentes (5):
>   compiler: Add new system value SYSTEM_VALUE_BASE_VERTEX_ID
>   nir: Add SYSTEM_VALUE_BASE_VERTEX_ID instrinsics
>   i965: emit basevertexid as a vertex element component
>   i965: gl_BaseVertex must be zero for non-indexed draw calls
>   intel/compiler: implement the basevertex(id) load intrinsics
>
> Neil Roberts (4):
>   intel/compiler: Add a uses_basevertexid flag
>   nir: Offset vertex_id by base_vertex_id instead of base_vertex
>   i965: Let nir lower gl_VertexID instead of the linker
>   spirv: Lower BaseVertex to BASE_VERTEX_ID instead of BASE_VERTEX
>
>  src/compiler/nir/nir.c                        |  4 +++
>  src/compiler/nir/nir_gather_info.c            |  1 +
>  src/compiler/nir/nir_intrinsics.h             |  1 +
>  src/compiler/nir/nir_lower_system_values.c    |  2 +-
>  src/compiler/shader_enums.c                   |  1 +
>  src/compiler/shader_enums.h                   | 15 +++++++++++
>  src/compiler/spirv/vtn_variables.c            |  2 +-
>  src/intel/compiler/brw_compiler.h             |  1 +
>  src/intel/compiler/brw_nir.c                  | 12 ++++++---
>  src/intel/compiler/brw_vec4.cpp               | 18 ++++++++-----
>  src/intel/vulkan/genX_cmd_buffer.c            |  8 +++---
>  src/intel/vulkan/genX_pipeline.c              |  4 +--
>  src/mesa/drivers/dri/i965/brw_context.c       |  3 ++-
>  src/mesa/drivers/dri/i965/brw_context.h       | 36 ++++++++++++++++++-------
>  src/mesa/drivers/dri/i965/brw_draw.c          | 33 ++++++++++++++++-------
>  src/mesa/drivers/dri/i965/brw_draw_upload.c   | 13 ++++-----
>  src/mesa/drivers/dri/i965/genX_state_upload.c | 39 +++++++++++++++------------
>  17 files changed, 132 insertions(+), 61 deletions(-)
>
> -- 
> 2.14.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171110/e22beb99/attachment.sig>


More information about the mesa-dev mailing list