wined3d: Introduce wined3d_buffer_ops.buffer_prepare_location().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3179a6af29
commit
6462ba5269
|
@ -593,31 +593,9 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined
|
|||
}
|
||||
|
||||
static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
|
||||
struct wined3d_context *context, DWORD location)
|
||||
struct wined3d_context *context, unsigned int location)
|
||||
{
|
||||
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
|
||||
struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer);
|
||||
|
||||
switch (location)
|
||||
{
|
||||
case WINED3D_LOCATION_SYSMEM:
|
||||
return wined3d_resource_prepare_sysmem(&buffer->resource);
|
||||
|
||||
case WINED3D_LOCATION_BUFFER:
|
||||
if (buffer_gl->buffer_object)
|
||||
return TRUE;
|
||||
|
||||
if (!(buffer->flags & WINED3D_BUFFER_USE_BO))
|
||||
{
|
||||
WARN("Trying to create BO for buffer %p with no WINED3D_BUFFER_USE_BO.\n", buffer);
|
||||
return FALSE;
|
||||
}
|
||||
return wined3d_buffer_gl_create_buffer_object(buffer_gl, context_gl);
|
||||
|
||||
default:
|
||||
ERR("Invalid location %s.\n", wined3d_debug_location(location));
|
||||
return FALSE;
|
||||
}
|
||||
return buffer->buffer_ops->buffer_prepare_location(buffer, context, location);
|
||||
}
|
||||
|
||||
BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
|
||||
|
@ -1434,6 +1412,17 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d
|
|||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
static BOOL wined3d_buffer_no3d_prepare_location(struct wined3d_buffer *buffer,
|
||||
struct wined3d_context *context, unsigned int location)
|
||||
{
|
||||
if (location == WINED3D_LOCATION_SYSMEM)
|
||||
return wined3d_resource_prepare_sysmem(&buffer->resource);
|
||||
|
||||
FIXME("Unhandled location %s.\n", wined3d_debug_location(location));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void wined3d_buffer_no3d_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context,
|
||||
const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges)
|
||||
{
|
||||
|
@ -1448,6 +1437,7 @@ static void wined3d_buffer_no3d_download_ranges(struct wined3d_buffer *buffer, s
|
|||
|
||||
static const struct wined3d_buffer_ops wined3d_buffer_no3d_ops =
|
||||
{
|
||||
wined3d_buffer_no3d_prepare_location,
|
||||
wined3d_buffer_no3d_upload_ranges,
|
||||
wined3d_buffer_no3d_download_ranges,
|
||||
};
|
||||
|
@ -1462,6 +1452,34 @@ HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wine
|
|||
return wined3d_buffer_init(buffer_no3d, device, desc, data, parent, parent_ops, &wined3d_buffer_no3d_ops);
|
||||
}
|
||||
|
||||
static BOOL wined3d_buffer_gl_prepare_location(struct wined3d_buffer *buffer,
|
||||
struct wined3d_context *context, unsigned int location)
|
||||
{
|
||||
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
|
||||
struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer);
|
||||
|
||||
switch (location)
|
||||
{
|
||||
case WINED3D_LOCATION_SYSMEM:
|
||||
return wined3d_resource_prepare_sysmem(&buffer->resource);
|
||||
|
||||
case WINED3D_LOCATION_BUFFER:
|
||||
if (buffer_gl->buffer_object)
|
||||
return TRUE;
|
||||
|
||||
if (!(buffer->flags & WINED3D_BUFFER_USE_BO))
|
||||
{
|
||||
WARN("Trying to create BO for buffer %p with no WINED3D_BUFFER_USE_BO.\n", buffer);
|
||||
return FALSE;
|
||||
}
|
||||
return wined3d_buffer_gl_create_buffer_object(buffer_gl, context_gl);
|
||||
|
||||
default:
|
||||
ERR("Invalid location %s.\n", wined3d_debug_location(location));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Context activation is done by the caller. */
|
||||
static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context,
|
||||
const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges)
|
||||
|
@ -1504,6 +1522,7 @@ static void wined3d_buffer_gl_download_ranges(struct wined3d_buffer *buffer, str
|
|||
|
||||
static const struct wined3d_buffer_ops wined3d_buffer_gl_ops =
|
||||
{
|
||||
wined3d_buffer_gl_prepare_location,
|
||||
wined3d_buffer_gl_upload_ranges,
|
||||
wined3d_buffer_gl_download_ranges,
|
||||
};
|
||||
|
@ -1522,6 +1541,24 @@ HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined
|
|||
return wined3d_buffer_init(&buffer_gl->b, device, desc, data, parent, parent_ops, &wined3d_buffer_gl_ops);
|
||||
}
|
||||
|
||||
static BOOL wined3d_buffer_vk_prepare_location(struct wined3d_buffer *buffer,
|
||||
struct wined3d_context *context, unsigned int location)
|
||||
{
|
||||
switch (location)
|
||||
{
|
||||
case WINED3D_LOCATION_SYSMEM:
|
||||
return wined3d_resource_prepare_sysmem(&buffer->resource);
|
||||
|
||||
case WINED3D_LOCATION_BUFFER:
|
||||
/* The Vulkan buffer is created during resource creation. */
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
FIXME("Unhandled location %s.\n", wined3d_debug_location(location));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context,
|
||||
const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges)
|
||||
{
|
||||
|
@ -1536,6 +1573,7 @@ static void wined3d_buffer_vk_download_ranges(struct wined3d_buffer *buffer, str
|
|||
|
||||
static const struct wined3d_buffer_ops wined3d_buffer_vk_ops =
|
||||
{
|
||||
wined3d_buffer_vk_prepare_location,
|
||||
wined3d_buffer_vk_upload_ranges,
|
||||
wined3d_buffer_vk_download_ranges,
|
||||
};
|
||||
|
|
|
@ -4130,6 +4130,8 @@ struct wined3d_map_range
|
|||
|
||||
struct wined3d_buffer_ops
|
||||
{
|
||||
BOOL (*buffer_prepare_location)(struct wined3d_buffer *buffer,
|
||||
struct wined3d_context *context, unsigned int location);
|
||||
void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data,
|
||||
unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges);
|
||||
void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data,
|
||||
|
|
Loading…
Reference in New Issue