Mesa (master): compiler/nir: Add conditional lowering for gl_BaseVertex
AntÃa Puentes Felpeto
apuentes at kemper.freedesktop.org
Wed May 2 09:34:31 UTC 2018
Module: Mesa
Branch: master
Commit: 0fb204fac14cd2c7cf4a04f4060d4000bf5e3d35
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0fb204fac14cd2c7cf4a04f4060d4000bf5e3d35
Author: Antia Puentes <apuentes at igalia.com>
Date: Sat Apr 28 14:09:21 2018 +0200
compiler/nir: Add conditional lowering for gl_BaseVertex
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/compiler/nir/nir.h | 6 ++++++
src/compiler/nir/nir_lower_system_values.c | 15 +++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f8e71d54a5..ec3dbf035c 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1930,6 +1930,12 @@ typedef struct nir_shader_compiler_options {
/* Indicates that the driver only has zero-based vertex id */
bool vertex_id_zero_based;
+ /**
+ * If enabled, gl_BaseVertex will be lowered as:
+ * is_indexed_draw (~0/0) & firstvertex
+ */
+ bool lower_base_vertex;
+
bool lower_cs_local_index_from_id;
bool lower_device_index_to_zero;
diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c
index 47709e9887..487da04262 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -121,6 +121,21 @@ convert_block(nir_block *block, nir_builder *b)
}
break;
+ case SYSTEM_VALUE_BASE_VERTEX:
+ /**
+ * From the OpenGL 4.6 (11.1.3.9 Shader Inputs) specification:
+ *
+ * "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."
+ */
+ if (b->shader->options->lower_base_vertex)
+ sysval = nir_iand(b,
+ nir_load_is_indexed_draw(b),
+ nir_load_first_vertex(b));
+ break;
+
case SYSTEM_VALUE_INSTANCE_INDEX:
sysval = nir_iadd(b,
nir_load_instance_id(b),
More information about the mesa-commit
mailing list