Skip to content

Commit 5d9f7d8

Browse files
committed
vkd3d: Enable storage image usage for potential resolve destinations.
This allows multisample resolves to be performed on resources which do not support render target usage. Signed-off-by: Philip Rebohle <[email protected]>
1 parent 0ed7f6b commit 5d9f7d8

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

libs/vkd3d/command.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8464,7 +8464,7 @@ enum vkd3d_resolve_image_path d3d12_command_list_select_resolve_path(struct d3d1
84648464
}
84658465
}
84668466

8467-
if (dst_resource->desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)
8467+
if (dst_resource->flags & VKD3D_RESOURCE_STORAGE_IMAGE)
84688468
{
84698469
/* Use the compute path if we need to use a pipeline anyway, or if
84708470
* the destination image does not support render target usage. */

libs/vkd3d/resource.c

+13
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,16 @@ static HRESULT vkd3d_get_image_create_info(struct d3d12_device *device,
774774
if (!(desc->Flags & D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE) || desc->SampleDesc.Count > 1)
775775
image_info->usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
776776

777+
/* Add storage image usage if the image cannot be rendered to, but may
778+
* be used as a destination image for multisample resolves. */
779+
if (desc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && desc->SampleDesc.Count == 1 &&
780+
!(image_info->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) &&
781+
(format->vk_aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT) &&
782+
(format->vk_format_features & VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT) &&
783+
(format->vk_format_features & VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT) &&
784+
(!heap_properties || !is_cpu_accessible_heap(heap_properties)))
785+
image_info->usage |= VK_IMAGE_USAGE_STORAGE_BIT;
786+
777787
/* Additional usage flags for shader-based copies */
778788
if (vkd3d_format_allows_shader_copies(format->dxgi_format))
779789
{
@@ -873,6 +883,9 @@ static HRESULT vkd3d_get_image_create_info(struct d3d12_device *device,
873883
{
874884
resource->common_layout = vk_common_image_layout_from_d3d12_desc(device, desc);
875885
}
886+
887+
if (image_info->usage & VK_IMAGE_USAGE_STORAGE_BIT)
888+
resource->flags |= VKD3D_RESOURCE_STORAGE_IMAGE;
876889
}
877890

878891
return S_OK;

libs/vkd3d/vkd3d_private.h

+1
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ enum vkd3d_resource_flag
877877
VKD3D_RESOURCE_EXTERNAL = (1u << 5),
878878
VKD3D_RESOURCE_ACCELERATION_STRUCTURE = (1u << 6),
879879
VKD3D_RESOURCE_GENERAL_LAYOUT = (1u << 7),
880+
VKD3D_RESOURCE_STORAGE_IMAGE = (1u << 8),
880881
};
881882

882883
struct d3d12_sparse_image_region

0 commit comments

Comments
 (0)