[PATCH 4/5] wined3d: Eliminate holes in wined3d_resource structure.

Józef Kucia jkucia at codeweavers.com
Fri Apr 7 07:45:14 CDT 2017


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---

Before:

struct wined3d_resource {
        LONG                       ref;                  /*     0     4 */
        LONG                       bind_count;           /*     4     4 */
        LONG                       map_count;            /*     8     4 */

        /* XXX 4 bytes hole, try to pack */

        struct wined3d_device *    device;               /*    16     8 */
        enum wined3d_resource_type type;                 /*    24     4 */
        enum wined3d_gl_resource_type gl_type;           /*    28     4 */
        const struct wined3d_format  * format;           /*    32     8 */
        unsigned int               format_flags;         /*    40     4 */
        enum wined3d_multisample_type multisample_type;  /*    44     4 */
        UINT                       multisample_quality;  /*    48     4 */
        DWORD                      usage;                /*    52     4 */
        enum wined3d_pool          pool;                 /*    56     4 */
        DWORD                      access_flags;         /*    60     4 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        DWORD                      draw_binding;         /*    64     4 */
        DWORD                      map_binding;          /*    68     4 */
        UINT                       width;                /*    72     4 */
        UINT                       height;               /*    76     4 */
        UINT                       depth;                /*    80     4 */
        UINT                       size;                 /*    84     4 */
        DWORD                      priority;             /*    88     4 */

        /* XXX 4 bytes hole, try to pack */

        void *                     heap_memory;          /*    96     8 */
        struct list                resource_list_entry;  /*   104    16 */
        LONG                       access_count;         /*   120     4 */

        /* XXX 4 bytes hole, try to pack */

        /* --- cacheline 2 boundary (128 bytes) --- */
        void *                     parent;               /*   128     8 */
        const struct wined3d_parent_ops  * parent_ops;   /*   136     8 */
        const struct wined3d_resource_ops  * resource_ops; /*   144     8 */

        /* size: 152, cachelines: 3, members: 26 */
        /* sum members: 140, holes: 3, sum holes: 12 */
        /* last cacheline: 24 bytes */
};

After:

struct wined3d_resource {
        LONG                       ref;                  /*     0     4 */
        LONG                       bind_count;           /*     4     4 */
        LONG                       map_count;            /*     8     4 */
        LONG                       access_count;         /*    12     4 */
        struct wined3d_device *    device;               /*    16     8 */
        enum wined3d_resource_type type;                 /*    24     4 */
        enum wined3d_gl_resource_type gl_type;           /*    28     4 */
        const struct wined3d_format  * format;           /*    32     8 */
        unsigned int               format_flags;         /*    40     4 */
        enum wined3d_multisample_type multisample_type;  /*    44     4 */
        UINT                       multisample_quality;  /*    48     4 */
        DWORD                      usage;                /*    52     4 */
        enum wined3d_pool          pool;                 /*    56     4 */
        DWORD                      access_flags;         /*    60     4 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        WORD                       draw_binding;         /*    64     2 */
        WORD                       map_binding;          /*    66     2 */
        UINT                       width;                /*    68     4 */
        UINT                       height;               /*    72     4 */
        UINT                       depth;                /*    76     4 */
        UINT                       size;                 /*    80     4 */
        DWORD                      priority;             /*    84     4 */
        void *                     heap_memory;          /*    88     8 */
        void *                     parent;               /*    96     8 */
        const struct wined3d_parent_ops  * parent_ops;   /*   104     8 */
        const struct wined3d_resource_ops  * resource_ops; /*   112     8 */
        struct list                resource_list_entry;  /*   120    16 */
        /* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */

        /* size: 136, cachelines: 3, members: 26 */
        /* last cacheline: 8 bytes */

32-bit - before:
        /* size: 108, cachelines: 2, members: 26 */
        /* last cacheline: 44 bytes */
after:
        /* size: 104, cachelines: 2, members: 26 */
        /* last cacheline: 40 bytes */

---
 dlls/wined3d/wined3d_private.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 8ce3363..1641390 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2749,6 +2749,7 @@ struct wined3d_resource
     LONG ref;
     LONG bind_count;
     LONG map_count;
+    LONG access_count;
     struct wined3d_device *device;
     enum wined3d_resource_type type;
     enum wined3d_gl_resource_type gl_type;
@@ -2759,20 +2760,20 @@ struct wined3d_resource
     DWORD usage;
     enum wined3d_pool pool;
     DWORD access_flags;
-    DWORD draw_binding;
-    DWORD map_binding;
+    WORD draw_binding;
+    WORD map_binding;
     UINT width;
     UINT height;
     UINT depth;
     UINT size;
     DWORD priority;
     void *heap_memory;
-    struct list resource_list_entry;
-    LONG access_count;
 
     void *parent;
     const struct wined3d_parent_ops *parent_ops;
     const struct wined3d_resource_ops *resource_ops;
+
+    struct list resource_list_entry;
 };
 
 static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource)
-- 
2.10.2




More information about the wine-patches mailing list