Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/cs.c | 56 +++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 31 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 839853840e9..dbc277a491f 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -75,11 +75,6 @@ static void wined3d_command_list_destroy_object(void *object) for (i = 0; i < list->upload_count; ++i) 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); }
@@ -3735,45 +3730,56 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device { struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context); struct wined3d_command_list *object; + size_t offset; + BYTE *memory;
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;
+ object = (void *)memory; + offset = sizeof(*object); + memset(object, 0, sizeof(*object)); + object->refcount = 1; object->device = deferred->c.device;
- if (!(object->data = heap_alloc(deferred->data_size))) - goto out_free_list; - 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->resources = (void *)(memory + offset); + offset += deferred->resource_count * sizeof(*object->resources); object->resource_count = deferred->resource_count; memcpy(object->resources, deferred->resources, deferred->resource_count * sizeof(*object->resources)); /* Transfer our references to the resources to the command list. */
- if (!(object->uploads = heap_alloc(deferred->upload_count * sizeof(*object->uploads)))) - goto out_free_resources; + object->uploads = (void *)(memory + offset); + offset += deferred->upload_count * sizeof(*object->uploads); object->upload_count = deferred->upload_count; memcpy(object->uploads, deferred->uploads, deferred->upload_count * sizeof(*object->uploads)); /* Transfer our references to the resources to the command list. */
- if (!(object->command_lists = heap_alloc(deferred->command_list_count * sizeof(*object->command_lists)))) - goto out_free_uploads; + object->command_lists = (void *)(memory + offset); + offset += deferred->command_list_count * sizeof(*object->command_lists); object->command_list_count = deferred->command_list_count; memcpy(object->command_lists, deferred->command_lists, deferred->command_list_count * sizeof(*object->command_lists)); /* Transfer our references to the command lists to the command list. */
- if (!(object->queries = heap_alloc(deferred->query_count * sizeof(*object->queries)))) - goto out_free_command_lists; + object->queries = (void *)(memory + offset); + offset += deferred->query_count * sizeof(*object->queries); object->query_count = deferred->query_count; memcpy(object->queries, deferred->queries, deferred->query_count * sizeof(*object->queries)); /* Transfer our references to the queries to the command list. */
+ object->data = (void *)(memory + offset); + object->data_size = deferred->data_size; + memcpy(object->data, deferred->data, deferred->data_size); + deferred->data_size = 0; deferred->resource_count = 0; deferred->upload_count = 0; @@ -3790,16 +3796,4 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device *list = object;
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; }