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 <lionel.g.landwerlin@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
This commit is contained in:
Lionel Landwerlin
2019-07-31 13:51:50 +03:00
parent 41d9873459
commit 3ade8f0040
9 changed files with 66 additions and 20 deletions

View File

@@ -93,6 +93,8 @@ public:
void void
array_refcount_test::SetUp() array_refcount_test::SetUp()
{ {
glsl_type_singleton_init_or_ref();
mem_ctx = ralloc_context(NULL); mem_ctx = ralloc_context(NULL);
instructions.make_empty(); instructions.make_empty();
@@ -117,6 +119,8 @@ array_refcount_test::TearDown()
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
mem_ctx = NULL; mem_ctx = NULL;
glsl_type_singleton_decref();
} }
static operand static operand

View File

@@ -57,6 +57,8 @@ public:
void void
common_builtin::SetUp() common_builtin::SetUp()
{ {
glsl_type_singleton_init_or_ref();
this->mem_ctx = ralloc_context(NULL); this->mem_ctx = ralloc_context(NULL);
this->ir.make_empty(); this->ir.make_empty();
@@ -79,6 +81,8 @@ common_builtin::TearDown()
{ {
ralloc_free(this->mem_ctx); ralloc_free(this->mem_ctx);
this->mem_ctx = NULL; this->mem_ctx = NULL;
glsl_type_singleton_decref();
} }
void void

View File

@@ -54,6 +54,8 @@ public:
void void
copy_constant_to_storage::SetUp() copy_constant_to_storage::SetUp()
{ {
glsl_type_singleton_init_or_ref();
this->mem_ctx = ralloc_context(NULL); this->mem_ctx = ralloc_context(NULL);
} }
@@ -62,6 +64,8 @@ copy_constant_to_storage::TearDown()
{ {
ralloc_free(this->mem_ctx); ralloc_free(this->mem_ctx);
this->mem_ctx = NULL; this->mem_ctx = NULL;
glsl_type_singleton_decref();
} }
void void

View File

@@ -26,7 +26,25 @@
#include "main/macros.h" #include "main/macros.h"
#include "ir.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); void *mem_ctx = ralloc_context(NULL);
@@ -52,7 +70,7 @@ TEST(ir_variable_constructor, interface)
EXPECT_EQ(iface, v->get_interface_type()); 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); void *mem_ctx = ralloc_context(NULL);

View File

@@ -46,6 +46,8 @@ public:
void void
invalidate_locations::SetUp() invalidate_locations::SetUp()
{ {
glsl_type_singleton_init_or_ref();
this->mem_ctx = ralloc_context(NULL); this->mem_ctx = ralloc_context(NULL);
this->ir.make_empty(); this->ir.make_empty();
} }
@@ -55,6 +57,8 @@ invalidate_locations::TearDown()
{ {
ralloc_free(this->mem_ctx); ralloc_free(this->mem_ctx);
this->mem_ctx = NULL; this->mem_ctx = NULL;
glsl_type_singleton_decref();
} }
TEST_F(invalidate_locations, simple_vertex_in_generic) TEST_F(invalidate_locations, simple_vertex_in_generic)

View File

@@ -57,6 +57,8 @@ public:
void void
expand_source::SetUp() expand_source::SetUp()
{ {
glsl_type_singleton_init_or_ref();
mem_ctx = ralloc_context(NULL); mem_ctx = ralloc_context(NULL);
memset(expanded_src, 0, sizeof(expanded_src)); memset(expanded_src, 0, sizeof(expanded_src));
@@ -72,6 +74,8 @@ expand_source::TearDown()
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
mem_ctx = NULL; mem_ctx = NULL;
glsl_type_singleton_decref();
} }
static ir_dereference_variable * static ir_dereference_variable *

View File

@@ -44,6 +44,8 @@ public:
void void
add_neg_to_sub::SetUp() add_neg_to_sub::SetUp()
{ {
glsl_type_singleton_init_or_ref();
mem_ctx = ralloc_context(NULL); mem_ctx = ralloc_context(NULL);
instructions.make_empty(); instructions.make_empty();
@@ -70,6 +72,8 @@ add_neg_to_sub::TearDown()
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
mem_ctx = NULL; mem_ctx = NULL;
glsl_type_singleton_decref();
} }
TEST_F(add_neg_to_sub, a_plus_b) TEST_F(add_neg_to_sub, a_plus_b)

View File

@@ -68,6 +68,8 @@ public:
void void
set_uniform_initializer::SetUp() set_uniform_initializer::SetUp()
{ {
glsl_type_singleton_init_or_ref();
this->mem_ctx = ralloc_context(NULL); this->mem_ctx = ralloc_context(NULL);
this->prog = rzalloc(NULL, struct gl_shader_program); this->prog = rzalloc(NULL, struct gl_shader_program);
this->prog->data = rzalloc(this->prog, struct gl_shader_program_data); this->prog->data = rzalloc(this->prog, struct gl_shader_program_data);
@@ -86,6 +88,8 @@ set_uniform_initializer::TearDown()
ralloc_free(this->prog); ralloc_free(this->prog);
this->prog = NULL; this->prog = NULL;
glsl_type_singleton_decref();
} }
/** /**

View File

@@ -51,8 +51,6 @@ get_matching_input(void *mem_ctx,
class link_varyings : public ::testing::Test { class link_varyings : public ::testing::Test {
public: public:
link_varyings();
virtual void SetUp(); virtual void SetUp();
virtual void TearDown(); virtual void TearDown();
@@ -73,8 +71,23 @@ public:
ir_variable *junk[VARYING_SLOT_TESS_MAX]; ir_variable *junk[VARYING_SLOT_TESS_MAX];
}; };
link_varyings::link_varyings() void
link_varyings::SetUp()
{ {
glsl_type_singleton_init_or_ref();
this->mem_ctx = ralloc_context(NULL);
this->ir.make_empty();
this->consumer_inputs =
_mesa_hash_table_create(NULL, _mesa_key_hash_string,
_mesa_key_string_equal);
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[] = { static const glsl_struct_field f[] = {
glsl_struct_field(glsl_type::vec(4), "v") glsl_struct_field(glsl_type::vec(4), "v")
}; };
@@ -87,21 +100,6 @@ link_varyings::link_varyings()
"simple_interface"); "simple_interface");
} }
void
link_varyings::SetUp()
{
this->mem_ctx = ralloc_context(NULL);
this->ir.make_empty();
this->consumer_inputs =
_mesa_hash_table_create(NULL, _mesa_key_hash_string,
_mesa_key_string_equal);
this->consumer_interface_inputs =
_mesa_hash_table_create(NULL, _mesa_key_hash_string,
_mesa_key_string_equal);
}
void void
link_varyings::TearDown() link_varyings::TearDown()
{ {
@@ -112,6 +110,8 @@ link_varyings::TearDown()
this->consumer_inputs = NULL; this->consumer_inputs = NULL;
_mesa_hash_table_destroy(this->consumer_interface_inputs, NULL); _mesa_hash_table_destroy(this->consumer_interface_inputs, NULL);
this->consumer_interface_inputs = NULL; this->consumer_interface_inputs = NULL;
glsl_type_singleton_decref();
} }
TEST_F(link_varyings, single_simple_input) TEST_F(link_varyings, single_simple_input)