diff options
author | Kenneth Graunke <[email protected]> | 2015-11-03 00:31:22 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-11-18 12:28:32 -0800 |
commit | 9ff71b649b4b3808a9e17ce69743c6037fd6603c (patch) | |
tree | 43664cd40ec6c9edb84b72a59cae59cd6d90797a /src/mesa/drivers | |
parent | 7bc097899924f40140981567c7bb52297dd801f2 (diff) |
i965/nir: Validate that NIR passes call nir_metadata_preserve().
Failing to call nir_metadata_preserve() can have nasty consequences:
some pass breaks dominance information, but leaves it marked as valid,
causing some subsequent pass to go haywire and probably crash.
This pass adds a simple validation mechanism to ensure passes handle
this properly. We add a new bogus metadata flag that isn't used for
anything in particular, set it before each pass, and ensure it *isn't*
still set after the pass. nir_metadata_preserve will reset the flag,
so correct passes will work, and bad passes will assert fail.
(I would have made these functions static inline, but nir.h is included
in C++, so we can't bit-or enums without lots of casting...)
Thanks to Dylan Baker for the idea.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_nir.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c index b19f9691956..7826729db85 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.c +++ b/src/mesa/drivers/dri/i965/brw_nir.c @@ -178,9 +178,13 @@ brw_nir_lower_outputs(nir_shader *nir, bool is_scalar) this_progress; \ })) -#define OPT(pass, ...) _OPT( \ - this_progress = pass(nir ,##__VA_ARGS__); \ - progress = progress || this_progress; \ +#define OPT(pass, ...) _OPT( \ + nir_metadata_set_validation_flag(nir); \ + this_progress = pass(nir ,##__VA_ARGS__); \ + if (this_progress) { \ + progress = true; \ + nir_metadata_check_validation_flag(nir); \ + } \ ) #define OPT_V(pass, ...) _OPT( \ |