Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always enable storage image usage for non-RTV 2D images #1806

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/vkd3d/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -8464,7 +8464,7 @@ enum vkd3d_resolve_image_path d3d12_command_list_select_resolve_path(struct d3d1
}
}

if (dst_resource->desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)
if (dst_resource->flags & VKD3D_RESOURCE_STORAGE_IMAGE)
{
/* Use the compute path if we need to use a pipeline anyway, or if
* the destination image does not support render target usage. */
Expand Down
13 changes: 13 additions & 0 deletions libs/vkd3d/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,16 @@ static HRESULT vkd3d_get_image_create_info(struct d3d12_device *device,
if (!(desc->Flags & D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE) || desc->SampleDesc.Count > 1)
image_info->usage |= VK_IMAGE_USAGE_SAMPLED_BIT;

/* Add storage image usage if the image cannot be rendered to, but may
* be used as a destination image for multisample resolves. */
if (desc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && desc->SampleDesc.Count == 1 &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be safe to land this if we check for AMD or NVIDIA for now. I'm still concerned about e.g. Intel/Turnip.

!(image_info->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) &&
(format->vk_aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT) &&
(format->vk_format_features & VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT) &&
(format->vk_format_features & VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT) &&
(!heap_properties || !is_cpu_accessible_heap(heap_properties)))
image_info->usage |= VK_IMAGE_USAGE_STORAGE_BIT;

/* Additional usage flags for shader-based copies */
if (vkd3d_format_allows_shader_copies(format->dxgi_format))
{
Expand Down Expand Up @@ -873,6 +883,9 @@ static HRESULT vkd3d_get_image_create_info(struct d3d12_device *device,
{
resource->common_layout = vk_common_image_layout_from_d3d12_desc(device, desc);
}

if (image_info->usage & VK_IMAGE_USAGE_STORAGE_BIT)
resource->flags |= VKD3D_RESOURCE_STORAGE_IMAGE;
}

return S_OK;
Expand Down
1 change: 1 addition & 0 deletions libs/vkd3d/vkd3d_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ enum vkd3d_resource_flag
VKD3D_RESOURCE_EXTERNAL = (1u << 5),
VKD3D_RESOURCE_ACCELERATION_STRUCTURE = (1u << 6),
VKD3D_RESOURCE_GENERAL_LAYOUT = (1u << 7),
VKD3D_RESOURCE_STORAGE_IMAGE = (1u << 8),
};

struct d3d12_sparse_image_region
Expand Down
Loading