i965/vs: Rework memory contexts for shader compilation data.

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>
This commit is contained in:
Kenneth Graunke
2012-11-26 23:52:20 -08:00
parent 031146736c
commit 746fc346ea
5 changed files with 12 additions and 8 deletions
+3 -2
View File
@@ -1130,7 +1130,8 @@ extern "C" {
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;
@@ -1169,7 +1170,7 @@ brw_vs_emit(struct brw_context *brw,
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);
+3 -1
View File
@@ -200,7 +200,9 @@ class vec4_visitor : public backend_visitor
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()
@@ -2809,7 +2809,8 @@ vec4_visitor::resolve_ud_negate(src_reg *reg)
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;
@@ -2819,7 +2820,7 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
this->prog = prog;
this->shader = shader;
this->mem_ctx = ralloc_context(NULL);
this->mem_ctx = mem_ctx;
this->failed = false;
this->base_ir = NULL;
@@ -2849,7 +2850,6 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
vec4_visitor::~vec4_visitor()
{
ralloc_free(this->mem_ctx);
hash_table_dtor(this->variable_ht);
}
+1 -1
View File
@@ -279,7 +279,7 @@ do_vs_prog(struct brw_context *brw,
/* Emit GEN4 code.
*/
if (!brw_vs_emit(brw, prog, &c)) {
if (!brw_vs_emit(brw, prog, &c, mem_ctx)) {
ralloc_free(mem_ctx);
return false;
}
+2 -1
View File
@@ -105,7 +105,8 @@ struct brw_vs_compile {
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,