[Mesa-stable] [PATCH 3/4] i965: Handle non-zero texture buffer offsets in buffer object range calculation.

Nanley Chery nanleychery at gmail.com
Fri May 11 23:22:11 UTC 2018


On Mon, Mar 19, 2018 at 11:26:58AM -0700, Francisco Jerez wrote:
> Otherwise the specified surface state will allow the GPU to access
> memory up to BufferOffset bytes past the end of the buffer.  Found by
> inspection.
> 
> Cc: mesa-stable at lists.freedesktop.org
> ---
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index ed4def9046e..2ab15af793a 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -654,7 +654,8 @@ buffer_texture_range_size(struct brw_context *brw,
>      * so that when ISL divides by stride to obtain the number of texels, that
>      * texel count is clamped to MAX_TEXTURE_BUFFER_SIZE.
>      */
> -   return MIN3((unsigned)obj->BufferSize, buffer_size,
> +   return MIN3((unsigned)obj->BufferSize,
> +               buffer_size - obj->BufferOffset,
>                 brw->ctx.Const.MaxTextureBufferSize * texel_size);

I don't understand this change. Previously we took the minimum between:
1) The TextureBuffer size specified by glTexBufferRange().
2) The size of the buffer object specified by glTexBuffer().
3) The maximum allowed texture buffer size.

This patch modifies case 2 to be subtracted by the offset which will
always be 0 for glTexBuffer().

>  }
>  
> -- 
> 2.16.1
> 


More information about the mesa-stable mailing list