summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-04-11 13:32:59 -0700
committerJason Ekstrand <[email protected]>2016-04-13 12:40:12 -0700
commitffa0e12e15bdfd0116446bfc5697e9e250770981 (patch)
tree5ee88398fd741e3b525d6fd38da229a5c3aaa909 /src
parentf69a61b1aa7f7fc8dd190cb3d5da1e7bca7de809 (diff)
nir: Convert nir_variable_mode to a bitfield
There are several passes where we need to specify some set of variable modes that the pass needs top operate on. This lets us easily do that. Acked-by: Eric Anholt <[email protected]> Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir.h33
-rw-r--r--src/compiler/nir/nir_validate.c3
2 files changed, 19 insertions, 17 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index ebac75075ec..255c3a03d72 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -81,16 +81,16 @@ typedef struct {
} nir_state_slot;
typedef enum {
- nir_var_all = -1,
- nir_var_shader_in,
- nir_var_shader_out,
- nir_var_global,
- nir_var_local,
- nir_var_uniform,
- nir_var_shader_storage,
- nir_var_system_value,
- nir_var_param,
- nir_var_shared,
+ nir_var_shader_in = (1 << 0),
+ nir_var_shader_out = (1 << 1),
+ nir_var_global = (1 << 2),
+ nir_var_local = (1 << 3),
+ nir_var_uniform = (1 << 4),
+ nir_var_shader_storage = (1 << 5),
+ nir_var_system_value = (1 << 6),
+ nir_var_param = (1 << 7),
+ nir_var_shared = (1 << 8),
+ nir_var_all = ~0,
} nir_variable_mode;
/**
@@ -156,6 +156,12 @@ typedef struct nir_variable {
char *name;
struct nir_variable_data {
+ /**
+ * Storage class of the variable.
+ *
+ * \sa nir_variable_mode
+ */
+ nir_variable_mode mode;
/**
* Is the variable read-only?
@@ -170,13 +176,6 @@ typedef struct nir_variable {
unsigned invariant:1;
/**
- * Storage class of the variable.
- *
- * \sa nir_variable_mode
- */
- nir_variable_mode mode:5;
-
- /**
* Interpolation mode for shader inputs / outputs
*
* \sa glsl_interp_qualifier
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index 9f18d1c33e4..3c3306c75fb 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -903,6 +903,9 @@ validate_var_decl(nir_variable *var, bool is_global, validate_state *state)
{
assert(is_global == nir_variable_is_global(var));
+ /* Must have exactly one mode set */
+ assert(util_bitcount(var->data.mode) == 1);
+
/*
* TODO validate some things ir_validate.cpp does (requires more GLSL type
* support)