[Mesa-dev] [PATCH 2/5] i965: Use native integer uniforms when the new VS backend is in use.

Kenneth Graunke kenneth at whitecape.org
Fri Aug 19 23:43:57 PDT 2011


On 08/19/2011 05:56 PM, Eric Anholt wrote:
> ---
>  src/mesa/drivers/dri/i965/brw_context.c        |    6 +++++
>  src/mesa/drivers/dri/i965/brw_context.h        |    2 -
>  src/mesa/drivers/dri/i965/brw_curbe.c          |    3 +-
>  src/mesa/drivers/dri/i965/brw_vec4_emit.cpp    |    1 -
>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |   29 ++++-------------------
>  src/mesa/drivers/dri/i965/gen6_vs_state.c      |    3 +-
>  6 files changed, 13 insertions(+), 31 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 8c73408..67d3c54 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -250,6 +250,12 @@ GLboolean brwCreateContext( int api,
>  
>     brw->new_vs_backend = (getenv("INTEL_NEW_VS") != NULL);
>  
> +   /* If we're using the new shader backend, we require integer uniforms
> +    * stored as actual integers.
> +    */
> +   if (brw->new_vs_backend)
> +      ctx->Const.NativeIntegers = true;
> +
>     return GL_TRUE;
>  }

This hunk above looks good.  But the rest of the changes
below---removing convert_param---sure look like they're going to break
non-float uniforms when using the old VS.  Presumably you didn't mean to
include that...

> diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
> index e936a88..21068d9 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.h
> +++ b/src/mesa/drivers/dri/i965/brw_context.h
> @@ -321,9 +321,7 @@ struct brw_vs_prog_data {
>     GLuint urb_entry_size;
>  
>     const float *param[MAX_UNIFORMS * 4]; /* should be: BRW_MAX_CURBE */
> -   enum param_conversion param_convert[MAX_UNIFORMS * 4];
>     const float *pull_param[MAX_UNIFORMS * 4];
> -   enum param_conversion pull_param_convert[MAX_UNIFORMS * 4];
>  
>     bool uses_new_param_layout;
>  };
> diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c
> index 960be10..b9a4beb 100644
> --- a/src/mesa/drivers/dri/i965/brw_curbe.c
> +++ b/src/mesa/drivers/dri/i965/brw_curbe.c
> @@ -246,8 +246,7 @@ static void prepare_constant_buffer(struct brw_context *brw)
>  
>        if (brw->vs.prog_data->uses_new_param_layout) {
>  	 for (i = 0; i < brw->vs.prog_data->nr_params; i++) {
> -	    buf[offset + i] = convert_param(brw->vs.prog_data->param_convert[i],
> -					    brw->vs.prog_data->param[i]);
> +	    buf[offset + i] = *brw->vs.prog_data->param[i];
>  	 }
>        } else {
>  	 /* Load the subset of push constants that will get used when
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
> index 65ac7d9..794f499 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
> @@ -120,7 +120,6 @@ vec4_visitor::setup_uniforms(int reg)
>  	 unsigned int slot = this->uniforms * 4 + i;
>  
>  	 c->prog_data.param[slot] = NULL;
> -	 c->prog_data.param_convert[slot] = PARAM_CONVERT_ZERO;
>        }
>  
>        this->uniforms++;
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> index b3a07bd..46f826c 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> @@ -362,32 +362,14 @@ vec4_visitor::setup_uniform_values(int loc, const glsl_type *type)
>     case GLSL_TYPE_INT:
>     case GLSL_TYPE_BOOL:
>        for (unsigned int i = 0; i < type->vector_elements; i++) {
> -	 int slot = this->uniforms * 4 + i;
> -	 switch (type->base_type) {
> -	 case GLSL_TYPE_FLOAT:
> -	    c->prog_data.param_convert[slot] = PARAM_NO_CONVERT;
> -	    break;
> -	 case GLSL_TYPE_UINT:
> -	    c->prog_data.param_convert[slot] = PARAM_CONVERT_F2U;
> -	    break;
> -	 case GLSL_TYPE_INT:
> -	    c->prog_data.param_convert[slot] = PARAM_CONVERT_F2I;
> -	    break;
> -	 case GLSL_TYPE_BOOL:
> -	    c->prog_data.param_convert[slot] = PARAM_CONVERT_F2B;
> -	    break;
> -	 default:
> -	    assert(!"not reached");
> -	    c->prog_data.param_convert[slot] = PARAM_NO_CONVERT;
> -	    break;
> -	 }
> -	 c->prog_data.param[slot] = &values[i];
> +	 c->prog_data.param[this->uniforms * 4 + i] = &values[i];
>        }
>  
> +      /* Set up pad elements to get things aligned to a vec4 boundary. */
>        for (unsigned int i = type->vector_elements; i < 4; i++) {
> -	 c->prog_data.param_convert[this->uniforms * 4 + i] =
> -	    PARAM_CONVERT_ZERO;
> -	 c->prog_data.param[this->uniforms * 4 + i] = NULL;
> +	 static float zero = 0;
> +
> +	 c->prog_data.param[this->uniforms * 4 + i] = &zero;
>        }
>  
>        this->uniform_size[this->uniforms] = type->vector_elements;
> @@ -448,7 +430,6 @@ vec4_visitor::setup_builtin_uniform_values(ir_variable *ir)
>  	 last_swiz = swiz;
>  
>  	 c->prog_data.param[this->uniforms * 4 + j] = &values[swiz];
> -	 c->prog_data.param_convert[this->uniforms * 4 + j] = PARAM_NO_CONVERT;
>  	 if (swiz <= last_swiz)
>  	    this->uniform_size[this->uniforms]++;
>        }
> diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c
> index b94121e..f1123af 100644
> --- a/src/mesa/drivers/dri/i965/gen6_vs_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c
> @@ -83,8 +83,7 @@ gen6_prepare_vs_push_constants(struct brw_context *brw)
>  
>        if (brw->vs.prog_data->uses_new_param_layout) {
>  	 for (i = 0; i < brw->vs.prog_data->nr_params; i++) {
> -	    *param = convert_param(brw->vs.prog_data->param_convert[i],
> -				   brw->vs.prog_data->param[i]);
> +	    *param = *brw->vs.prog_data->param[i];
>  	    param++;
>  	 }
>  	 params_uploaded += brw->vs.prog_data->nr_params / 4;


More information about the mesa-dev mailing list