summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-09-14 16:49:53 -0700
committerJordan Justen <[email protected]>2017-10-31 23:36:53 -0700
commit54f691311c1f56c6aed693c21e820e4dd52b7f20 (patch)
tree62223980b06b1b9f3688a4bed4a773d13184baa9 /src/compiler/nir/nir.h
parent120da009755414ba62b0f902a67ad22004b9a304 (diff)
nir: Add hooks for testing serialization
Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir.h')
-rw-r--r--src/compiler/nir/nir.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index dd833cf1831..87c725625d7 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2312,6 +2312,8 @@ nir_variable *nir_variable_clone(const nir_variable *c, nir_shader *shader);
nir_deref *nir_deref_clone(const nir_deref *deref, void *mem_ctx);
nir_deref_var *nir_deref_var_clone(const nir_deref_var *deref, void *mem_ctx);
+nir_shader *nir_shader_serialize_deserialize(void *mem_ctx, nir_shader *s);
+
#ifdef DEBUG
void nir_validate_shader(nir_shader *shader);
void nir_metadata_set_validation_flag(nir_shader *shader);
@@ -2328,6 +2330,16 @@ should_clone_nir(void)
}
static inline bool
+should_serialize_deserialize_nir(void)
+{
+ static int test_serialize = -1;
+ if (test_serialize < 0)
+ test_serialize = env_var_as_boolean("NIR_TEST_SERIALIZE", false);
+
+ return test_serialize;
+}
+
+static inline bool
should_print_nir(void)
{
static int should_print = -1;
@@ -2341,6 +2353,7 @@ static inline void nir_validate_shader(nir_shader *shader) { (void) shader; }
static inline void nir_metadata_set_validation_flag(nir_shader *shader) { (void) shader; }
static inline void nir_metadata_check_validation_flag(nir_shader *shader) { (void) shader; }
static inline bool should_clone_nir(void) { return false; }
+static inline bool should_serialize_deserialize_nir(void) { return false; }
static inline bool should_print_nir(void) { return false; }
#endif /* DEBUG */
@@ -2352,6 +2365,10 @@ static inline bool should_print_nir(void) { return false; }
ralloc_free(nir); \
nir = clone; \
} \
+ if (should_serialize_deserialize_nir()) { \
+ void *mem_ctx = ralloc_parent(nir); \
+ nir = nir_shader_serialize_deserialize(mem_ctx, nir); \
+ } \
} while (0)
#define NIR_PASS(progress, nir, pass, ...) _PASS(nir, \