st/glsl_to_nir: make use of nir linker for linking uniforms
[mesa.git] / src / compiler / glsl / tests / general_ir_test.cpp
index 217305bf8474ed1bfca367d0ed97847a980c1cc8..275cff2a999c37851b93808a5a76cfe6ceacef13 100644 (file)
  * 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 "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);
 
@@ -34,24 +52,25 @@ TEST(ir_variable_constructor, interface)
       glsl_struct_field(glsl_type::vec(4), "v")
    };
 
-   const glsl_type *const interface =
+   const glsl_type *const iface =
       glsl_type::get_interface_instance(f,
                                         ARRAY_SIZE(f),
                                         GLSL_INTERFACE_PACKING_STD140,
+                                        false,
                                         "simple_interface");
 
    static const char name[] = "named_instance";
 
    ir_variable *const v =
-      new(mem_ctx) ir_variable(interface, name, ir_var_uniform);
+      new(mem_ctx) ir_variable(iface, name, ir_var_uniform);
 
    EXPECT_STREQ(name, v->name);
    EXPECT_NE(name, v->name);
-   EXPECT_EQ(interface, v->type);
-   EXPECT_EQ(interface, v->get_interface_type());
+   EXPECT_EQ(iface, v->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);
 
@@ -59,14 +78,15 @@ TEST(ir_variable_constructor, interface_array)
       glsl_struct_field(glsl_type::vec(4), "v")
    };
 
-   const glsl_type *const interface =
+   const glsl_type *const iface =
       glsl_type::get_interface_instance(f,
                                         ARRAY_SIZE(f),
                                         GLSL_INTERFACE_PACKING_STD140,
+                                        false,
                                         "simple_interface");
 
    const glsl_type *const interface_array =
-      glsl_type::get_array_instance(interface, 2);
+      glsl_type::get_array_instance(iface, 2);
 
    static const char name[] = "array_instance";
 
@@ -76,5 +96,5 @@ TEST(ir_variable_constructor, interface_array)
    EXPECT_STREQ(name, v->name);
    EXPECT_NE(name, v->name);
    EXPECT_EQ(interface_array, v->type);
-   EXPECT_EQ(interface, v->get_interface_type());
+   EXPECT_EQ(iface, v->get_interface_type());
 }