diff options
author | Jason Ekstrand <[email protected]> | 2019-03-27 10:13:28 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-03-29 21:57:51 -0500 |
commit | 7dbd934e269e80941b2d73e4b405a151a1145a21 (patch) | |
tree | 75f1721bac05185d35cf5f302df72eb6d5c421c9 /src/compiler/nir/nir_validate.c | |
parent | b8e077daee4d6369d774efaa99879a9871c68194 (diff) |
nir: Lock around validation fail shader dumping
This prevents getting mixed-up results if a multi-threaded app has two
validation errors in different threads.
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_validate.c')
-rw-r--r-- | src/compiler/nir/nir_validate.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 80f397098a2..5f812974720 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -26,6 +26,7 @@ */ #include "nir.h" +#include "c11/threads.h" #include <assert.h> /* @@ -1180,11 +1181,18 @@ destroy_validate_state(validate_state *state) _mesa_hash_table_destroy(state->errors, NULL); } +mtx_t fail_dump_mutex = _MTX_INITIALIZER_NP; + static void dump_errors(validate_state *state, const char *when) { struct hash_table *errors = state->errors; + /* Lock around dumping so that we get clean dumps in a multi-threaded + * scenario + */ + mtx_lock(&fail_dump_mutex); + if (when) { fprintf(stderr, "NIR validation failed %s\n", when); fprintf(stderr, "%d errors:\n", _mesa_hash_table_num_entries(errors)); @@ -1203,6 +1211,8 @@ dump_errors(validate_state *state, const char *when) } } + mtx_unlock(&fail_dump_mutex); + abort(); } |