aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-01-15 16:15:50 -0800
committerJason Ekstrand <[email protected]>2016-01-15 16:15:50 -0800
commitf509a890828dc54ffc113a581147ccfa8408b082 (patch)
treeb79b2447b8838a98ee70deb675ec4ef33bd95d3d /src
parent6b64dddd7118e75dbb9d6aa4917b296f384aba89 (diff)
nir/lower_system_values: Lower vertexID to id+base if needed
Diffstat (limited to 'src')
-rw-r--r--src/glsl/nir/nir.h3
-rw-r--r--src/glsl/nir/nir_lower_system_values.c10
-rw-r--r--src/mesa/drivers/dri/i965/brw_shader.cpp1
3 files changed, 14 insertions, 0 deletions
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 3d2d280db12..725703d0588 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1534,6 +1534,9 @@ typedef struct nir_shader_compiler_options {
* are simulated by floats.)
*/
bool native_integers;
+
+ /* Indicates that the driver only has zero-based vertex id */
+ bool vertex_id_zero_based;
} nir_shader_compiler_options;
typedef struct nir_shader_info {
diff --git a/src/glsl/nir/nir_lower_system_values.c b/src/glsl/nir/nir_lower_system_values.c
index f642c38561a..69d0554fbca 100644
--- a/src/glsl/nir/nir_lower_system_values.c
+++ b/src/glsl/nir/nir_lower_system_values.c
@@ -103,6 +103,16 @@ convert_block(nir_block *block, void *void_state)
break;
}
+ case SYSTEM_VALUE_VERTEX_ID:
+ if (b->shader->options->vertex_id_zero_based) {
+ sysval = nir_iadd(b,
+ nir_load_system_value(b, nir_intrinsic_load_vertex_id_zero_base, 0),
+ nir_load_system_value(b, nir_intrinsic_load_base_vertex, 0));
+ } else {
+ sysval = nir_load_system_value(b, nir_intrinsic_load_vertex_id, 0);
+ }
+ break;
+
default: {
nir_intrinsic_op sysval_op =
nir_intrinsic_from_system_value(var->data.location);
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index d507e99d352..fec96bac923 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -96,6 +96,7 @@ brw_compiler_create(void *mem_ctx, const struct brw_device_info *devinfo)
nir_shader_compiler_options *nir_options =
rzalloc(compiler, nir_shader_compiler_options);
nir_options->native_integers = true;
+ nir_options->vertex_id_zero_based = true;
nir_options->lower_fdiv = true;
/* In order to help allow for better CSE at the NIR level we tell NIR
* to split all ffma instructions during opt_algebraic and we then