From 1fb85cd5731aaa492df204df6b388ab7e992477c Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 21 Apr 2020 22:37:10 +0430 Subject: [PATCH] wined3d: Store the preferred binding in the wined3d_bo_gl structure. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/buffer.c | 22 ++++++++++------------ dlls/wined3d/texture.c | 7 ++++--- dlls/wined3d/view.c | 12 ++++++------ dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index b7ba2be16d1..a9d9d8fb71d 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -135,7 +135,7 @@ void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD loc /* Context activation is done by the caller. */ static void wined3d_buffer_gl_bind(struct wined3d_buffer_gl *buffer_gl, struct wined3d_context_gl *context_gl) { - wined3d_context_gl_bind_bo(context_gl, buffer_gl->buffer_type_hint, buffer_gl->bo.id); + wined3d_context_gl_bind_bo(context_gl, buffer_gl->bo.binding, buffer_gl->bo.id); } /* Context activation is done by the caller. */ @@ -225,6 +225,7 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf bo = &buffer_gl->bo; GL_EXTCALL(glGenBuffers(1, &bo->id)); + bo->binding = wined3d_buffer_gl_binding_from_bind_flags(gl_info, buffer_gl->b.resource.bind_flags); buffer_gl->b.buffer_object = (uintptr_t)bo; error = gl_info->gl_ops.gl.p_glGetError(); if (!bo->id || error != GL_NO_ERROR) @@ -248,17 +249,15 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf if (gl_info->supported[APPLE_FLUSH_BUFFER_RANGE]) { - 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)); + GL_EXTCALL(glBufferParameteriAPPLE(bo->binding, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE)); + GL_EXTCALL(glBufferParameteriAPPLE(bo->binding, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE)); checkGLcall("glBufferParameteriAPPLE"); buffer_gl->b.flags |= WINED3D_BUFFER_APPLESYNC; } /* No setup is needed here for GL_ARB_map_buffer_range. */ } - GL_EXTCALL(glBufferData(buffer_gl->buffer_type_hint, buffer_gl->b.resource.size, NULL, gl_usage)); + GL_EXTCALL(glBufferData(bo->binding, buffer_gl->b.resource.size, NULL, gl_usage)); error = gl_info->gl_ops.gl.p_glGetError(); if (error != GL_NO_ERROR) { @@ -803,7 +802,7 @@ static void wined3d_buffer_gl_sync_apple(struct wined3d_buffer_gl *buffer_gl, { wined3d_buffer_gl_bind(buffer_gl, context_gl); - GL_EXTCALL(glBufferData(buffer_gl->buffer_type_hint, buffer_gl->b.resource.size, + GL_EXTCALL(glBufferData(buffer_gl->bo.binding, buffer_gl->b.resource.size, NULL, buffer_gl->buffer_object_usage)); checkGLcall("glBufferData"); return; @@ -854,7 +853,7 @@ drop_fence: gl_info->gl_ops.gl.p_glFinish(); wined3d_buffer_gl_bind(buffer_gl, context_gl); - GL_EXTCALL(glBufferParameteriAPPLE(buffer_gl->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE)); + GL_EXTCALL(glBufferParameteriAPPLE(buffer_gl->bo.binding, 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; } @@ -1172,7 +1171,7 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou wined3d_buffer_gl_bind(buffer_gl, context_gl); for (i = 0; i < range_count; ++i) { - GL_EXTCALL(glFlushMappedBufferRangeAPPLE(buffer_gl->buffer_type_hint, + GL_EXTCALL(glFlushMappedBufferRangeAPPLE(buffer_gl->bo.binding, buffer->maps[i].offset, buffer->maps[i].size)); checkGLcall("glFlushMappedBufferRangeAPPLE"); } @@ -1503,7 +1502,7 @@ static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer *buffer, struc while (range_count--) { range = &ranges[range_count]; - GL_EXTCALL(glBufferSubData(buffer_gl->buffer_type_hint, + GL_EXTCALL(glBufferSubData(buffer_gl->bo.binding, range->offset, range->size, (BYTE *)data + range->offset - data_offset)); } checkGLcall("buffer upload"); @@ -1526,7 +1525,7 @@ static void wined3d_buffer_gl_download_ranges(struct wined3d_buffer *buffer, str while (range_count--) { range = &ranges[range_count]; - GL_EXTCALL(glGetBufferSubData(buffer_gl->buffer_type_hint, + GL_EXTCALL(glGetBufferSubData(buffer_gl->bo.binding, range->offset, range->size, (BYTE *)data + range->offset - data_offset)); } checkGLcall("buffer download"); @@ -1561,7 +1560,6 @@ HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined TRACE("Not creating a BO because the buffer has dynamic usage and no GL support.\n"); else buffer_gl->b.flags |= WINED3D_BUFFER_USE_BO; - buffer_gl->buffer_type_hint = wined3d_buffer_gl_binding_from_bind_flags(gl_info, desc->bind_flags); return wined3d_buffer_init(&buffer_gl->b, device, desc, data, parent, parent_ops, &wined3d_buffer_gl_ops); } diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index e41c0f3999b..d075ccc9cd2 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1638,9 +1638,10 @@ static void wined3d_texture_prepare_buffer_object(struct wined3d_texture *textur return; GL_EXTCALL(glGenBuffers(1, &bo->id)); - GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, bo->id)); - GL_EXTCALL(glBufferData(GL_PIXEL_UNPACK_BUFFER, sub_resource->size, NULL, GL_STREAM_DRAW)); - GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0)); + bo->binding = GL_PIXEL_UNPACK_BUFFER; + GL_EXTCALL(glBindBuffer(bo->binding, bo->id)); + GL_EXTCALL(glBufferData(bo->binding, sub_resource->size, NULL, GL_STREAM_DRAW)); + GL_EXTCALL(glBindBuffer(bo->binding, 0)); checkGLcall("Create buffer object"); TRACE("Created buffer object %u for texture %p, sub-resource %u.\n", bo->id, texture, sub_resource_idx); diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 19339424682..e1dd4de8dab 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1032,8 +1032,8 @@ void wined3d_unordered_access_view_gl_clear_uint(struct wined3d_unordered_access wined3d_unordered_access_view_invalidate_location(&view_gl->v, ~WINED3D_LOCATION_BUFFER); get_buffer_view_range(&buffer_gl->b, &view_gl->v.desc, &format->f, &offset, &size); - wined3d_context_gl_bind_bo(context_gl, buffer_gl->buffer_type_hint, buffer_gl->bo.id); - GL_EXTCALL(glClearBufferSubData(buffer_gl->buffer_type_hint, format->internal, + wined3d_context_gl_bind_bo(context_gl, buffer_gl->bo.binding, buffer_gl->bo.id); + GL_EXTCALL(glClearBufferSubData(buffer_gl->bo.binding, format->internal, offset, size, format->format, format->type, clear_value)); checkGLcall("clear unordered access view"); } @@ -1073,7 +1073,7 @@ void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_ src.buffer_object = (uintptr_t)&view_gl->counter_bo; src.addr = NULL; - wined3d_context_gl_copy_bo_address(context_gl, &dst, wined3d_buffer_gl(buffer)->buffer_type_hint, + wined3d_context_gl_copy_bo_address(context_gl, &dst, wined3d_buffer_gl(buffer)->bo.binding, &src, GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint)); wined3d_buffer_invalidate_location(buffer, ~dst_location); @@ -1102,9 +1102,9 @@ static void wined3d_unordered_access_view_gl_cs_init(void *object) static const GLuint initial_value = 0; GL_EXTCALL(glGenBuffers(1, &bo->id)); - GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bo->id)); - GL_EXTCALL(glBufferData(GL_ATOMIC_COUNTER_BUFFER, - sizeof(initial_value), &initial_value, GL_STATIC_DRAW)); + bo->binding = GL_ATOMIC_COUNTER_BUFFER; + GL_EXTCALL(glBindBuffer(bo->binding, bo->id)); + GL_EXTCALL(glBufferData(bo->binding, sizeof(initial_value), &initial_value, GL_STATIC_DRAW)); checkGLcall("create atomic counter buffer"); } context_release(context); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 8b7f518b4d9..e6cbfce17d8 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1522,6 +1522,7 @@ do { \ struct wined3d_bo_gl { GLuint id; + GLenum binding; }; static inline GLuint wined3d_bo_gl_id(uintptr_t bo) @@ -4422,7 +4423,6 @@ struct wined3d_buffer_gl struct wined3d_bo_gl bo; GLenum buffer_object_usage; - GLenum buffer_type_hint; }; static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer *buffer)