Move compiler.h and imports.h/c from src/mesa/main into src/util
[mesa.git] / src / compiler / glsl / tests / varyings_test.cpp
index 7643e1bbbf917390e0f91e48cd5021e46a29a3be..30df36acb2b7305f0bf91e613678a05abad9f29e 100644 (file)
@@ -21,7 +21,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 #include <gtest/gtest.h>
-#include "main/compiler.h"
+#include "util/compiler.h"
 #include "main/mtypes.h"
 #include "main/macros.h"
 #include "util/ralloc.h"
@@ -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,32 +71,33 @@ 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,
-                                        "simple_interface");
-}
-
 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_hash_table_create(NULL, _mesa_hash_string,
                                  _mesa_key_string_equal);
 
    this->consumer_interface_inputs =
-         _mesa_hash_table_create(NULL, _mesa_key_hash_string,
+         _mesa_hash_table_create(NULL, _mesa_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
@@ -111,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)