[Mesa-dev] [PATCH v2 0/7] Fix shader_draw_parameters CTS tests
Antia Puentes
apuentes at igalia.com
Mon Dec 4 20:12:46 UTC 2017
This patch series is a v2 of the one we sent some weeks ago to fix
gl_BaseVertex in i965. The original patch series can be found on here:
https://patchwork.freedesktop.org/series/33623/
* Rationale:
gl_BaseVertex must be zero for non-indexed draw comands. However,
for this kind of draw comands, we were setting it to the value passed
as <first> argument of the command.
The series fixes this bug for i965. Notice that we still need the value of
the <first> argument of the non-indexed draw call to calculate gl_VertexID,
as for those gl_VertexID must be equal to: gl_VertexIDBaseZero + <first>.
The Vertex Elements' composition will be now as follows:
* VE 1: <firstvertex, BaseInstance, VertexID, InstanceID>
* VE 2: <Draw ID, BaseVertex, 0, 0>
- BaseVertex will be the <basevertex> passed to indexed draw calls,
zero otherwise.
- firstvertex will be the <first> vertex passed to non-indexed draw calls,
and will be the <basevertex> for indexed draw commands. Setting firstvertex
to <basevertex> for indexed draw commands is convinient for two reasons:
1) In case of indirect draw calls, we can keep pointing to the indirect buffer
when emitting the vertices.
2) We can calculate gl_VertexID as VertexID(basezero) + firstindex for both
types of draw commands and these two values will be in the same Vertex Element.
We will only emit VE2 if gl_DrawID or gl_BaseVertex are referenced in the
shader.
* Changes in v2:
- Rename the new system value as SYSTEM_VALUE_FIRST_VERTEX and
the related variables through the series.
- Squash patches 1-2 of the original series, and 4 and 6.
- Move patch 5 to the end of the patch series.
- Swap the order of patches 7 and 8.
* OpenGL 4.6 specification bits:
- 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."
Antia Puentes (3):
compiler: Add SYSTEM_VALUE_FIRST_VERTEX and instrinsics
intel: emit first_vertex and reorder the VE' components
i965: gl_BaseVertex must be zero for non-indexed draw calls
Neil Roberts (4):
intel/compiler: Add a uses_firstvertex flag
i965: Let nir lower gl_VertexID instead of the linker
nir: Offset vertex_id by first_vertex instead of base_vertex
spirv: Lower BaseVertex to FIRST_VERTEX 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 | 11 +++++---
src/intel/compiler/brw_vec4.cpp | 17 ++++++++----
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(+), 59 deletions(-)
--
2.14.1
More information about the mesa-dev
mailing list