st/mesa: init hash keys with memset(), not designated initializers

Since the compiler may not zero-out padding in the object.
Add a couple comments about this to prevent misunderstandings in
the future.

Fixes: 67d96816ff ("st/mesa: move, clean-up shader variant key decls/inits")

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
Brian Paul
2019-03-08 10:09:15 -07:00
parent d2cff164cd
commit e5e2be3c73
2 changed files with 17 additions and 5 deletions
+7 -2
View File
@@ -112,7 +112,10 @@ st_update_fp( struct st_context *st )
!stfp->variants->key.bitmap) {
shader = stfp->variants->driver_shader;
} else {
struct st_fp_variant_key key = {0};
struct st_fp_variant_key key;
/* use memset, not an initializer to be sure all memory is zeroed */
memset(&key, 0, sizeof(key));
key.st = st->has_shareable_shaders ? NULL : st;
@@ -168,7 +171,9 @@ st_update_vp( struct st_context *st )
stvp->variants->key.passthrough_edgeflags == st->vertdata_edgeflags) {
st->vp_variant = stvp->variants;
} else {
struct st_vp_variant_key key = {0};
struct st_vp_variant_key key;
memset(&key, 0, sizeof(key));
key.st = st->has_shareable_shaders ? NULL : st;
+10 -3
View File
@@ -1772,7 +1772,10 @@ st_get_cp_variant(struct st_context *st,
{
struct pipe_context *pipe = st->pipe;
struct st_basic_variant *v;
struct st_basic_variant_key key = {0};
struct st_basic_variant_key key;
/* use memset, not an initializer to be sure all memory is zeroed */
memset(&key, 0, sizeof(key));
key.st = st->has_shareable_shaders ? NULL : st;
@@ -1995,7 +1998,9 @@ st_precompile_shader_variant(struct st_context *st,
switch (prog->Target) {
case GL_VERTEX_PROGRAM_ARB: {
struct st_vertex_program *p = (struct st_vertex_program *)prog;
struct st_vp_variant_key key = {0};
struct st_vp_variant_key key;
memset(&key, 0, sizeof(key));
key.st = st->has_shareable_shaders ? NULL : st;
st_get_vp_variant(st, p, &key);
@@ -2022,7 +2027,9 @@ st_precompile_shader_variant(struct st_context *st,
case GL_FRAGMENT_PROGRAM_ARB: {
struct st_fragment_program *p = (struct st_fragment_program *)prog;
struct st_fp_variant_key key = {0};
struct st_fp_variant_key key;
memset(&key, 0, sizeof(key));
key.st = st->has_shareable_shaders ? NULL : st;
st_get_fp_variant(st, p, &key);