From 7c8ce3c51c156a5f0fddd438a4dbe30d67ca4c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 7 May 2019 15:37:01 +0200 Subject: [PATCH] vkd3d: Pass device to vkd3d_format_from_d3d12_resource_desc(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d/command.c | 34 ++++++++++++++++++++-------------- libs/vkd3d/device.c | 5 +++-- libs/vkd3d/resource.c | 8 +++++--- libs/vkd3d/vkd3d_private.h | 2 +- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 960d3be4..57415deb 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -2029,7 +2029,7 @@ static void d3d12_command_list_transition_resource_to_initial_state(struct d3d12 assert(d3d12_resource_is_texture(resource)); - if (!(format = vkd3d_format_from_d3d12_resource_desc(&resource->desc, 0))) + if (!(format = vkd3d_format_from_d3d12_resource_desc(list->device, &resource->desc, 0))) { ERR("Resource %p has invalid format %#x.\n", resource, resource->desc.Format); return; @@ -3226,8 +3226,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic assert(d3d12_resource_is_buffer(dst_resource)); assert(d3d12_resource_is_texture(src_resource)); - if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&src_resource->desc, - dst->u.PlacedFootprint.Footprint.Format))) + if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(list->device, + &src_resource->desc, dst->u.PlacedFootprint.Footprint.Format))) { WARN("Invalid format %#x.\n", dst->u.PlacedFootprint.Footprint.Format); return; @@ -3249,8 +3249,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic assert(d3d12_resource_is_texture(dst_resource)); assert(d3d12_resource_is_buffer(src_resource)); - if (!(src_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, - src->u.PlacedFootprint.Footprint.Format))) + if (!(src_format = vkd3d_format_from_d3d12_resource_desc(list->device, + &dst_resource->desc, src->u.PlacedFootprint.Footprint.Format))) { WARN("Invalid format %#x.\n", src->u.PlacedFootprint.Footprint.Format); return; @@ -3272,12 +3272,14 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic assert(d3d12_resource_is_texture(dst_resource)); assert(d3d12_resource_is_texture(src_resource)); - if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, DXGI_FORMAT_UNKNOWN))) + if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(list->device, + &dst_resource->desc, DXGI_FORMAT_UNKNOWN))) { WARN("Invalid format %#x.\n", dst_resource->desc.Format); return; } - if (!(src_format = vkd3d_format_from_d3d12_resource_desc(&src_resource->desc, DXGI_FORMAT_UNKNOWN))) + if (!(src_format = vkd3d_format_from_d3d12_resource_desc(list->device, + &src_resource->desc, DXGI_FORMAT_UNKNOWN))) { WARN("Invalid format %#x.\n", src_resource->desc.Format); return; @@ -3348,12 +3350,14 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyResource(ID3D12GraphicsComm } else { - if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, DXGI_FORMAT_UNKNOWN))) + if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(list->device, + &dst_resource->desc, DXGI_FORMAT_UNKNOWN))) { WARN("Invalid format %#x.\n", dst_resource->desc.Format); return; } - if (!(src_format = vkd3d_format_from_d3d12_resource_desc(&src_resource->desc, DXGI_FORMAT_UNKNOWN))) + if (!(src_format = vkd3d_format_from_d3d12_resource_desc(list->device, + &src_resource->desc, DXGI_FORMAT_UNKNOWN))) { WARN("Invalid format %#x.\n", src_resource->desc.Format); return; @@ -3398,12 +3402,14 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresource(ID3D12Graphi const struct vkd3d_format *src_format, *dst_format, *vk_format; struct d3d12_resource *dst_resource, *src_resource; const struct vkd3d_vk_device_procs *vk_procs; + const struct d3d12_device *device; VkImageResolve vk_image_resolve; TRACE("iface %p, dst_resource %p, dst_sub_resource_idx %u, src_resource %p, src_sub_resource_idx %u, " "format %#x.\n", iface, dst, dst_sub_resource_idx, src, src_sub_resource_idx, format); - vk_procs = &list->device->vk_procs; + device = list->device; + vk_procs = &device->vk_procs; dst_resource = unsafe_impl_from_ID3D12Resource(dst); src_resource = unsafe_impl_from_ID3D12Resource(src); @@ -3416,12 +3422,12 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresource(ID3D12Graphi d3d12_command_list_end_current_render_pass(list); - if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, DXGI_FORMAT_UNKNOWN))) + if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(device, &dst_resource->desc, DXGI_FORMAT_UNKNOWN))) { WARN("Invalid format %#x.\n", dst_resource->desc.Format); return; } - if (!(src_format = vkd3d_format_from_d3d12_resource_desc(&src_resource->desc, DXGI_FORMAT_UNKNOWN))) + if (!(src_format = vkd3d_format_from_d3d12_resource_desc(device, &src_resource->desc, DXGI_FORMAT_UNKNOWN))) { WARN("Invalid format %#x.\n", src_resource->desc.Format); return; @@ -3429,7 +3435,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresource(ID3D12Graphi if (dxgi_format_is_typeless(dst_resource->desc.Format) || dxgi_format_is_typeless(src_resource->desc.Format)) { - if (!(vk_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, format))) + if (!(vk_format = vkd3d_format_from_d3d12_resource_desc(device, &dst_resource->desc, format))) { WARN("Invalid format %#x.\n", format); return; @@ -3736,7 +3742,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsC const struct vkd3d_format *format; VkImageMemoryBarrier vk_barrier; - if (!(format = vkd3d_format_from_d3d12_resource_desc(&resource->desc, 0))) + if (!(format = vkd3d_format_from_d3d12_resource_desc(list->device, &resource->desc, 0))) { ERR("Resource %p has invalid format %#x.\n", resource, resource->desc.Format); continue; diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index cb2934a2..b1f320b9 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -2631,7 +2631,7 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour if (info->Alignment < D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT) { - if (!(format = vkd3d_format_from_d3d12_resource_desc(desc, 0))) + if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0))) { WARN("Invalid format %#x.\n", desc->Format); goto invalid; @@ -2840,6 +2840,7 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i UINT64 base_offset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts, UINT *row_counts, UINT64 *row_sizes, UINT64 *total_bytes) { + struct d3d12_device *device = impl_from_ID3D12Device(iface); static const struct vkd3d_format vkd3d_format_unknown = {DXGI_FORMAT_UNKNOWN, VK_FORMAT_UNDEFINED, 1, 1, 1, 1, 0}; @@ -2866,7 +2867,7 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i { format = &vkd3d_format_unknown; } - else if (!(format = vkd3d_format_from_d3d12_resource_desc(desc, 0))) + else if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0))) { WARN("Invalid format %#x.\n", desc->Format); return; diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index aba850f2..b0a9c9ae 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -577,7 +577,7 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device, VkImageCreateInfo image_info; VkResult vr; - if (!(format = vkd3d_format_from_d3d12_resource_desc(desc, 0))) + if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0))) { WARN("Invalid DXGI format %#x.\n", desc->Format); return E_INVALIDARG; @@ -1709,7 +1709,7 @@ static bool vkd3d_create_buffer_view(struct d3d12_device *device, format = vkd3d_get_format(DXGI_FORMAT_R32_UINT, false); element_size = structure_stride; } - else if ((format = vkd3d_format_from_d3d12_resource_desc(&resource->desc, view_format))) + else if ((format = vkd3d_format_from_d3d12_resource_desc(device, &resource->desc, view_format))) { element_size = format->byte_count; } @@ -1888,7 +1888,9 @@ struct vkd3d_texture_view_desc static bool init_default_texture_view_desc(struct vkd3d_texture_view_desc *desc, struct d3d12_resource *resource, DXGI_FORMAT view_format) { - if (!(desc->format = vkd3d_format_from_d3d12_resource_desc(&resource->desc, view_format))) + const struct d3d12_device *device = resource->device; + + if (!(desc->format = vkd3d_format_from_d3d12_resource_desc(device, &resource->desc, view_format))) { FIXME("Failed to find format (resource format %#x, view format %#x).\n", resource->desc.Format, view_format); diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 8314298e..0de0abf6 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -1039,7 +1039,7 @@ const struct vkd3d_format *vkd3d_get_format(DXGI_FORMAT dxgi_format, bool depth_ bool dxgi_format_is_typeless(DXGI_FORMAT dxgi_format) DECLSPEC_HIDDEN; static inline const struct vkd3d_format *vkd3d_format_from_d3d12_resource_desc( - const D3D12_RESOURCE_DESC *desc, DXGI_FORMAT view_format) + const struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc, DXGI_FORMAT view_format) { return vkd3d_get_format(view_format ? view_format : desc->Format, desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL);