[Mesa-dev] [PATCH] i965: Add comment to explain the weird-looking shadow compares.

Kenneth Graunke kenneth at whitecape.org
Sat Apr 12 13:04:59 PDT 2014


On 04/12/2014 03:34 AM, Chris Forbes wrote:
> This always looks crazy when I stumble across it, until I remember
> what the hardware is doing. Describing it ought to short-circuit
> that process next time :)
> 
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
>  src/mesa/drivers/dri/i965/intel_state.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_state.c b/src/mesa/drivers/dri/i965/intel_state.c
> index bfc35d8..1597db6 100644
> --- a/src/mesa/drivers/dri/i965/intel_state.c
> +++ b/src/mesa/drivers/dri/i965/intel_state.c
> @@ -40,6 +40,17 @@
>  int
>  intel_translate_shadow_compare_func(GLenum func)
>  {
> +   /* GL specifies the result of shadow comparisons as:
> +    *     1     if   ref <op> texel,
> +    *     0     otherwise.
> +    *
> +    * The hardware does:
> +    *     0     if texel <op> ref,
> +    *     1     otherwise.
> +    *
> +    * So, these look a bit strange because there's both a negation
> +    * and swapping of the arguments involved.
> +    */

Thanks for adding this!  I've had to do this a few times as well.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

>     switch (func) {
>     case GL_NEVER:
>         return BRW_COMPAREFUNCTION_ALWAYS;
> @@ -50,11 +61,11 @@ intel_translate_shadow_compare_func(GLenum func)
>     case GL_GREATER:
>         return BRW_COMPAREFUNCTION_GEQUAL;
>     case GL_GEQUAL:
> -      return BRW_COMPAREFUNCTION_GREATER;
> +       return BRW_COMPAREFUNCTION_GREATER;

Although your patch makes the 6-7 space indent consistent...we really
want to use 2*3=6, not 7. :)  If you wouldn't mind switching that before
pushing...

>     case GL_NOTEQUAL:
> -      return BRW_COMPAREFUNCTION_EQUAL;
> +       return BRW_COMPAREFUNCTION_EQUAL;
>     case GL_EQUAL:
> -      return BRW_COMPAREFUNCTION_NOTEQUAL;
> +       return BRW_COMPAREFUNCTION_NOTEQUAL;
>     case GL_ALWAYS:
>         return BRW_COMPAREFUNCTION_NEVER;
>     }
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140412/306bb9f7/attachment.sig>


More information about the mesa-dev mailing list