[Mesa-dev] [PATCH 13/17] i965/fs: Use 'c' as the mem_ctx in fs_visitor.

Kenneth Graunke kenneth at whitecape.org
Thu May 15 23:19:44 PDT 2014


Previously, the memory context situation was a bit of a mess:

fs_visitor allocated its own memory context, and freed it in the
destructor.  However, some data produced by fs_visitor (such as the list
of instructions) needs to live beyond when fs_visitor is "done", so the
caller can pass it to fs_generator.

Everything worked out because brw_wm_fs_emit's fs_visitor variables
happen to not go out of scope until the end of the function.  But that
meant that moving the declaration of, say, the SIMD16 fs_visitor
instance, could cause everything to explode.

Using a memory context that exists for the duration of the compile is
clearer, and should be equivalent.

Ultimately, we don't want to use 'c', but this matches the behavior of
fs_generator and gen8_fs_generator, so it'll be simple to change later.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 35d0d9c..46527d9 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2966,7 +2966,7 @@ fs_visitor::fs_visitor(struct brw_context *brw,
    this->c = c;
    this->prog_data = &c->prog_data;
    this->fp = fp;
-   this->mem_ctx = ralloc_context(NULL);
+   this->mem_ctx = c;
    this->failed = false;
    this->simd16_unsupported = false;
    this->no16_msg = NULL;
@@ -3009,6 +3009,5 @@ fs_visitor::fs_visitor(struct brw_context *brw,
 
 fs_visitor::~fs_visitor()
 {
-   ralloc_free(this->mem_ctx);
    hash_table_dtor(this->variable_ht);
 }
-- 
1.9.2



More information about the mesa-dev mailing list