[Mesa-dev] [PATCH 12/12] i965/fs: Move struct brw_compile (p) entirely inside fs_generator.

Kenneth Graunke kenneth at whitecape.org
Tue Nov 20 21:40:20 PST 2012


The brw_compile structure contains the brw_instruction store and the
brw_eu_emit.c state tracking fields.  These are only useful for the
final assembly generation pass; the earlier compilation stages doesn't
need them.

This also means that the code generator for future hardware won't have
access to the brw_compile structure, which is extremely desirable
because it prevents accidental generation of Gen4-7 code.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp         | 2 --
 src/mesa/drivers/dri/i965/brw_fs.h           | 1 +
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp    | 4 +++-
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 1 -
 src/mesa/drivers/dri/i965/brw_shader.h       | 1 -
 src/mesa/drivers/dri/i965/brw_vec4.h         | 1 +
 src/mesa/drivers/dri/i965/brw_wm.h           | 1 -
 7 files changed, 5 insertions(+), 6 deletions(-)

Taking the p pointer out of backend_visitor ensures that fs_visitor *can't*
access it (which is important, since it's now uninitialized).

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index a570829..f19f275 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2133,8 +2133,6 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,
    bool start_busy = false;
    float start_time = 0;
 
-   brw_init_compile(brw, &c->func, c);
-
    if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
       start_busy = (intel->batch.last_bo &&
                     drm_intel_bo_busy(intel->batch.last_bo));
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 868c44e..7e55631 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -485,6 +485,7 @@ private:
    struct intel_context *intel;
    struct gl_context *ctx;
 
+   struct brw_compile _p;
    struct brw_compile *p;
    struct brw_wm_compile *c;
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
index 442551d..d41c5fa 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
@@ -45,13 +45,15 @@ fs_generator::fs_generator(struct brw_context *brw,
 
    : brw(brw), c(c), prog(prog), fp(fp), dual_source_output(dual_source_output)
 {
-   p = &c->func;
    intel = &brw->intel;
    ctx = &intel->ctx;
 
    shader = prog ? prog->_LinkedShaders[MESA_SHADER_FRAGMENT] : NULL;
 
    mem_ctx = c;
+
+   p = &_p;
+   brw_init_compile(brw, p, mem_ctx);
 }
 
 fs_generator::~fs_generator()
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index e21c2f9..7effb84 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2181,7 +2181,6 @@ fs_visitor::fs_visitor(struct brw_context *brw,
                        unsigned dispatch_width)
 {
    this->c = c;
-   this->p = &c->func;
    this->brw = brw;
    this->fp = fp;
    this->prog = prog;
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 0abc667..46fe570 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -41,7 +41,6 @@ public:
    struct brw_context *brw;
    struct intel_context *intel;
    struct gl_context *ctx;
-   struct brw_compile *p;
    struct brw_shader *shader;
    struct gl_shader_program *prog;
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 5f35de5..88430ff 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -215,6 +215,7 @@ public:
    const struct gl_vertex_program *vp;
    struct brw_vs_compile *c;
    struct brw_vs_prog_data *prog_data;
+   struct brw_compile *p;
 
    char *fail_msg;
    bool failed;
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index 478be86..a4ac3f1 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -77,7 +77,6 @@ struct brw_wm_prog_key {
 };
 
 struct brw_wm_compile {
-   struct brw_compile func;
    struct brw_wm_prog_key key;
    struct brw_wm_prog_data prog_data;
 
-- 
1.8.0



More information about the mesa-dev mailing list