compiler: Add SYSTEM_VALUE_IS_INDEXED_DRAW and instrinsics
authorAntia Puentes <apuentes@igalia.com>
Sat, 28 Apr 2018 12:09:18 +0000 (14:09 +0200)
committerAntia Puentes <apuentes@igalia.com>
Wed, 2 May 2018 09:20:40 +0000 (11:20 +0200)
This VS system value contains if the draw command used to start the
rendering was an indexed draw command or a non-indexed one
(~0/0 respectively). Useful to calculate the gl_BaseVertex as:
(SYSTEM_VALUE_IS_INDEXED_DRAW & SYSTEM_VALUE_FIRST_VERTEX).

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir.c
src/compiler/nir/nir_gather_info.c
src/compiler/nir/nir_intrinsics.py
src/compiler/shader_enums.c
src/compiler/shader_enums.h

index ea28fbd1af5f908371b0baa74f560f7e222cc76d..dc1c560319e03c68ae8f51c96107062a0a71f120 100644 (file)
@@ -1991,6 +1991,8 @@ nir_intrinsic_from_system_value(gl_system_value val)
       return nir_intrinsic_load_base_instance;
    case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE:
       return nir_intrinsic_load_vertex_id_zero_base;
+   case SYSTEM_VALUE_IS_INDEXED_DRAW:
+      return nir_intrinsic_load_is_indexed_draw;
    case SYSTEM_VALUE_FIRST_VERTEX:
       return nir_intrinsic_load_first_vertex;
    case SYSTEM_VALUE_BASE_VERTEX:
@@ -2070,6 +2072,8 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
       return SYSTEM_VALUE_VERTEX_ID_ZERO_BASE;
    case nir_intrinsic_load_first_vertex:
       return SYSTEM_VALUE_FIRST_VERTEX;
+   case nir_intrinsic_load_is_indexed_draw:
+      return SYSTEM_VALUE_IS_INDEXED_DRAW;
    case nir_intrinsic_load_base_vertex:
       return SYSTEM_VALUE_BASE_VERTEX;
    case nir_intrinsic_load_invocation_id:
index a6a699ab25f483a7d4f4a737c43f6872ffd18200..dba9f199ec652253d6162381b288d140b9a8d4c7 100644 (file)
@@ -266,6 +266,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader)
    case nir_intrinsic_load_vertex_id_zero_base:
    case nir_intrinsic_load_base_vertex:
    case nir_intrinsic_load_first_vertex:
+   case nir_intrinsic_load_is_indexed_draw:
    case nir_intrinsic_load_base_instance:
    case nir_intrinsic_load_instance_id:
    case nir_intrinsic_load_sample_id:
index f26aaf35ee30c77d2d19fdd7b2bc47cb709e9073..b1754a7e50e888e39551900ca2a4872d1b45e528 100644 (file)
@@ -414,6 +414,7 @@ system_value("front_face", 1)
 system_value("vertex_id", 1)
 system_value("vertex_id_zero_base", 1)
 system_value("first_vertex", 1)
+system_value("is_indexed_draw", 1)
 system_value("base_vertex", 1)
 system_value("instance_id", 1)
 system_value("base_instance", 1)
index ebee076b43c0b6cc0fa3074dd4ad076c002157c5..d596d7d04a06048896f1457ef24c73fcbbe82b62 100644 (file)
@@ -217,6 +217,7 @@ gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_INSTANCE_INDEX),
      ENUM(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE),
      ENUM(SYSTEM_VALUE_FIRST_VERTEX),
+     ENUM(SYSTEM_VALUE_IS_INDEXED_DRAW),
      ENUM(SYSTEM_VALUE_BASE_VERTEX),
      ENUM(SYSTEM_VALUE_BASE_INSTANCE),
      ENUM(SYSTEM_VALUE_DRAW_ID),
index 8a277a14f21c58cf12cc01c8169f9433ff6686e5..1ef4d5a33d0e08f8c6f436e5ac4e153fe031fea2 100644 (file)
@@ -517,6 +517,13 @@ typedef enum
     */
    SYSTEM_VALUE_FIRST_VERTEX,
 
+   /**
+    * If the Draw command used to start the rendering was an indexed draw
+    * or not (~0/0). Useful to calculate \c SYSTEM_VALUE_BASE_VERTEX as
+    * \c SYSTEM_VALUE_IS_INDEXED_DRAW & \c SYSTEM_VALUE_FIRST_VERTEX.
+    */
+   SYSTEM_VALUE_IS_INDEXED_DRAW,
+
    /**
     * Value of \c baseinstance passed to instanced draw entry points
     *