[PATCH 4/5] wined3d: Move the "buffer_type_hint" field from struct wined3d_buffer to struct wined3d_buffer_gl.

Henri Verbeet hverbeet at codeweavers.com
Fri Oct 26 08:13:08 CDT 2018


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/buffer.c          | 203 +++++++++++++++++++++--------------------
 dlls/wined3d/view.c            |  14 +--
 dlls/wined3d/wined3d_private.h |   3 +-
 3 files changed, 115 insertions(+), 105 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 4b66193746f..1481e9bc6f6 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -133,9 +133,9 @@ void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD loc
 }
 
 /* Context activation is done by the caller. */
-static void buffer_bind(struct wined3d_buffer *buffer, struct wined3d_context *context)
+static void wined3d_buffer_gl_bind(struct wined3d_buffer_gl *buffer_gl, struct wined3d_context *context)
 {
-    context_bind_bo(context, buffer->buffer_type_hint, buffer->buffer_object);
+    context_bind_bo(context, buffer_gl->buffer_type_hint, buffer_gl->b.buffer_object);
 }
 
 /* Context activation is done by the caller. */
@@ -194,14 +194,14 @@ static void buffer_destroy_buffer_object(struct wined3d_buffer *buffer, struct w
 }
 
 /* Context activation is done by the caller. */
-static BOOL buffer_create_buffer_object(struct wined3d_buffer *buffer, struct wined3d_context *context)
+static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buffer_gl, struct wined3d_context *context)
 {
     const struct wined3d_gl_info *gl_info = context->gl_info;
     GLenum gl_usage = GL_STATIC_DRAW;
     GLenum error;
 
-    TRACE("Creating an OpenGL buffer object for wined3d_buffer %p with usage %s.\n",
-            buffer, debug_d3dusage(buffer->resource.usage));
+    TRACE("Creating an OpenGL buffer object for wined3d buffer %p with usage %s.\n",
+            buffer_gl, debug_d3dusage(buffer_gl->b.resource.usage));
 
     /* Make sure that the gl error is cleared. Do not use checkGLcall
      * here because checkGLcall just prints a fixme and continues. However,
@@ -216,15 +216,15 @@ static BOOL buffer_create_buffer_object(struct wined3d_buffer *buffer, struct wi
      * to be verified to check if the rhw and color values are in the correct
      * format. */
 
-    GL_EXTCALL(glGenBuffers(1, &buffer->buffer_object));
+    GL_EXTCALL(glGenBuffers(1, &buffer_gl->b.buffer_object));
     error = gl_info->gl_ops.gl.p_glGetError();
-    if (!buffer->buffer_object || error != GL_NO_ERROR)
+    if (!buffer_gl->b.buffer_object || error != GL_NO_ERROR)
     {
         ERR("Failed to create a BO with error %s (%#x).\n", debug_glerror(error), error);
         goto fail;
     }
 
-    buffer_bind(buffer, context);
+    wined3d_buffer_gl_bind(buffer_gl, context);
     error = gl_info->gl_ops.gl.p_glGetError();
     if (error != GL_NO_ERROR)
     {
@@ -232,22 +232,24 @@ static BOOL buffer_create_buffer_object(struct wined3d_buffer *buffer, struct wi
         goto fail;
     }
 
-    if (buffer->resource.usage & WINED3DUSAGE_DYNAMIC)
+    if (buffer_gl->b.resource.usage & WINED3DUSAGE_DYNAMIC)
     {
         TRACE("Buffer has WINED3DUSAGE_DYNAMIC set.\n");
         gl_usage = GL_STREAM_DRAW_ARB;
 
         if (gl_info->supported[APPLE_FLUSH_BUFFER_RANGE])
         {
-            GL_EXTCALL(glBufferParameteriAPPLE(buffer->buffer_type_hint, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE));
-            GL_EXTCALL(glBufferParameteriAPPLE(buffer->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE));
+            GL_EXTCALL(glBufferParameteriAPPLE(buffer_gl->buffer_type_hint,
+                    GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE));
+            GL_EXTCALL(glBufferParameteriAPPLE(buffer_gl->buffer_type_hint,
+                    GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE));
             checkGLcall("glBufferParameteriAPPLE");
-            buffer->flags |= WINED3D_BUFFER_APPLESYNC;
+            buffer_gl->b.flags |= WINED3D_BUFFER_APPLESYNC;
         }
         /* No setup is needed here for GL_ARB_map_buffer_range. */
     }
 
-    GL_EXTCALL(glBufferData(buffer->buffer_type_hint, buffer->resource.size, NULL, gl_usage));
+    GL_EXTCALL(glBufferData(buffer_gl->buffer_type_hint, buffer_gl->b.resource.size, NULL, gl_usage));
     error = gl_info->gl_ops.gl.p_glGetError();
     if (error != GL_NO_ERROR)
     {
@@ -255,17 +257,17 @@ static BOOL buffer_create_buffer_object(struct wined3d_buffer *buffer, struct wi
         goto fail;
     }
 
-    buffer->buffer_object_usage = gl_usage;
-    buffer_invalidate_bo_range(buffer, 0, 0);
+    buffer_gl->b.buffer_object_usage = gl_usage;
+    buffer_invalidate_bo_range(&buffer_gl->b, 0, 0);
 
     return TRUE;
 
 fail:
     /* Clean up all BO init, but continue because we can work without a BO :-) */
     ERR("Failed to create a buffer object. Continuing, but performance issues may occur.\n");
-    buffer->flags &= ~WINED3D_BUFFER_USE_BO;
-    buffer_destroy_buffer_object(buffer, context);
-    buffer_clear_dirty_areas(buffer);
+    buffer_gl->b.flags &= ~WINED3D_BUFFER_USE_BO;
+    buffer_destroy_buffer_object(&buffer_gl->b, context);
+    buffer_clear_dirty_areas(&buffer_gl->b);
     return FALSE;
 }
 
@@ -532,18 +534,18 @@ ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
 }
 
 /* Context activation is done by the caller. */
-static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context,
+static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer_gl *buffer_gl, struct wined3d_context *context,
         const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges)
 {
     const struct wined3d_gl_info *gl_info = context->gl_info;
     const struct wined3d_map_range *range;
 
-    buffer_bind(buffer, context);
+    wined3d_buffer_gl_bind(buffer_gl, context);
 
     while (range_count--)
     {
         range = &ranges[range_count];
-        GL_EXTCALL(glBufferSubData(buffer->buffer_type_hint,
+        GL_EXTCALL(glBufferSubData(buffer_gl->buffer_type_hint,
                 range->offset, range->size, (BYTE *)data + range->offset - data_offset));
     }
     checkGLcall("glBufferSubData");
@@ -600,7 +602,8 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined
         }
     }
 
-    wined3d_buffer_upload_ranges(buffer, context, data, 0, buffer->modified_areas, buffer->maps);
+    wined3d_buffer_gl_upload_ranges(wined3d_buffer_gl(buffer),
+            context, data, 0, buffer->modified_areas, buffer->maps);
 
     heap_free(data);
 }
