[Mesa-dev] [RFC 13/27] i965: Merge memory context allocation for shader visitors
Topi Pohjolainen
topi.pohjolainen at intel.com
Sat Feb 22 01:05:39 PST 2014
Such like fs_visitor the dynamic data generated by vec4_visitor does
not have lifecycle longer than the visitor itself. Hence it can be
taken cared of by the common base.
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 2 --
src/mesa/drivers/dri/i965/brw_shader.cpp | 8 +++++++-
src/mesa/drivers/dri/i965/brw_shader.h | 7 ++++++-
src/mesa/drivers/dri/i965/brw_vec4.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_vec4.h | 1 -
src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 7 +++----
src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h | 1 -
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 2 --
src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 5 ++---
src/mesa/drivers/dri/i965/brw_vs.h | 3 +--
10 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 09fa6c1..953c7ac 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2954,7 +2954,6 @@ fs_visitor::fs_visitor(struct brw_context *brw,
{
this->c = c;
this->fp = fp;
- this->mem_ctx = ralloc_context(NULL);
this->failed = false;
this->variable_ht = hash_table_ctor(0,
hash_table_pointer_hash,
@@ -2989,6 +2988,5 @@ fs_visitor::fs_visitor(struct brw_context *brw,
fs_visitor::~fs_visitor()
{
- ralloc_free(this->mem_ctx);
hash_table_dtor(this->variable_ht);
}
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 17763c8..50dab8b 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -551,10 +551,16 @@ backend_visitor::backend_visitor(struct gl_shader_program *shader_prog,
backend_emitter::backend_emitter(struct brw_context *brw)
: brw(brw),
- ctx(&brw->ctx)
+ ctx(&brw->ctx),
+ mem_ctx(ralloc_context(NULL))
{
}
+backend_emitter::~backend_emitter()
+{
+ ralloc_free(mem_ctx);
+}
+
bool
backend_instruction::is_tex()
{
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index b45687a..55c9268 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -89,6 +89,7 @@ class backend_emitter {
protected:
explicit backend_emitter(struct brw_context *brw);
+ ~backend_emitter();
public:
@@ -96,7 +97,7 @@ public:
struct gl_context * const ctx;
/** ralloc context for temporary data used during compile */
- void *mem_ctx;
+ void * const mem_ctx;
/**
* List of either fs_inst or vec4_instruction (inheriting from
@@ -108,6 +109,10 @@ public:
virtual void dump_instructions();
virtual void invalidate_live_intervals() = 0;
+
+private:
+ backend_emitter(const backend_emitter& );
+ const backend_emitter& operator=(const backend_emitter& );
};
uint32_t brw_texture_offset(struct gl_context *ctx, ir_constant *offset);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 14790d9..d45d8cb 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1675,7 +1675,7 @@ brw_vs_emit(struct brw_context *brw,
}
}
- vec4_vs_visitor v(brw, c, prog_data, prog, mem_ctx);
+ vec4_vs_visitor v(brw, c, prog_data, prog);
if (!v.run()) {
if (prog) {
prog->LinkStatus = false;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 0aff357..0ac9be5 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -288,7 +288,6 @@ public:
struct brw_vec4_prog_data *prog_data,
struct gl_shader_program *shader_prog,
gl_shader_stage stage,
- void *mem_ctx,
bool debug_flag,
bool no_spills,
shader_time_shader_type st_base,
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
index f6ae3e4..b3115e4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
@@ -36,10 +36,9 @@ namespace brw {
vec4_gs_visitor::vec4_gs_visitor(struct brw_context *brw,
struct brw_gs_compile *c,
struct gl_shader_program *prog,
- void *mem_ctx,
bool no_spills)
: vec4_visitor(brw, &c->base, &c->gp->program.Base, &c->key.base,
- &c->prog_data.base, prog, MESA_SHADER_GEOMETRY, mem_ctx,
+ &c->prog_data.base, prog, MESA_SHADER_GEOMETRY,
INTEL_DEBUG & DEBUG_GS, no_spills,
ST_GS, ST_GS_WRITTEN, ST_GS_RESET),
c(c)
@@ -589,7 +588,7 @@ brw_gs_emit(struct brw_context *brw,
if (likely(!(INTEL_DEBUG & DEBUG_NO_DUAL_OBJECT_GS))) {
c->prog_data.dual_instanced_dispatch = false;
- vec4_gs_visitor v(brw, c, prog, mem_ctx, true /* no_spills */);
+ vec4_gs_visitor v(brw, c, prog, true /* no_spills */);
if (v.run()) {
return generate_assembly(brw, prog, &c->gp->program.Base,
&c->prog_data.base, mem_ctx, &v.instructions,
@@ -609,7 +608,7 @@ brw_gs_emit(struct brw_context *brw,
*/
c->prog_data.dual_instanced_dispatch = true;
- vec4_gs_visitor v(brw, c, prog, mem_ctx, false /* no_spills */);
+ vec4_gs_visitor v(brw, c, prog, false /* no_spills */);
if (!v.run()) {
prog->LinkStatus = false;
ralloc_strcat(&prog->InfoLog, v.fail_msg);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
index 25415ea..3662820 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
@@ -80,7 +80,6 @@ public:
vec4_gs_visitor(struct brw_context *brw,
struct brw_gs_compile *c,
struct gl_shader_program *prog,
- void *mem_ctx,
bool no_spills);
protected:
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 145cb8c..de3519c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3309,7 +3309,6 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
struct brw_vec4_prog_data *prog_data,
struct gl_shader_program *shader_prog,
gl_shader_stage stage,
- void *mem_ctx,
bool debug_flag,
bool no_spills,
shader_time_shader_type st_base,
@@ -3330,7 +3329,6 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
st_written(st_written),
st_reset(st_reset)
{
- this->mem_ctx = mem_ctx;
this->failed = false;
this->base_ir = NULL;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
index 79cb40f..0828270 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
@@ -210,12 +210,11 @@ vec4_vs_visitor::emit_thread_end()
vec4_vs_visitor::vec4_vs_visitor(struct brw_context *brw,
struct brw_vs_compile *vs_compile,
struct brw_vs_prog_data *vs_prog_data,
- struct gl_shader_program *prog,
- void *mem_ctx)
+ struct gl_shader_program *prog)
: vec4_visitor(brw, &vs_compile->base, &vs_compile->vp->program.Base,
&vs_compile->key.base, &vs_prog_data->base, prog,
MESA_SHADER_VERTEX,
- mem_ctx, INTEL_DEBUG & DEBUG_VS, false /* no_spills */,
+ INTEL_DEBUG & DEBUG_VS, false /* no_spills */,
ST_VS, ST_VS_WRITTEN, ST_VS_RESET),
vs_compile(vs_compile),
vs_prog_data(vs_prog_data)
diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h
index 97308a7..d81e8a4 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.h
+++ b/src/mesa/drivers/dri/i965/brw_vs.h
@@ -107,8 +107,7 @@ public:
vec4_vs_visitor(struct brw_context *brw,
struct brw_vs_compile *vs_compile,
struct brw_vs_prog_data *vs_prog_data,
- struct gl_shader_program *prog,
- void *mem_ctx);
+ struct gl_shader_program *prog);
protected:
virtual dst_reg *make_reg_for_system_value(ir_variable *ir);
--
1.8.3.1
More information about the mesa-dev
mailing list