On 01/12/2016 10:49 AM, [email protected] wrote:
From: Roland Scheidegger <[email protected]>

Discovered by accident, valgrind was complaining (could have possibly caused
us to create redundant geometry shader variants).

v2: convinced by Brian and Jose, just use memset for both gs and vs keys,
just as easy and less error prone.
---
  src/gallium/auxiliary/draw/draw_llvm.c | 5 ++++-
  src/gallium/auxiliary/draw/draw_llvm.h | 7 ++-----
  2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index f25dafe..142d78a 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1861,6 +1861,8 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char 
*store)

     key = (struct draw_llvm_variant_key *)store;

+   memset(key, 0, offsetof(struct draw_llvm_variant_key, vertex_element[0]));
+
     key->clamp_vertex_color = llvm->draw->rasterizer->clamp_vertex_color; /**/

     /* Presumably all variants of the shader should have the same
@@ -1883,7 +1885,6 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char 
*store)
     key->ucp_enable = llvm->draw->rasterizer->clip_plane_enable;
     key->has_gs = llvm->draw->gs.geometry_shader != NULL;
     key->num_outputs = draw_total_vs_outputs(llvm->draw);
-   key->pad1 = 0;

     /* All variants of this shader will have the same value for
      * nr_samplers.  Not yet trying to compact away holes in the
@@ -2315,6 +2316,8 @@ draw_gs_llvm_make_variant_key(struct draw_llvm *llvm, 
char *store)

     key = (struct draw_gs_llvm_variant_key *)store;

+   memset(key, 0, offsetof(struct draw_gs_llvm_variant_key, samplers[0]));
+
     key->num_outputs = draw_total_gs_outputs(llvm->draw);

     /* All variants of this shader will have the same value for
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h 
b/src/gallium/auxiliary/draw/draw_llvm.h
index f617a29..271433c 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -311,12 +311,8 @@ struct draw_llvm_variant_key
     unsigned need_edgeflags:1;
     unsigned has_gs:1;
     unsigned num_outputs:8;
-   /*
-    * it is important there are no holes in this struct
-    * (and all padding gets zeroed).
-    */
     unsigned ucp_enable:PIPE_MAX_CLIP_PLANES;
-   unsigned pad1:24-PIPE_MAX_CLIP_PLANES;
+   /* note padding here - must use memset */

     /* Variable number of vertex elements:
      */
@@ -332,6 +328,7 @@ struct draw_gs_llvm_variant_key
     unsigned nr_samplers:8;
     unsigned nr_sampler_views:8;
     unsigned num_outputs:8;
+   /* note padding here - must use memset */

     struct draw_sampler_static_state samplers[1];
  };


Reviewed-by: Brian Paul <[email protected]>

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to