mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d: Always use UINT views to clear UAVs with integer formats.
We would previously try to use float pipelines for SINT formats.
This commit is contained in:
parent
a54187f3c9
commit
90f26759b5
Notes:
Henri Verbeet
2024-06-14 00:05:12 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/850
@ -5434,6 +5434,52 @@ static const struct vkd3d_format *vkd3d_fixup_clear_uav_uint_colour(struct d3d12
|
||||
}
|
||||
}
|
||||
|
||||
static struct vkd3d_view *create_uint_view(struct d3d12_device *device, const struct vkd3d_resource_view *view,
|
||||
struct d3d12_resource *resource, VkClearColorValue *colour)
|
||||
{
|
||||
struct vkd3d_texture_view_desc view_desc;
|
||||
const struct vkd3d_format *uint_format;
|
||||
struct vkd3d_view *uint_view;
|
||||
|
||||
if (!(uint_format = vkd3d_find_uint_format(device, view->format->dxgi_format))
|
||||
&& !(uint_format = vkd3d_fixup_clear_uav_uint_colour(device, view->format->dxgi_format, colour)))
|
||||
{
|
||||
ERR("Unhandled format %#x.\n", view->format->dxgi_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (d3d12_resource_is_buffer(resource))
|
||||
{
|
||||
if (!vkd3d_create_buffer_view(device, VKD3D_DESCRIPTOR_MAGIC_UAV, resource->u.vk_buffer,
|
||||
uint_format, view->info.buffer.offset, view->info.buffer.size, &uint_view))
|
||||
{
|
||||
ERR("Failed to create buffer view.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return uint_view;
|
||||
}
|
||||
|
||||
memset(&view_desc, 0, sizeof(view_desc));
|
||||
view_desc.view_type = view->info.texture.vk_view_type;
|
||||
view_desc.format = uint_format;
|
||||
view_desc.miplevel_idx = view->info.texture.miplevel_idx;
|
||||
view_desc.miplevel_count = 1;
|
||||
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->u.vk_image, &view_desc, &uint_view))
|
||||
{
|
||||
ERR("Failed to create image view.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return uint_view;
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID3D12GraphicsCommandList5 *iface,
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource,
|
||||
const UINT values[4], UINT rect_count, const D3D12_RECT *rects)
|
||||
@ -5441,8 +5487,6 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID
|
||||
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList5(iface);
|
||||
struct vkd3d_view *descriptor, *uint_view = NULL;
|
||||
struct d3d12_device *device = list->device;
|
||||
struct vkd3d_texture_view_desc view_desc;
|
||||
const struct vkd3d_format *uint_format;
|
||||
const struct vkd3d_resource_view *view;
|
||||
struct d3d12_resource *resource_impl;
|
||||
VkClearColorValue colour;
|
||||
@ -5456,44 +5500,11 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID
|
||||
view = &descriptor->v;
|
||||
memcpy(colour.uint32, values, sizeof(colour.uint32));
|
||||
|
||||
if (view->format->type != VKD3D_FORMAT_TYPE_UINT)
|
||||
if (view->format->type != VKD3D_FORMAT_TYPE_UINT
|
||||
&& !(descriptor = uint_view = create_uint_view(device, view, resource_impl, &colour)))
|
||||
{
|
||||
if (!(uint_format = vkd3d_find_uint_format(device, view->format->dxgi_format))
|
||||
&& !(uint_format = vkd3d_fixup_clear_uav_uint_colour(device, view->format->dxgi_format, &colour)))
|
||||
{
|
||||
ERR("Unhandled format %#x.\n", view->format->dxgi_format);
|
||||
return;
|
||||
}
|
||||
|
||||
if (d3d12_resource_is_buffer(resource_impl))
|
||||
{
|
||||
if (!vkd3d_create_buffer_view(device, VKD3D_DESCRIPTOR_MAGIC_UAV, resource_impl->u.vk_buffer,
|
||||
uint_format, view->info.buffer.offset, view->info.buffer.size, &uint_view))
|
||||
{
|
||||
ERR("Failed to create buffer view.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&view_desc, 0, sizeof(view_desc));
|
||||
view_desc.view_type = view->info.texture.vk_view_type;
|
||||
view_desc.format = uint_format;
|
||||
view_desc.miplevel_idx = view->info.texture.miplevel_idx;
|
||||
view_desc.miplevel_count = 1;
|
||||
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))
|
||||
{
|
||||
ERR("Failed to create image view.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
descriptor = uint_view;
|
||||
ERR("Failed to create UINT view.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
d3d12_command_list_clear_uav(list, resource_impl, descriptor, &colour, rect_count, rects);
|
||||
@ -5507,19 +5518,32 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewFloat(I
|
||||
const float values[4], UINT rect_count, const D3D12_RECT *rects)
|
||||
{
|
||||
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList5(iface);
|
||||
struct vkd3d_view *descriptor, *uint_view = NULL;
|
||||
struct d3d12_device *device = list->device;
|
||||
const struct vkd3d_resource_view *view;
|
||||
struct d3d12_resource *resource_impl;
|
||||
VkClearColorValue colour;
|
||||
struct vkd3d_view *view;
|
||||
|
||||
TRACE("iface %p, gpu_handle %s, cpu_handle %s, resource %p, values %p, rect_count %u, rects %p.\n",
|
||||
iface, debug_gpu_handle(gpu_handle), debug_cpu_handle(cpu_handle), resource, values, rect_count, rects);
|
||||
|
||||
resource_impl = unsafe_impl_from_ID3D12Resource(resource);
|
||||
if (!(view = d3d12_desc_from_cpu_handle(cpu_handle)->s.u.view))
|
||||
if (!(descriptor = d3d12_desc_from_cpu_handle(cpu_handle)->s.u.view))
|
||||
return;
|
||||
view = &descriptor->v;
|
||||
memcpy(colour.float32, values, sizeof(colour.float32));
|
||||
|
||||
d3d12_command_list_clear_uav(list, resource_impl, view, &colour, rect_count, rects);
|
||||
if (view->format->type == VKD3D_FORMAT_TYPE_SINT
|
||||
&& !(descriptor = uint_view = create_uint_view(device, view, resource_impl, &colour)))
|
||||
{
|
||||
ERR("Failed to create UINT view.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
d3d12_command_list_clear_uav(list, resource_impl, descriptor, &colour, rect_count, rects);
|
||||
|
||||
if (uint_view)
|
||||
vkd3d_view_decref(uint_view, device);
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d3d12_command_list_DiscardResource(ID3D12GraphicsCommandList5 *iface,
|
||||
|
Loading…
Reference in New Issue
Block a user