wined3d: Use a single allocation for command list data.
Signed-off-by: Jan Sikorski <jsikorski@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
be00048203
commit
89d61c28e4
|
@ -76,11 +76,6 @@ static void wined3d_command_list_destroy_object(void *object)
|
||||||
for (i = 0; i < list->upload_count; ++i)
|
for (i = 0; i < list->upload_count; ++i)
|
||||||
heap_free(list->uploads[i].sysmem);
|
heap_free(list->uploads[i].sysmem);
|
||||||
|
|
||||||
heap_free(list->command_lists);
|
|
||||||
heap_free(list->uploads);
|
|
||||||
heap_free(list->resources);
|
|
||||||
heap_free(list->data);
|
|
||||||
heap_free(list->queries);
|
|
||||||
heap_free(list);
|
heap_free(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3734,45 +3729,54 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
|
||||||
{
|
{
|
||||||
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
|
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
|
||||||
struct wined3d_command_list *object;
|
struct wined3d_command_list *object;
|
||||||
|
void *memory;
|
||||||
|
|
||||||
TRACE("context %p, list %p.\n", context, list);
|
TRACE("context %p, list %p.\n", context, list);
|
||||||
|
|
||||||
if (!(object = heap_alloc_zero(sizeof(*object))))
|
memory = heap_alloc(sizeof(*object) + deferred->resource_count * sizeof(*object->resources)
|
||||||
|
+ deferred->upload_count * sizeof(*object->uploads)
|
||||||
|
+ deferred->command_list_count * sizeof(*object->command_lists)
|
||||||
|
+ deferred->query_count * sizeof(*object->queries)
|
||||||
|
+ deferred->data_size);
|
||||||
|
|
||||||
|
if (!memory)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
object = memory;
|
||||||
|
memory = &object[1];
|
||||||
|
memset(object, 0, sizeof(*object));
|
||||||
object->refcount = 1;
|
object->refcount = 1;
|
||||||
object->device = deferred->c.device;
|
object->device = deferred->c.device;
|
||||||
|
|
||||||
if (!(object->data = heap_alloc(deferred->data_size)))
|
object->resources = memory;
|
||||||
goto out_free_list;
|
memory = &object->resources[deferred->resource_count];
|
||||||
object->data_size = deferred->data_size;
|
|
||||||
memcpy(object->data, deferred->data, deferred->data_size);
|
|
||||||
|
|
||||||
if (!(object->resources = heap_alloc(deferred->resource_count * sizeof(*object->resources))))
|
|
||||||
goto out_free_data;
|
|
||||||
object->resource_count = deferred->resource_count;
|
object->resource_count = deferred->resource_count;
|
||||||
memcpy(object->resources, deferred->resources, deferred->resource_count * sizeof(*object->resources));
|
memcpy(object->resources, deferred->resources, deferred->resource_count * sizeof(*object->resources));
|
||||||
/* Transfer our references to the resources to the command list. */
|
/* Transfer our references to the resources to the command list. */
|
||||||
|
|
||||||
if (!(object->uploads = heap_alloc(deferred->upload_count * sizeof(*object->uploads))))
|
object->uploads = memory;
|
||||||
goto out_free_resources;
|
memory = &object->uploads[deferred->upload_count];
|
||||||
object->upload_count = deferred->upload_count;
|
object->upload_count = deferred->upload_count;
|
||||||
memcpy(object->uploads, deferred->uploads, deferred->upload_count * sizeof(*object->uploads));
|
memcpy(object->uploads, deferred->uploads, deferred->upload_count * sizeof(*object->uploads));
|
||||||
/* Transfer our references to the resources to the command list. */
|
/* Transfer our references to the resources to the command list. */
|
||||||
|
|
||||||
if (!(object->command_lists = heap_alloc(deferred->command_list_count * sizeof(*object->command_lists))))
|
object->command_lists = memory;
|
||||||
goto out_free_uploads;
|
memory = &object->command_lists[deferred->command_list_count];
|
||||||
object->command_list_count = deferred->command_list_count;
|
object->command_list_count = deferred->command_list_count;
|
||||||
memcpy(object->command_lists, deferred->command_lists,
|
memcpy(object->command_lists, deferred->command_lists,
|
||||||
deferred->command_list_count * sizeof(*object->command_lists));
|
deferred->command_list_count * sizeof(*object->command_lists));
|
||||||
/* Transfer our references to the command lists to the command list. */
|
/* Transfer our references to the command lists to the command list. */
|
||||||
|
|
||||||
if (!(object->queries = heap_alloc(deferred->query_count * sizeof(*object->queries))))
|
object->queries = memory;
|
||||||
goto out_free_command_lists;
|
memory = &object->queries[deferred->query_count];
|
||||||
object->query_count = deferred->query_count;
|
object->query_count = deferred->query_count;
|
||||||
memcpy(object->queries, deferred->queries, deferred->query_count * sizeof(*object->queries));
|
memcpy(object->queries, deferred->queries, deferred->query_count * sizeof(*object->queries));
|
||||||
/* Transfer our references to the queries to the command list. */
|
/* Transfer our references to the queries to the command list. */
|
||||||
|
|
||||||
|
object->data = memory;
|
||||||
|
object->data_size = deferred->data_size;
|
||||||
|
memcpy(object->data, deferred->data, deferred->data_size);
|
||||||
|
|
||||||
deferred->data_size = 0;
|
deferred->data_size = 0;
|
||||||
deferred->resource_count = 0;
|
deferred->resource_count = 0;
|
||||||
deferred->upload_count = 0;
|
deferred->upload_count = 0;
|
||||||
|
@ -3789,16 +3793,4 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
|
||||||
*list = object;
|
*list = object;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
out_free_command_lists:
|
|
||||||
heap_free(object->command_lists);
|
|
||||||
out_free_uploads:
|
|
||||||
heap_free(object->uploads);
|
|
||||||
out_free_resources:
|
|
||||||
heap_free(object->resources);
|
|
||||||
out_free_data:
|
|
||||||
heap_free(object->data);
|
|
||||||
out_free_list:
|
|
||||||
heap_free(object);
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue