Module: Mesa
Branch: 9.2
Commit: 4f247c28e5e626772804f713e0ec72bb517bb0cc
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f247c28e5e626772804f713e0ec72bb517bb0cc

Author: Chris Forbes <[email protected]>
Date:   Sun Oct 27 12:09:51 2013 +1300

i965: Gen4-5: Include alpha func/ref in program key

V2: Better explanation of the rationale for doing this.

Signed-off-by: Chris Forbes <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
(cherry picked from commit 1080fc610ef20e376c3a54b3cee2be911df9f012)

---

 src/mesa/drivers/dri/i965/brw_wm.c |   16 ++++++++++++++++
 src/mesa/drivers/dri/i965/brw_wm.h |    2 ++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index 10ca5ff..1358f27 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -287,6 +287,10 @@ brw_wm_debug_recompile(struct brw_context *brw,
                       old_key->drawable_height, key->drawable_height);
    found |= key_debug(brw, "input slots valid",
                       old_key->input_slots_valid, key->input_slots_valid);
+   found |= key_debug(brw, "mrt alpha test function",
+                      old_key->alpha_test_func, key->alpha_test_func);
+   found |= key_debug(brw, "mrt alpha test reference value",
+                      old_key->alpha_test_ref, key->alpha_test_ref);
 
    found |= brw_debug_recompile_sampler_key(brw, &old_key->tex, &key->tex);
 
@@ -467,6 +471,18 @@ static void brw_wm_populate_key( struct brw_context *brw,
    if (brw->gen < 6)
       key->input_slots_valid = brw->vue_map_geom_out.slots_valid;
 
+
+   /* _NEW_COLOR | _NEW_BUFFERS */
+   /* Pre-gen6, the hardware alpha test always used each render
+    * target's alpha to do alpha test, as opposed to render target 0's alpha
+    * like GL requires.  Fix that by building the alpha test into the
+    * shader, and we'll skip enabling the fixed function alpha test.
+    */
+   if (brw->gen < 6 && ctx->DrawBuffer->_NumColorDrawBuffers > 1 && 
ctx->Color.AlphaEnabled) {
+      key->alpha_test_func = ctx->Color.AlphaFunc;
+      key->alpha_test_ref = ctx->Color.AlphaRef;
+   }
+
    /* The unique fragment program ID */
    key->program_string_id = fp->id;
 }
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h 
b/src/mesa/drivers/dri/i965/brw_wm.h
index f7a2c5f..8ad172e 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -70,6 +70,8 @@ struct brw_wm_prog_key {
    GLushort drawable_height;
    GLbitfield64 input_slots_valid;
    GLuint program_string_id:32;
+   GLenum alpha_test_func;          /* < For Gen4/5 MRT alpha test */
+   float alpha_test_ref;
 
    struct brw_sampler_prog_key_data tex;
 };

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to