diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index e3810e2f..75af27dd 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -4979,6 +4979,22 @@ static void d3d12_command_list_clear_uav(struct d3d12_command_list *list, } } +static const struct vkd3d_format *vkd3d_fixup_clear_uav_uint_colour(struct d3d12_device *device, + DXGI_FORMAT dxgi_format, VkClearColorValue *colour) +{ + switch (dxgi_format) + { + case DXGI_FORMAT_R11G11B10_FLOAT: + colour->uint32[0] = (colour->uint32[0] & 0x7ff) + | ((colour->uint32[1] & 0x7ff) << 11) + | ((colour->uint32[2] & 0x3ff) << 22); + return vkd3d_get_format(device, DXGI_FORMAT_R32_UINT, false); + + default: + return NULL; + } +} + static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID3D12GraphicsCommandList1 *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) @@ -5000,7 +5016,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID if (view->format->type != VKD3D_FORMAT_TYPE_UINT) { - if (!(uint_format = vkd3d_find_uint_format(device, view->format->dxgi_format))) + 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; diff --git a/tests/d3d12.c b/tests/d3d12.c index 5d549e2d..52de0079 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -4839,11 +4839,11 @@ static void test_clear_unordered_access_view_buffer(void) {0x100, 0, 0, 0}, 0, false, true}, {DXGI_FORMAT_R11G11B10_FLOAT, { 0, BUFFER_SIZE / sizeof(uint32_t), 0, 0, D3D12_BUFFER_UAV_FLAG_NONE}, - {0, 0, 0, 0}, 0, false, true}, + {0, 0, 0, 0}, 0}, {DXGI_FORMAT_R11G11B10_FLOAT, { 0, BUFFER_SIZE / sizeof(uint32_t), 0, 0, D3D12_BUFFER_UAV_FLAG_NONE}, - {0x7ff, 0x7ff, 0x3ff, 0}, 0xffffffff, false, true}, + {0x7ff, 0x7ff, 0x3ff, 0}, 0xffffffff}, {DXGI_FORMAT_R11G11B10_FLOAT, { 0, BUFFER_SIZE / sizeof(uint32_t), 0, 0, D3D12_BUFFER_UAV_FLAG_NONE}, - {0x7ff, 0, 0x3ff, 0}, 0xffc007ff, false, true}, + {0x7ff, 0, 0x3ff, 0}, 0xffc007ff}, {DXGI_FORMAT_R11G11B10_FLOAT, { 0, BUFFER_SIZE / sizeof(uint32_t), 0, 0, D3D12_BUFFER_UAV_FLAG_NONE}, {0x3f000000 /* 0.5f */, 0x3f800000 /* 1.0f */, 0x40000000 /* 2.0f */, 0}, 0x801e0380, true}, {DXGI_FORMAT_R11G11B10_FLOAT, { 0, BUFFER_SIZE / sizeof(uint32_t), 0, 0, D3D12_BUFFER_UAV_FLAG_NONE}, @@ -5011,7 +5011,7 @@ static void test_clear_unordered_access_view_image(void) {DXGI_FORMAT_R8G8B8A8_UINT, 1, 1, 0, 0, 1, 0, {}, {1, 2, 3, 4}, 0x04030201}, {DXGI_FORMAT_R8G8B8A8_UINT, 1, 1, 0, 0, 1, 0, {}, {0x123, 0, 0, 0}, 0x00000023, false, true}, {DXGI_FORMAT_R8G8B8A8_UNORM, 1, 1, 0, 0, 1, 0, {}, {1, 2, 3, 4}, 0x04030201}, - {DXGI_FORMAT_R11G11B10_FLOAT, 1, 1, 0, 0, 1, 0, {}, {1, 2, 3, 4}, 0x00c01001, false, true}, + {DXGI_FORMAT_R11G11B10_FLOAT, 1, 1, 0, 0, 1, 0, {}, {1, 2, 3, 4}, 0x00c01001}, /* Test float clears with formats. */ {DXGI_FORMAT_R16G16_UNORM, 1, 1, 0, 0, 1, 0, {}, {0x3f000000 /* 0.5f */, 0x3f800000 /* 1.0f */, 0, 0}, 0xffff8000, true},