Module: Mesa Branch: 9.1 Commit: 3114f5acd30383603bb060d75cdf0ec7b6f4fdaa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3114f5acd30383603bb060d75cdf0ec7b6f4fdaa
Author: Kenneth Graunke <[email protected]> Date: Mon Jan 28 22:03:18 2013 -0800 i965/blorp: Support overriding destination alpha to 1.0. Currently, Blorp requires the source and destination formats to be equal. However, we'd really like to be able to blit between XRGB and ARGB formats; our BLT engine paths have supported this for a long time. For ARGB -> XRGB, nothing needs to occur: the missing alpha is already interpreted as 1.0. For XRGB -> ARGB, we need to smash the alpha channel to 1.0 when writing the destination colors. This is fairly straightforward with blending. For now, this code is never used, as the source and destination formats still must be equal. The next patch will relax that restriction. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Tested-by: Martin Steigerwald <[email protected]> (cherry picked from commit c0554141a9b831b4e614747104dcbbe0fe489b9d) --- src/mesa/drivers/dri/i965/gen6_blorp.cpp | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.cpp b/src/mesa/drivers/dri/i965/gen6_blorp.cpp index eb61898..3834ae2 100644 --- a/src/mesa/drivers/dri/i965/gen6_blorp.cpp +++ b/src/mesa/drivers/dri/i965/gen6_blorp.cpp @@ -283,6 +283,25 @@ gen6_blorp_emit_blend_state(struct brw_context *brw, blend->blend1.write_disable_b = false; blend->blend1.write_disable_a = false; + /* When blitting from an XRGB source to a ARGB destination, we need to + * interpret the missing channel as 1.0. Blending can do that for us: + * we simply use the RGB values from the fragment shader ("source RGB"), + * but smash the alpha channel to 1. + */ + if (_mesa_get_format_bits(params->dst.mt->format, GL_ALPHA_BITS) > 0 && + _mesa_get_format_bits(params->src.mt->format, GL_ALPHA_BITS) == 0) { + blend->blend0.blend_enable = 1; + blend->blend0.ia_blend_enable = 1; + + blend->blend0.blend_func = BRW_BLENDFUNCTION_ADD; + blend->blend0.ia_blend_func = BRW_BLENDFUNCTION_ADD; + + blend->blend0.source_blend_factor = BRW_BLENDFACTOR_SRC_COLOR; + blend->blend0.dest_blend_factor = BRW_BLENDFACTOR_ZERO; + blend->blend0.ia_source_blend_factor = BRW_BLENDFACTOR_ONE; + blend->blend0.ia_dest_blend_factor = BRW_BLENDFACTOR_ZERO; + } + return cc_blend_state_offset; } _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
