[Mesa-dev] [PATCH 9/9] spirv: Lower BaseVertex to BASE_VERTEX_ID instead of BASE_VERTEX

Antia Puentes apuentes at igalia.com
Fri Nov 10 17:53:37 UTC 2017


From: Neil Roberts <nroberts at igalia.com>

The base vertex in Vulkan is different from GL in that for non-indexed
primitives the value is taken from the firstVertex parameter instead
of being set to zero. This coincides with the new
SYSTEM_VALUE_BASE_VERTEX_ID instead of BASE_VERTEX.
---
 src/compiler/spirv/vtn_variables.c | 2 +-
 src/intel/vulkan/genX_cmd_buffer.c | 8 ++++----
 src/intel/vulkan/genX_pipeline.c   | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 1cf9d597cf0..82d04f2558b 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1155,7 +1155,7 @@ vtn_get_builtin_location(struct vtn_builder *b,
       set_mode_system_value(mode);
       break;
    case SpvBuiltInBaseVertex:
-      *location = SYSTEM_VALUE_BASE_VERTEX;
+      *location = SYSTEM_VALUE_BASE_VERTEX_ID;
       set_mode_system_value(mode);
       break;
    case SpvBuiltInBaseInstance:
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index fbb5706606a..4e9b884d3ac 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2175,7 +2175,7 @@ void genX(CmdDraw)(
 
    genX(cmd_buffer_flush_state)(cmd_buffer);
 
-   if (vs_prog_data->uses_basevertex || vs_prog_data->uses_baseinstance)
+   if (vs_prog_data->uses_basevertexid || vs_prog_data->uses_baseinstance)
       emit_base_vertex_instance(cmd_buffer, firstVertex, firstInstance);
    if (vs_prog_data->uses_drawid)
       emit_draw_index(cmd_buffer, 0);
@@ -2213,7 +2213,7 @@ void genX(CmdDrawIndexed)(
 
    genX(cmd_buffer_flush_state)(cmd_buffer);
 
-   if (vs_prog_data->uses_basevertex || vs_prog_data->uses_baseinstance)
+   if (vs_prog_data->uses_basevertexid || vs_prog_data->uses_baseinstance)
       emit_base_vertex_instance(cmd_buffer, vertexOffset, firstInstance);
    if (vs_prog_data->uses_drawid)
       emit_draw_index(cmd_buffer, 0);
@@ -2369,7 +2369,7 @@ void genX(CmdDrawIndirect)(
       struct anv_bo *bo = buffer->bo;
       uint32_t bo_offset = buffer->offset + offset;
 
-      if (vs_prog_data->uses_basevertex || vs_prog_data->uses_baseinstance)
+      if (vs_prog_data->uses_basevertexid || vs_prog_data->uses_baseinstance)
          emit_base_vertex_instance_bo(cmd_buffer, bo, bo_offset + 8);
       if (vs_prog_data->uses_drawid)
          emit_draw_index(cmd_buffer, i);
@@ -2408,7 +2408,7 @@ void genX(CmdDrawIndexedIndirect)(
       uint32_t bo_offset = buffer->offset + offset;
 
       /* TODO: We need to stomp base vertex to 0 somehow */
-      if (vs_prog_data->uses_basevertex || vs_prog_data->uses_baseinstance)
+      if (vs_prog_data->uses_basevertexid || vs_prog_data->uses_baseinstance)
          emit_base_vertex_instance_bo(cmd_buffer, bo, bo_offset + 12);
       if (vs_prog_data->uses_drawid)
          emit_draw_index(cmd_buffer, i);
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index 7e3a785c584..01e48ce4559 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -97,7 +97,7 @@ emit_vertex_input(struct anv_pipeline *pipeline,
    const uint32_t elements_double = double_inputs_read >> VERT_ATTRIB_GENERIC0;
    const bool needs_svgs_elem = vs_prog_data->uses_vertexid ||
                                 vs_prog_data->uses_instanceid ||
-                                vs_prog_data->uses_basevertex ||
+                                vs_prog_data->uses_basevertexid ||
                                 vs_prog_data->uses_baseinstance;
 
    uint32_t elem_count = __builtin_popcount(elements) -
@@ -177,7 +177,7 @@ emit_vertex_input(struct anv_pipeline *pipeline,
        * This means, that if we have BaseInstance, we need BaseVertex as
        * well.  Just do all or nothing.
        */
-      uint32_t base_ctrl = (vs_prog_data->uses_basevertex ||
+      uint32_t base_ctrl = (vs_prog_data->uses_basevertexid ||
                             vs_prog_data->uses_baseinstance) ?
                            VFCOMP_STORE_SRC : VFCOMP_STORE_0;
 
-- 
2.14.1



More information about the mesa-dev mailing list