[Mesa-dev] [PATCH 2/4] i965: Gen4-5: Include alpha func/ref in program key

Eric Anholt eric at anholt.net
Mon Oct 28 22:57:58 CET 2013


Chris Forbes <chrisf at ijw.co.nz> writes:

> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
>  src/mesa/drivers/dri/i965/brw_wm.c | 12 ++++++++++++
>  src/mesa/drivers/dri/i965/brw_wm.h |  2 ++
>  2 files changed, 14 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
> index 0fda490..557ab7a 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm.c
> @@ -289,6 +289,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);
>  
> @@ -488,6 +492,14 @@ static void brw_wm_populate_key( struct brw_context *brw,
>                                           BRW_FS_VARYING_INPUT_MASK) > 16)
>        key->input_slots_valid = brw->vue_map_geom_out.slots_valid;
>  
> +
> +   /* _NEW_COLOR | _NEW_BUFFERS */
> +   /* Func for shader-based alpha test */

I'd rather have a comment explaining *why* we're doing this:

      /* 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;
>  }

Other than the few little comments I've had, this is:

Reviewed-by: Eric Anholt <eric at anholt.net>

Avoiding recompiles for ref would be nice, but not required IMO (I
expect the ref to be constant for any shader, generally).  If you're
interested, I think it should be pretty doable with a
_mesa_add_state_reference of a new slot type.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131028/ee9b4f85/attachment.pgp>


More information about the mesa-dev mailing list