During compilation, we allocate a bunch of things: the IR needs to last
at least until code generation...and then the program store needs to
last until after we upload the program.
For simplicity's sake, just keep it all around until we upload the
program. After that, it can all be freed.
This will also save a lot of headaches during the upcoming refactoring.
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
bool
brw_vs_emit(struct brw_context *brw,
struct gl_shader_program *prog,
bool
brw_vs_emit(struct brw_context *brw,
struct gl_shader_program *prog,
- struct brw_vs_compile *c)
+ struct brw_vs_compile *c,
+ void *mem_ctx)
{
struct intel_context *intel = &brw->intel;
bool start_busy = false;
{
struct intel_context *intel = &brw->intel;
bool start_busy = false;
shader->compiled_once = true;
}
shader->compiled_once = true;
}
- vec4_visitor v(brw, c, prog, shader);
+ vec4_visitor v(brw, c, prog, shader, mem_ctx);
if (!v.run()) {
prog->LinkStatus = false;
ralloc_strcat(&prog->InfoLog, v.fail_msg);
if (!v.run()) {
prog->LinkStatus = false;
ralloc_strcat(&prog->InfoLog, v.fail_msg);
public:
vec4_visitor(struct brw_context *brw,
struct brw_vs_compile *c,
public:
vec4_visitor(struct brw_context *brw,
struct brw_vs_compile *c,
- struct gl_shader_program *prog, struct brw_shader *shader);
+ struct gl_shader_program *prog,
+ struct brw_shader *shader,
+ void *mem_ctx);
~vec4_visitor();
dst_reg dst_null_f()
~vec4_visitor();
dst_reg dst_null_f()
vec4_visitor::vec4_visitor(struct brw_context *brw,
struct brw_vs_compile *c,
struct gl_shader_program *prog,
vec4_visitor::vec4_visitor(struct brw_context *brw,
struct brw_vs_compile *c,
struct gl_shader_program *prog,
- struct brw_shader *shader)
+ struct brw_shader *shader,
+ void *mem_ctx)
{
this->c = c;
this->p = &c->func;
{
this->c = c;
this->p = &c->func;
this->prog = prog;
this->shader = shader;
this->prog = prog;
this->shader = shader;
- this->mem_ctx = ralloc_context(NULL);
+ this->mem_ctx = mem_ctx;
this->failed = false;
this->base_ir = NULL;
this->failed = false;
this->base_ir = NULL;
vec4_visitor::~vec4_visitor()
{
vec4_visitor::~vec4_visitor()
{
- ralloc_free(this->mem_ctx);
hash_table_dtor(this->variable_ht);
}
hash_table_dtor(this->variable_ht);
}
- if (!brw_vs_emit(brw, prog, &c)) {
+ if (!brw_vs_emit(brw, prog, &c, mem_ctx)) {
ralloc_free(mem_ctx);
return false;
}
ralloc_free(mem_ctx);
return false;
}
bool brw_vs_emit(struct brw_context *brw,
struct gl_shader_program *prog,
bool brw_vs_emit(struct brw_context *brw,
struct gl_shader_program *prog,
- struct brw_vs_compile *c);
+ struct brw_vs_compile *c,
+ void *mem_ctx);
bool brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
void brw_vs_debug_recompile(struct brw_context *brw,
struct gl_shader_program *prog,
bool brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
void brw_vs_debug_recompile(struct brw_context *brw,
struct gl_shader_program *prog,