Commit 645d3cac authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Introduce wined3d_buffer_load_location().

parent 171e272f
...@@ -564,25 +564,67 @@ static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer, ...@@ -564,25 +564,67 @@ static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
} }
} }
/* Context activation is done by the caller. */ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) struct wined3d_context *context, DWORD location)
{ {
const struct wined3d_gl_info *gl_info = context->gl_info; 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. */ TRACE("buffer %p, context %p, location %s.\n",
if (buffer->resource.heap_memory) buffer, context, wined3d_debug_location(location));
return buffer->resource.heap_memory;
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)) case WINED3D_LOCATION_BUFFER:
return NULL; FIXME("Not implemented yet.\n");
return FALSE;
buffer_bind(buffer, context); default:
GL_EXTCALL(glGetBufferSubData(buffer->buffer_type_hint, 0, buffer->resource.size, buffer->resource.heap_memory)); ERR("Invalid location %s.\n", wined3d_debug_location(location));
checkGLcall("buffer download"); return FALSE;
buffer->flags |= WINED3D_BUFFER_DOUBLEBUFFER; }
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; return buffer->resource.heap_memory;
} }
......
...@@ -3185,6 +3185,8 @@ void buffer_mark_used(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; ...@@ -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_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN;
void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context, void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context,
const struct wined3d_state *state) DECLSPEC_HIDDEN; 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; 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, 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; struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment