diff options
author | Antia Puentes <[email protected]> | 2018-04-28 14:09:18 +0200 |
---|---|---|
committer | Antia Puentes <[email protected]> | 2018-05-02 11:20:40 +0200 |
commit | 9e6b886cf25f88eea584d38c6763dbded99bd064 (patch) | |
tree | 5a26de9923666b27ded3420edcccd5819e04d20b | |
parent | 0737c1e3a603e13ce9764ff5432e332b233c4b9d (diff) |
compiler: Add SYSTEM_VALUE_IS_INDEXED_DRAW and instrinsics
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 <[email protected]>
-rw-r--r-- | src/compiler/nir/nir.c | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_gather_info.c | 1 | ||||
-rw-r--r-- | src/compiler/nir/nir_intrinsics.py | 1 | ||||
-rw-r--r-- | src/compiler/shader_enums.c | 1 | ||||
-rw-r--r-- | src/compiler/shader_enums.h | 7 |
5 files changed, 14 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index ea28fbd1af5..dc1c560319e 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -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: diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index a6a699ab25f..dba9f199ec6 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -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: diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py index f26aaf35ee3..b1754a7e50e 100644 --- a/src/compiler/nir/nir_intrinsics.py +++ b/src/compiler/nir/nir_intrinsics.py @@ -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) diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c index ebee076b43c..d596d7d04a0 100644 --- a/src/compiler/shader_enums.c +++ b/src/compiler/shader_enums.c @@ -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), diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h index 8a277a14f21..1ef4d5a33d0 100644 --- a/src/compiler/shader_enums.h +++ b/src/compiler/shader_enums.h @@ -518,6 +518,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 * * \sa SYSTEM_VALUE_INSTANCE_ID |