Mesa (main): glthread: don't execute display lists if they have no effect

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Oct 27 01:46:56 UTC 2021


Module: Mesa
Branch: main
Commit: 6b370cbe289e5c0908f53283afd711f439be8879
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b370cbe289e5c0908f53283afd711f439be8879

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Oct 22 16:59:17 2021 -0400

glthread: don't execute display lists if they have no effect

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13403>

---

 src/mesa/main/dlist.c  | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 src/mesa/main/mtypes.h |  1 +
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 2ace2291005..a741fa6a71a 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -78,6 +78,10 @@
 
 #define USE_BITMAP_ATLAS 1
 
+static bool
+_mesa_glthread_should_execute_list(struct gl_context *ctx,
+                                   struct gl_display_list *dlist);
+
 /**
  * Flush vertices.
  *
@@ -13743,6 +13747,8 @@ _mesa_EndList(void)
       replace_op_vertex_list_recursively(ctx, ctx->ListState.CurrentList);
 
    struct gl_dlist_state *list = &ctx->ListState;
+   list->CurrentList->execute_glthread =
+      _mesa_glthread_should_execute_list(ctx, list->CurrentList);
 
    if ((list->CurrentList->Head == list->CurrentBlock) &&
        (list->CurrentPos < BLOCK_SIZE)) {
@@ -15036,7 +15042,8 @@ _mesa_glthread_execute_list(struct gl_context *ctx, GLuint list)
    struct gl_display_list *dlist;
 
    if (list == 0 ||
-       !_mesa_get_list(ctx, list, &dlist, true))
+       !_mesa_get_list(ctx, list, &dlist, true) ||
+       !dlist->execute_glthread)
       return;
 
    Node *n = get_list_head(ctx, dlist);
@@ -15110,6 +15117,47 @@ _mesa_glthread_execute_list(struct gl_context *ctx, GLuint list)
    }
 }
 
+static bool
+_mesa_glthread_should_execute_list(struct gl_context *ctx,
+                                   struct gl_display_list *dlist)
+{
+   Node *n = get_list_head(ctx, dlist);
+
+   while (1) {
+      const OpCode opcode = n[0].opcode;
+
+      switch (opcode) {
+      case OPCODE_CALL_LIST:
+      case OPCODE_CALL_LISTS:
+      case OPCODE_DISABLE:
+      case OPCODE_ENABLE:
+      case OPCODE_LIST_BASE:
+      case OPCODE_MATRIX_MODE:
+      case OPCODE_POP_ATTRIB:
+      case OPCODE_POP_MATRIX:
+      case OPCODE_PUSH_ATTRIB:
+      case OPCODE_PUSH_MATRIX:
+      case OPCODE_ACTIVE_TEXTURE:   /* GL_ARB_multitexture */
+      case OPCODE_MATRIX_PUSH:
+      case OPCODE_MATRIX_POP:
+         return true;
+      case OPCODE_CONTINUE:
+         n = (Node *)get_pointer(&n[1]);
+         continue;
+      case OPCODE_END_OF_LIST:
+         return false;
+      default:
+         /* ignore */
+         break;
+      }
+
+      /* increment n to point to next compiled command */
+      assert(n[0].InstSize > 0);
+      n += n[0].InstSize;
+   }
+   return false;
+}
+
 
 /**
  * Clients may call this function to help debug display list problems.
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index c54e1664540..4bb2d8844d5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4696,6 +4696,7 @@ union gl_dlist_node;
 struct gl_display_list
 {
    GLuint Name;
+   bool execute_glthread;
    bool small_list;
    /* If small_list and begins_with_a_nop are true, this means
     * the 'start' has been incremented to skip a NOP at the



More information about the mesa-commit mailing list