[Mesa-dev] [PATCH 08/24] i965: Don't use MAX_SURFACES in mark_surface_used

Kenneth Graunke kenneth at whitecape.org
Wed Mar 1 09:10:21 UTC 2017


On Tuesday, February 28, 2017 9:03:20 PM PST Jason Ekstrand wrote:
> Vulkan doesn't respect MAX_SURFACES so this assert isn't valid in that
> case.  It should, however, assert that it isn't insanely large.
> ---
>  src/mesa/drivers/dri/i965/brw_shader.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
> index 02aa0b2..8b852d5 100644
> --- a/src/mesa/drivers/dri/i965/brw_shader.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
> @@ -33,7 +33,10 @@ extern "C" void
>  brw_mark_surface_used(struct brw_stage_prog_data *prog_data,
>                        unsigned surf_index)
>  {
> -   assert(surf_index < BRW_MAX_SURFACES);
> +   /* A binding table index is 8 bits and the top 3 values are reserved for
> +    * special things (stateless and SLM).
> +    */
> +   assert(surf_index <= 252);
>  
>     prog_data->binding_table.size_bytes =
>        MAX2(prog_data->binding_table.size_bytes, (surf_index + 1) * 4);
> 

We were trying to avoid overflowing the brw_stage_state::surf_offset[]
bounds...I think it makes sense to do this, but it would be nice to
add some kind of assert in the GL-specific code to enforce this...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170301/421af5ad/attachment.sig>


More information about the mesa-dev mailing list