Skip to contentSkip to conversation

for mesa: Fill the padding between entrys in the sampler key

PATCH In review Pierre Willenbrock 1 participant 2 messages Apr 25, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 for mesa: Fill the padding between entrys in the sampler key

I thought i'd send this here first, in case someone has something to say about it. Found by valgrind.

Regards,
Pierre

commit 079d2ff410664a1c2c6dc4bf9982d84314734735

Author: Pierre Willenbrock <[email protected]>
Date:   Sun Apr 25 21:55:48 2010 +0200

Fill the padding between entrys in the sampler key

This struct is used to generate a hash, ignoring the entry boundaries.

src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +5 -1
index d7650af..6504aaf 100644
@@ -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;
 

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#1 lore raw

Missed a few bits in the last one. Why is it that one finds these things seconds after hitting the send button?

Quoted 5 lines · Pierre Willenbrock

I thought i'd send this here first, in case someone has something to say about it. Found by valgrind.

Regards,
Pierre

commit cb00b1c589933451414977fb7da974a6af8236a7

Author: Pierre Willenbrock <[email protected]>
Date:   Sun Apr 25 22:00:06 2010 +0200

Fill the padding between entrys in the sampler key

This struct is used to generate a hash, ignoring the entry boundaries.

src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +7 -1
index d7650af..1582ff1 100644
@@ -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

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx