glsl/tests: take refs on glsl types
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 31 Jul 2019 10:51:50 +0000 (13:51 +0300)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 21 Aug 2019 07:44:10 +0000 (09:44 +0200)
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>
src/compiler/glsl/tests/array_refcount_test.cpp
src/compiler/glsl/tests/builtin_variable_test.cpp
src/compiler/glsl/tests/copy_constant_to_storage_tests.cpp
src/compiler/glsl/tests/general_ir_test.cpp
src/compiler/glsl/tests/invalidate_locations_test.cpp
src/compiler/glsl/tests/lower_int64_test.cpp
src/compiler/glsl/tests/opt_add_neg_to_sub_test.cpp
src/compiler/glsl/tests/set_uniform_initializer_tests.cpp
src/compiler/glsl/tests/varyings_test.cpp

index edd9cf42a31239bbd8da50e0026ae17a8c48fc5d..3d2778d46a55268ac4c8f573c981bf537efb4bc1 100644 (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
index 11e384a072280353e5b47f1003ed263eab35ffd5..cbaa9a385d79fa6da765d9b613e60d0804ddf8a2 100644 (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
index cd48bc523c128c200a0d1d64677f176e7dfd61aa..2cce7238503ebe12bcfff2191c6aeaec304baae3 100644 (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
index c8bc16b7ad0b77b44c217c36176cd74c6b70a37c..e05ecf9c3d5c29335f272d9e225a13f4e827dc3f 100644 (file)
 #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);
 
index ba94d7e3a217c2e79a69a304e0d02d488a7b0527..48c8884d5e488949222b34c061dd424465fdbbae 100644 (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)
index 4ddc433582edf18189375b0e19cd71b58b77eb9c..a7e8186e41b8a97a5ce489091fbd38b62ff7a215 100644 (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 *
index b82e47ffb23af6e89ca7d62aa64ecbd4ca35cacc..fa45d06eb7a92d12a5658be4ce3b9cc98ecff636 100644 (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)
index 94a6d270ec43f342f333780f6308d7da49837c48..2bcb25d466c36125fbd413a0619d5a01f94cce5a 100644 (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();
 }
 
 /**
index eb134c9e8f2e2e98f8e7f07e17077088a2a9a10a..7495773485894d5e093aa37887e6371d921bd22f 100644 (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,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)