mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 11:19:26 +00:00
wined3d: Treat NOOVERWRITE maps on a previously discarded buffer as if they were DISCARD maps.
For the purposes of wined3d_cs_map_upload_bo(). That is, if a buffer was just created or just discarded [e.g. with wined3d_device_evict_managed_resources()], and then subsequently mapped with WINED3D_MAP_NOOVERWRITE, treat it as if it had been mapped with WINED3D_MAP_DISCARD instead, thus allowing the adapter_alloc_upload_bo callback to allocate a new buffer from the client thread. This was the source of a bunch of stalls in Grand Theft Auto V, although it's hard to measure a difference in performance. Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1b1b03055d
commit
83fc1807f9
|
@ -1321,6 +1321,9 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d
|
|||
}
|
||||
buffer->maps_size = 1;
|
||||
|
||||
if (buffer->locations & WINED3D_LOCATION_DISCARDED)
|
||||
buffer->resource.client.addr.buffer_object = CLIENT_BO_DISCARDED;
|
||||
|
||||
if (data)
|
||||
wined3d_buffer_init_data(buffer, device, data);
|
||||
|
||||
|
|
|
@ -67,6 +67,14 @@ struct wined3d_command_list
|
|||
struct wined3d_deferred_query_issue *queries;
|
||||
};
|
||||
|
||||
static void discard_client_address(struct wined3d_resource *resource)
|
||||
{
|
||||
struct wined3d_client_resource *client = &resource->client;
|
||||
|
||||
client->addr.buffer_object = CLIENT_BO_DISCARDED;
|
||||
client->addr.addr = NULL;
|
||||
}
|
||||
|
||||
static void invalidate_client_address(struct wined3d_resource *resource)
|
||||
{
|
||||
struct wined3d_client_resource *client = &resource->client;
|
||||
|
@ -2430,7 +2438,7 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou
|
|||
{
|
||||
struct wined3d_cs_unload_resource *op;
|
||||
|
||||
invalidate_client_address(resource);
|
||||
discard_client_address(resource);
|
||||
|
||||
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
|
||||
op->opcode = WINED3D_CS_OP_UNLOAD_RESOURCE;
|
||||
|
@ -3134,6 +3142,9 @@ static bool wined3d_cs_map_upload_bo(struct wined3d_device_context *context, str
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if ((flags & WINED3D_MAP_NOOVERWRITE) && client->addr.buffer_object == CLIENT_BO_DISCARDED)
|
||||
flags = (flags & ~WINED3D_MAP_NOOVERWRITE) | WINED3D_MAP_DISCARD;
|
||||
|
||||
if (flags & WINED3D_MAP_DISCARD)
|
||||
{
|
||||
if (!device->adapter->adapter_ops->adapter_alloc_bo(device, resource, sub_resource_idx, &addr))
|
||||
|
|
|
@ -4276,6 +4276,8 @@ static inline ULONG wined3d_atomic_decrement_mutex_lock(volatile LONG *refcount)
|
|||
return count - 1;
|
||||
}
|
||||
|
||||
#define CLIENT_BO_DISCARDED ((struct wined3d_bo *)~(UINT_PTR)0)
|
||||
|
||||
struct wined3d_client_resource
|
||||
{
|
||||
/* The resource's persistently mapped address, which we may use to perform
|
||||
|
|
Loading…
Reference in a new issue