@@ -627,7 +630,7 @@ static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
                 WARN("Trying to create BO for buffer %p with no WINED3D_BUFFER_USE_BO.\n", buffer);
                 return FALSE;
             }
-            return buffer_create_buffer_object(buffer, context);
+            return wined3d_buffer_gl_create_buffer_object(wined3d_buffer_gl(buffer), context);
 
         default:
             ERR("Invalid location %s.\n", wined3d_debug_location(location));
@@ -638,6 +641,7 @@ static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
 BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
         struct wined3d_context *context, DWORD location)
 {
+    struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer);
     const struct wined3d_gl_info *gl_info = context->gl_info;
 
     TRACE("buffer %p, context %p, location %s.\n",
@@ -672,15 +676,15 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
     switch (location)
     {
         case WINED3D_LOCATION_SYSMEM:
-            buffer_bind(buffer, context);
-            GL_EXTCALL(glGetBufferSubData(buffer->buffer_type_hint, 0, buffer->resource.size,
+            wined3d_buffer_gl_bind(buffer_gl, context);
+            GL_EXTCALL(glGetBufferSubData(buffer_gl->buffer_type_hint, 0, buffer->resource.size,
                     buffer->resource.heap_memory));
             checkGLcall("buffer download");
             break;
 
         case WINED3D_LOCATION_BUFFER:
             if (!buffer->conversion_map)
-                wined3d_buffer_upload_ranges(buffer, context, buffer->resource.heap_memory,
+                wined3d_buffer_gl_upload_ranges(buffer_gl, context, buffer->resource.heap_memory,
                         0, buffer->modified_areas, buffer->maps);
             else
                 buffer_conversion_upload(buffer, context);
@@ -809,7 +813,8 @@ void * CDECL wined3d_buffer_get_parent(const struct wined3d_buffer *buffer)
 }
 
 /* The caller provides a context and binds the buffer */
-static void buffer_sync_apple(struct wined3d_buffer *buffer, DWORD flags, const struct wined3d_gl_info *gl_info)
+static void wined3d_buffer_gl_sync_apple(struct wined3d_buffer_gl *buffer_gl,
+        DWORD flags, const struct wined3d_gl_info *gl_info)
 {
     enum wined3d_fence_result ret;
     HRESULT hr;
@@ -821,16 +826,17 @@ static void buffer_sync_apple(struct wined3d_buffer *buffer, DWORD flags, const
 
     if (flags & WINED3D_MAP_DISCARD)
     {
-        GL_EXTCALL(glBufferData(buffer->buffer_type_hint, buffer->resource.size, NULL, buffer->buffer_object_usage));
+        GL_EXTCALL(glBufferData(buffer_gl->buffer_type_hint, buffer_gl->b.resource.size,
+                NULL, buffer_gl->b.buffer_object_usage));
         checkGLcall("glBufferData");
         return;
     }
 
-    if (!buffer->fence)
+    if (!buffer_gl->b.fence)
     {
-        TRACE("Creating fence for buffer %p.\n", buffer);
+        TRACE("Creating fence for buffer %p.\n", buffer_gl);
 
-        if (FAILED(hr = wined3d_fence_create(buffer->resource.device, &buffer->fence)))
+        if (FAILED(hr = wined3d_fence_create(buffer_gl->b.resource.device, &buffer_gl->b.fence)))
         {
             if (hr == WINED3DERR_NOTAVAILABLE)
                 FIXME("Fences not supported, dropping async buffer locks.\n");
@@ -844,8 +850,8 @@ static void buffer_sync_apple(struct wined3d_buffer *buffer, DWORD flags, const
         return;
     }
 
-    TRACE("Synchronizing buffer %p.\n", buffer);
-    ret = wined3d_fence_wait(buffer->fence, buffer->resource.device);
+    TRACE("Synchronizing buffer %p.\n", buffer_gl);
+    ret = wined3d_fence_wait(buffer_gl->b.fence, buffer_gl->b.resource.device);
     switch (ret)
     {
         case WINED3D_FENCE_NOT_STARTED:
@@ -863,16 +869,16 @@ static void buffer_sync_apple(struct wined3d_buffer *buffer, DWORD flags, const
     }
 
 drop_fence:
-    if (buffer->fence)
+    if (buffer_gl->b.fence)
     {
-        wined3d_fence_destroy(buffer->fence);
-        buffer->fence = NULL;
+        wined3d_fence_destroy(buffer_gl->b.fence);
+        buffer_gl->b.fence = NULL;
     }
 
     gl_info->gl_ops.gl.p_glFinish();
-    GL_EXTCALL(glBufferParameteriAPPLE(buffer->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE));
-    checkGLcall("glBufferParameteriAPPLE(buffer->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE)");
-    buffer->flags &= ~WINED3D_BUFFER_APPLESYNC;
+    GL_EXTCALL(glBufferParameteriAPPLE(buffer_gl->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE));
+    checkGLcall("glBufferParameteriAPPLE(buffer_gl->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE)");
+    buffer_gl->b.flags &= ~WINED3D_BUFFER_APPLESYNC;
 }
 
 static void buffer_mark_used(struct wined3d_buffer *buffer)
@@ -996,18 +1002,19 @@ struct wined3d_resource * CDECL wined3d_buffer_get_resource(struct wined3d_buffe
     return &buffer->resource;
 }
 
-static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UINT size, BYTE **data, DWORD flags)
+static HRESULT wined3d_buffer_gl_map(struct wined3d_buffer_gl *buffer_gl,
+        unsigned int offset, unsigned int size, BYTE **data, DWORD flags)
 {
-    struct wined3d_device *device = buffer->resource.device;
+    struct wined3d_device *device = buffer_gl->b.resource.device;
     struct wined3d_context *context;
     LONG count;
     BYTE *base;
 
-    TRACE("buffer %p, offset %u, size %u, data %p, flags %#x.\n", buffer, offset, size, data, flags);
+    TRACE("buffer_gl %p, offset %u, size %u, data %p, flags %#x.\n", buffer_gl, offset, size, data, flags);
 
-    count = ++buffer->resource.map_count;
+    count = ++buffer_gl->b.resource.map_count;
 
-    if (buffer->buffer_object)
+    if (buffer_gl->b.buffer_object)
     {
         unsigned int dirty_offset = offset, dirty_size = size;
 
@@ -1022,18 +1029,18 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
         }
 
         if (((flags & WINED3D_MAP_WRITE) && !(flags & (WINED3D_MAP_NOOVERWRITE | WINED3D_MAP_DISCARD)))
-                || (!(flags & WINED3D_MAP_WRITE) && (buffer->locations & WINED3D_LOCATION_SYSMEM))
-                || buffer->flags & WINED3D_BUFFER_PIN_SYSMEM)
+                || (!(flags & WINED3D_MAP_WRITE) && (buffer_gl->b.locations & WINED3D_LOCATION_SYSMEM))
+                || buffer_gl->b.flags & WINED3D_BUFFER_PIN_SYSMEM)
         {
-            if (!(buffer->locations & WINED3D_LOCATION_SYSMEM))
+            if (!(buffer_gl->b.locations & WINED3D_LOCATION_SYSMEM))
             {
                 context = context_acquire(device, NULL, 0);
-                wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_SYSMEM);
+                wined3d_buffer_load_location(&buffer_gl->b, context, WINED3D_LOCATION_SYSMEM);
                 context_release(context);
             }
 
             if (flags & WINED3D_MAP_WRITE)
-                wined3d_buffer_invalidate_range(buffer, WINED3D_LOCATION_BUFFER, dirty_offset, dirty_size);
+                wined3d_buffer_invalidate_range(&buffer_gl->b, WINED3D_LOCATION_BUFFER, dirty_offset, dirty_size);
         }
         else
         {
@@ -1043,19 +1050,19 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
             gl_info = context->gl_info;
 
             if (flags & WINED3D_MAP_DISCARD)
-                wined3d_buffer_validate_location(buffer, WINED3D_LOCATION_BUFFER);
+                wined3d_buffer_validate_location(&buffer_gl->b, WINED3D_LOCATION_BUFFER);
             else
-                wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER);
+                wined3d_buffer_load_location(&buffer_gl->b, context, WINED3D_LOCATION_BUFFER);
 
             if (flags & WINED3D_MAP_WRITE)
-                buffer_invalidate_bo_range(buffer, dirty_offset, dirty_size);
+                buffer_invalidate_bo_range(&buffer_gl->b, dirty_offset, dirty_size);
 
-            if ((flags & WINED3D_MAP_DISCARD) && buffer->resource.heap_memory)
-                wined3d_buffer_evict_sysmem(buffer);
+            if ((flags & WINED3D_MAP_DISCARD) && buffer_gl->b.resource.heap_memory)
+                wined3d_buffer_evict_sysmem(&buffer_gl->b);
 
             if (count == 1)
             {
-                buffer_bind(buffer, context);
+                wined3d_buffer_gl_bind(buffer_gl, context);
 
                 /* Filter redundant WINED3D_MAP_DISCARD maps. The 3DMark2001
                  * multitexture fill rate test seems to depend on this. When
@@ -1064,49 +1071,49 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
                  * buffer. The r600g driver only does this when the buffer is
                  * currently in use, while the proprietary NVIDIA driver
                  * appears to do this unconditionally. */
-                if (buffer->flags & WINED3D_BUFFER_DISCARD)
+                if (buffer_gl->b.flags & WINED3D_BUFFER_DISCARD)
                     flags &= ~WINED3D_MAP_DISCARD;
 
                 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
                 {
                     GLbitfield mapflags = wined3d_resource_gl_map_flags(flags);
-                    buffer->map_ptr = GL_EXTCALL(glMapBufferRange(buffer->buffer_type_hint,
-                            0, buffer->resource.size, mapflags));
+                    buffer_gl->b.map_ptr = GL_EXTCALL(glMapBufferRange(buffer_gl->buffer_type_hint,
+                            0, buffer_gl->b.resource.size, mapflags));
                     checkGLcall("glMapBufferRange");
                 }
                 else
                 {
-                    if (buffer->flags & WINED3D_BUFFER_APPLESYNC)
-                        buffer_sync_apple(buffer, flags, gl_info);
-                    buffer->map_ptr = GL_EXTCALL(glMapBuffer(buffer->buffer_type_hint,
+                    if (buffer_gl->b.flags & WINED3D_BUFFER_APPLESYNC)
+                        wined3d_buffer_gl_sync_apple(buffer_gl, flags, gl_info);
+                    buffer_gl->b.map_ptr = GL_EXTCALL(glMapBuffer(buffer_gl->buffer_type_hint,
                             GL_READ_WRITE));
                     checkGLcall("glMapBuffer");
                 }
 
-                if (((DWORD_PTR)buffer->map_ptr) & (RESOURCE_ALIGNMENT - 1))
+                if (((DWORD_PTR)buffer_gl->b.map_ptr) & (RESOURCE_ALIGNMENT - 1))
                 {
-                    WARN("Pointer %p is not %u byte aligned.\n", buffer->map_ptr, RESOURCE_ALIGNMENT);
+                    WARN("Pointer %p is not %u byte aligned.\n", buffer_gl->b.map_ptr, RESOURCE_ALIGNMENT);
 
-                    GL_EXTCALL(glUnmapBuffer(buffer->buffer_type_hint));
+                    GL_EXTCALL(glUnmapBuffer(buffer_gl->buffer_type_hint));
                     checkGLcall("glUnmapBuffer");
-                    buffer->map_ptr = NULL;
+                    buffer_gl->b.map_ptr = NULL;
 
-                    if (buffer->resource.usage & WINED3DUSAGE_DYNAMIC)
+                    if (buffer_gl->b.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");
-                        wined3d_buffer_drop_bo(buffer);
+                        wined3d_buffer_drop_bo(&buffer_gl->b);
                     }
                     else
                     {
                         TRACE("Falling back to doublebuffered operation.\n");
-                        wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_SYSMEM);
-                        buffer->flags |= WINED3D_BUFFER_PIN_SYSMEM;
+                        wined3d_buffer_load_location(&buffer_gl->b, context, WINED3D_LOCATION_SYSMEM);
+                        buffer_gl->b.flags |= WINED3D_BUFFER_PIN_SYSMEM;
                     }
-                    TRACE("New pointer is %p.\n", buffer->resource.heap_memory);
+                    TRACE("New pointer is %p.\n", buffer_gl->b.resource.heap_memory);
                 }
             }
 
@@ -1114,10 +1121,10 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
         }
 
         if (flags & WINED3D_MAP_DISCARD)
-            buffer->flags |= WINED3D_BUFFER_DISCARD;
+            buffer_gl->b.flags |= WINED3D_BUFFER_DISCARD;
     }
 
-    base = buffer->map_ptr ? buffer->map_ptr : buffer->resource.heap_memory;
+    base = buffer_gl->b.map_ptr ? buffer_gl->b.map_ptr : buffer_gl->b.resource.heap_memory;
     *data = base + offset;
 
     TRACE("Returning memory at %p (base %p, offset %u).\n", *data, base, offset);
@@ -1126,64 +1133,64 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
     return WINED3D_OK;
 }
 
-static void wined3d_buffer_unmap(struct wined3d_buffer *buffer)
+static void wined3d_buffer_gl_unmap(struct wined3d_buffer_gl *buffer_gl)
 {
     ULONG i;
 
-    TRACE("buffer %p.\n", buffer);
+    TRACE("buffer_gl %p.\n", buffer_gl);
 
     /* In the case that the number of Unmap calls > the
      * 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_gl->b.resource.map_count)
     {
         WARN("Unmap called without a previous map call.\n");
         return;
     }
 
-    if (--buffer->resource.map_count)
+    if (--buffer_gl->b.resource.map_count)
     {
         /* Delay loading the buffer until everything is unlocked */
         TRACE("Ignoring unmap.\n");
         return;
     }
 
-    if (buffer->map_ptr)
+    if (buffer_gl->b.map_ptr)
     {
-        struct wined3d_device *device = buffer->resource.device;
+        struct wined3d_device *device = buffer_gl->b.resource.device;
         const struct wined3d_gl_info *gl_info;
         struct wined3d_context *context;
 
         context = context_acquire(device, NULL, 0);
         gl_info = context->gl_info;
 
-        buffer_bind(buffer, context);
+        wined3d_buffer_gl_bind(buffer_gl, context);
 
         if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
         {
-            for (i = 0; i < buffer->modified_areas; ++i)
+            for (i = 0; i < buffer_gl->b.modified_areas; ++i)
             {
-                GL_EXTCALL(glFlushMappedBufferRange(buffer->buffer_type_hint,
-                        buffer->maps[i].offset, buffer->maps[i].size));
+                GL_EXTCALL(glFlushMappedBufferRange(buffer_gl->buffer_type_hint,
+                        buffer_gl->b.maps[i].offset, buffer_gl->b.maps[i].size));
                 checkGLcall("glFlushMappedBufferRange");
             }
         }
-        else if (buffer->flags & WINED3D_BUFFER_APPLESYNC)
+        else if (buffer_gl->b.flags & WINED3D_BUFFER_APPLESYNC)
         {
-            for (i = 0; i < buffer->modified_areas; ++i)
+            for (i = 0; i < buffer_gl->b.modified_areas; ++i)
             {
-                GL_EXTCALL(glFlushMappedBufferRangeAPPLE(buffer->buffer_type_hint,
-                        buffer->maps[i].offset, buffer->maps[i].size));
+                GL_EXTCALL(glFlushMappedBufferRangeAPPLE(buffer_gl->buffer_type_hint,
+                        buffer_gl->b.maps[i].offset, buffer_gl->b.maps[i].size));
                 checkGLcall("glFlushMappedBufferRangeAPPLE");
             }
         }
 
-        GL_EXTCALL(glUnmapBuffer(buffer->buffer_type_hint));
+        GL_EXTCALL(glUnmapBuffer(buffer_gl->buffer_type_hint));
         context_release(context);
 
-        buffer_clear_dirty_areas(buffer);
-        buffer->map_ptr = NULL;
+        buffer_clear_dirty_areas(&buffer_gl->b);
+        buffer_gl->b.map_ptr = NULL;
     }
 }
 
@@ -1204,8 +1211,8 @@ void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_off
     src.addr += src_offset;
 
     context = context_acquire(dst_buffer->resource.device, NULL, 0);
-    context_copy_bo_address(context, &dst, dst_buffer->buffer_type_hint,
-            &src, src_buffer->buffer_type_hint, size);
+    context_copy_bo_address(context, &dst, wined3d_buffer_gl(dst_buffer)->buffer_type_hint,
+            &src, wined3d_buffer_gl(src_buffer)->buffer_type_hint, size);
     context_release(context);
 
     wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size);
@@ -1227,7 +1234,7 @@ void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_co
         range.size = buffer->resource.size;
     }
 
-    wined3d_buffer_upload_ranges(buffer, context, data, range.offset, 1, &range);
+    wined3d_buffer_gl_upload_ranges(wined3d_buffer_gl(buffer), context, data, range.offset, 1, &range);
 }
 
 static void wined3d_buffer_init_data(struct wined3d_buffer *buffer,
@@ -1274,7 +1281,7 @@ static void buffer_resource_preload(struct wined3d_resource *resource)
 static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx,
         struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
 {
-    struct wined3d_buffer *buffer = buffer_from_resource(resource);
+    struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer_from_resource(resource));
     UINT offset, size;
 
     if (sub_resource_idx)
@@ -1293,8 +1300,8 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
         offset = size = 0;
     }
 
