diff --git a/src/compiler/nir/tests/builder_tests.cpp b/src/compiler/nir/tests/builder_tests.cpp index c897eb1de97..244057dd1d9 100644 --- a/src/compiler/nir/tests/builder_tests.cpp +++ b/src/compiler/nir/tests/builder_tests.cpp @@ -67,19 +67,16 @@ protected: std::vector stores; - void *mem_ctx; - - nir_builder *b; + nir_builder *b, _b; }; nir_builder_test::nir_builder_test() { glsl_type_singleton_init_or_ref(); - mem_ctx = ralloc_context(NULL); static const nir_shader_compiler_options options = { }; - b = rzalloc(mem_ctx, nir_builder); - *b = nir_builder_init_simple_shader(mem_ctx, MESA_SHADER_COMPUTE, &options); + _b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, &options); + b = &_b; } nir_builder_test::~nir_builder_test() @@ -89,7 +86,7 @@ nir_builder_test::~nir_builder_test() nir_print_shader(b->shader, stdout); } - ralloc_free(mem_ctx); + ralloc_free(b->shader); glsl_type_singleton_decref(); } diff --git a/src/compiler/nir/tests/load_store_vectorizer_tests.cpp b/src/compiler/nir/tests/load_store_vectorizer_tests.cpp index b16b630e864..7d98ca2a808 100644 --- a/src/compiler/nir/tests/load_store_vectorizer_tests.cpp +++ b/src/compiler/nir/tests/load_store_vectorizer_tests.cpp @@ -78,9 +78,7 @@ protected: std::string swizzle(nir_alu_instr *instr, int src); - void *mem_ctx; - - nir_builder *b; + nir_builder *b, _b; std::map movs; std::map loads; std::map res_map; @@ -90,10 +88,9 @@ nir_load_store_vectorize_test::nir_load_store_vectorize_test() { glsl_type_singleton_init_or_ref(); - mem_ctx = ralloc_context(NULL); static const nir_shader_compiler_options options = { }; - b = rzalloc(mem_ctx, nir_builder); - *b = nir_builder_init_simple_shader(mem_ctx, MESA_SHADER_COMPUTE, &options); + _b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, &options); + b = &_b; } nir_load_store_vectorize_test::~nir_load_store_vectorize_test() @@ -103,7 +100,7 @@ nir_load_store_vectorize_test::~nir_load_store_vectorize_test() nir_print_shader(b->shader, stdout); } - ralloc_free(mem_ctx); + ralloc_free(b->shader); glsl_type_singleton_decref(); } diff --git a/src/compiler/nir/tests/serialize_tests.cpp b/src/compiler/nir/tests/serialize_tests.cpp index 327e5ec61d0..60e338e5791 100644 --- a/src/compiler/nir/tests/serialize_tests.cpp +++ b/src/compiler/nir/tests/serialize_tests.cpp @@ -38,8 +38,7 @@ protected: nir_alu_instr *get_last_alu(nir_shader *); void ASSERT_SWIZZLE_EQ(nir_alu_instr *, nir_alu_instr *, unsigned count, unsigned src); - void *mem_ctx; - nir_builder *b; + nir_builder *b, _b; nir_shader *dup; const nir_shader_compiler_options options; }; @@ -49,10 +48,8 @@ nir_serialize_test::nir_serialize_test() { glsl_type_singleton_init_or_ref(); - mem_ctx = ralloc_context(NULL); - - b = rzalloc(mem_ctx, nir_builder); - *b = nir_builder_init_simple_shader(mem_ctx, MESA_SHADER_COMPUTE, &options); + _b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, &options); + b = &_b; } nir_serialize_test::~nir_serialize_test() @@ -65,7 +62,7 @@ nir_serialize_test::~nir_serialize_test() nir_print_shader(dup, stdout); } - ralloc_free(mem_ctx); + ralloc_free(b->shader); glsl_type_singleton_decref(); } @@ -79,7 +76,7 @@ nir_serialize_test::serialize() { nir_serialize(&blob, b->shader, false); blob_reader_init(&reader, blob.data, blob.size); - nir_shader *cloned = nir_deserialize(mem_ctx, &options, &reader); + nir_shader *cloned = nir_deserialize(b->shader, &options, &reader); blob_finish(&blob); dup = cloned; diff --git a/src/compiler/nir/tests/vars_tests.cpp b/src/compiler/nir/tests/vars_tests.cpp index 1580b5dc493..63a99773df3 100644 --- a/src/compiler/nir/tests/vars_tests.cpp +++ b/src/compiler/nir/tests/vars_tests.cpp @@ -92,21 +92,19 @@ protected: nir_deref_instr *get_deref(nir_deref_type deref_type, unsigned index); - void *mem_ctx; void *lin_ctx; - nir_builder *b; + nir_builder *b, _b; }; nir_vars_test::nir_vars_test() { glsl_type_singleton_init_or_ref(); - mem_ctx = ralloc_context(NULL); - lin_ctx = linear_alloc_parent(mem_ctx, 0); static const nir_shader_compiler_options options = { }; - b = rzalloc(mem_ctx, nir_builder); - *b = nir_builder_init_simple_shader(mem_ctx, MESA_SHADER_COMPUTE, &options); + _b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, &options); + b = &_b; + lin_ctx = linear_alloc_parent(b->shader, 0); } nir_vars_test::~nir_vars_test() @@ -116,7 +114,7 @@ nir_vars_test::~nir_vars_test() nir_print_shader(b->shader, stdout); } - ralloc_free(mem_ctx); + ralloc_free(b->shader); glsl_type_singleton_decref(); } @@ -1840,7 +1838,7 @@ TEST_F(nir_split_vars_test, simple_no_split_array_struct) struct glsl_struct_field field; field.type = glsl_float_type(); - field.name = ralloc_asprintf(b, "field1"); + field.name = ralloc_asprintf(b->shader, "field1"); field.location = -1; field.offset = 0;