Commit 334a3bbe authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Handle WINED3D_LOCATION_DISCARDED in wined3d_buffer_get_memory().

This can't currently happen. However, we'd like to use wined3d_buffer_get_memory() in wined3d_cs_exec_update_sub_resource(). This would probably also help in implementing ID3D11DeviceContext1::DiscardResource(). Signed-off-by: 's avatarZebediah Figura <z.figura12@gmail.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 9c1a80f4
......@@ -603,13 +603,26 @@ BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_c
return buffer->resource.heap_memory;
}
DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_bo_address *data)
DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context,
struct wined3d_bo_address *data)
{
unsigned int locations = buffer->locations;
TRACE("buffer %p, data %p, locations %s.\n",
buffer, data, wined3d_debug_location(locations));
TRACE("buffer %p, context %p, data %p, locations %s.\n",
buffer, context, data, wined3d_debug_location(locations));
if (locations & WINED3D_LOCATION_DISCARDED)
{
locations = ((buffer->flags & WINED3D_BUFFER_USE_BO) ? WINED3D_LOCATION_BUFFER : WINED3D_LOCATION_SYSMEM);
if (!wined3d_buffer_prepare_location(buffer, context, locations))
{
data->buffer_object = 0;
data->addr = NULL;
return 0;
}
wined3d_buffer_validate_location(buffer, locations);
wined3d_buffer_invalidate_location(buffer, WINED3D_LOCATION_DISCARDED);
}
if (locations & WINED3D_LOCATION_BUFFER)
{
data->buffer_object = buffer->buffer_object;
......@@ -1006,13 +1019,14 @@ void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_off
TRACE("dst_buffer %p, dst_offset %u, src_buffer %p, src_offset %u, size %u.\n",
dst_buffer, dst_offset, src_buffer, src_offset, size);
dst_location = wined3d_buffer_get_memory(dst_buffer, &dst);
context = context_acquire(dst_buffer->resource.device, NULL, 0);
dst_location = wined3d_buffer_get_memory(dst_buffer, context, &dst);
dst.addr += dst_offset;
wined3d_buffer_get_memory(src_buffer, &src);
wined3d_buffer_get_memory(src_buffer, context, &src);
src.addr += src_offset;
context = context_acquire(dst_buffer->resource.device, NULL, 0);
wined3d_context_copy_bo_address(context, &dst, &src, size);
context_release(context);
......
......@@ -304,7 +304,7 @@ void context_update_stream_info(struct wined3d_context *context, const struct wi
else
{
wined3d_buffer_load(buffer, context, state);
wined3d_buffer_get_memory(buffer, &data);
wined3d_buffer_get_memory(buffer, context, &data);
element->data.buffer_object = data.buffer_object;
element->data.addr += (ULONG_PTR)data.addr;
}
......
......@@ -1611,7 +1611,7 @@ void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_
if (!view->counter_bo)
return;
dst_location = wined3d_buffer_get_memory(buffer, &dst);
dst_location = wined3d_buffer_get_memory(buffer, context, &dst);
dst.addr += offset;
src.buffer_object = view->counter_bo;
......
......@@ -4899,7 +4899,8 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc
void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
void 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;
DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_bo_address *data) DECLSPEC_HIDDEN;
DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context,
struct wined3d_bo_address *data) 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;
......
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