[Mesa-dev] [PATCH 1/3] i965: Fix off by one errors in texture buffer size calculations.
Eric Anholt
eric at anholt.net
Tue Sep 17 15:53:38 PDT 2013
Kenneth Graunke <kenneth at whitecape.org> writes:
> The value that's split into width/height/depth needs to be the size of
> the buffer minus one. This makes it consistent with the constant buffer
> and shader time SURFACE_STATE setup code.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> Cc: Paul Berry <stereotype441 at gmail.com>
> Cc: Eric Anholt <eric at anholt.net>
> ---
> src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 2 +-
> src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> 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 8d87786..0078161 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -228,7 +228,7 @@ brw_update_buffer_texture_surface(struct gl_context *ctx,
> *surf_offset + 4,
> bo, 0, I915_GEM_DOMAIN_SAMPLER, 0);
>
> - int w = intel_obj->Base.Size / texel_size;
> + int w = (intel_obj->Base.Size / texel_size) - 1;
> surf[2] = ((w & 0x7f) << BRW_SURFACE_WIDTH_SHIFT |
> ((w >> 7) & 0x1fff) << BRW_SURFACE_HEIGHT_SHIFT);
> surf[3] = (((w >> 20) & 0x7f) << BRW_SURFACE_DEPTH_SHIFT |
> diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
> index 37e3174..c38843f 100644
> --- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
> @@ -260,7 +260,7 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx,
> I915_GEM_DOMAIN_SAMPLER, 0);
>
> int texel_size = _mesa_get_format_bytes(format);
> - int w = intel_obj->Base.Size / texel_size;
> + int w = (intel_obj->Base.Size / texel_size) - 1;
This is all:
Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130917/f95d4516/attachment.pgp>
More information about the mesa-dev
mailing list