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
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

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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)

View File

@@ -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 *

View File

@@ -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)

View File

@@ -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();
}
/**

View File

@@ -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,8 +71,23 @@ public:
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[] = {
glsl_struct_field(glsl_type::vec(4), "v")
};
@@ -87,21 +100,6 @@ link_varyings::link_varyings()
"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
link_varyings::TearDown()
{
@@ -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)