[PATCH 2/3] wined3d: Move the bo_user field to struct wined3d_buffer.

Zebediah Figura zfigura at codeweavers.com
Wed Oct 20 00:12:00 CDT 2021


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/wined3d/buffer.c          | 18 +++++++++---------
 dlls/wined3d/context_gl.c      | 20 ++++++++++----------
 dlls/wined3d/context_vk.c      |  8 ++++----
 dlls/wined3d/state.c           |  6 +++---
 dlls/wined3d/wined3d_private.h |  3 +--
 5 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 54291f1d9dd..55dcd9e67e8 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -187,8 +187,8 @@ static void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *bu
         wined3d_context_gl_end_transform_feedback(context_gl);
     }
 
-    buffer_gl->bo_user.valid = false;
-    list_remove(&buffer_gl->bo_user.entry);
+    buffer_gl->b.bo_user.valid = false;
+    list_remove(&buffer_gl->b.bo_user.entry);
     wined3d_context_gl_destroy_bo(context_gl, &buffer_gl->bo);
     buffer_gl->b.buffer_object = 0;
 }
@@ -225,7 +225,7 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf
         return FALSE;
     }
 
-    list_add_head(&buffer_gl->bo.b.users, &buffer_gl->bo_user.entry);
+    list_add_head(&buffer_gl->bo.b.users, &buffer_gl->b.bo_user.entry);
     buffer_gl->b.buffer_object = (uintptr_t)bo;
     buffer_invalidate_bo_range(&buffer_gl->b, 0, 0);
 
@@ -1439,8 +1439,8 @@ static BOOL wined3d_buffer_vk_create_buffer_object(struct wined3d_buffer_vk *buf
         return FALSE;
     }
 
-    list_init(&buffer_vk->bo_user.entry);
-    list_add_head(&buffer_vk->bo.b.users, &buffer_vk->bo_user.entry);
+    list_init(&buffer_vk->b.bo_user.entry);
+    list_add_head(&buffer_vk->bo.b.users, &buffer_vk->b.bo_user.entry);
     buffer_vk->b.buffer_object = (uintptr_t)&buffer_vk->bo;
     buffer_invalidate_bo_range(&buffer_vk->b, 0, 0);
 
