Module: wine Branch: master Commit: 171e272f852465e1d015c79f0ebc632e4643f873 URL: http://source.winehq.org/git/wine.git/?a=commit;h=171e272f852465e1d015c79f0e...
Author: Józef Kucia jkucia@codeweavers.com Date: Thu Oct 20 12:50:50 2016 +0200
wined3d: Introduce wined3d_buffer_prepapre_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 | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index c7f0d81..558be1b 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -538,6 +538,32 @@ ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer) return refcount; }
+static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer, + struct wined3d_context *context, DWORD location) +{ + switch (location) + { + case WINED3D_LOCATION_SYSMEM: + if (buffer->resource.heap_memory) + return TRUE; + + if (!wined3d_resource_allocate_sysmem(&buffer->resource)) + { + ERR("Failed to allocate system memory.\n"); + return FALSE; + } + return TRUE; + + case WINED3D_LOCATION_BUFFER: + FIXME("Not implemented yet.\n"); + return FALSE; + + default: + ERR("Invalid location %s.\n", wined3d_debug_location(location)); + return FALSE; + } +} + /* Context activation is done by the caller. */ BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) { @@ -547,8 +573,8 @@ BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_c if (buffer->resource.heap_memory) return buffer->resource.heap_memory;
- if (!wined3d_resource_allocate_sysmem(&buffer->resource)) - ERR("Failed to allocate system memory.\n"); + if (!wined3d_buffer_prepare_location(buffer, context, WINED3D_LOCATION_SYSMEM)) + return NULL;
buffer_bind(buffer, context); GL_EXTCALL(glGetBufferSubData(buffer->buffer_type_hint, 0, buffer->resource.size, buffer->resource.heap_memory));