-    map_desc->row_pitch = map_desc->slice_pitch = buffer->desc.byte_width;
-    return wined3d_buffer_map(buffer, offset, size, (BYTE **)&map_desc->data, flags);
+    map_desc->row_pitch = map_desc->slice_pitch = buffer_gl->b.desc.byte_width;
+    return wined3d_buffer_gl_map(buffer_gl, offset, size, (BYTE **)&map_desc->data, flags);
 }
 
 static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
@@ -1305,7 +1312,7 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou
         return E_INVALIDARG;
     }
 
-    wined3d_buffer_unmap(buffer_from_resource(resource));
+    wined3d_buffer_gl_unmap(wined3d_buffer_gl(buffer_from_resource(resource)));
     return WINED3D_OK;
 }
 
@@ -1377,7 +1384,6 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d
         return hr;
     }
     buffer->desc = *desc;
-    buffer->buffer_type_hint = buffer_type_hint_from_bind_flags(gl_info, desc->bind_flags);
     buffer->bind_flags = desc->bind_flags;
     buffer->locations = data ? WINED3D_LOCATION_DISCARDED : WINED3D_LOCATION_SYSMEM;
 
@@ -1444,6 +1450,7 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct
         const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops,
         struct wined3d_buffer **buffer)
 {
+    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     struct wined3d_buffer_gl *object;
     HRESULT hr;
 
@@ -1456,6 +1463,8 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct
     if (!(object = heap_alloc_zero(sizeof(*object))))
         return E_OUTOFMEMORY;
 
+    object->buffer_type_hint = buffer_type_hint_from_bind_flags(gl_info, desc->bind_flags);
+
     if (FAILED(hr = wined3d_buffer_init(&object->b, device, desc, data, parent, parent_ops)))
     {
         WARN("Failed to initialize buffer, hr %#x.\n", hr);
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index 7bb8b81c0db..35d15e63195 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -1023,8 +1023,8 @@ void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_vi
 {
     const struct wined3d_gl_info *gl_info = context->gl_info;
     const struct wined3d_format_gl *format;
+    struct wined3d_buffer_gl *buffer_gl;
     struct wined3d_resource *resource;
-    struct wined3d_buffer *buffer;
     unsigned int offset, size;
 
     resource = view->resource;
@@ -1049,13 +1049,13 @@ void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_vi
         return;
     }
 
-    buffer = buffer_from_resource(resource);
-    wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER);
+    buffer_gl = wined3d_buffer_gl(buffer_from_resource(resource));
+    wined3d_buffer_load_location(&buffer_gl->b, context, WINED3D_LOCATION_BUFFER);
     wined3d_unordered_access_view_invalidate_location(view, ~WINED3D_LOCATION_BUFFER);
 
-    get_buffer_view_range(buffer, &view->desc, &format->f, &offset, &size);
-    context_bind_bo(context, buffer->buffer_type_hint, buffer->buffer_object);
-    GL_EXTCALL(glClearBufferSubData(buffer->buffer_type_hint, format->internal,
+    get_buffer_view_range(&buffer_gl->b, &view->desc, &format->f, &offset, &size);
+    context_bind_bo(context, buffer_gl->buffer_type_hint, buffer_gl->b.buffer_object);
+    GL_EXTCALL(glClearBufferSubData(buffer_gl->buffer_type_hint, format->internal,
             offset, size, format->format, format->type, clear_value));
     checkGLcall("clear unordered access view");
 }
@@ -1092,7 +1092,7 @@ void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_
     src.buffer_object = view->counter_bo;
     src.addr = NULL;
 
-    context_copy_bo_address(context, &dst, buffer->buffer_type_hint,
+    context_copy_bo_address(context, &dst, wined3d_buffer_gl(buffer)->buffer_type_hint,
             &src, GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint));
 
     wined3d_buffer_invalidate_location(buffer, ~dst_location);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0402603c527..226fdd0d3f5 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3760,7 +3760,6 @@ struct wined3d_buffer
 
     GLuint buffer_object;
     GLenum buffer_object_usage;
-    GLenum buffer_type_hint;
     unsigned int bind_flags;
     DWORD flags;
     DWORD locations;
@@ -3799,6 +3798,8 @@ void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_co
 struct wined3d_buffer_gl
 {
     struct wined3d_buffer b;
+
+    GLenum buffer_type_hint;
 };
 
 static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer *buffer)
-- 
2.11.0




More information about the wine-devel mailing list