@@ -1449,13 +1449,13 @@ static BOOL wined3d_buffer_vk_create_buffer_object(struct wined3d_buffer_vk *buf
 
 const VkDescriptorBufferInfo *wined3d_buffer_vk_get_buffer_info(struct wined3d_buffer_vk *buffer_vk)
 {
-    if (buffer_vk->bo_user.valid)
+    if (buffer_vk->b.bo_user.valid)
         return &buffer_vk->buffer_info;
 
     buffer_vk->buffer_info.buffer = buffer_vk->bo.vk_buffer;
     buffer_vk->buffer_info.offset = buffer_vk->bo.buffer_offset;
     buffer_vk->buffer_info.range = buffer_vk->b.resource.size;
-    buffer_vk->bo_user.valid = true;
+    buffer_vk->b.bo_user.valid = true;
 
     return &buffer_vk->buffer_info;
 }
@@ -1491,8 +1491,8 @@ static void wined3d_buffer_vk_unload_location(struct wined3d_buffer *buffer,
     switch (location)
     {
         case WINED3D_LOCATION_BUFFER:
-            buffer_vk->bo_user.valid = false;
-            list_remove(&buffer_vk->bo_user.entry);
+            buffer_vk->b.bo_user.valid = false;
+            list_remove(&buffer_vk->b.bo_user.entry);
             wined3d_context_vk_destroy_bo(context_vk, &buffer_vk->bo);
             buffer_vk->bo.vk_buffer = VK_NULL_HANDLE;
             buffer_vk->bo.memory = NULL;
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c
index 83cf87f8404..d2dd9e0bd09 100644
--- a/dlls/wined3d/context_gl.c
+++ b/dlls/wined3d/context_gl.c
@@ -3816,7 +3816,7 @@ static void context_gl_load_shader_resources(struct wined3d_context_gl *context_
             buffer_gl = wined3d_buffer_gl(state->cb[i][j].buffer);
             wined3d_buffer_load(&buffer_gl->b, &context_gl->c, state);
             wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
-            if (!buffer_gl->bo_user.valid)
+            if (!buffer_gl->b.bo_user.valid)
                 device_invalidate_state(context_gl->c.device, STATE_CONSTANT_BUFFER(i));
         }
 
@@ -3902,7 +3902,7 @@ static void context_gl_load_stream_output_buffers(struct wined3d_context_gl *con
         wined3d_buffer_load(&buffer_gl->b, &context_gl->c, state);
         wined3d_buffer_invalidate_location(&buffer_gl->b, ~WINED3D_LOCATION_BUFFER);
         wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
-        if (!buffer_gl->bo_user.valid)
+        if (!buffer_gl->b.bo_user.valid)
             device_invalidate_state(context_gl->c.device, STATE_STREAM_OUTPUT);
     }
 }
@@ -3959,7 +3959,7 @@ static BOOL context_apply_draw_state(struct wined3d_context *context,
         e = &context->stream_info.elements[wined3d_bit_scan(&map)];
         buffer_gl = wined3d_buffer_gl(state->streams[e->stream_idx].buffer);
 
-        if (!buffer_gl->bo_user.valid)
+        if (!buffer_gl->b.bo_user.valid)
             device_invalidate_state(device, STATE_STREAMSRC);
         else
             wined3d_buffer_load(&buffer_gl->b, context, state);
@@ -3976,7 +3976,7 @@ static BOOL context_apply_draw_state(struct wined3d_context *context,
         if (context->stream_info.all_vbo)
         {
             wined3d_buffer_load(&buffer_gl->b, context, state);
-            if (!buffer_gl->bo_user.valid)
+            if (!buffer_gl->b.bo_user.valid)
                 device_invalidate_state(device, STATE_INDEXBUFFER);
             wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
         }
@@ -5101,7 +5101,7 @@ void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context
             gl_info->gl_ops.gl.p_glTexCoordPointer(format_gl->vtx_format, format_gl->vtx_type, e->stride,
                     e->data.addr + state->load_base_vertex_index * e->stride);
             gl_info->gl_ops.gl.p_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-            wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
+            state->streams[e->stream_idx].buffer->bo_user.valid = true;
         }
         else
         {
@@ -5190,7 +5190,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte
         checkGLcall("glVertexPointer(...)");
         gl_info->gl_ops.gl.p_glEnableClientState(GL_VERTEX_ARRAY);
         checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
-        wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
+        state->streams[e->stream_idx].buffer->bo_user.valid = true;
     }
 
     /* Normals */
@@ -5214,7 +5214,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte
         checkGLcall("glNormalPointer(...)");
         gl_info->gl_ops.gl.p_glEnableClientState(GL_NORMAL_ARRAY);
         checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
-        wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
+        state->streams[e->stream_idx].buffer->bo_user.valid = true;
     }
     else
     {
@@ -5244,7 +5244,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte
         checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
         gl_info->gl_ops.gl.p_glEnableClientState(GL_COLOR_ARRAY);
         checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
-        wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
+        state->streams[e->stream_idx].buffer->bo_user.valid = true;
     }
     else
     {
@@ -5313,7 +5313,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte
             }
             gl_info->gl_ops.gl.p_glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
             checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
-            wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
+            state->streams[e->stream_idx].buffer->bo_user.valid = true;
         }
         else
         {
@@ -5407,7 +5407,7 @@ static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *c
 
         format_gl = wined3d_format_gl(element->format);
         stream = &state->streams[element->stream_idx];
-        wined3d_buffer_gl(stream->buffer)->bo_user.valid = true;
+        stream->buffer->bo_user.valid = true;
 
         if ((stream->flags & WINED3DSTREAMSOURCE_INSTANCEDATA) && !context->instance_count)
             context->instance_count = state->streams[0].frequency;
diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c
index 8bcd6d61eb3..ad7b0a8ba86 100644
--- a/dlls/wined3d/context_vk.c
+++ b/dlls/wined3d/context_vk.c
@@ -3091,7 +3091,7 @@ static void wined3d_context_vk_load_shader_resources(struct wined3d_context_vk *
 
                 buffer_vk = wined3d_buffer_vk(buffer);
                 wined3d_buffer_load(buffer, &context_vk->c, state);
-                if (!buffer_vk->bo_user.valid)
+                if (!buffer_vk->b.bo_user.valid)
                 {
                     if (pipeline == WINED3D_PIPELINE_GRAPHICS)
                         context_invalidate_state(&context_vk->c, STATE_GRAPHICS_CONSTANT_BUFFER(binding->shader_type));
@@ -3257,7 +3257,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c
         buffer_vk = wined3d_buffer_vk(buffer);
         wined3d_buffer_load(&buffer_vk->b, &context_vk->c, state);
         wined3d_buffer_vk_barrier(buffer_vk, context_vk, WINED3D_BIND_VERTEX_BUFFER);
-        if (!buffer_vk->bo_user.valid)
+        if (!buffer_vk->b.bo_user.valid)
             context_invalidate_state(&context_vk->c, STATE_STREAMSRC);
     }
 
@@ -3272,7 +3272,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c
             wined3d_buffer_load(&buffer_vk->b, &context_vk->c, state);
             wined3d_buffer_vk_barrier(buffer_vk, context_vk, WINED3D_BIND_STREAM_OUTPUT);
             wined3d_buffer_invalidate_location(&buffer_vk->b, ~WINED3D_LOCATION_BUFFER);
-            if (!buffer_vk->bo_user.valid)
+            if (!buffer_vk->b.bo_user.valid)
                 context_vk->update_stream_output = 1;
         }
         context_vk->c.transform_feedback_active = 1;
@@ -3283,7 +3283,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c
         buffer_vk = wined3d_buffer_vk(state->index_buffer);
         wined3d_buffer_load(&buffer_vk->b, &context_vk->c, state);
         wined3d_buffer_vk_barrier(buffer_vk, context_vk, WINED3D_BIND_INDEX_BUFFER);
-        if (!buffer_vk->bo_user.valid)
+        if (!buffer_vk->b.bo_user.valid)
             context_invalidate_state(&context_vk->c, STATE_INDEXBUFFER);
     }
 
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index c7f041066d1..fd2ade572c8 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4458,7 +4458,7 @@ static void indexbuffer(struct wined3d_context *context, const struct wined3d_st
 
     buffer_gl = wined3d_buffer_gl(state->index_buffer);
     GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer_gl->bo.id));
