[Mesa-dev] [PATCH 5/7] i965/fs: Don't renumber UNIFORM registers.

Ian Romanick idr at freedesktop.org
Wed Mar 12 10:52:24 PDT 2014


On 03/11/2014 11:48 PM, Kenneth Graunke wrote:
> Previously, remove_dead_constants() would renumber the UNIFORM registers
> to be sequential starting from zero, and the resulting register number
> would be used directly as an index into the params[] array.
> 
> This renumbering made it difficult to collect and save information about
> pull constant locations, since setup_pull_constants() and
> move_uniform_array_access_to_pull_constants() used different names.
> 
> This patch generalizes setup_pull_constants() to decide whether each
> uniform register should be a pull constant, push constant, or neither
> (because it's unused).  Then, it stores mappings from UNIFORM register
> numbers to params[] or pull_params[] indices in the push_constant_loc
> and pull_constant_loc arrays.  (We already did this for pull constants.)
> 
> Then, assign_curb_setup() just needs to consult the push_constant_loc
> array to get the real index into the params[] array.
> 
> This effectively folds all the remove_dead_constants() functionality
> into assign_constant_locations(), while being less irritable to work
> with.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp         | 187 +++++++++++----------------
>  src/mesa/drivers/dri/i965/brw_fs.h           |  13 +-
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |   3 +-
>  3 files changed, 85 insertions(+), 118 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 3c8237a..5e01e78 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -1412,7 +1409,19 @@ fs_visitor::assign_curb_setup()
>  
>        for (unsigned int i = 0; i < 3; i++) {
>  	 if (inst->src[i].file == UNIFORM) {
> -	    int constant_nr = inst->src[i].reg + inst->src[i].reg_offset;
> +	    int uniform_nr = inst->src[i].reg + inst->src[i].reg_offset;

Should be safe to fix the tabs here. :)

> +            int constant_nr;
> +            if (uniform_nr >= 0 && uniform_nr < (int) uniforms) {
> +               constant_nr = push_constant_loc[uniform_nr];
> +            } else {
> +               /* Section 5.11 of the OpenGL 4.1 spec says:
> +                * "Out-of-bounds reads return undefined values, which include
> +                *  values from other variables of the active program or zero."
> +                * Just return the first push constant.
> +                */
> +               constant_nr = 0;
> +            }
> +
>  	    struct brw_reg brw_reg = brw_vec1_grf(c->nr_payload_regs +
>  						  constant_nr / 8,
>  						  constant_nr % 8);



More information about the mesa-dev mailing list