[Mesa-dev] [PATCH] mesa: add a UniformBooleanTrue option

Ian Romanick idr at freedesktop.org
Mon Sep 5 14:50:03 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/05/2011 12:59 PM, Bryan Cain wrote:
> Drivers supporting native integers set UniformBooleanTrue to the integer value
> that should be used for true when uploading uniform booleans.  This is ~0 for
> Gallium and 1 for i965.

I was going to suggest something very similar.  We may end up changing
this later, but for now

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> ---
>  src/mesa/drivers/dri/i965/brw_context.c |    4 +++-
>  src/mesa/main/mtypes.h                  |    6 ++++++
>  src/mesa/main/uniforms.c                |    5 ++++-
>  src/mesa/state_tracker/st_extensions.c  |    1 +
>  4 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 6ef0fcb..5ea7385 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -253,8 +253,10 @@ GLboolean brwCreateContext( int api,
>     /* If we're using the new shader backend, we require integer uniforms
>      * stored as actual integers.
>      */
> -   if (brw->new_vs_backend)
> +   if (brw->new_vs_backend) {
>        ctx->Const.NativeIntegers = true;
> +      ctx->Const.UniformBooleanTrue = 1;
> +   }
>  
>     return GL_TRUE;
>  }
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 44ebf0a..ad59797 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2722,6 +2722,12 @@ struct gl_constants
>      */
>     GLboolean NativeIntegers;
>  
> +   /**
> +    * If the driver supports real 32-bit integers, what integer value should be
> +    * used for boolean true in uniform uploads?  (Usually 1 or ~0.)
> +    */
> +   GLuint UniformBooleanTrue;
> +
>     /** Which texture units support GL_ATI_envmap_bumpmap as targets */
>     GLbitfield SupportedBumpUnits;
>  
> diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
> index fe1ce6d..b0f9c33 100644
> --- a/src/mesa/main/uniforms.c
> +++ b/src/mesa/main/uniforms.c
> @@ -802,7 +802,10 @@ set_program_uniform(struct gl_context *ctx, struct gl_program *program,
>                 else
>                    uniformVal[i].b = uniformVal[i].u ? 1 : 0;
>                 
> -               if (!ctx->Const.NativeIntegers)
> +               if (ctx->Const.NativeIntegers)
> +                  uniformVal[i].u =
> +                        uniformVal[i].b ? ctx->Const.UniformBooleanTrue : 0;
> +               else
>                    uniformVal[i].f = uniformVal[i].b ? 1.0f : 0.0f;
>              }
>           }
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index aa7f3b5..76e84eb 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -207,6 +207,7 @@ void st_init_limits(struct st_context *st)
>        c->MaxProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET);
>  
>        c->GLSLVersion = 120;
> +      c->UniformBooleanTrue = ~0;
>     }
>  }
>  

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk5lRAsACgkQX1gOwKyEAw+mPQCeN+S7/j7EhBMuIics/jKVWH51
2PwAnjltuxc9PJ3POpOHt8Ca206pMR25
=Vm1m
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list