From 3dd8683ec5ee2ef2ae2d50c530cd75665b25527a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 12 Sep 2018 15:19:52 +0200 Subject: [PATCH] vkd3d: Pass VkImage to vkd3d_allocate_image_memory(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For consistency with vkd3d_allocate_buffer_memory(). Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d/resource.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 219b95c3..37c8dff2 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -501,27 +501,25 @@ HRESULT vkd3d_allocate_buffer_memory(struct d3d12_device *device, VkBuffer vk_bu return S_OK; } -static HRESULT vkd3d_allocate_image_memory(struct d3d12_resource *resource, struct d3d12_device *device, - const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags) +static HRESULT vkd3d_allocate_image_memory(struct d3d12_device *device, VkImage vk_image, + const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, + VkDeviceMemory *vk_memory) { const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; VkMemoryRequirements memory_requirements; VkResult vr; HRESULT hr; - assert(D3D12_RESOURCE_DIMENSION_TEXTURE1D <= resource->desc.Dimension - && resource->desc.Dimension <= D3D12_RESOURCE_DIMENSION_TEXTURE3D); - - VK_CALL(vkGetImageMemoryRequirements(device->vk_device, resource->u.vk_image, &memory_requirements)); + VK_CALL(vkGetImageMemoryRequirements(device->vk_device, vk_image, &memory_requirements)); if (FAILED(hr = vkd3d_allocate_device_memory(device, heap_properties, heap_flags, - &memory_requirements, &resource->vk_memory))) + &memory_requirements, vk_memory))) return hr; - if ((vr = VK_CALL(vkBindImageMemory(device->vk_device, resource->u.vk_image, resource->vk_memory, 0))) < 0) + if ((vr = VK_CALL(vkBindImageMemory(device->vk_device, vk_image, *vk_memory, 0))) < 0) { WARN("Failed to bind memory, vr %d.\n", vr); - VK_CALL(vkFreeMemory(device->vk_device, resource->vk_memory, NULL)); - resource->vk_memory = VK_NULL_HANDLE; + VK_CALL(vkFreeMemory(device->vk_device, *vk_memory, NULL)); + *vk_memory = VK_NULL_HANDLE; return hresult_from_vk_result(vr); } @@ -977,7 +975,8 @@ static HRESULT d3d12_committed_resource_init(struct d3d12_resource *resource, st resource->flags |= VKD3D_RESOURCE_INITIAL_STATE_TRANSITION; if (FAILED(hr = vkd3d_create_image(resource, device, heap_properties, heap_flags))) return hr; - if (FAILED(hr = vkd3d_allocate_image_memory(resource, device, heap_properties, heap_flags))) + if (FAILED(hr = vkd3d_allocate_image_memory(device, resource->u.vk_image, + heap_properties, heap_flags, &resource->vk_memory))) { d3d12_resource_destroy(resource, device); return hr;