[Mesa-dev] [PATCH] i965: fix alpha test for MRT
Chris Forbes
chrisf at ijw.co.nz
Mon Jul 1 04:45:28 PDT 2013
Include src0 alpha in the RT write message when using MRT, so it is used
for the alpha test instead of the normal per-RT alpha value.
Fixes broken rendering in Dota2 under Wine [FDO #62647] -- but not
tested against much else.
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
src/mesa/drivers/dri/i965/brw_fs_emit.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_wm.c | 4 ++++
src/mesa/drivers/dri/i965/brw_wm.h | 1 +
4 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
index f390989..10f4c99 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
@@ -129,7 +129,7 @@ fs_generator::generate_fb_write(fs_inst *inst)
if (inst->target > 0 &&
c->key.nr_color_regions > 1 &&
- c->key.sample_alpha_to_coverage) {
+ (c->key.sample_alpha_to_coverage || c->key.alpha_test)) {
/* Set "Source0 Alpha Present to RenderTarget" bit in message
* header.
*/
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index a67b6ed..0c8dc1b 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2255,7 +2255,7 @@ fs_visitor::emit_fb_writes()
src0_alpha_to_render_target = intel->gen >= 6 &&
!do_dual_src &&
c->key.nr_color_regions > 1 &&
- c->key.sample_alpha_to_coverage;
+ (c->key.sample_alpha_to_coverage || c->key.alpha_test);
/* m2, m3 header */
nr += 2;
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 6eb4a1d..3265596 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -279,6 +279,8 @@ brw_wm_debug_recompile(struct brw_context *brw,
old_key->nr_color_regions, key->nr_color_regions);
found |= key_debug(intel, "sample alpha to coverage",
old_key->sample_alpha_to_coverage, key->sample_alpha_to_coverage);
+ found |= key_debug(intel, "MRT alpha test w/a",
+ old_key->alpha_test, key->alpha_test);
found |= key_debug(intel, "rendering to FBO",
old_key->render_to_fbo, key->render_to_fbo);
found |= key_debug(intel, "fragment color clamping",
@@ -463,6 +465,8 @@ static void brw_wm_populate_key( struct brw_context *brw,
key->nr_color_regions = ctx->DrawBuffer->_NumColorDrawBuffers;
/* _NEW_MULTISAMPLE */
key->sample_alpha_to_coverage = ctx->Multisample.SampleAlphaToCoverage;
+ /* _NEW_COLOR */
+ key->alpha_test = ctx->Color.AlphaEnabled;
/* BRW_NEW_VUE_MAP_GEOM_OUT */
if (intel->gen < 6)
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index 28e8734..13b17d0 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -63,6 +63,7 @@ struct brw_wm_prog_key {
GLuint flat_shade:1;
GLuint nr_color_regions:5;
GLuint sample_alpha_to_coverage:1;
+ GLuint alpha_test:1;
GLuint render_to_fbo:1;
GLuint clamp_fragment_color:1;
GLuint line_aa:2;
--
1.8.3.2
More information about the mesa-dev
mailing list