[PATCH 1/3] wined3d: Handle discarded buffers in buffer_resource_sub_resource_map().
Zebediah Figura
zfigura at codeweavers.com
Mon Jan 24 20:20:37 CST 2022
This is essentially dead code currently; we never leave buffers in a discarded
state.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/wined3d/buffer.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index b42c7bd919a..e1c1f7aa5fc 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -915,6 +915,7 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
struct wined3d_buffer *buffer = buffer_from_resource(resource);
struct wined3d_device *device = resource->device;
struct wined3d_context *context;
+ struct wined3d_bo_address addr;
unsigned int offset, size;
uint8_t *base;
LONG count;
@@ -927,10 +928,13 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
count = ++resource->map_count;
- if (buffer->buffer_object)
+ context = context_acquire(device, NULL, 0);
+
+ wined3d_buffer_get_memory(buffer, context, &addr);
+
+ if (addr.buffer_object)
{
unsigned int dirty_offset = offset, dirty_size = size;
- struct wined3d_bo_address addr;
/* DISCARD invalidates the entire buffer, regardless of the specified
* offset and size. Some applications also depend on the entire buffer
@@ -946,20 +950,13 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
|| (!(flags & WINED3D_MAP_WRITE) && (buffer->locations & WINED3D_LOCATION_SYSMEM))
|| buffer->flags & WINED3D_BUFFER_PIN_SYSMEM)
{
- if (!(buffer->locations & WINED3D_LOCATION_SYSMEM))
- {
- context = context_acquire(device, NULL, 0);
- wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_SYSMEM);
- context_release(context);
- }
+ wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_SYSMEM);
if (flags & WINED3D_MAP_WRITE)
wined3d_buffer_invalidate_range(buffer, WINED3D_LOCATION_BUFFER, dirty_offset, dirty_size);
}
else
{
- context = context_acquire(device, NULL, 0);
-
if (flags & WINED3D_MAP_DISCARD)
wined3d_buffer_validate_location(buffer, WINED3D_LOCATION_BUFFER);
else
@@ -976,8 +973,6 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
if (count == 1)
{
- addr.buffer_object = buffer->buffer_object;
- addr.addr = 0;
buffer->map_ptr = wined3d_context_map_bo_address(context, &addr, resource->size, flags);
/* We are accessing buffer->resource.client from the CS thread,
* but it's safe because the client thread will wait for the
@@ -1009,11 +1004,11 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
TRACE("New pointer is %p.\n", resource->heap_memory);
}
}
-
- context_release(context);
}
}
+ context_release(context);
+
base = buffer->map_ptr ? buffer->map_ptr : resource->heap_memory;
*map_ptr = base + offset;
--
2.34.1
More information about the wine-devel
mailing list