1 /* 2 * Copyright © 2023 Valve Corporation 3 * SPDX-License-Identifier: MIT 4 */ 5 6 #ifndef NIR_TESTS_NIR_TEST_H 7 #define NIR_TESTS_NIR_TEST_H 8 9 #include <gtest/gtest.h> 10 11 #include "nir.h" 12 #include "nir_builder.h" 13 14 class nir_test : public ::testing::Test { 15 protected: nir_test(const char * name)16 nir_test(const char *name) 17 { 18 glsl_type_singleton_init_or_ref(); 19 20 _b = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, &options, "%s", name); 21 b = &_b; 22 } 23 ~nir_test()24 virtual ~nir_test() 25 { 26 if (HasFailure()) { 27 printf("\nShader from the failed test:\n\n"); 28 nir_print_shader(b->shader, stdout); 29 } 30 31 ralloc_free(b->shader); 32 33 glsl_type_singleton_decref(); 34 } 35 36 nir_shader_compiler_options options = {}; 37 nir_builder _b; 38 nir_builder *b; 39 }; 40 41 #endif 42