vkd3d: Expose the image view usage to Vulkan.

This prevents a failure with MoltenVK, which is not able to
create 2D-array view for any usage other than color attachment.
This commit is contained in:
Giovanni Mascellani 2023-09-21 23:10:25 +02:00 committed by Alexandre Julliard
parent 2dd4211b77
commit 83ddfb9e8d
Notes: Alexandre Julliard 2023-09-26 22:48:16 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/365
4 changed files with 22 additions and 0 deletions

View File

@ -5462,6 +5462,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID
view_desc.layer_idx = view->info.texture.layer_idx;
view_desc.layer_count = view->info.texture.layer_count;
view_desc.vk_image_aspect = VK_IMAGE_ASPECT_COLOR_BIT;
view_desc.usage = VK_IMAGE_USAGE_STORAGE_BIT;
if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_UAV, resource_impl->u.vk_image, &view_desc,
&uint_view))

View File

@ -83,6 +83,7 @@ static const struct vkd3d_optional_extension_info optional_device_extensions[] =
VK_EXTENSION(KHR_DRAW_INDIRECT_COUNT, KHR_draw_indirect_count),
VK_EXTENSION(KHR_GET_MEMORY_REQUIREMENTS_2, KHR_get_memory_requirements2),
VK_EXTENSION(KHR_IMAGE_FORMAT_LIST, KHR_image_format_list),
VK_EXTENSION(KHR_MAINTENANCE2, KHR_maintenance2),
VK_EXTENSION(KHR_MAINTENANCE3, KHR_maintenance3),
VK_EXTENSION(KHR_PUSH_DESCRIPTOR, KHR_push_descriptor),
VK_EXTENSION(KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE, KHR_sampler_mirror_clamp_to_edge),

View File

@ -2998,6 +2998,7 @@ static bool init_default_texture_view_desc(struct vkd3d_texture_view_desc *desc,
desc->components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
desc->components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
desc->allowed_swizzle = false;
desc->usage = 0;
return true;
}
@ -3039,6 +3040,7 @@ bool vkd3d_create_texture_view(struct d3d12_device *device, uint32_t magic, VkIm
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
const struct vkd3d_format *format = desc->format;
VkImageViewUsageCreateInfoKHR usage_desc;
struct VkImageViewCreateInfo view_desc;
VkImageView vk_view = VK_NULL_HANDLE;
struct vkd3d_view *object;
@ -3060,6 +3062,13 @@ bool vkd3d_create_texture_view(struct d3d12_device *device, uint32_t magic, VkIm
view_desc.subresourceRange.levelCount = desc->miplevel_count;
view_desc.subresourceRange.baseArrayLayer = desc->layer_idx;
view_desc.subresourceRange.layerCount = desc->layer_count;
if (device->vk_info.KHR_maintenance2)
{
usage_desc.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO;
usage_desc.pNext = NULL;
usage_desc.usage = desc->usage;
view_desc.pNext = &usage_desc;
}
if ((vr = VK_CALL(vkCreateImageView(device->vk_device, &view_desc, NULL, &vk_view))) < 0)
{
WARN("Failed to create Vulkan image view, vr %d.\n", vr);
@ -3196,6 +3205,7 @@ static void vkd3d_create_null_srv(struct d3d12_desc *descriptor,
vkd3d_desc.components.b = VK_COMPONENT_SWIZZLE_ZERO;
vkd3d_desc.components.a = VK_COMPONENT_SWIZZLE_ZERO;
vkd3d_desc.allowed_swizzle = true;
vkd3d_desc.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_SRV, vk_image, &vkd3d_desc, &descriptor->s.u.view);
}
@ -3268,6 +3278,7 @@ void d3d12_desc_create_srv(struct d3d12_desc *descriptor,
vkd3d_desc.miplevel_count = VK_REMAINING_MIP_LEVELS;
vkd3d_desc.allowed_swizzle = true;
vkd3d_desc.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
if (desc)
{
@ -3421,6 +3432,7 @@ static void vkd3d_create_null_uav(struct d3d12_desc *descriptor,
vkd3d_desc.components.b = VK_COMPONENT_SWIZZLE_B;
vkd3d_desc.components.a = VK_COMPONENT_SWIZZLE_A;
vkd3d_desc.allowed_swizzle = false;
vkd3d_desc.usage = VK_IMAGE_USAGE_STORAGE_BIT;
vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_UAV, vk_image, &vkd3d_desc, &descriptor->s.u.view);
}
@ -3480,6 +3492,8 @@ static void vkd3d_create_texture_uav(struct d3d12_desc *descriptor,
if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
return;
vkd3d_desc.usage = VK_IMAGE_USAGE_STORAGE_BIT;
if (vkd3d_format_is_compressed(vkd3d_desc.format))
{
WARN("UAVs cannot be created for compressed formats.\n");
@ -3747,6 +3761,8 @@ void d3d12_rtv_desc_create_rtv(struct d3d12_rtv_desc *rtv_desc, struct d3d12_dev
if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
return;
vkd3d_desc.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
if (vkd3d_desc.format->vk_aspect_mask != VK_IMAGE_ASPECT_COLOR_BIT)
{
WARN("Trying to create RTV for depth/stencil format %#x.\n", vkd3d_desc.format->dxgi_format);
@ -3847,6 +3863,8 @@ void d3d12_dsv_desc_create_dsv(struct d3d12_dsv_desc *dsv_desc, struct d3d12_dev
if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
return;
vkd3d_desc.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
if (!(vkd3d_desc.format->vk_aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)))
{
WARN("Trying to create DSV for format %#x.\n", vkd3d_desc.format->dxgi_format);

View File

@ -121,6 +121,7 @@ struct vkd3d_vulkan_info
bool KHR_draw_indirect_count;
bool KHR_get_memory_requirements2;
bool KHR_image_format_list;
bool KHR_maintenance2;
bool KHR_maintenance3;
bool KHR_push_descriptor;
bool KHR_sampler_mirror_clamp_to_edge;
@ -835,6 +836,7 @@ struct vkd3d_texture_view_desc
VkImageAspectFlags vk_image_aspect;
VkComponentMapping components;
bool allowed_swizzle;
VkImageUsageFlags usage;
};
struct vkd3d_desc_header