[PATCH 1/5] wined3d: Introduce a sub resource structure.

Stefan Dösinger stefan at codeweavers.com
Mon Feb 10 06:28:17 CST 2014


This structure will be a base structure for buffers, surfaces and
volumes. It will take care of location management, opengl buffers,
mapping and (at least for now) memory allocation. Sub resources will
also store the pointer to the container resource.

Patches 1-3 just reformat code. I have split them out for easier
reviewing of patch 4. Feel free to merge them into one when committing.
---
 dlls/wined3d/buffer.c          | 124 +++++++++++++++++++++--------------------
 dlls/wined3d/cs.c              |  16 +++---
 dlls/wined3d/drawprim.c        |   2 +-
 dlls/wined3d/wined3d_private.h |  11 +++-
 4 files changed, 81 insertions(+), 72 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index c53021b..61d62f8 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -47,7 +47,7 @@ static void buffer_invalidate_bo_range(struct wined3d_buffer *buffer, UINT offse
     if (!offset && !size)
         goto invalidate_all;
 
-    if (offset > buffer->resource.size || offset + size > buffer->resource.size)
+    if (offset > buffer->sub_resource.resource.size || offset + size > buffer->sub_resource.resource.size)
     {
         WARN("Invalid range specified, invalidating entire buffer.\n");
         goto invalidate_all;
@@ -75,7 +75,7 @@ static void buffer_invalidate_bo_range(struct wined3d_buffer *buffer, UINT offse
 invalidate_all:
     buffer->modified_areas = 1;
     buffer->maps[0].offset = 0;
-    buffer->maps[0].size = buffer->resource.size;
+    buffer->maps[0].size = buffer->sub_resource.resource.size;
 }
 
 static inline void buffer_clear_dirty_areas(struct wined3d_buffer *This)
@@ -94,7 +94,7 @@ static BOOL buffer_is_fully_dirty(const struct wined3d_buffer *buffer)
 
     for (i = 0; i < buffer->modified_areas; ++i)
     {
-        if (!buffer->maps[i].offset && buffer->maps[i].size == buffer->resource.size)
+        if (!buffer->maps[i].offset && buffer->maps[i].size == buffer->sub_resource.resource.size)
             return TRUE;
     }
     return FALSE;
@@ -125,7 +125,7 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, struct wine
     const struct wined3d_gl_info *gl_info = context->gl_info;
 
     TRACE("Creating an OpenGL vertex buffer object for wined3d_buffer %p with usage %s.\n",
-            This, debug_d3dusage(This->resource.usage));
+            This, debug_d3dusage(This->sub_resource.resource.usage));
 
     /* Make sure that the gl error is cleared. Do not use checkGLcall
     * here because checkGLcall just prints a fixme and continues. However,
@@ -158,7 +158,7 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, struct wine
         goto fail;
     }
 
-    if (This->resource.usage & WINED3DUSAGE_DYNAMIC)
+    if (This->sub_resource.resource.usage & WINED3DUSAGE_DYNAMIC)
     {
         TRACE("Buffer has WINED3DUSAGE_DYNAMIC set.\n");
         gl_usage = GL_STREAM_DRAW_ARB;
@@ -181,7 +181,8 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, struct wine
      * calling glBufferSubData on updates. Upload the actual data in case
      * we're not double buffering, so we can release the heap mem afterwards
      */
-    GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->resource.size, This->resource.heap_memory, gl_usage));
+    GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->sub_resource.resource.size,
+            This->sub_resource.resource.heap_memory, gl_usage));
     error = gl_info->gl_ops.gl.p_glGetError();
     if (error != GL_NO_ERROR)
     {
@@ -194,7 +195,7 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, struct wine
     if (This->flags & WINED3D_BUFFER_DOUBLEBUFFER)
         buffer_invalidate_bo_range(This, 0, 0);
     else
-        wined3d_resource_free_sysmem(&This->resource);
+        wined3d_resource_free_sysmem(&This->sub_resource.resource);
 
     return;
 
@@ -315,7 +316,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This, const struct wined3d_s
      */
     if (This->flags & WINED3D_BUFFER_HASDESC)
     {
-        if(This->resource.usage & WINED3DUSAGE_STATICDECL) return FALSE;
+        if(This->sub_resource.resource.usage & WINED3DUSAGE_STATICDECL) return FALSE;
     }
 
     if (!fixup_flags)
@@ -457,7 +458,7 @@ void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *co
     data->buffer_object = buffer->buffer_object;
     if (!buffer->buffer_object)
     {
-        if ((buffer->flags & WINED3D_BUFFER_CREATEBO) && !buffer->resource.map_count)
+        if ((buffer->flags & WINED3D_BUFFER_CREATEBO) && !buffer->sub_resource.resource.map_count)
         {
             buffer_create_buffer_object(buffer, context);
             buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
@@ -468,7 +469,7 @@ void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *co
                 return;
             }
         }
-        data->addr = buffer->resource.heap_memory;
+        data->addr = buffer->sub_resource.resource.heap_memory;
     }
     else
     {
@@ -478,7 +479,7 @@ void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *co
 
 ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
 {
-    ULONG refcount = InterlockedIncrement(&buffer->resource.ref);
+    ULONG refcount = InterlockedIncrement(&buffer->sub_resource.resource.ref);
 
     TRACE("%p increasing refcount to %u.\n", buffer, refcount);
 
@@ -491,20 +492,21 @@ BYTE *buffer_get_sysmem(struct wined3d_buffer *This, struct wined3d_context *con
     const struct wined3d_gl_info *gl_info = context->gl_info;
 
     /* Heap_memory exists if the buffer is double buffered or has no buffer object at all. */
-    if (This->resource.heap_memory)
-        return This->resource.heap_memory;
+    if (This->sub_resource.resource.heap_memory)
+        return This->sub_resource.resource.heap_memory;
 
-    if (!wined3d_resource_allocate_sysmem(&This->resource))
+    if (!wined3d_resource_allocate_sysmem(&This->sub_resource.resource))
         ERR("Failed to allocate system memory.\n");
 
     if (This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
         context_invalidate_state(context, STATE_INDEXBUFFER);
 
     GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
-    GL_EXTCALL(glGetBufferSubDataARB(This->buffer_type_hint, 0, This->resource.size, This->resource.heap_memory));
+    GL_EXTCALL(glGetBufferSubDataARB(This->buffer_type_hint, 0,
+            This->sub_resource.resource.size, This->sub_resource.resource.heap_memory));
     This->flags |= WINED3D_BUFFER_DOUBLEBUFFER;
 
-    return This->resource.heap_memory;
+    return This->sub_resource.resource.heap_memory;
 }
 
 static void buffer_unload(struct wined3d_resource *resource)
@@ -545,7 +547,7 @@ static void buffer_unload(struct wined3d_resource *resource)
 
 ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
 {
-    ULONG refcount = InterlockedDecrement(&buffer->resource.ref);
+    ULONG refcount = InterlockedDecrement(&buffer->sub_resource.resource.ref);
     struct wined3d_context *context;
 
     TRACE("%p decreasing refcount to %u.\n", buffer, refcount);
@@ -554,15 +556,15 @@ ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
     {
         if (buffer->buffer_object)
         {
-            context = context_acquire(buffer->resource.device, NULL);
+            context = context_acquire(buffer->sub_resource.resource.device, NULL);
             delete_gl_buffer(buffer, context->gl_info);
             context_release(context);
 
             HeapFree(GetProcessHeap(), 0, buffer->conversion_map);
         }
 
-        resource_cleanup(&buffer->resource);
-        buffer->resource.parent_ops->wined3d_object_destroyed(buffer->resource.parent);
+        resource_cleanup(&buffer->sub_resource.resource);
+        buffer->sub_resource.resource.parent_ops->wined3d_object_destroyed(buffer->sub_resource.resource.parent);
         HeapFree(GetProcessHeap(), 0, buffer->maps);
         HeapFree(GetProcessHeap(), 0, buffer);
     }
@@ -574,17 +576,17 @@ void * CDECL wined3d_buffer_get_parent(const struct wined3d_buffer *buffer)
 {
     TRACE("buffer %p.\n", buffer);
 
-    return buffer->resource.parent;
+    return buffer->sub_resource.resource.parent;
 }
 
 DWORD CDECL wined3d_buffer_set_priority(struct wined3d_buffer *buffer, DWORD priority)
 {
-    return resource_set_priority(&buffer->resource, priority);
+    return resource_set_priority(&buffer->sub_resource.resource, priority);
 }
 
 DWORD CDECL wined3d_buffer_get_priority(const struct wined3d_buffer *buffer)
 {
-    return resource_get_priority(&buffer->resource);
+    return resource_get_priority(&buffer->sub_resource.resource);
 }
 
 /* The caller provides a context and binds the buffer */
@@ -599,7 +601,8 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st
 
     if (flags & WINED3D_MAP_DISCARD)
     {
-        GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->resource.size, NULL, This->buffer_object_usage));
+        GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->sub_resource.resource.size,
+                NULL, This->buffer_object_usage));
         checkGLcall("glBufferDataARB\n");
         return;
     }
