[Mesa-dev] [PATCH 14/17] i965/fs: Plumb a mem_ctx all the way through the FS compile.
Kenneth Graunke
kenneth at whitecape.org
Thu May 15 23:19:45 PDT 2014
'c' is going away, but we still need a memory context that lives
for the duration of the compile.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_fs.cpp | 12 +++++++-----
src/mesa/drivers/dri/i965/brw_fs.h | 3 +++
src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 5 ++---
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 ++-
src/mesa/drivers/dri/i965/brw_wm.c | 9 +++++----
src/mesa/drivers/dri/i965/brw_wm.h | 1 +
src/mesa/drivers/dri/i965/gen8_fs_generator.cpp | 3 ++-
8 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
index 38969d8..71e0ad3 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
@@ -27,7 +27,7 @@
brw_blorp_eu_emitter::brw_blorp_eu_emitter(struct brw_context *brw)
: mem_ctx(ralloc_context(NULL)), c(rzalloc(mem_ctx, struct brw_wm_compile)),
- generator(brw, c, NULL, NULL, false)
+ generator(brw, mem_ctx, c, NULL, NULL, false)
{
}
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 6fc92b4..579e492 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -3103,7 +3103,9 @@ fs_visitor::run()
}
const unsigned *
-brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,
+brw_wm_fs_emit(struct brw_context *brw,
+ void *mem_ctx,
+ struct brw_wm_compile *c,
struct gl_fragment_program *fp,
struct gl_shader_program *prog,
unsigned *final_assembly_size)
@@ -3126,7 +3128,7 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,
/* Now the main event: Visit the shader IR and generate our FS IR for it.
*/
- fs_visitor v(brw, c, prog, fp, 8);
+ fs_visitor v(brw, mem_ctx, c, prog, fp, 8);
if (!v.run()) {
if (prog) {
prog->LinkStatus = false;
@@ -3140,7 +3142,7 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,
}
exec_list *simd16_instructions = NULL;
- fs_visitor v2(brw, c, prog, fp, 16);
+ fs_visitor v2(brw, mem_ctx, c, prog, fp, 16);
if (brw->gen >= 5 && likely(!(INTEL_DEBUG & DEBUG_NO16))) {
if (!v.simd16_unsupported) {
/* Try a SIMD16 compile */
@@ -3159,11 +3161,11 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,
const unsigned *assembly = NULL;
if (brw->gen >= 8) {
- gen8_fs_generator g(brw, c, prog, fp, v.do_dual_src);
+ gen8_fs_generator g(brw, mem_ctx, c, prog, fp, v.do_dual_src);
assembly = g.generate_assembly(&v.instructions, simd16_instructions,
final_assembly_size);
} else {
- fs_generator g(brw, c, prog, fp, v.do_dual_src);
+ fs_generator g(brw, mem_ctx, c, prog, fp, v.do_dual_src);
assembly = g.generate_assembly(&v.instructions, simd16_instructions,
final_assembly_size);
}
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 6611c38..d42b7b8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -250,6 +250,7 @@ class fs_visitor : public backend_visitor
public:
fs_visitor(struct brw_context *brw,
+ void *mem_ctx,
struct brw_wm_compile *c,
struct gl_shader_program *shader_prog,
struct gl_fragment_program *fp,
@@ -596,6 +597,7 @@ class fs_generator
{
public:
fs_generator(struct brw_context *brw,
+ void *mem_ctx,
struct brw_wm_compile *c,
struct gl_shader_program *prog,
struct gl_fragment_program *fp,
@@ -722,6 +724,7 @@ class gen8_fs_generator : public gen8_generator
{
public:
gen8_fs_generator(struct brw_context *brw,
+ void *mem_ctx,
struct brw_wm_compile *c,
struct gl_shader_program *prog,
struct gl_fragment_program *fp,
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 99207b3..a337aef 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -37,18 +37,17 @@ extern "C" {
#include "brw_cfg.h"
fs_generator::fs_generator(struct brw_context *brw,
+ void *mem_ctx,
struct brw_wm_compile *c,
struct gl_shader_program *prog,
struct gl_fragment_program *fp,
bool dual_source_output)
- : brw(brw), c(c), key(&c->key), prog(prog), fp(fp), dual_source_output(dual_source_output)
+ : brw(brw), c(c), key(&c->key), prog(prog), fp(fp), dual_source_output(dual_source_output), mem_ctx(mem_ctx)
{
ctx = &brw->ctx;
prog_data = &c->prog_data;
- mem_ctx = c;
-
p = rzalloc(mem_ctx, struct brw_compile);
brw_init_compile(brw, p, mem_ctx);
}
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 46527d9..4be5928 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2954,6 +2954,7 @@ fs_visitor::resolve_bool_comparison(ir_rvalue *rvalue, fs_reg *reg)
}
fs_visitor::fs_visitor(struct brw_context *brw,
+ void *mem_ctx,
struct brw_wm_compile *c,
struct gl_shader_program *shader_prog,
struct gl_fragment_program *fp,
@@ -2966,7 +2967,7 @@ fs_visitor::fs_visitor(struct brw_context *brw,
this->c = c;
this->prog_data = &c->prog_data;
this->fp = fp;
- this->mem_ctx = c;
+ this->mem_ctx = mem_ctx;
this->failed = false;
this->simd16_unsupported = false;
this->no16_msg = NULL;
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 059d848..780c78f 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -146,6 +146,7 @@ bool do_wm_prog(struct brw_context *brw,
struct brw_wm_prog_key *key)
{
struct gl_context *ctx = &brw->ctx;
+ void *mem_ctx = ralloc_context(NULL);
struct brw_wm_compile *c;
const GLuint *program;
struct gl_shader *fs = NULL;
@@ -154,7 +155,7 @@ bool do_wm_prog(struct brw_context *brw,
if (prog)
fs = prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
- c = rzalloc(NULL, struct brw_wm_compile);
+ c = rzalloc(mem_ctx, struct brw_wm_compile);
/* Allocate the references to the uniforms that will end up in the
* prog_data associated with the compiled program, and which will be freed
@@ -180,9 +181,9 @@ bool do_wm_prog(struct brw_context *brw,
c->key.persample_shading,
&fp->program);
- program = brw_wm_fs_emit(brw, c, &fp->program, prog, &program_size);
+ program = brw_wm_fs_emit(brw, mem_ctx, c, &fp->program, prog, &program_size);
if (program == NULL) {
- ralloc_free(c);
+ ralloc_free(mem_ctx);
return false;
}
@@ -200,7 +201,7 @@ bool do_wm_prog(struct brw_context *brw,
&c->prog_data, sizeof(c->prog_data),
&brw->wm.base.prog_offset, &brw->wm.prog_data);
- ralloc_free(c);
+ ralloc_free(mem_ctx);
return true;
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index 5721d6f..dd57a97 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -91,6 +91,7 @@ struct brw_wm_compile {
* Returns the final assembly and the program's size.
*/
const unsigned *brw_wm_fs_emit(struct brw_context *brw,
+ void *mem_ctx,
struct brw_wm_compile *c,
struct gl_fragment_program *fp,
struct gl_shader_program *prog,
diff --git a/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp b/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp
index 63481b3..9a09888 100644
--- a/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp
@@ -36,11 +36,12 @@ extern "C" {
#include "glsl/ir_print_visitor.h"
gen8_fs_generator::gen8_fs_generator(struct brw_context *brw,
+ void *mem_ctx,
struct brw_wm_compile *c,
struct gl_shader_program *shader_prog,
struct gl_fragment_program *fp,
bool dual_source_output)
- : gen8_generator(brw, shader_prog, fp ? &fp->Base : NULL, c),
+ : gen8_generator(brw, shader_prog, fp ? &fp->Base : NULL, mem_ctx),
c(c), key(&c->key),
fp(fp), dual_source_output(dual_source_output)
{
--
1.9.2
More information about the mesa-dev
mailing list