[Mesa-dev] [PATCH 05/20] i965: Merge memory context allocation for shader visitors
Topi Pohjolainen
topi.pohjolainen at intel.com
Fri Apr 11 00:28:45 PDT 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 +--
src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp | 3 +--
src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp | 3 +--
12 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index d9e1ba1..790d799 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2958,7 +2958,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->simd16_unsupported = false;
this->no16_msg = NULL;
@@ -2997,6 +2996,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 496f540..bac76a6 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -550,10 +550,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() const
{
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 805d65c..20b621d 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -90,6 +90,7 @@ class backend_emitter {
protected:
explicit backend_emitter(struct brw_context *brw);
+ ~backend_emitter();
public:
@@ -97,7 +98,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
@@ -109,6 +110,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 740d9ff..89d7d37 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1796,7 +1796,7 @@ brw_vs_emit(struct brw_context *brw,
if (unlikely(INTEL_DEBUG & DEBUG_VS))
brw_dump_ir(brw, "vertex", prog, &shader->base, &c->vp->program.Base);
- 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 bb4bc15..0c47618 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -296,7 +296,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 13d6d38..d44b7c5 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)
@@ -599,7 +598,7 @@ brw_gs_emit(struct brw_context *brw,
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,
@@ -619,7 +618,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 32b08c5..c63a90b 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3346,7 +3346,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,
@@ -3367,7 +3366,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);
diff --git a/src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp
index cb70096..199d5ef 100644
--- a/src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp
@@ -46,8 +46,7 @@ public:
copy_propagation_vec4_visitor(struct brw_context *brw,
struct gl_shader_program *shader_prog)
: vec4_visitor(brw, NULL, NULL, NULL, NULL, shader_prog,
- MESA_SHADER_VERTEX, NULL,
- false, false /* no_spills */,
+ MESA_SHADER_VERTEX, false, false /* no_spills */,
ST_NONE, ST_NONE, ST_NONE)
{
}
diff --git a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
index 7563aef..3c36666 100644
--- a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
@@ -49,8 +49,7 @@ public:
register_coalesce_vec4_visitor(struct brw_context *brw,
struct gl_shader_program *shader_prog)
: vec4_visitor(brw, NULL, NULL, NULL, NULL, shader_prog,
- MESA_SHADER_VERTEX, NULL,
- false, false /* no_spills */,
+ MESA_SHADER_VERTEX, false, false /* no_spills */,
ST_NONE, ST_NONE, ST_NONE)
{
}
--
1.8.3.1
More information about the mesa-dev
mailing list