Module: wine Branch: master Commit: 645d3cac14b1303d0152ac6463586ce147c25b9c URL: http://source.winehq.org/git/wine.git/?a=commit;h=645d3cac14b1303d0152ac6463...
Author: Józef Kucia jkucia@codeweavers.com Date: Thu Oct 20 12:50:51 2016 +0200
wined3d: Introduce wined3d_buffer_load_location().
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/buffer.c | 66 ++++++++++++++++++++++++++++++++++-------- dlls/wined3d/wined3d_private.h | 2 ++ 2 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 558be1b..94b290f 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -564,25 +564,67 @@ static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer, } }
-/* Context activation is done by the caller. */ -BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) +BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, + struct wined3d_context *context, DWORD location) { 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 (buffer->resource.heap_memory) - return buffer->resource.heap_memory; + TRACE("buffer %p, context %p, location %s.\n", + buffer, context, wined3d_debug_location(location)); + + if (buffer->locations & location) + { + TRACE("Location (%#x) is already up to date.\n", location); + return WINED3D_OK; + } + + if (!buffer->locations) + { + ERR("Buffer %p does not have any up to date location.\n", buffer); + wined3d_buffer_validate_location(buffer, WINED3D_LOCATION_DISCARDED); + return wined3d_buffer_load_location(buffer, context, location); + } + + TRACE("Current buffer location %s.\n", wined3d_debug_location(buffer->locations)); + + if (!wined3d_buffer_prepare_location(buffer, context, location)) + return FALSE; + + if (buffer->locations & WINED3D_LOCATION_DISCARDED) + { + TRACE("Buffer previously discarded, nothing to do.\n"); + wined3d_buffer_validate_location(buffer, location); + wined3d_buffer_invalidate_location(buffer, WINED3D_LOCATION_DISCARDED); + return TRUE; + } + + switch (location) + { + case WINED3D_LOCATION_SYSMEM: + buffer_bind(buffer, context); + GL_EXTCALL(glGetBufferSubData(buffer->buffer_type_hint, 0, buffer->resource.size, + buffer->resource.heap_memory)); + checkGLcall("buffer download"); + buffer->flags |= WINED3D_BUFFER_DOUBLEBUFFER; + break;
- if (!wined3d_buffer_prepare_location(buffer, context, WINED3D_LOCATION_SYSMEM)) - return NULL; + case WINED3D_LOCATION_BUFFER: + FIXME("Not implemented yet.\n"); + return FALSE;
- buffer_bind(buffer, context); - GL_EXTCALL(glGetBufferSubData(buffer->buffer_type_hint, 0, buffer->resource.size, buffer->resource.heap_memory)); - checkGLcall("buffer download"); - buffer->flags |= WINED3D_BUFFER_DOUBLEBUFFER; + default: + ERR("Invalid location %s.\n", wined3d_debug_location(location)); + return FALSE; + }
- wined3d_buffer_validate_location(buffer, WINED3D_LOCATION_SYSMEM); + wined3d_buffer_validate_location(buffer, location); + return TRUE; +}
+/* Context activation is done by the caller. */ +BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) +{ + wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_SYSMEM); return buffer->resource.heap_memory; }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 45a24f1..8001e5e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3185,6 +3185,8 @@ void buffer_mark_used(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN; void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN; +BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, struct wined3d_context *context, + DWORD location) DECLSPEC_HIDDEN; BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN; HRESULT wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset, struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;