[Mesa-dev] [PATCH 2/4] Fill the padding between entrys in the sampler key
Brian Paul
brianp at vmware.com
Tue Apr 27 14:57:29 PDT 2010
Pierre Willenbrock wrote:
> This struct is used to generate a hash, ignoring the entry boundaries.
> ---
> src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
> index d7650af..1582ff1 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
> @@ -228,6 +228,8 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
> {
> GLcontext *ctx = &brw->intel.ctx;
> int unit;
> + char *last_entry_end = ((char*)&key->sampler_count) +
> + sizeof(key->sampler_count);
>
> key->sampler_count = 0;
>
> @@ -240,7 +242,9 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
> struct gl_texture_image *firstImage =
> texObj->Image[0][intelObj->firstLevel];
>
> - memset(entry, 0, sizeof(*entry));
> + memset(last_entry_end, 0,
> + (char*)entry - last_entry_end + sizeof(*entry));
> + last_entry_end = ((char*)entry) + sizeof(*entry);
>
> entry->tex_target = texObj->Target;
>
> @@ -280,6 +284,8 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
> key->sampler_count = unit + 1;
> }
> }
> + struct wm_sampler_entry *entry = &key->sampler[key->sampler_count];
> + memset(last_entry_end, 0, (char*)entry - last_entry_end);
> }
>
> /* All samplers must be uploaded in a single contiguous array, which
I think Eric A. should review this too.
The last two added lines should probably be put inside a {}-block to
avoid warnings about declaring 'entry' after code.
-Brian
More information about the mesa-dev
mailing list