[Mesa-dev] [PATCH 02/21] nir: Add a new "param" variable mode for parameters and return variables
Jason Ekstrand
jason at jlekstrand.net
Sun Feb 14 02:14:19 UTC 2016
---
src/compiler/nir/nir.c | 4 ++++
src/compiler/nir/nir.h | 9 ++++++++-
src/compiler/nir/nir_validate.c | 2 +-
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index df40a55..acb2692 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -115,6 +115,10 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var)
assert(!"nir_shader_add_variable cannot be used for local variables");
break;
+ case nir_var_param:
+ assert(!"nir_shader_add_variable cannot be used for function parameters");
+ break;
+
case nir_var_global:
exec_list_push_tail(&shader->globals, &var->node);
break;
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index cccb3a4..ef3b79e 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -88,7 +88,8 @@ typedef enum {
nir_var_local,
nir_var_uniform,
nir_var_shader_storage,
- nir_var_system_value
+ nir_var_system_value,
+ nir_var_param,
} nir_variable_mode;
/**
@@ -331,6 +332,12 @@ typedef struct nir_variable {
#define nir_foreach_variable(var, var_list) \
foreach_list_typed(nir_variable, var, node, var_list)
+static inline bool
+nir_variable_is_global(const nir_variable *var)
+{
+ return var->data.mode != nir_var_local && var->data.mode != nir_var_param;
+}
+
typedef struct nir_register {
struct exec_node node;
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index d1a9048..24094f6 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -867,7 +867,7 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state)
static void
validate_var_decl(nir_variable *var, bool is_global, validate_state *state)
{
- assert(is_global != (var->data.mode == nir_var_local));
+ assert(is_global == nir_variable_is_global(var));
/*
* TODO validate some things ir_validate.cpp does (requires more GLSL type
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list