@@ -626,7 +629,7 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st
         return;
     }
     TRACE("Synchronizing buffer %p\n", This);
-    ret = wined3d_event_query_finish(This->query, This->resource.device);
+    ret = wined3d_event_query_finish(This->query, This->sub_resource.resource.device);
     switch(ret)
     {
         case WINED3D_EVENT_QUERY_NOT_STARTED:
@@ -675,7 +678,7 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
         if (flags & WINED3D_BUFFER_NOSYNC)
             mapflags |= GL_MAP_UNSYNCHRONIZED_BIT;
         map = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0,
-                    This->resource.size, mapflags));
+                    This->sub_resource.resource.size, mapflags));
         checkGLcall("glMapBufferRange");
     }
     else
@@ -704,7 +707,7 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
         start = This->maps[This->modified_areas].offset;
         len = This->maps[This->modified_areas].size;
 
-        memcpy(map + start, (BYTE *)This->resource.heap_memory + start, len);
+        memcpy(map + start, (BYTE *)This->sub_resource.resource.heap_memory + start, len);
 
         if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
         {
@@ -726,7 +729,7 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
         const struct wined3d_state *state)
 {
     DWORD flags = buffer->flags & (WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
-    struct wined3d_device *device = buffer->resource.device;
+    struct wined3d_device *device = buffer->sub_resource.resource.device;
     UINT start = 0, end = 0, len = 0, vertices;
     const struct wined3d_gl_info *gl_info;
     BOOL decl_changed = FALSE;
@@ -735,7 +738,7 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
 
     TRACE("buffer %p.\n", buffer);
 
-    if (buffer->resource.map_count)
+    if (buffer->sub_resource.resource.map_count)
     {
         WARN("Buffer is mapped, skipping preload.\n");
         return;
@@ -796,11 +799,11 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
         buffer->draw_count = 0;
 
         if (buffer->decl_change_count > VB_MAXDECLCHANGES
-                || (buffer->conversion_map && (buffer->resource.usage & WINED3DUSAGE_DYNAMIC)))
+                || (buffer->conversion_map && (buffer->sub_resource.resource.usage & WINED3DUSAGE_DYNAMIC)))
         {
             FIXME("Too many declaration changes or converting dynamic buffer, stopping converting\n");
 
-            buffer_unload(&buffer->resource);
+            buffer_unload(&buffer->sub_resource.resource);
             buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
 
             /* The stream source state handler might have read the memory of
@@ -833,9 +836,9 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
             if (buffer->full_conversion_count > VB_MAXFULLCONVERSIONS)
             {
                 FIXME("Too many full buffer conversions, stopping converting.\n");
-                buffer_unload(&buffer->resource);
+                buffer_unload(&buffer->sub_resource.resource);
                 buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
-                if (buffer->resource.bind_count)
+                if (buffer->sub_resource.resource.bind_count)
                     device_invalidate_state(device, STATE_STREAMSRC);
                 return;
             }
@@ -856,7 +859,7 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
     if (!buffer->conversion_map)
     {
         /* That means that there is nothing to fixup. Just upload from
-         * buffer->resource.heap_memory directly into the vbo. Do not
+         * buffer->sub_resource.resource.heap_memory directly into the vbo. Do not
          * free the system memory copy because drawPrimitive may need it if
          * the stride is 0, for instancing emulation, vertex blending
          * emulation or shader emulation. */
@@ -881,9 +884,9 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
     }
 
     /* Now for each vertex in the buffer that needs conversion */
-    vertices = buffer->resource.size / buffer->stride;
+    vertices = buffer->sub_resource.resource.size / buffer->stride;
 
-    data = HeapAlloc(GetProcessHeap(), 0, buffer->resource.size);
+    data = HeapAlloc(GetProcessHeap(), 0, buffer->sub_resource.resource.size);
 
     while(buffer->modified_areas)
     {
@@ -892,7 +895,7 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
         len = buffer->maps[buffer->modified_areas].size;
         end = start + len;
 
-        memcpy(data + start, (BYTE *)buffer->resource.heap_memory + start, end - start);
+        memcpy(data + start, (BYTE *)buffer->sub_resource.resource.heap_memory + start, end - start);
         for (i = start / buffer->stride; i < min((end / buffer->stride) + 1, vertices); ++i)
         {
             for (j = 0; j < buffer->stride; ++j)
@@ -930,7 +933,7 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
 void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
 {
     struct wined3d_context *context;
-    context = context_acquire(buffer->resource.device, NULL);
+    context = context_acquire(buffer->sub_resource.resource.device, NULL);
     buffer_internal_preload(buffer, context, NULL);
     context_release(context);
 }
@@ -939,7 +942,7 @@ struct wined3d_resource * CDECL wined3d_buffer_get_resource(struct wined3d_buffe
 {
     TRACE("buffer %p.\n", buffer);
 
-    return &buffer->resource;
+    return &buffer->sub_resource.resource;
 }
 
 HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UINT size, BYTE **data, DWORD flags)
@@ -950,8 +953,8 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
 
     TRACE("buffer %p, offset %u, size %u, data %p, flags %#x\n", buffer, offset, size, data, flags);
 
-    flags = wined3d_resource_sanitize_map_flags(&buffer->resource, flags);
-    count = ++buffer->resource.map_count;
+    flags = wined3d_resource_sanitize_map_flags(&buffer->sub_resource.resource, flags);
+    count = ++buffer->sub_resource.resource.map_count;
 
     if (buffer->buffer_object)
     {
@@ -968,7 +971,7 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
         {
             if (count == 1)
             {
-                struct wined3d_device *device = buffer->resource.device;
+                struct wined3d_device *device = buffer->sub_resource.resource.device;
                 struct wined3d_context *context;
                 const struct wined3d_gl_info *gl_info;
 
@@ -983,7 +986,7 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
                 {
                     GLbitfield mapflags = wined3d_resource_gl_map_flags(flags);
                     buffer->map_ptr = GL_EXTCALL(glMapBufferRange(buffer->buffer_type_hint,
-                            0, buffer->resource.size, mapflags));
+                            0, buffer->sub_resource.resource.size, mapflags));
                     checkGLcall("glMapBufferRange");
                 }
                 else
@@ -1003,16 +1006,16 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
                     checkGLcall("glUnmapBufferARB");
                     buffer->map_ptr = NULL;
 
-                    if (buffer->resource.usage & WINED3DUSAGE_DYNAMIC)
+                    if (buffer->sub_resource.resource.usage & WINED3DUSAGE_DYNAMIC)
                     {
                         /* The extra copy is more expensive than not using VBOs at
                          * all on the Nvidia Linux driver, which is the only driver
                          * that returns unaligned pointers
                          */
                         TRACE("Dynamic buffer, dropping VBO\n");
-                        buffer_unload(&buffer->resource);
+                        buffer_unload(&buffer->sub_resource.resource);
                         buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
-                        if (buffer->resource.bind_count)
+                        if (buffer->sub_resource.resource.bind_count)
                             device_invalidate_state(device, STATE_STREAMSRC);
                     }
                     else
@@ -1020,7 +1023,7 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
                         TRACE("Falling back to doublebuffered operation\n");
                         buffer_get_sysmem(buffer, context);
                     }
-                    TRACE("New pointer is %p.\n", buffer->resource.heap_memory);
+                    TRACE("New pointer is %p.\n", buffer->sub_resource.resource.heap_memory);
                     buffer->map_ptr = NULL;
                 }
                 context_release(context);
@@ -1047,7 +1050,7 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
         }
     }
 
-    base = buffer->map_ptr ? buffer->map_ptr : buffer->resource.heap_memory;
+    base = buffer->map_ptr ? buffer->map_ptr : buffer->sub_resource.resource.heap_memory;
     *data = base + offset;
 
     TRACE("Returning memory at %p (base %p, offset %u).\n", *data, base, offset);
@@ -1066,13 +1069,13 @@ void CDECL wined3d_buffer_unmap(struct wined3d_buffer *buffer)
      * number of Map calls, d3d returns always D3D_OK.
      * This is also needed to prevent Map from returning garbage on
      * the next call (this will happen if the lock_count is < 0). */
-    if (!buffer->resource.map_count)
+    if (!buffer->sub_resource.resource.map_count)
     {
         WARN("Unmap called without a previous map call.\n");
         return;
     }
 
-    if (--buffer->resource.map_count)
+    if (--buffer->sub_resource.resource.map_count)
     {
         /* Delay loading the buffer until everything is unlocked */
         TRACE("Ignoring unmap.\n");
@@ -1081,7 +1084,7 @@ void CDECL wined3d_buffer_unmap(struct wined3d_buffer *buffer)
 
     if (!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER) && buffer->buffer_object)
     {
-        struct wined3d_device *device = buffer->resource.device;
+        struct wined3d_device *device = buffer->sub_resource.resource.device;
         const struct wined3d_gl_info *gl_info;
         struct wined3d_context *context;
 
@@ -1145,7 +1148,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
         return WINED3DERR_INVALIDCALL;
     }
 
-    hr = resource_init(&buffer->resource, device, WINED3D_RTYPE_BUFFER, format,
+    hr = resource_init(&buffer->sub_resource.resource, device, WINED3D_RTYPE_BUFFER, format,
             WINED3D_MULTISAMPLE_NONE, 0, usage, pool, size, 1, 1, size,
             parent, parent_ops, &buffer_resource_ops);
     if (FAILED(hr))
@@ -1155,8 +1158,9 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
     }
     buffer->buffer_type_hint = bind_hint;
 
-    TRACE("size %#x, usage %#x, format %s, memory @ %p, iface @ %p.\n", buffer->resource.size, buffer->resource.usage,
-            debug_d3dformat(buffer->resource.format->id), buffer->resource.heap_memory, buffer);
+    TRACE("size %#x, usage %#x, format %s, memory @ %p, iface @ %p.\n",
+            buffer->sub_resource.resource.size, buffer->sub_resource.resource.usage,
+            debug_d3dformat(buffer->sub_resource.resource.format->id), buffer->sub_resource.resource.heap_memory, buffer);
 
     if (device->create_parms.flags & WINED3DCREATE_SOFTWARE_VERTEXPROCESSING)
     {
@@ -1180,11 +1184,11 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
     {
         TRACE("Not creating a vbo because GL_ARB_vertex_buffer is not supported\n");
     }
-    else if(buffer->resource.pool == WINED3D_POOL_SYSTEM_MEM)
+    else if(buffer->sub_resource.resource.pool == WINED3D_POOL_SYSTEM_MEM)
     {
         TRACE("Not creating a vbo because the vertex buffer is in system memory\n");
     }
-    else if(!dynamic_buffer_ok && (buffer->resource.usage & WINED3DUSAGE_DYNAMIC))
+    else if(!dynamic_buffer_ok && (buffer->sub_resource.resource.usage & WINED3DUSAGE_DYNAMIC))
     {
         TRACE("Not creating a vbo because the buffer has dynamic usage and no GL support\n");
     }
@@ -1201,8 +1205,8 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
         if (FAILED(hr))
         {
             ERR("Failed to map buffer, hr %#x\n", hr);
-            buffer_unload(&buffer->resource);
-            resource_cleanup(&buffer->resource);
+            buffer_unload(&buffer->sub_resource.resource);
+            resource_cleanup(&buffer->sub_resource.resource);
             return hr;
         }
 
@@ -1215,8 +1219,8 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
     if (!buffer->maps)
     {
         ERR("Out of memory\n");
-        buffer_unload(&buffer->resource);
-        resource_cleanup(&buffer->resource);
+        buffer_unload(&buffer->sub_resource.resource);
+        resource_cleanup(&buffer->sub_resource.resource);
         return E_OUTOFMEMORY;
     }
     buffer->maps_size = 1;
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 4d7c76e..d2aec0d 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -449,9 +449,9 @@ static void wined3d_cs_exec_set_stream_source(struct wined3d_cs *cs, const void
     stream->stride = op->stride;
 
     if (op->buffer)
-        InterlockedIncrement(&op->buffer->resource.bind_count);
+        InterlockedIncrement(&op->buffer->sub_resource.resource.bind_count);
     if (prev)
-        InterlockedDecrement(&prev->resource.bind_count);
+        InterlockedDecrement(&prev->sub_resource.resource.bind_count);
 
     device_invalidate_state(cs->device, STATE_STREAMSRC);
 }
@@ -508,9 +508,9 @@ static void wined3d_cs_exec_set_stream_output(struct wined3d_cs *cs, const void
     stream->offset = op->offset;
 
     if (op->buffer)
-        InterlockedIncrement(&op->buffer->resource.bind_count);
+        InterlockedIncrement(&op->buffer->sub_resource.resource.bind_count);
     if (prev)
-        InterlockedDecrement(&prev->resource.bind_count);
+        InterlockedDecrement(&prev->sub_resource.resource.bind_count);
 }
 
 void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx,
@@ -537,9 +537,9 @@ static void wined3d_cs_exec_set_index_buffer(struct wined3d_cs *cs, const void *
     cs->state.index_format = op->format_id;
 
     if (op->buffer)
-        InterlockedIncrement(&op->buffer->resource.bind_count);
+        InterlockedIncrement(&op->buffer->sub_resource.resource.bind_count);
     if (prev)
-        InterlockedDecrement(&prev->resource.bind_count);
+        InterlockedDecrement(&prev->sub_resource.resource.bind_count);
 
     device_invalidate_state(cs->device, STATE_INDEXBUFFER);
 }
@@ -566,9 +566,9 @@ static void wined3d_cs_exec_set_constant_buffer(struct wined3d_cs *cs, const voi
     cs->state.cb[op->type][op->cb_idx] = op->buffer;
 
     if (op->buffer)
-        InterlockedIncrement(&op->buffer->resource.bind_count);
+        InterlockedIncrement(&op->buffer->sub_resource.resource.bind_count);
     if (prev)
-        InterlockedDecrement(&prev->resource.bind_count);
+        InterlockedDecrement(&prev->sub_resource.resource.bind_count);
 }
 
 void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type,
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 43c4e17..fc06ab3 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -693,7 +693,7 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co
     {
         struct wined3d_buffer *index_buffer = state->index_buffer;
         if (!index_buffer->buffer_object || !stream_info->all_vbo)
-            idx_data = index_buffer->resource.heap_memory;
+            idx_data = index_buffer->sub_resource.resource.heap_memory;
         else
         {
             ib_query = index_buffer->query;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 991db87..f45d1de 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -5,7 +5,7 @@
  * Copyright 2002-2003 Raphael Junqueira
  * Copyright 2002-2003, 2004 Jason Edmeades
  * Copyright 2005 Oliver Stieber
- * Copyright 2006-2011, 2013 Stefan Dösinger for CodeWeavers
+ * Copyright 2006-2011, 2013-2014 Stefan Dösinger for CodeWeavers
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -2028,6 +2028,11 @@ GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
 /* Tests show that the start address of resources is 32 byte aligned */
 #define RESOURCE_ALIGNMENT 16
 
+struct wined3d_sub_resource
+{
+    struct wined3d_resource resource;
+};
+
 enum wined3d_texture_state
 {
     WINED3DTEXSTA_ADDRESSU       = 0,
@@ -2535,7 +2540,7 @@ struct wined3d_map_range
 
 struct wined3d_buffer
 {
-    struct wined3d_resource resource;
+    struct wined3d_sub_resource sub_resource;
 
     struct wined3d_buffer_desc desc;
 
@@ -2559,7 +2564,7 @@ struct wined3d_buffer
 
 static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resource *resource)
 {
-    return CONTAINING_RECORD(resource, struct wined3d_buffer, resource);
+    return CONTAINING_RECORD(resource, struct wined3d_buffer, sub_resource.resource);
 }
 
 void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context,
-- 
1.8.3.2




More information about the wine-patches mailing list