On 25/04/14 11:41, Chia-I Wu wrote:
> Hi,
> 
> This series cleans up GL_KHR_debug support, fixes message control for some
> corner cases, and makes one enhancement: cheap
> glPushDebugGroup/glPopDebugGroup for command stream annotation.
> 
> Patch 1-12 refactor the code.  There should be no functional difference.
> These patches are also part of the series I sent the other day for threaded
> glCompileShader.
> 
> Patch 13 makes an interface change to hide struct gl_debug_state from the rest
> of the driver.  I need this for threaded glCompileShader support.  But I think
> this is a good idea anyhow because, unlike other context states,
> gl_debug_state is created on demand.  This prevents others from having to do
> an if-check.
> 
> Patch 14-16 refactor more of the code.  No functional difference is expected
> either.
> 
> Patch 17 makes debug group pushing copy-on-write.  This makes the operation
> very cheap in a common scenario.
> 
> Patch 18 simplifies the debug namespace code a lot and fixes a few corner
> cases.
> 
Hi Chia-I,

While you're around you may want to fold gl_debug_state::Defaults inside
gl_debug_state::Namespaces as done in the attached patch.

I must admit I've never looked at the spec to confirm if it would make sense
to do so, although it saves us ~13K per gl_debug_state struct on x86-64 builds.

-Emil

> Please review.
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 

>From 4a28db23deba72d55e0ac02fae91c99cb46f92ae Mon Sep 17 00:00:00 2001
From: Emil Velikov <emil.l.veli...@gmail.com>
Date: Wed, 26 Feb 2014 05:08:35 +0000
Subject: [PATCH] mesa: fold gl_debug_state::Defaults into
 gl_debug_state::Namespaces

XXX Write me

... effectively saving 13KiB per gl_debug_state struct
as the boolean state is saved within an existing hole
in the gl_debug_namespace struct.

struct gl_debug_namespace
 pahole-before:
	/* size: 80, cachelines: 2, members: 3 */
	/* sum members: 76, holes: 1, sum holes: 4 */
	/* last cacheline: 16 bytes */

 pahole-after:
	/* size: 80, cachelines: 2, members: 4 */
	/* last cacheline: 16 bytes */

struct gl_debug_state
 pahole-before:
	/* size: 292712, cachelines: 4574, members: 13 */
	/* sum members: 292707, holes: 1, sum holes: 5 */
	/* padding: 30564 */
	/* last cacheline: 40 bytes */

 pahole-after:
	/* size: 278888, cachelines: 4358, members: 12 */
	/* padding: 16743 */
	/* last cacheline: 40 bytes */

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/mesa/main/errors.c | 22 +++++++++++-----------
 src/mesa/main/mtypes.h |  8 ++++----
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index 5f4eac6..bdc8900 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -200,19 +200,19 @@ _mesa_get_debug_state(struct gl_context *ctx)
       }
       else {
          struct gl_debug_state *debug = ctx->Debug;
+         struct gl_debug_namespace *nspace;
          int s, t, sev;
 
          /* Enable all the messages with severity HIGH or MEDIUM by default. */
-         memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH], GL_TRUE,
-                sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH]);
-         memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM], GL_TRUE,
-                sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM]);
-         memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW], GL_FALSE,
-                sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW]);
-
          /* Initialize state for filtering known debug messages. */
          for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) {
             for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) {
+               nspace = &debug->Namespaces[0][s][t];
+
+               nspace->Defaults[MESA_DEBUG_SEVERITY_HIGH] = GL_TRUE;
+               nspace->Defaults[MESA_DEBUG_SEVERITY_MEDIUM] = GL_TRUE;
+               nspace->Defaults[MESA_DEBUG_SEVERITY_LOW] = GL_FALSE;
+
                debug->Namespaces[0][s][t].IDs = _mesa_NewHashTable();
                assert(debug->Namespaces[0][s][t].IDs);
 
@@ -271,7 +271,7 @@ should_log(struct gl_context *ctx,
          struct gl_debug_severity *entry;
 
          if (state == NOT_FOUND) {
-            if (debug->Defaults[gstack][severity][source][type])
+            if (nspace->Defaults[severity])
                state = ENABLED;
             else
                state = DISABLED;
@@ -661,7 +661,7 @@ control_messages(struct gl_context *ctx,
             struct gl_debug_severity *entry;
 
             /* change the default for IDs we've never seen before. */
-            debug->Defaults[gstack][sev][s][t] = enabled;
+            debug->Namespaces[gstack][s][t].Defaults[sev] = enabled;
 
             /* Now change the state of IDs we *have* seen... */
             foreach(node, &debug->Namespaces[gstack][s][t].Severity[sev]) {
@@ -982,8 +982,8 @@ _mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length,
             struct simple_node *node;
 
             /* copy default settings for unknown ids */
-            debug->Defaults[currStackDepth][sev][s][t] =
-               debug->Defaults[prevStackDepth][sev][s][t];
+            debug->Namespaces[currStackDepth][s][t].Defaults[sev] =
+               debug->Namespaces[prevStackDepth][s][t].Defaults[sev];
 
             /* copy known id severity settings */
             make_empty_list(&debug->Namespaces[currStackDepth][s][t].Severity[sev]);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7989cab..292cf84 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3818,6 +3818,7 @@ struct gl_debug_namespace
 {
    struct _mesa_HashTable *IDs;
    unsigned ZeroID; /* a HashTable won't take zero, so store its state here */
+   GLboolean Defaults[MESA_DEBUG_SEVERITY_COUNT];
    /** lists of IDs in the hash table at each severity */
    struct simple_node Severity[MESA_DEBUG_SEVERITY_COUNT];
 };
@@ -3826,10 +3827,6 @@ struct gl_debug_state
 {
    GLDEBUGPROC Callback;
    const void *CallbackData;
-   GLboolean SyncOutput;
-   GLboolean DebugOutput;
-   GLboolean ARBCallback; /* Used to track if current callback is of type ARB_debug_output or KHR_debug */
-   GLboolean Defaults[MAX_DEBUG_GROUP_STACK_DEPTH][MESA_DEBUG_SEVERITY_COUNT][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT];
    struct gl_debug_namespace Namespaces[MAX_DEBUG_GROUP_STACK_DEPTH][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT];
    struct gl_debug_msg Log[MAX_DEBUG_LOGGED_MESSAGES];
    struct gl_debug_msg DebugGroupMsgs[MAX_DEBUG_GROUP_STACK_DEPTH];
@@ -3838,6 +3835,9 @@ struct gl_debug_state
    GLint NextMsg;
    GLint NextMsgLength; /* redundant, but copied here from Log[NextMsg].length
                            for the sake of the offsetof() code in get.c */
+   GLboolean SyncOutput;
+   GLboolean DebugOutput;
+   GLboolean ARBCallback; /* Used to track if current callback is of type ARB_debug_output or KHR_debug */
 };
 
 /**
-- 
1.9.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to