-    buffer_gl->bo_user.valid = true;
+    buffer_gl->b.bo_user.valid = true;
 }
 
 static void depth_clip(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info)
@@ -4575,7 +4575,7 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
         buffer_gl = wined3d_buffer_gl(buffer_state->buffer);
         GL_EXTCALL(glBindBufferRange(GL_UNIFORM_BUFFER, base + i, buffer_gl->bo.id,
                 buffer_state->offset, buffer_state->size));
-        buffer_gl->bo_user.valid = true;
+        buffer_gl->b.bo_user.valid = true;
     }
     checkGLcall("bind constant buffers");
 }
@@ -4649,7 +4649,7 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state
         }
         size = buffer_gl->b.resource.size - offset;
         GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i, buffer_gl->bo.id, offset, size));
-        buffer_gl->bo_user.valid = true;
+        buffer_gl->b.bo_user.valid = true;
     }
     checkGLcall("bind transform feedback buffers");
 }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9ece1954018..8666d9699c9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -5000,6 +5000,7 @@ struct wined3d_buffer
     DWORD locations;
     void *map_ptr;
     uintptr_t buffer_object;
+    struct wined3d_bo_user bo_user;
 
     struct wined3d_range *maps;
     SIZE_T maps_size, modified_areas;
@@ -5042,7 +5043,6 @@ struct wined3d_buffer_gl
     struct wined3d_buffer b;
 
     struct wined3d_bo_gl bo;
-    struct wined3d_bo_user bo_user;
 };
 
 static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer *buffer)
@@ -5064,7 +5064,6 @@ struct wined3d_buffer_vk
     struct wined3d_buffer b;
 
     struct wined3d_bo_vk bo;
-    struct wined3d_bo_user bo_user;
     VkDescriptorBufferInfo buffer_info;
     uint32_t bind_mask;
 };
-- 
2.33.0




More information about the wine-devel mailing list