From: Lionel Landwerlin Date: Wed, 31 Jul 2019 10:51:50 +0000 (+0300) Subject: glsl/tests: take refs on glsl types X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3ade8f0040f34be4eccebf042ee7354f2f09a99a;p=mesa.git glsl/tests: take refs on glsl types Much like each driver, tests as standalone entities must take references on the glsl types. Signed-off-by: Lionel Landwerlin Reviewed-by: Eric Anholt Reviewed-by: Tapani Pälli --- diff --git a/src/compiler/glsl/tests/array_refcount_test.cpp b/src/compiler/glsl/tests/array_refcount_test.cpp index edd9cf42a31..3d2778d46a5 100644 --- a/src/compiler/glsl/tests/array_refcount_test.cpp +++ b/src/compiler/glsl/tests/array_refcount_test.cpp @@ -93,6 +93,8 @@ public: void array_refcount_test::SetUp() { + glsl_type_singleton_init_or_ref(); + mem_ctx = ralloc_context(NULL); instructions.make_empty(); @@ -117,6 +119,8 @@ array_refcount_test::TearDown() ralloc_free(mem_ctx); mem_ctx = NULL; + + glsl_type_singleton_decref(); } static operand diff --git a/src/compiler/glsl/tests/builtin_variable_test.cpp b/src/compiler/glsl/tests/builtin_variable_test.cpp index 11e384a0722..cbaa9a385d7 100644 --- a/src/compiler/glsl/tests/builtin_variable_test.cpp +++ b/src/compiler/glsl/tests/builtin_variable_test.cpp @@ -57,6 +57,8 @@ public: void common_builtin::SetUp() { + glsl_type_singleton_init_or_ref(); + this->mem_ctx = ralloc_context(NULL); this->ir.make_empty(); @@ -79,6 +81,8 @@ common_builtin::TearDown() { ralloc_free(this->mem_ctx); this->mem_ctx = NULL; + + glsl_type_singleton_decref(); } void diff --git a/src/compiler/glsl/tests/copy_constant_to_storage_tests.cpp b/src/compiler/glsl/tests/copy_constant_to_storage_tests.cpp index cd48bc523c1..2cce7238503 100644 --- a/src/compiler/glsl/tests/copy_constant_to_storage_tests.cpp +++ b/src/compiler/glsl/tests/copy_constant_to_storage_tests.cpp @@ -54,6 +54,8 @@ public: void copy_constant_to_storage::SetUp() { + glsl_type_singleton_init_or_ref(); + this->mem_ctx = ralloc_context(NULL); } @@ -62,6 +64,8 @@ copy_constant_to_storage::TearDown() { ralloc_free(this->mem_ctx); this->mem_ctx = NULL; + + glsl_type_singleton_decref(); } void diff --git a/src/compiler/glsl/tests/general_ir_test.cpp b/src/compiler/glsl/tests/general_ir_test.cpp index c8bc16b7ad0..e05ecf9c3d5 100644 --- a/src/compiler/glsl/tests/general_ir_test.cpp +++ b/src/compiler/glsl/tests/general_ir_test.cpp @@ -26,7 +26,25 @@ #include "main/macros.h" #include "ir.h" -TEST(ir_variable_constructor, interface) +class ir_variable_constructor : public ::testing::Test { +public: + virtual void SetUp(); + virtual void TearDown(); +}; + +void +ir_variable_constructor::SetUp() +{ + glsl_type_singleton_init_or_ref(); +} + +void +ir_variable_constructor::TearDown() +{ + glsl_type_singleton_decref(); +} + +TEST_F(ir_variable_constructor, interface) { void *mem_ctx = ralloc_context(NULL); @@ -52,7 +70,7 @@ TEST(ir_variable_constructor, interface) EXPECT_EQ(iface, v->get_interface_type()); } -TEST(ir_variable_constructor, interface_array) +TEST_F(ir_variable_constructor, interface_array) { void *mem_ctx = ralloc_context(NULL); diff --git a/src/compiler/glsl/tests/invalidate_locations_test.cpp b/src/compiler/glsl/tests/invalidate_locations_test.cpp index ba94d7e3a21..48c8884d5e4 100644 --- a/src/compiler/glsl/tests/invalidate_locations_test.cpp +++ b/src/compiler/glsl/tests/invalidate_locations_test.cpp @@ -46,6 +46,8 @@ public: void invalidate_locations::SetUp() { + glsl_type_singleton_init_or_ref(); + this->mem_ctx = ralloc_context(NULL); this->ir.make_empty(); } @@ -55,6 +57,8 @@ invalidate_locations::TearDown() { ralloc_free(this->mem_ctx); this->mem_ctx = NULL; + + glsl_type_singleton_decref(); } TEST_F(invalidate_locations, simple_vertex_in_generic) diff --git a/src/compiler/glsl/tests/lower_int64_test.cpp b/src/compiler/glsl/tests/lower_int64_test.cpp index 4ddc433582e..a7e8186e41b 100644 --- a/src/compiler/glsl/tests/lower_int64_test.cpp +++ b/src/compiler/glsl/tests/lower_int64_test.cpp @@ -57,6 +57,8 @@ public: void expand_source::SetUp() { + glsl_type_singleton_init_or_ref(); + mem_ctx = ralloc_context(NULL); memset(expanded_src, 0, sizeof(expanded_src)); @@ -72,6 +74,8 @@ expand_source::TearDown() ralloc_free(mem_ctx); mem_ctx = NULL; + + glsl_type_singleton_decref(); } static ir_dereference_variable * diff --git a/src/compiler/glsl/tests/opt_add_neg_to_sub_test.cpp b/src/compiler/glsl/tests/opt_add_neg_to_sub_test.cpp index b82e47ffb23..fa45d06eb7a 100644 --- a/src/compiler/glsl/tests/opt_add_neg_to_sub_test.cpp +++ b/src/compiler/glsl/tests/opt_add_neg_to_sub_test.cpp @@ -44,6 +44,8 @@ public: void add_neg_to_sub::SetUp() { + glsl_type_singleton_init_or_ref(); + mem_ctx = ralloc_context(NULL); instructions.make_empty(); @@ -70,6 +72,8 @@ add_neg_to_sub::TearDown() ralloc_free(mem_ctx); mem_ctx = NULL; + + glsl_type_singleton_decref(); } TEST_F(add_neg_to_sub, a_plus_b) diff --git a/src/compiler/glsl/tests/set_uniform_initializer_tests.cpp b/src/compiler/glsl/tests/set_uniform_initializer_tests.cpp index 94a6d270ec4..2bcb25d466c 100644 --- a/src/compiler/glsl/tests/set_uniform_initializer_tests.cpp +++ b/src/compiler/glsl/tests/set_uniform_initializer_tests.cpp @@ -68,6 +68,8 @@ public: void set_uniform_initializer::SetUp() { + glsl_type_singleton_init_or_ref(); + this->mem_ctx = ralloc_context(NULL); this->prog = rzalloc(NULL, struct gl_shader_program); this->prog->data = rzalloc(this->prog, struct gl_shader_program_data); @@ -86,6 +88,8 @@ set_uniform_initializer::TearDown() ralloc_free(this->prog); this->prog = NULL; + + glsl_type_singleton_decref(); } /** diff --git a/src/compiler/glsl/tests/varyings_test.cpp b/src/compiler/glsl/tests/varyings_test.cpp index eb134c9e8f2..74957734858 100644 --- a/src/compiler/glsl/tests/varyings_test.cpp +++ b/src/compiler/glsl/tests/varyings_test.cpp @@ -51,8 +51,6 @@ get_matching_input(void *mem_ctx, class link_varyings : public ::testing::Test { public: - link_varyings(); - virtual void SetUp(); virtual void TearDown(); @@ -73,23 +71,11 @@ public: ir_variable *junk[VARYING_SLOT_TESS_MAX]; }; -link_varyings::link_varyings() -{ - static const glsl_struct_field f[] = { - glsl_struct_field(glsl_type::vec(4), "v") - }; - - this->simple_interface = - glsl_type::get_interface_instance(f, - ARRAY_SIZE(f), - GLSL_INTERFACE_PACKING_STD140, - false, - "simple_interface"); -} - void link_varyings::SetUp() { + glsl_type_singleton_init_or_ref(); + this->mem_ctx = ralloc_context(NULL); this->ir.make_empty(); @@ -100,6 +86,18 @@ link_varyings::SetUp() this->consumer_interface_inputs = _mesa_hash_table_create(NULL, _mesa_key_hash_string, _mesa_key_string_equal); + + /* Needs to happen after glsl type initialization */ + static const glsl_struct_field f[] = { + glsl_struct_field(glsl_type::vec(4), "v") + }; + + this->simple_interface = + glsl_type::get_interface_instance(f, + ARRAY_SIZE(f), + GLSL_INTERFACE_PACKING_STD140, + false, + "simple_interface"); } void @@ -112,6 +110,8 @@ link_varyings::TearDown() this->consumer_inputs = NULL; _mesa_hash_table_destroy(this->consumer_interface_inputs, NULL); this->consumer_interface_inputs = NULL; + + glsl_type_singleton_decref(); } TEST_F(link_varyings, single_simple_input)