fail |= run_tests(devinfo);
}
+ free(devinfo);
return fail;
}
class cmod_propagation_test : public ::testing::Test {
virtual void SetUp();
+ virtual void TearDown();
public:
struct brw_compiler *compiler;
struct gen_device_info *devinfo;
- struct gl_context *ctx;
+ void *ctx;
struct brw_wm_prog_data *prog_data;
struct gl_shader_program *shader_prog;
fs_visitor *v;
{
public:
cmod_propagation_fs_visitor(struct brw_compiler *compiler,
+ void *mem_ctx,
struct brw_wm_prog_data *prog_data,
nir_shader *shader)
- : fs_visitor(compiler, NULL, NULL, NULL,
+ : fs_visitor(compiler, NULL, mem_ctx, NULL,
&prog_data->base, shader, 8, -1) {}
};
void cmod_propagation_test::SetUp()
{
- ctx = (struct gl_context *)calloc(1, sizeof(*ctx));
- compiler = (struct brw_compiler *)calloc(1, sizeof(*compiler));
- devinfo = (struct gen_device_info *)calloc(1, sizeof(*devinfo));
+ ctx = ralloc_context(NULL);
+ compiler = rzalloc(ctx, struct brw_compiler);
+ devinfo = rzalloc(ctx, struct gen_device_info);
compiler->devinfo = devinfo;
- prog_data = ralloc(NULL, struct brw_wm_prog_data);
+ prog_data = ralloc(ctx, struct brw_wm_prog_data);
nir_shader *shader =
- nir_shader_create(NULL, MESA_SHADER_FRAGMENT, NULL, NULL);
+ nir_shader_create(ctx, MESA_SHADER_FRAGMENT, NULL, NULL);
- v = new cmod_propagation_fs_visitor(compiler, prog_data, shader);
+ v = new cmod_propagation_fs_visitor(compiler, ctx, prog_data, shader);
devinfo->gen = 7;
}
+void cmod_propagation_test::TearDown()
+{
+ delete v;
+ v = NULL;
+
+ ralloc_free(ctx);
+ ctx = NULL;
+}
+
static fs_inst *
instruction(bblock_t *block, int num)
{
class copy_propagation_test : public ::testing::Test {
virtual void SetUp();
+ virtual void TearDown();
public:
struct brw_compiler *compiler;
struct gen_device_info *devinfo;
- struct gl_context *ctx;
+ void *ctx;
struct brw_wm_prog_data *prog_data;
struct gl_shader_program *shader_prog;
fs_visitor *v;
{
public:
copy_propagation_fs_visitor(struct brw_compiler *compiler,
+ void *mem_ctx,
struct brw_wm_prog_data *prog_data,
nir_shader *shader)
- : fs_visitor(compiler, NULL, NULL, NULL,
+ : fs_visitor(compiler, NULL, mem_ctx, NULL,
&prog_data->base, shader, 8, -1) {}
};
void copy_propagation_test::SetUp()
{
- ctx = (struct gl_context *)calloc(1, sizeof(*ctx));
- compiler = (struct brw_compiler *)calloc(1, sizeof(*compiler));
- devinfo = (struct gen_device_info *)calloc(1, sizeof(*devinfo));
+ ctx = ralloc_context(NULL);
+ compiler = rzalloc(ctx, struct brw_compiler);
+ devinfo = rzalloc(ctx, struct gen_device_info);
compiler->devinfo = devinfo;
- prog_data = ralloc(NULL, struct brw_wm_prog_data);
+ prog_data = ralloc(ctx, struct brw_wm_prog_data);
nir_shader *shader =
- nir_shader_create(NULL, MESA_SHADER_FRAGMENT, NULL, NULL);
+ nir_shader_create(ctx, MESA_SHADER_FRAGMENT, NULL, NULL);
- v = new copy_propagation_fs_visitor(compiler, prog_data, shader);
+ v = new copy_propagation_fs_visitor(compiler, ctx, prog_data, shader);
devinfo->gen = 4;
}
+void copy_propagation_test::TearDown()
+{
+ delete v;
+ v = NULL;
+
+ ralloc_free(ctx);
+ ctx = NULL;
+}
+
static fs_inst *
instruction(bblock_t *block, int num)
{
class saturate_propagation_test : public ::testing::Test {
virtual void SetUp();
+ virtual void TearDown();
public:
struct brw_compiler *compiler;
struct gen_device_info *devinfo;
- struct gl_context *ctx;
+ void *ctx;
struct brw_wm_prog_data *prog_data;
struct gl_shader_program *shader_prog;
fs_visitor *v;
{
public:
saturate_propagation_fs_visitor(struct brw_compiler *compiler,
+ void *mem_ctx,
struct brw_wm_prog_data *prog_data,
nir_shader *shader)
- : fs_visitor(compiler, NULL, NULL, NULL,
+ : fs_visitor(compiler, NULL, mem_ctx, NULL,
&prog_data->base, shader, 16, -1) {}
};
void saturate_propagation_test::SetUp()
{
- ctx = (struct gl_context *)calloc(1, sizeof(*ctx));
- compiler = (struct brw_compiler *)calloc(1, sizeof(*compiler));
- devinfo = (struct gen_device_info *)calloc(1, sizeof(*devinfo));
+ ctx = ralloc_context(NULL);
+ compiler = rzalloc(ctx, struct brw_compiler);
+ devinfo = rzalloc(ctx, struct gen_device_info);
compiler->devinfo = devinfo;
- prog_data = ralloc(NULL, struct brw_wm_prog_data);
+ prog_data = ralloc(ctx, struct brw_wm_prog_data);
nir_shader *shader =
- nir_shader_create(NULL, MESA_SHADER_FRAGMENT, NULL, NULL);
+ nir_shader_create(ctx, MESA_SHADER_FRAGMENT, NULL, NULL);
- v = new saturate_propagation_fs_visitor(compiler, prog_data, shader);
+ v = new saturate_propagation_fs_visitor(compiler, ctx, prog_data, shader);
devinfo->gen = 6;
}
+void saturate_propagation_test::TearDown()
+{
+ delete v;
+ v = NULL;
+
+ ralloc_free(ctx);
+ ctx = NULL;
+}
+
+
static fs_inst *
instruction(bblock_t *block, int num)
{
class scoreboard_test : public ::testing::Test {
virtual void SetUp();
+ virtual void TearDown();
public:
struct brw_compiler *compiler;
struct gen_device_info *devinfo;
- struct gl_context *ctx;
+ void *ctx;
struct brw_wm_prog_data *prog_data;
struct gl_shader_program *shader_prog;
fs_visitor *v;
void scoreboard_test::SetUp()
{
- ctx = (struct gl_context *)calloc(1, sizeof(*ctx));
- compiler = (struct brw_compiler *)calloc(1, sizeof(*compiler));
- devinfo = (struct gen_device_info *)calloc(1, sizeof(*devinfo));
+ ctx = ralloc_context(NULL);
+ compiler = rzalloc(ctx, struct brw_compiler);
+ devinfo = rzalloc(ctx, struct gen_device_info);
compiler->devinfo = devinfo;
- prog_data = ralloc(NULL, struct brw_wm_prog_data);
+ prog_data = ralloc(ctx, struct brw_wm_prog_data);
nir_shader *shader =
- nir_shader_create(NULL, MESA_SHADER_FRAGMENT, NULL, NULL);
+ nir_shader_create(ctx, MESA_SHADER_FRAGMENT, NULL, NULL);
- v = new fs_visitor(compiler, NULL, NULL, NULL, &prog_data->base, shader, 8, -1);
+ v = new fs_visitor(compiler, NULL, ctx, NULL, &prog_data->base, shader, 8, -1);
devinfo->gen = 12;
}
+void scoreboard_test::TearDown()
+{
+ delete v;
+ v = NULL;
+
+ ralloc_free(ctx);
+ ctx = NULL;
+}
+
static fs_inst *
instruction(bblock_t *block, int num)
{
class cmod_propagation_test : public ::testing::Test {
virtual void SetUp();
+ virtual void TearDown();
public:
struct brw_compiler *compiler;
struct gen_device_info *devinfo;
- struct gl_context *ctx;
+ void *ctx;
struct gl_shader_program *shader_prog;
struct brw_vue_prog_data *prog_data;
vec4_visitor *v;
{
public:
cmod_propagation_vec4_visitor(struct brw_compiler *compiler,
+ void *mem_ctx,
nir_shader *shader,
struct brw_vue_prog_data *prog_data)
- : vec4_visitor(compiler, NULL, NULL, prog_data, shader, NULL,
+ : vec4_visitor(compiler, NULL, NULL, prog_data, shader, mem_ctx,
false, -1)
{
prog_data->dispatch_mode = DISPATCH_MODE_4X2_DUAL_OBJECT;
void cmod_propagation_test::SetUp()
{
- ctx = (struct gl_context *)calloc(1, sizeof(*ctx));
- compiler = (struct brw_compiler *)calloc(1, sizeof(*compiler));
- devinfo = (struct gen_device_info *)calloc(1, sizeof(*devinfo));
- prog_data = (struct brw_vue_prog_data *)calloc(1, sizeof(*prog_data));
+ ctx = ralloc_context(NULL);
+ compiler = rzalloc(ctx, struct brw_compiler);
+ devinfo = rzalloc(ctx, struct gen_device_info);
compiler->devinfo = devinfo;
+ prog_data = ralloc(ctx, struct brw_vue_prog_data);
nir_shader *shader =
- nir_shader_create(NULL, MESA_SHADER_VERTEX, NULL, NULL);
+ nir_shader_create(ctx, MESA_SHADER_VERTEX, NULL, NULL);
- v = new cmod_propagation_vec4_visitor(compiler, shader, prog_data);
+ v = new cmod_propagation_vec4_visitor(compiler, ctx, shader, prog_data);
devinfo->gen = 4;
}
+void cmod_propagation_test::TearDown()
+{
+ delete v;
+ v = NULL;
+
+ ralloc_free(ctx);
+ ctx = NULL;
+}
+
static vec4_instruction *
instruction(bblock_t *block, int num)
{
class copy_propagation_test : public ::testing::Test {
virtual void SetUp();
+ virtual void TearDown();
public:
struct brw_compiler *compiler;
struct gen_device_info *devinfo;
- struct gl_context *ctx;
+ void *ctx;
struct gl_shader_program *shader_prog;
struct brw_vue_prog_data *prog_data;
vec4_visitor *v;
{
public:
copy_propagation_vec4_visitor(struct brw_compiler *compiler,
+ void *mem_ctx,
nir_shader *shader,
struct brw_vue_prog_data *prog_data)
- : vec4_visitor(compiler, NULL, NULL, prog_data, shader, NULL,
+ : vec4_visitor(compiler, NULL, NULL, prog_data, shader, mem_ctx,
false /* no_spills */, -1)
{
prog_data->dispatch_mode = DISPATCH_MODE_4X2_DUAL_OBJECT;
void copy_propagation_test::SetUp()
{
- ctx = (struct gl_context *)calloc(1, sizeof(*ctx));
- compiler = (struct brw_compiler *)calloc(1, sizeof(*compiler));
- devinfo = (struct gen_device_info *)calloc(1, sizeof(*devinfo));
- prog_data = (struct brw_vue_prog_data *)calloc(1, sizeof(*prog_data));
+ ctx = ralloc_context(NULL);
+ compiler = rzalloc(ctx, struct brw_compiler);
+ devinfo = rzalloc(ctx, struct gen_device_info);
compiler->devinfo = devinfo;
+ prog_data = ralloc(ctx, struct brw_vue_prog_data);
nir_shader *shader =
- nir_shader_create(NULL, MESA_SHADER_VERTEX, NULL, NULL);
+ nir_shader_create(ctx, MESA_SHADER_VERTEX, NULL, NULL);
- v = new copy_propagation_vec4_visitor(compiler, shader, prog_data);
+ v = new copy_propagation_vec4_visitor(compiler, ctx, shader, prog_data);
devinfo->gen = 4;
}
+void copy_propagation_test::TearDown()
+{
+ delete v;
+ v = NULL;
+
+ ralloc_free(ctx);
+ ctx = NULL;
+}
+
+
static void
copy_propagation(vec4_visitor *v)
{
class dead_code_eliminate_test : public ::testing::Test {
virtual void SetUp();
+ virtual void TearDown();
public:
struct brw_compiler *compiler;
struct gen_device_info *devinfo;
- struct gl_context *ctx;
+ void *ctx;
struct gl_shader_program *shader_prog;
struct brw_vue_prog_data *prog_data;
vec4_visitor *v;
{
public:
dead_code_eliminate_vec4_visitor(struct brw_compiler *compiler,
+ void *mem_ctx,
nir_shader *shader,
struct brw_vue_prog_data *prog_data)
- : vec4_visitor(compiler, NULL, NULL, prog_data, shader, NULL,
+ : vec4_visitor(compiler, NULL, NULL, prog_data, shader, mem_ctx,
false /* no_spills */, -1)
{
prog_data->dispatch_mode = DISPATCH_MODE_4X2_DUAL_OBJECT;
void dead_code_eliminate_test::SetUp()
{
- ctx = (struct gl_context *)calloc(1, sizeof(*ctx));
- compiler = (struct brw_compiler *)calloc(1, sizeof(*compiler));
- devinfo = (struct gen_device_info *)calloc(1, sizeof(*devinfo));
- prog_data = (struct brw_vue_prog_data *)calloc(1, sizeof(*prog_data));
+ ctx = ralloc_context(NULL);
+ compiler = rzalloc(ctx, struct brw_compiler);
+ devinfo = rzalloc(ctx, struct gen_device_info);
compiler->devinfo = devinfo;
+ prog_data = ralloc(ctx, struct brw_vue_prog_data);
nir_shader *shader =
- nir_shader_create(NULL, MESA_SHADER_VERTEX, NULL, NULL);
+ nir_shader_create(ctx, MESA_SHADER_VERTEX, NULL, NULL);
- v = new dead_code_eliminate_vec4_visitor(compiler, shader, prog_data);
+ v = new dead_code_eliminate_vec4_visitor(compiler, ctx, shader, prog_data);
devinfo->gen = 4;
}
+void dead_code_eliminate_test::TearDown()
+{
+ delete v;
+ v = NULL;
+
+ ralloc_free(ctx);
+ ctx = NULL;
+}
+
static void
dead_code_eliminate(vec4_visitor *v)
{
class register_coalesce_test : public ::testing::Test {
virtual void SetUp();
+ virtual void TearDown();
public:
struct brw_compiler *compiler;
struct gen_device_info *devinfo;
- struct gl_context *ctx;
+ void *ctx;
struct gl_shader_program *shader_prog;
struct brw_vue_prog_data *prog_data;
vec4_visitor *v;
{
public:
register_coalesce_vec4_visitor(struct brw_compiler *compiler,
+ void *mem_ctx,
nir_shader *shader,
struct brw_vue_prog_data *prog_data)
- : vec4_visitor(compiler, NULL, NULL, prog_data, shader, NULL,
+ : vec4_visitor(compiler, NULL, NULL, prog_data, shader, mem_ctx,
false /* no_spills */, -1)
{
prog_data->dispatch_mode = DISPATCH_MODE_4X2_DUAL_OBJECT;
void register_coalesce_test::SetUp()
{
- ctx = (struct gl_context *)calloc(1, sizeof(*ctx));
- compiler = (struct brw_compiler *)calloc(1, sizeof(*compiler));
- devinfo = (struct gen_device_info *)calloc(1, sizeof(*devinfo));
- prog_data = (struct brw_vue_prog_data *)calloc(1, sizeof(*prog_data));
+ ctx = ralloc_context(NULL);
+ compiler = rzalloc(ctx, struct brw_compiler);
+ devinfo = rzalloc(ctx, struct gen_device_info);
compiler->devinfo = devinfo;
+ prog_data = ralloc(ctx, struct brw_vue_prog_data);
+
nir_shader *shader =
- nir_shader_create(NULL, MESA_SHADER_VERTEX, NULL, NULL);
+ nir_shader_create(ctx, MESA_SHADER_VERTEX, NULL, NULL);
- v = new register_coalesce_vec4_visitor(compiler, shader, prog_data);
+ v = new register_coalesce_vec4_visitor(compiler, ctx, shader, prog_data);
devinfo->gen = 4;
}
+void register_coalesce_test::TearDown()
+{
+ delete v;
+ v = NULL;
+
+ ralloc_free(ctx);
+ ctx = NULL;
+}
+
static void
_register_coalesce(vec4_visitor *v, const char *func)
{