Mesa (master): mesa/draw: Make sure all the unused fields are initialized to zero

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 19 18:32:06 UTC 2020


Module: Mesa
Branch: master
Commit: d46a5cfe781a1f51a1338d994fb8097d9d579d2e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d46a5cfe781a1f51a1338d994fb8097d9d579d2e

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Tue Feb 18 16:41:03 2020 -0800

mesa/draw: Make sure all the unused fields are initialized to zero

Not initializing prim.indexed caused a few thousand failures on Intel
drivers.

I also compared the generated assembly with this change and before
a6d31589097.  The code is still somewhat improved, which I am assuming
was the original goal. _mesa_DrawArrays, for example, appears to drop an
instruction or two... though the body of the function is only one byte
shorter.

MR !3591 will eventually delete the uninitialized fields.  However, I
believe that explicitly initializing the whole thing is more future
proof.  This ensures that if someone adds fields in the future, they
will also be initialized.  Once the extra fields are removed, the two
implementations should generate idential code.

Fixes: a6d31589097 ("mesa: don't use memset in glDrawArrays")
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3870>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3870>

---

 src/mesa/main/draw.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index 2062f99dc0e..5a28c77e42c 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -352,23 +352,22 @@ _mesa_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
                   GLsizei count, GLuint numInstances, GLuint baseInstance,
                   GLuint drawID)
 {
-   struct _mesa_prim prim;
-
    if (skip_validated_draw(ctx))
       return;
 
    /* OpenGL 4.5 says that primitive restart is ignored with non-indexed
     * draws.
     */
-   prim.begin = 1;
-   prim.end = 1;
-   prim.mode = mode;
-   prim.num_instances = numInstances;
-   prim.base_instance = baseInstance;
-   prim.draw_id = drawID;
-   prim.start = start;
-   prim.count = count;
-   prim.basevertex = 0;
+   struct _mesa_prim prim = {
+      .begin = 1,
+      .end = 1,
+      .mode = mode,
+      .num_instances = numInstances,
+      .base_instance = baseInstance,
+      .draw_id = drawID,
+      .start = start,
+      .count = count,
+   };
 
    ctx->Driver.Draw(ctx, &prim, 1, NULL,
                     GL_TRUE, start, start + count - 1, NULL, 0, NULL);



More information about the mesa-commit mailing list