vkd3d: Partially implement clears for texture UAVs.

In the long term, we may want to use shaders to clear UAVs.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-09-13 11:26:01 +02:00 committed by Alexandre Julliard
parent 0e8fc6e957
commit b9d7569b8c
3 changed files with 49 additions and 16 deletions

View File

@ -3881,6 +3881,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID
const struct vkd3d_vk_device_procs *vk_procs;
const struct d3d12_desc *cpu_descriptor;
struct d3d12_resource *resource_impl;
VkImageSubresourceRange range;
VkClearColorValue color;
TRACE("iface %p, gpu_handle %#"PRIx64", cpu_handle %lx, resource %p, values %p, rect_count %u, rects %p.\n",
iface, gpu_handle.ptr, cpu_handle.ptr, resource, values, rect_count, rects);
@ -3891,11 +3893,6 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID
d3d12_command_list_track_resource_usage(list, resource_impl);
if (d3d12_resource_is_texture(resource_impl))
{
FIXME("Not implemented for textures.\n");
return;
}
if (rect_count)
{
FIXME("Clear rects not supported.\n");
@ -3905,14 +3902,34 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID
d3d12_command_list_end_current_render_pass(list);
cpu_descriptor = d3d12_desc_from_cpu_handle(cpu_handle);
if (!cpu_descriptor->view_size)
{
FIXME("Not supported for UAV descriptor %p.\n", cpu_descriptor);
return;
}
VK_CALL(vkCmdFillBuffer(list->vk_command_buffer, resource_impl->u.vk_buffer,
cpu_descriptor->view_offset, cpu_descriptor->view_size, values[0]));
if (d3d12_resource_is_buffer(resource_impl))
{
if (!cpu_descriptor->uav.buffer.size)
{
FIXME("Not supported for UAV descriptor %p.\n", cpu_descriptor);
return;
}
VK_CALL(vkCmdFillBuffer(list->vk_command_buffer, resource_impl->u.vk_buffer,
cpu_descriptor->uav.buffer.offset, cpu_descriptor->uav.buffer.size, values[0]));
}
else
{
color.uint32[0] = values[0];
color.uint32[1] = values[1];
color.uint32[2] = values[2];
color.uint32[3] = values[3];
range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
range.baseMipLevel = cpu_descriptor->uav.texture.miplevel_idx;
range.levelCount = 1;
range.baseArrayLayer = cpu_descriptor->uav.texture.layer_idx;
range.layerCount = cpu_descriptor->uav.texture.layer_count;
VK_CALL(vkCmdClearColorImage(list->vk_command_buffer,
resource_impl->u.vk_image, VK_IMAGE_LAYOUT_GENERAL, &color, 1, &range));
}
}
static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewFloat(ID3D12GraphicsCommandList *iface,

View File

@ -1635,8 +1635,8 @@ static void vkd3d_create_buffer_uav(struct d3d12_desc *descriptor, struct d3d12_
{
const struct vkd3d_format *format = vkd3d_get_format(DXGI_FORMAT_R32_UINT, false);
descriptor->view_offset = desc->u.Buffer.FirstElement * format->byte_count;
descriptor->view_size = desc->u.Buffer.NumElements * format->byte_count;
descriptor->uav.buffer.offset = desc->u.Buffer.FirstElement * format->byte_count;
descriptor->uav.buffer.size = desc->u.Buffer.NumElements * format->byte_count;
}
}
@ -1691,6 +1691,10 @@ static void vkd3d_create_texture_uav(struct d3d12_desc *descriptor,
descriptor->magic = VKD3D_DESCRIPTOR_MAGIC_UAV;
descriptor->vk_descriptor_type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
descriptor->u.view = view;
descriptor->uav.texture.miplevel_idx = vkd3d_desc.miplevel_idx;
descriptor->uav.texture.layer_idx = vkd3d_desc.layer_idx;
descriptor->uav.texture.layer_count = vkd3d_desc.layer_count;
}
void d3d12_desc_create_uav(struct d3d12_desc *descriptor, struct d3d12_device *device,

View File

@ -272,8 +272,20 @@ struct d3d12_desc
struct vkd3d_view *view;
} u;
VkDeviceSize view_offset;
VkDeviceSize view_size;
union
{
struct
{
VkDeviceSize offset;
VkDeviceSize size;
} buffer;
struct
{
unsigned int miplevel_idx;
unsigned int layer_idx;
unsigned int layer_count;
} texture;
} uav;
};
static inline struct d3d12_desc *d3d12_desc_from_cpu_handle(D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle)