[Mesa-dev] [PATCH] i965: Initialize grf_used in fs_visitor::emit_repclear_shader().

Jason Ekstrand jason at jlekstrand.net
Mon Oct 13 17:32:29 PDT 2014


On Mon, Oct 13, 2014 at 5:12 PM, Kenneth Graunke <kenneth at whitecape.org>
wrote:

> fs_visitor::grf_used is used to calculate prog_data->reg_blocks_16,
> which was getting populated with an uninitialized value.  Normally,
> grf_used is set by the register allocator, but emit_repclear_shader
> bypasses that; it must set grf_used directly.
>
> This bug was well hidden: reg_blocks and reg_blocks_16 are unused on
> Gen6+.  However, when uploading programs, we look for an existing entry
> in the cache.  If we find a potential hit, we memcmp the two prog_data
> structures, including the uninitialized reg_blocks_16 field.  Of course,
> this only happens if we upload the repclear shader twice - which only
> happens if the precompile guesses the program key incorrectly.
>
> On Gen6+, precompile guesses the program key for the repclear shader
> correctly, so this bug ought to remain untriggered.  However, on Gen5,
> we make more mistakes when guessing the key, which is how I spotted the
> bug.  It is reproducible on Haswell by making precompile choose daft
> values for fields.
>
> Cc: Jason Ekstrand <jason at jlekstrand.net>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 8d470f2..8d9e63f 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -2614,6 +2614,8 @@ fs_visitor::emit_repclear_shader()
>
>     calculate_cfg();
>
> +   grf_used = 0;
> +
>

I'm not sure 0 is actually the value we want.  It usually uses at least a
couple of grfs because it uses a uniform.
--Jason


>     assign_constant_locations();
>     assign_curb_setup();
>
> --
> 2.1.2
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141013/6c75afa6/attachment-0001.html>


More information about the mesa-dev mailing list