Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
July 2019
- 65 participants
- 633 messages
[PATCH vkd3d v2 3/6] vkd3d: Handle SINT and UINT formats in ClearRenderTargetView().
by Józef Kucia
From: Jactry Zeng <jzeng(a)codeweavers.com>
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/command.c | 24 +++++++++++++++-
libs/vkd3d/utils.c | 40 ++++++++++++++++++++++++++
libs/vkd3d/vkd3d_private.h | 2 ++
tests/d3d12.c | 59 +++++++++++++++++---------------------
4 files changed, 92 insertions(+), 33 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index eeae9cf4efe2..d620f9fd0f3c 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -4631,11 +4631,11 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearDepthStencilView(ID3D12Gra
static void STDMETHODCALLTYPE d3d12_command_list_ClearRenderTargetView(ID3D12GraphicsCommandList1 *iface,
D3D12_CPU_DESCRIPTOR_HANDLE rtv, const FLOAT color[4], UINT rect_count, const D3D12_RECT *rects)
{
- const union VkClearValue clear_value = {{{color[0], color[1], color[2], color[3]}}};
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList1(iface);
const struct d3d12_rtv_desc *rtv_desc = d3d12_rtv_desc_from_cpu_handle(rtv);
struct VkAttachmentDescription attachment_desc;
struct VkAttachmentReference color_reference;
+ VkClearValue clear_value;
TRACE("iface %p, rtv %#lx, color %p, rect_count %u, rects %p.\n",
iface, rtv.ptr, color, rect_count, rects);
@@ -4655,6 +4655,28 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearRenderTargetView(ID3D12Gra
color_reference.attachment = 0;
color_reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ if (vk_format_is_signed_integer(rtv_desc->format))
+ {
+ clear_value.color.uint32[0] = color[0];
+ clear_value.color.uint32[1] = color[1];
+ clear_value.color.uint32[2] = color[2];
+ clear_value.color.uint32[3] = color[3];
+ }
+ else if (vk_format_is_unsigned_integer(rtv_desc->format))
+ {
+ clear_value.color.uint32[0] = max(0, color[0]);
+ clear_value.color.uint32[1] = max(0, color[1]);
+ clear_value.color.uint32[2] = max(0, color[2]);
+ clear_value.color.uint32[3] = max(0, color[3]);
+ }
+ else
+ {
+ clear_value.color.float32[0] = color[0];
+ clear_value.color.float32[1] = color[1];
+ clear_value.color.float32[2] = color[2];
+ clear_value.color.float32[3] = color[3];
+ }
+
d3d12_command_list_clear(list, &attachment_desc, &color_reference, NULL,
rtv_desc->view, rtv_desc->width, rtv_desc->height, rtv_desc->layer_count,
&clear_value, rect_count, rects);
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c
index 5c8d3635b22c..d87349ab29a3 100644
--- a/libs/vkd3d/utils.c
+++ b/libs/vkd3d/utils.c
@@ -262,6 +262,46 @@ bool dxgi_format_is_typeless(DXGI_FORMAT dxgi_format)
}
}
+bool vk_format_is_signed_integer(VkFormat format)
+{
+ switch (format)
+ {
+ case VK_FORMAT_R32G32B32A32_SINT:
+ case VK_FORMAT_R16G16B16A16_SINT:
+ case VK_FORMAT_R32G32B32_SINT:
+ case VK_FORMAT_R8G8B8A8_SINT:
+ case VK_FORMAT_R32G32_SINT:
+ case VK_FORMAT_R16G16_SINT:
+ case VK_FORMAT_R8G8_SINT:
+ case VK_FORMAT_R32_SINT:
+ case VK_FORMAT_R16_SINT:
+ case VK_FORMAT_R8_SINT:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool vk_format_is_unsigned_integer(VkFormat format)
+{
+ switch (format)
+ {
+ case VK_FORMAT_R32G32B32A32_UINT:
+ case VK_FORMAT_R16G16B16A16_UINT:
+ case VK_FORMAT_R32G32B32_UINT:
+ case VK_FORMAT_R8G8B8A8_UINT:
+ case VK_FORMAT_R32G32_UINT:
+ case VK_FORMAT_R16G16_UINT:
+ case VK_FORMAT_R8G8_UINT:
+ case VK_FORMAT_R32_UINT:
+ case VK_FORMAT_R16_UINT:
+ case VK_FORMAT_R8_UINT:
+ return true;
+ default:
+ return false;
+ }
+}
+
DXGI_FORMAT vkd3d_get_dxgi_format(VkFormat format)
{
DXGI_FORMAT dxgi_format;
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 6e2dc2b2bb8e..79155768e2fe 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1123,6 +1123,8 @@ HRESULT vkd3d_init_depth_stencil_formats(struct d3d12_device *device) DECLSPEC_H
void vkd3d_cleanup_depth_stencil_formats(struct d3d12_device *device) DECLSPEC_HIDDEN;
bool dxgi_format_is_typeless(DXGI_FORMAT dxgi_format) DECLSPEC_HIDDEN;
+bool vk_format_is_signed_integer(VkFormat format) DECLSPEC_HIDDEN;
+bool vk_format_is_unsigned_integer(VkFormat format) DECLSPEC_HIDDEN;
static inline const struct vkd3d_format *vkd3d_format_from_d3d12_resource_desc(
const struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc, DXGI_FORMAT view_format)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 4223ec2c690d..c53d6053de1c 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -4329,15 +4329,14 @@ static void test_clear_depth_stencil_view(void)
destroy_test_context(&context);
}
-#define test_clear_rtv_r8g8b8a8_2d(a, b, c, d, e, f, g) test_clear_rtv_r8g8b8a8_2d_(__LINE__, a, b, c, d, e, f, g)
+#define test_clear_rtv_r8g8b8a8_2d(a, b, c, d, e, f) test_clear_rtv_r8g8b8a8_2d_(__LINE__, a, b, c, d, e, f)
static void test_clear_rtv_r8g8b8a8_2d_(unsigned int line, const struct test_context *context,
ID3D12Resource *resource, D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle,
- const float *color, unsigned int expected, unsigned int max_diff, bool is_todo)
+ const float *color, unsigned int expected, unsigned int max_diff)
{
ID3D12GraphicsCommandList_ClearRenderTargetView(context->list, rtv_handle, color, 0, NULL);
transition_resource_state(context->list, resource,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- todo_if(is_todo)
check_sub_resource_uint_(line, resource, 0, context->queue, context->list, expected, max_diff);
reset_command_list(context->list, context->allocator);
@@ -4345,16 +4344,14 @@ static void test_clear_rtv_r8g8b8a8_2d_(unsigned int line, const struct test_con
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
}
-#define test_clear_rtv_r16g16b16a16_2d(a, b, c, d, e, f, g) test_clear_rtv_r16g16b16a16_2d_(__LINE__, a, b, c, d, e, f, g)
+#define test_clear_rtv_r16g16b16a16_2d(a, b, c, d, e) test_clear_rtv_r16g16b16a16_2d_(__LINE__, a, b, c, d, e)
static void test_clear_rtv_r16g16b16a16_2d_(unsigned int line, const struct test_context *context,
- ID3D12Resource *resource, D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle,
- const float *color, uint64_t expected, unsigned int max_diff, bool is_todo)
+ ID3D12Resource *resource, D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle, const float *color, uint64_t expected)
{
ID3D12GraphicsCommandList_ClearRenderTargetView(context->list, rtv_handle, color, 0, NULL);
transition_resource_state(context->list, resource,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- todo_if(is_todo)
- check_sub_resource_uint64_(line, resource, 0, context->queue, context->list, expected, max_diff);
+ check_sub_resource_uint64_(line, resource, 0, context->queue, context->list, expected, 0);
reset_command_list(context->list, context->allocator);
transition_resource_state(context->list, resource,
@@ -4395,7 +4392,6 @@ static void test_clear_render_target_view(void)
const float *color;
unsigned int expected;
unsigned int max_diff;
- bool is_todo;
}
test_r8g8b8a8_unorm[] =
{
@@ -4404,21 +4400,20 @@ static void test_clear_render_target_view(void)
},
test_r8g8b8a8_uint[] =
{
- {green, 0x01000100, 0, true},
- {color, 0x00000000, 0, true},
- {negative_value, 0x00000001, 0, true},
+ {green, 0x01000100, 0},
+ {color, 0x00000000, 0},
+ {negative_value, 0x00000001, 0},
},
test_r8g8b8a8_sint[] =
{
- {green, 0x01000100, 0, true},
- {color, 0x00000000, 0, true},
- {negative_value, 0xfe00ff01, 0, true},
+ {green, 0x01000100, 0},
+ {color, 0x00000000, 0},
+ {negative_value, 0xfe00ff01, 0},
};
static const struct
{
const float *color;
uint64_t expected;
- bool is_todo;
}
test_r16g16b16a16_unorm[] =
{
@@ -4426,15 +4421,15 @@ static void test_clear_render_target_view(void)
},
test_r16g16b16a16_uint[] =
{
- {green, 0x0010000, true},
- {color, 0x00000000, true},
- {negative_value, 0x00000001, true},
+ {green, 0x0010000},
+ {color, 0x00000000},
+ {negative_value, 0x00000001},
},
test_r16g16b16a16_sint[] =
{
- {green, 0x0010000, true},
- {color, 0x00000000, true},
- {negative_value, 0xfffe0000ffff0001, true},
+ {green, 0x0010000},
+ {color, 0x00000000},
+ {negative_value, 0xfffe0000ffff0001},
};
STATIC_ASSERT(ARRAY_SIZE(array_colors) == ARRAY_SIZE(array_expected_colors));
@@ -4487,14 +4482,14 @@ static void test_clear_render_target_view(void)
{
vkd3d_test_set_context("Test %u", i);
test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, test_r8g8b8a8_unorm[i].color,
- test_r8g8b8a8_unorm[i].expected, test_r8g8b8a8_unorm[i].max_diff, test_r8g8b8a8_unorm[i].is_todo);
+ test_r8g8b8a8_unorm[i].expected, test_r8g8b8a8_unorm[i].max_diff);
}
vkd3d_test_set_context(NULL);
/* sRGB view */
rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
- test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, color, 0xbf95bc59, 2, false);
+ test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, color, 0xbf95bc59, 2);
/* DXGI_FORMAT_R8G8B8A8_UINT view */
rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UINT;
@@ -4503,7 +4498,7 @@ static void test_clear_render_target_view(void)
{
vkd3d_test_set_context("Test %u", i);
test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, test_r8g8b8a8_uint[i].color,
- test_r8g8b8a8_uint[i].expected, test_r8g8b8a8_uint[i].max_diff, test_r8g8b8a8_uint[i].is_todo);
+ test_r8g8b8a8_uint[i].expected, test_r8g8b8a8_uint[i].max_diff);
}
vkd3d_test_set_context(NULL);
@@ -4514,7 +4509,7 @@ static void test_clear_render_target_view(void)
{
vkd3d_test_set_context("Test %u", i);
test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, test_r8g8b8a8_sint[i].color,
- test_r8g8b8a8_sint[i].expected, test_r8g8b8a8_sint[i].max_diff, test_r8g8b8a8_sint[i].is_todo);
+ test_r8g8b8a8_sint[i].expected, test_r8g8b8a8_sint[i].max_diff);
}
vkd3d_test_set_context(NULL);
@@ -4537,8 +4532,8 @@ static void test_clear_render_target_view(void)
for (i = 0; i < ARRAY_SIZE(test_r16g16b16a16_unorm); i++)
{
vkd3d_test_set_context("Test %u", i);
- test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle, test_r16g16b16a16_unorm[i].color,
- test_r16g16b16a16_unorm[i].expected, 0, test_r16g16b16a16_unorm[i].is_todo);
+ test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle,
+ test_r16g16b16a16_unorm[i].color, test_r16g16b16a16_unorm[i].expected);
}
vkd3d_test_set_context(NULL);
@@ -4548,8 +4543,8 @@ static void test_clear_render_target_view(void)
for (i = 0; i < ARRAY_SIZE(test_r16g16b16a16_uint); i++)
{
vkd3d_test_set_context("Test %u", i);
- test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle, test_r16g16b16a16_uint[i].color,
- test_r16g16b16a16_uint[i].expected, 0, test_r16g16b16a16_uint[i].is_todo);
+ test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle,
+ test_r16g16b16a16_uint[i].color, test_r16g16b16a16_uint[i].expected);
}
vkd3d_test_set_context(NULL);
@@ -4559,8 +4554,8 @@ static void test_clear_render_target_view(void)
for (i = 0; i < ARRAY_SIZE(test_r16g16b16a16_sint); i++)
{
vkd3d_test_set_context("Test %u", i);
- test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle, test_r16g16b16a16_sint[i].color,
- test_r16g16b16a16_sint[i].expected, 0, test_r16g16b16a16_sint[i].is_todo);
+ test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle,
+ test_r16g16b16a16_sint[i].color, test_r16g16b16a16_sint[i].expected);
}
vkd3d_test_set_context(NULL);
--
2.21.0
July 17, 2019
[PATCH vkd3d v2 2/6] tests: Test ClearRenderTargetView() with R16G16B16A16 formats.
by Józef Kucia
From: Jactry Zeng <jzeng(a)codeweavers.com>
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
tests/d3d12.c | 131 +++++++++++++++++++++++++++++++++++++++
tests/d3d12_test_utils.h | 2 +
2 files changed, 133 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 970e2ea32369..4223ec2c690d 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -89,6 +89,11 @@ static bool compare_uint16(uint16_t a, uint16_t b, unsigned int max_diff)
return abs(a - b) <= max_diff;
}
+static bool compare_uint64(uint64_t a, uint64_t b, unsigned int max_diff)
+{
+ return abs(a - b) <= max_diff;
+}
+
static ULONG get_refcount(void *iface)
{
IUnknown *unk = iface;
@@ -531,6 +536,47 @@ static void check_sub_resource_uint16_(unsigned int line, ID3D12Resource *textur
release_resource_readback(&rb);
}
+#define check_readback_data_uint64(a, b, c, d) check_readback_data_uint64_(__LINE__, a, b, c, d)
+static void check_readback_data_uint64_(unsigned int line, struct resource_readback *rb,
+ const RECT *rect, uint64_t expected, unsigned int max_diff)
+{
+ RECT r = {0, 0, rb->width, rb->height};
+ unsigned int x = 0, y;
+ bool all_match = true;
+ uint64_t got = 0;
+
+ if (rect)
+ r = *rect;
+
+ for (y = r.top; y < r.bottom; ++y)
+ {
+ for (x = r.left; x < r.right; ++x)
+ {
+ got = get_readback_uint64(rb, x, y);
+ if (!compare_uint64(got, expected, max_diff))
+ {
+ all_match = false;
+ break;
+ }
+ }
+ if (!all_match)
+ break;
+ }
+ ok_(line)(all_match, "Got %#"PRIx64", expected %#"PRIx64" at (%u, %u).\n", got, expected, x, y);
+}
+
+#define check_sub_resource_uint64(a, b, c, d, e, f) check_sub_resource_uint64_(__LINE__, a, b, c, d, e, f)
+static void check_sub_resource_uint64_(unsigned int line, ID3D12Resource *texture,
+ unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
+ uint64_t expected, unsigned int max_diff)
+{
+ struct resource_readback rb;
+
+ get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list);
+ check_readback_data_uint64_(line, &rb, NULL, expected, max_diff);
+ release_resource_readback(&rb);
+}
+
#define check_sub_resource_vec4(a, b, c, d, e, f) check_sub_resource_vec4_(__LINE__, a, b, c, d, e, f)
static void check_sub_resource_vec4_(unsigned int line, ID3D12Resource *texture,
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
@@ -4299,6 +4345,22 @@ static void test_clear_rtv_r8g8b8a8_2d_(unsigned int line, const struct test_con
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
}
+#define test_clear_rtv_r16g16b16a16_2d(a, b, c, d, e, f, g) test_clear_rtv_r16g16b16a16_2d_(__LINE__, a, b, c, d, e, f, g)
+static void test_clear_rtv_r16g16b16a16_2d_(unsigned int line, const struct test_context *context,
+ ID3D12Resource *resource, D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle,
+ const float *color, uint64_t expected, unsigned int max_diff, bool is_todo)
+{
+ ID3D12GraphicsCommandList_ClearRenderTargetView(context->list, rtv_handle, color, 0, NULL);
+ transition_resource_state(context->list, resource,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ todo_if(is_todo)
+ check_sub_resource_uint64_(line, resource, 0, context->queue, context->list, expected, max_diff);
+
+ reset_command_list(context->list, context->allocator);
+ transition_resource_state(context->list, resource,
+ D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
+}
+
static void test_clear_render_target_view(void)
{
static const unsigned int array_expected_colors[] = {0xff00ff00, 0xff0000ff, 0xffff0000};
@@ -4352,6 +4414,28 @@ static void test_clear_render_target_view(void)
{color, 0x00000000, 0, true},
{negative_value, 0xfe00ff01, 0, true},
};
+ static const struct
+ {
+ const float *color;
+ uint64_t expected;
+ bool is_todo;
+ }
+ test_r16g16b16a16_unorm[] =
+ {
+ {green, 0xffff0000},
+ },
+ test_r16g16b16a16_uint[] =
+ {
+ {green, 0x0010000, true},
+ {color, 0x00000000, true},
+ {negative_value, 0x00000001, true},
+ },
+ test_r16g16b16a16_sint[] =
+ {
+ {green, 0x0010000, true},
+ {color, 0x00000000, true},
+ {negative_value, 0xfffe0000ffff0001, true},
+ };
STATIC_ASSERT(ARRAY_SIZE(array_colors) == ARRAY_SIZE(array_expected_colors));
@@ -4434,11 +4518,58 @@ static void test_clear_render_target_view(void)
}
vkd3d_test_set_context(NULL);
+ /* R16G16B16A16 views */
+ hr = ID3D12GraphicsCommandList_Close(command_list);
+ ok(hr == S_OK, "Failed to close command list, hr %#x.\n", hr);
+ reset_command_list(command_list, context.allocator);
+ ID3D12Resource_Release(resource);
+ resource_desc.Format = DXGI_FORMAT_R16G16B16A16_TYPELESS;
+ hr = ID3D12Device_CreateCommittedResource(device,
+ &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, NULL,
+ &IID_ID3D12Resource, (void **)&resource);
+ ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
+
+ memset(&rtv_desc, 0, sizeof(rtv_desc));
+ rtv_desc.Format = DXGI_FORMAT_R16G16B16A16_UNORM;
+ rtv_desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
+ ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+ for (i = 0; i < ARRAY_SIZE(test_r16g16b16a16_unorm); i++)
+ {
+ vkd3d_test_set_context("Test %u", i);
+ test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle, test_r16g16b16a16_unorm[i].color,
+ test_r16g16b16a16_unorm[i].expected, 0, test_r16g16b16a16_unorm[i].is_todo);
+ }
+ vkd3d_test_set_context(NULL);
+
+ /* DXGI_FORMAT_R16G16B16A16_UINT view */
+ rtv_desc.Format = DXGI_FORMAT_R16G16B16A16_UINT;
+ ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+ for (i = 0; i < ARRAY_SIZE(test_r16g16b16a16_uint); i++)
+ {
+ vkd3d_test_set_context("Test %u", i);
+ test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle, test_r16g16b16a16_uint[i].color,
+ test_r16g16b16a16_uint[i].expected, 0, test_r16g16b16a16_uint[i].is_todo);
+ }
+ vkd3d_test_set_context(NULL);
+
+ /* DXGI_FORMAT_R16G16B16A16_SINT view */
+ rtv_desc.Format = DXGI_FORMAT_R16G16B16A16_SINT;
+ ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+ for (i = 0; i < ARRAY_SIZE(test_r16g16b16a16_sint); i++)
+ {
+ vkd3d_test_set_context("Test %u", i);
+ test_clear_rtv_r16g16b16a16_2d(&context, resource, rtv_handle, test_r16g16b16a16_sint[i].color,
+ test_r16g16b16a16_sint[i].expected, 0, test_r16g16b16a16_sint[i].is_todo);
+ }
+ vkd3d_test_set_context(NULL);
+
/* 2D array texture */
hr = ID3D12GraphicsCommandList_Close(command_list);
ok(hr == S_OK, "Failed to close command list, hr %#x.\n", hr);
reset_command_list(command_list, context.allocator);
ID3D12Resource_Release(resource);
+ resource_desc.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS;
resource_desc.DepthOrArraySize = ARRAY_SIZE(array_colors);
hr = ID3D12Device_CreateCommittedResource(device,
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc,
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index 027a1fd68e97..5a9e1e7c9781 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -270,6 +270,8 @@ static unsigned int format_size(DXGI_FORMAT format)
case DXGI_FORMAT_R32G32B32A32_UINT:
case DXGI_FORMAT_R8G8_UNORM:
return 16;
+ case DXGI_FORMAT_R16G16B16A16_TYPELESS:
+ return 8;
case DXGI_FORMAT_R32_TYPELESS:
case DXGI_FORMAT_D32_FLOAT:
case DXGI_FORMAT_R32_FLOAT:
--
2.21.0
July 17, 2019
[PATCH vkd3d v2 1/6] tests: Test ClearRenderTargetView() with R8G8B8A8_{SINT, UINT} formats.
by Józef Kucia
From: Jactry Zeng <jzeng(a)codeweavers.com>
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
tests/d3d12.c | 95 +++++++++++++++++++++++++++++++++++++++------------
1 file changed, 73 insertions(+), 22 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index bd055fb5d444..970e2ea32369 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -4283,6 +4283,22 @@ static void test_clear_depth_stencil_view(void)
destroy_test_context(&context);
}
+#define test_clear_rtv_r8g8b8a8_2d(a, b, c, d, e, f, g) test_clear_rtv_r8g8b8a8_2d_(__LINE__, a, b, c, d, e, f, g)
+static void test_clear_rtv_r8g8b8a8_2d_(unsigned int line, const struct test_context *context,
+ ID3D12Resource *resource, D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle,
+ const float *color, unsigned int expected, unsigned int max_diff, bool is_todo)
+{
+ ID3D12GraphicsCommandList_ClearRenderTargetView(context->list, rtv_handle, color, 0, NULL);
+ transition_resource_state(context->list, resource,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ todo_if(is_todo)
+ check_sub_resource_uint_(line, resource, 0, context->queue, context->list, expected, max_diff);
+
+ reset_command_list(context->list, context->allocator);
+ transition_resource_state(context->list, resource,
+ D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
+}
+
static void test_clear_render_target_view(void)
{
static const unsigned int array_expected_colors[] = {0xff00ff00, 0xff0000ff, 0xffff0000};
@@ -4292,6 +4308,7 @@ static void test_clear_render_target_view(void)
{1.0f, 0.0f, 0.0f, 1.0f},
{0.0f, 0.0f, 1.0f, 1.0f},
};
+ static const float negative_value[] = {1.0f, -1.0f, -0.5f, -2.0f};
static const float color[] = {0.1f, 0.5f, 0.3f, 0.75f};
static const float green[] = {0.0f, 1.0f, 0.0f, 1.0f};
ID3D12GraphicsCommandList *command_list;
@@ -4311,6 +4328,30 @@ static void test_clear_render_target_view(void)
unsigned int i;
D3D12_BOX box;
HRESULT hr;
+ static const struct
+ {
+ const float *color;
+ unsigned int expected;
+ unsigned int max_diff;
+ bool is_todo;
+ }
+ test_r8g8b8a8_unorm[] =
+ {
+ {green, 0xff00ff00, 0},
+ {color, 0xbf4c7f19, 2},
+ },
+ test_r8g8b8a8_uint[] =
+ {
+ {green, 0x01000100, 0, true},
+ {color, 0x00000000, 0, true},
+ {negative_value, 0x00000001, 0, true},
+ },
+ test_r8g8b8a8_sint[] =
+ {
+ {green, 0x01000100, 0, true},
+ {color, 0x00000000, 0, true},
+ {negative_value, 0xfe00ff01, 0, true},
+ };
STATIC_ASSERT(ARRAY_SIZE(array_colors) == ARRAY_SIZE(array_expected_colors));
@@ -4358,34 +4399,45 @@ static void test_clear_render_target_view(void)
rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
rtv_desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
-
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, green, 0, NULL);
- transition_resource_state(command_list, resource,
- D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- check_sub_resource_uint(resource, 0, queue, command_list, 0xff00ff00, 0);
-
- reset_command_list(command_list, context.allocator);
- transition_resource_state(command_list, resource,
- D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
-
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, color, 0, NULL);
- transition_resource_state(command_list, resource,
- D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- check_sub_resource_uint(resource, 0, queue, command_list, 0xbf4c7f19, 2);
+ for (i = 0; i < ARRAY_SIZE(test_r8g8b8a8_unorm); i++)
+ {
+ vkd3d_test_set_context("Test %u", i);
+ test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, test_r8g8b8a8_unorm[i].color,
+ test_r8g8b8a8_unorm[i].expected, test_r8g8b8a8_unorm[i].max_diff, test_r8g8b8a8_unorm[i].is_todo);
+ }
+ vkd3d_test_set_context(NULL);
/* sRGB view */
- reset_command_list(command_list, context.allocator);
- transition_resource_state(command_list, resource,
- D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+ test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, color, 0xbf95bc59, 2, false);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtv_handle, color, 0, NULL);
- transition_resource_state(command_list, resource,
- D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- check_sub_resource_uint(resource, 0, queue, command_list, 0xbf95bc59, 2);
+ /* DXGI_FORMAT_R8G8B8A8_UINT view */
+ rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UINT;
+ ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+ for (i = 0; i < ARRAY_SIZE(test_r8g8b8a8_uint); i++)
+ {
+ vkd3d_test_set_context("Test %u", i);
+ test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, test_r8g8b8a8_uint[i].color,
+ test_r8g8b8a8_uint[i].expected, test_r8g8b8a8_uint[i].max_diff, test_r8g8b8a8_uint[i].is_todo);
+ }
+ vkd3d_test_set_context(NULL);
+
+ /* DXGI_FORMAT_R8G8B8A8_SINT view */
+ rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_SINT;
+ ID3D12Device_CreateRenderTargetView(device, resource, &rtv_desc, rtv_handle);
+ for (i = 0; i < ARRAY_SIZE(test_r8g8b8a8_sint); i++)
+ {
+ vkd3d_test_set_context("Test %u", i);
+ test_clear_rtv_r8g8b8a8_2d(&context, resource, rtv_handle, test_r8g8b8a8_sint[i].color,
+ test_r8g8b8a8_sint[i].expected, test_r8g8b8a8_sint[i].max_diff, test_r8g8b8a8_sint[i].is_todo);
+ }
+ vkd3d_test_set_context(NULL);
/* 2D array texture */
+ hr = ID3D12GraphicsCommandList_Close(command_list);
+ ok(hr == S_OK, "Failed to close command list, hr %#x.\n", hr);
+ reset_command_list(command_list, context.allocator);
ID3D12Resource_Release(resource);
resource_desc.DepthOrArraySize = ARRAY_SIZE(array_colors);
hr = ID3D12Device_CreateCommittedResource(device,
@@ -4394,7 +4446,6 @@ static void test_clear_render_target_view(void)
&IID_ID3D12Resource, (void **)&resource);
ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
- reset_command_list(command_list, context.allocator);
for (i = 0; i < ARRAY_SIZE(array_colors); ++i)
{
memset(&rtv_desc, 0, sizeof(rtv_desc));
--
2.21.0
July 17, 2019
[PATCH vkd3d] tests: Add tests for sample_b instruction.
by Jactry Zeng
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
---
tests/d3d12.c | 310 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 310 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index bd055fb..72951c9 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -31335,6 +31335,315 @@ static void test_conditional_rendering(void)
destroy_test_context(&context);
}
+static void test_sample_b(void)
+{
+ static const float red[] = {1.0f, 0.0f, 0.0f, 0.5f};
+ ID3D12GraphicsCommandList *command_list;
+ D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle;
+ D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle;
+ D3D12_STATIC_SAMPLER_DESC sampler_desc;
+ struct test_context_desc desc;
+ struct resource_readback rb;
+ struct test_context context;
+ unsigned int x_step, y_step;
+ ID3D12DescriptorHeap *heap;
+ ID3D12CommandQueue *queue;
+ ID3D12Resource *texture;
+ ID3D12Device *device;
+ unsigned int i, x, y;
+ float constant;
+ static const DWORD ps_sample_code[] =
+ {
+#if 0
+ Texture2D t;
+ SamplerState s;
+
+ float bias;
+
+ float4 main(float4 position : SV_POSITION) : SV_Target
+ {
+ float2 p;
+
+ p.x = position.x / 640.0f;
+ p.y = position.y / 480.0f;
+ return t.SampleBias(s, p, bias);
+ }
+#endif
+ 0x43425844, 0xc39b0686, 0x8244a7fc, 0x14c0b97a, 0x2900b3b7, 0x00000001, 0x00000150, 0x00000003,
+ 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49,
+ 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000b4, 0x00000040,
+ 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005a, 0x00106000, 0x00000000,
+ 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
+ 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000,
+ 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x0c00004a,
+ 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000,
+ 0x0020800a, 0x00000000, 0x00000000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps_sample = {ps_sample_code, sizeof(ps_sample_code)};
+ static const unsigned int r8g8b8a8_data[] =
+ {
+ 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
+ 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
+ 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
+ 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
+ };
+ static const uint8_t a8_data[] =
+ {
+ 0x00, 0xff, 0x7f, 0xf0,
+ 0x0f, 0x11, 0x00, 0x00,
+ 0xff, 0xf0, 0x0f, 0xff,
+ 0xfa, 0xfe, 0xaa, 0xcc,
+ };
+ static const unsigned int a8_expected_data[] =
+ {
+ 0x00000000, 0xff000000, 0x7f000000, 0xf0000000,
+ 0x0f000000, 0x11000000, 0x00000000, 0x00000000,
+ 0xff000000, 0xf0000000, 0x0f000000, 0xff000000,
+ 0xfa000000, 0xfe000000, 0xaa000000, 0xcc000000,
+ };
+ static const unsigned int rgba_level_0[] =
+ {
+ 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
+ 0xffff0000, 0xffff00ff, 0xff000000, 0xff7f7f7f,
+ 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000,
+ 0xffffffff, 0xff000000, 0xff000000, 0xff000000,
+ };
+ static const unsigned int rgba_level_1[] =
+ {
+ 0xffffffff, 0xff0000ff,
+ 0xff000000, 0xff00ff00,
+ };
+ static const unsigned int rgba_level_2[] =
+ {
+ 0xffff0000,
+ };
+ static const unsigned int level_1_colors[] =
+ {
+ 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
+ 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff,
+ 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
+ 0xff000000, 0xff000000, 0xff00ff00, 0xff00ff00,
+ };
+ static const unsigned int level_2_colors[] =
+ {
+ 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
+ 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
+ 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
+ 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
+ };
+ static const struct
+ {
+ unsigned int width;
+ unsigned int height;
+ unsigned int miplevel_count;
+ unsigned int array_size;
+ float lod_bias;
+ float min_lod;
+ float max_lod;
+ float ps_constant;
+ DXGI_FORMAT format;
+ D3D12_SUBRESOURCE_DATA data[3];
+ const unsigned int *expected_data;
+ }
+ tests[] =
+ {
+ {
+ 4, 4, 1, 1, 0.0f, 0.0f, D3D12_FLOAT32_MAX, 0.0f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {r8g8b8a8_data, 4 * sizeof(*r8g8b8a8_data), 16 * sizeof(*r8g8b8a8_data)},
+ },
+ r8g8b8a8_data,
+ },
+ {
+ 4, 4, 1, 1, 0.0f, 0.0f, D3D12_FLOAT32_MAX, 0.0f, DXGI_FORMAT_A8_UNORM,
+ {
+ {a8_data, 4 * sizeof(*a8_data), 16 * sizeof(*a8_data)},
+ },
+ a8_expected_data,
+ },
+ {
+ 4, 4, 3, 1, 0.0f, 0.0f, D3D12_FLOAT32_MAX, 0.0f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ rgba_level_0,
+ },
+ {
+ 4, 4, 3, 1, 8.0f, 0.0f, D3D12_FLOAT32_MAX, 0.0f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ level_1_colors,
+ },
+ {
+ 4, 4, 3, 1, 0.0f, 0.0f, D3D12_FLOAT32_MAX, 8.0f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ level_1_colors,
+ },
+ {
+ 4, 4, 3, 1, 0.0f, 0.0f, D3D12_FLOAT32_MAX, 8.4f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ level_1_colors,
+ },
+ {
+ 4, 4, 3, 1, 0.0f, 0.0f, D3D12_FLOAT32_MAX, 8.5f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ level_2_colors,
+ },
+ {
+ 4, 4, 3, 1, 0.0f, 0.0f, D3D12_FLOAT32_MAX, 9.0f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ level_2_colors,
+ },
+ {
+ 4, 4, 3, 1, 0.0f, 0.0f, 2.0f, 1.0f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ rgba_level_0,
+ },
+ {
+ 4, 4, 3, 1, 0.0f, 0.0f, 2.0f, 9.0f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ level_2_colors,
+ },
+ {
+ 4, 4, 3, 1, 0.0f, 0.0f, 1.0f, 9.0f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ level_1_colors,
+ },
+ {
+ 4, 4, 3, 1, 0.0f, 0.0f, 0.0f, 9.0f, DXGI_FORMAT_R8G8B8A8_UNORM,
+ {
+ {rgba_level_0, 4 * sizeof(*rgba_level_0), 0},
+ {rgba_level_1, 2 * sizeof(*rgba_level_1), 0},
+ {rgba_level_2, sizeof(*rgba_level_2), 0},
+ },
+ rgba_level_0,
+ },
+ };
+
+ memset(&desc, 0, sizeof(desc));
+ desc.rt_width = 640.0f;
+ desc.rt_height = 480.0f;
+ desc.no_root_signature = true;
+ if (!init_test_context(&context, &desc))
+ return;
+ device = context.device;
+ command_list = context.list;
+ queue = context.queue;
+
+ heap = create_gpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 1);
+ cpu_handle = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap);
+ gpu_handle = ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(heap);
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ vkd3d_test_set_context("Test %u", i);
+
+ memset(&sampler_desc, 0, sizeof(sampler_desc));
+ sampler_desc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT;
+ sampler_desc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
+ sampler_desc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
+ sampler_desc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
+ sampler_desc.MipLODBias = tests[i].lod_bias;
+ sampler_desc.MinLOD = tests[i].min_lod;
+ sampler_desc.MaxLOD = tests[i].max_lod;
+ context.root_signature = create_texture_root_signature_(__LINE__, context.device,
+ D3D12_SHADER_VISIBILITY_PIXEL, 1, 0, &sampler_desc);
+ context.pipeline_state = create_pipeline_state(device, context.root_signature,
+ context.render_target_desc.Format, NULL, &ps_sample, NULL);
+
+ texture = create_default_texture2d(device, tests[i].width, tests[i].height, tests[i].array_size,
+ tests[i].miplevel_count, tests[i].format, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST);
+ upload_texture_data(texture, tests[i].data, tests[i].miplevel_count * tests[i].array_size,
+ queue, command_list);
+ reset_command_list(command_list, context.allocator);
+ transition_resource_state(command_list, texture,
+ D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
+
+ ID3D12Device_CreateShaderResourceView(device, texture, NULL, cpu_handle);
+
+ ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, red, 0, NULL);
+
+ ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, FALSE, NULL);
+ ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
+ ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state);
+ ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &heap);
+ ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 0, gpu_handle);
+ ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
+ ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
+ constant = tests[i].ps_constant;
+ ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 1, 1, &constant, 0);
+ ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
+
+ transition_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+
+ x_step = desc.rt_width / tests[i].width;
+ y_step = desc.rt_height / tests[i].height;
+ get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list);
+ for (y = 0; y < tests[i].height; ++y)
+ {
+ for (x = 0; x < tests[i].width; ++x)
+ {
+ unsigned int color = get_readback_uint(&rb, x * x_step + x_step / 2, y * y_step + y_step / 2, 0);
+ ok(compare_color(color, tests[i].expected_data[tests[i].width * y + x], 0),
+ "Got color 0x%08x, expected 0x%08x at (%u, %u).\n",
+ color, tests[i].expected_data[tests[i].width * y + x], x, y);
+ }
+ }
+ release_resource_readback(&rb);
+
+ ID3D12Resource_Release(texture);
+ reset_command_list(command_list, context.allocator);
+ transition_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
+
+ ID3D12PipelineState_Release(context.pipeline_state);
+ context.pipeline_state = NULL;
+ ID3D12RootSignature_Release(context.root_signature);
+ context.root_signature = NULL;
+ }
+ vkd3d_test_set_context(NULL);
+
+ ID3D12DescriptorHeap_Release(heap);
+ destroy_test_context(&context);
+}
+
START_TEST(d3d12)
{
parse_args(argc, argv);
@@ -31496,4 +31805,5 @@ START_TEST(d3d12)
run_test(test_graphics_compute_queue_synchronization);
run_test(test_early_depth_stencil_tests);
run_test(test_conditional_rendering);
+ run_test(test_sample_b);
}
--
2.20.1
July 17, 2019
Re: [PATCH] wldap32: Use correct integer type when calling ber_printf() or ber_scanf().
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=54816
Your paranoid android.
=== debian9 (build log) ===
../../../wine/dlls/wldap32/ber.c:356:17: error: unknown type name ‘ber_tag_t’
../../../wine/dlls/wldap32/ber.c:375:17: error: unknown type name ‘ber_len_t’
../../../wine/dlls/wldap32/ber.c:451:17: error: unknown type name ‘ber_tag_t’
../../../wine/dlls/wldap32/ber.c:466:17: error: unknown type name ‘ber_len_t’
Makefile:209: recipe for target 'ber.o' failed
Makefile:8384: recipe for target 'dlls/wldap32' failed
Task: The win32 build failed
=== debian9 (build log) ===
../../../wine/dlls/wldap32/ber.c:356:17: error: unknown type name ‘ber_tag_t’
../../../wine/dlls/wldap32/ber.c:375:17: error: unknown type name ‘ber_len_t’
../../../wine/dlls/wldap32/ber.c:451:17: error: unknown type name ‘ber_tag_t’
../../../wine/dlls/wldap32/ber.c:466:17: error: unknown type name ‘ber_len_t’
Makefile:209: recipe for target 'ber.o' failed
Makefile:8173: recipe for target 'dlls/wldap32' failed
Task: The wow64 build failed
July 17, 2019
[PATCH] wldap32: Use correct integer type when calling ber_printf() or ber_scanf().
by Conor McCarthy
GCC compiles ber_tag_t and ber_len_t as 64-bit types on 64-bit machines,
but in Win64 they are 32-bit. As va_list arguments they pass unchecked and
unconverted.
Signed-off-by: Conor McCarthy <cmccarthy(a)codeweavers.com>
---
dlls/wldap32/ber.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/dlls/wldap32/ber.c b/dlls/wldap32/ber.c
index c2c6f269..d8fd502d 100644
--- a/dlls/wldap32/ber.c
+++ b/dlls/wldap32/ber.c
@@ -353,7 +353,7 @@ INT WINAPIV WLDAP32_ber_printf( BerElement *berelement, PCHAR fmt, ... )
}
case 't':
{
- unsigned int tag = va_arg( list, unsigned int );
+ ber_tag_t tag = va_arg( list, ULONG );
ret = ber_printf( berelement, new_fmt, tag );
break;
}
@@ -372,7 +372,7 @@ INT WINAPIV WLDAP32_ber_printf( BerElement *berelement, PCHAR fmt, ... )
case 'X':
{
char *str = va_arg( list, char * );
- int len = va_arg( list, int );
+ ber_len_t len = va_arg( list, ULONG );
new_fmt[0] = 'B'; /* 'X' is deprecated */
ret = ber_printf( berelement, new_fmt, str, len );
break;
@@ -447,8 +447,10 @@ INT WINAPIV WLDAP32_ber_scanf( BerElement *berelement, PCHAR fmt, ... )
}
case 't':
{
- unsigned int *tag = va_arg( list, unsigned int * );
- ret = ber_scanf( berelement, new_fmt, tag );
+ ULONG *tag = va_arg( list, ULONG * );
+ ber_tag_t ber_tag;
+ ret = ber_scanf( berelement, new_fmt, &ber_tag );
+ *tag = ber_tag;
break;
}
case 'v':
@@ -460,8 +462,10 @@ INT WINAPIV WLDAP32_ber_scanf( BerElement *berelement, PCHAR fmt, ... )
case 'B':
{
char **str = va_arg( list, char ** );
- int *len = va_arg( list, int * );
- ret = ber_scanf( berelement, new_fmt, str, len );
+ ULONG *len = va_arg( list, ULONG * );
+ ber_len_t ber_len;
+ ret = ber_scanf( berelement, new_fmt, str, &ber_len );
+ *len = ber_len;
break;
}
case 'O':
--
2.22.0
July 17, 2019
Re: [PATCH v4 7/7] winex11.drv: Don't react to small slow mouse movements.
by Derek Lesho
This is a modified version of staging's mouse-movements patch that applies
cleanly on the first 6 patches I sent.
On Tue, Jul 16, 2019 at 7:57 PM Derek Lesho <dereklesho52(a)gmail.com> wrote:
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42631
> From: Jordan Galby <gravemind2a+wine(a)gmail.com>
> Signed-off-by: Derek Lesho <dereklesho52(a)Gmail.com>
> ---
> dlls/winex11.drv/mouse.c | 66 +++++++++++++++++++++++++++++----------
> dlls/winex11.drv/x11drv.h | 2 ++
> 2 files changed, 51 insertions(+), 17 deletions(-)
>
> diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
> index 1ceac3d7f2..e9cb591cb5 100644
> --- a/dlls/winex11.drv/mouse.c
> +++ b/dlls/winex11.drv/mouse.c
> @@ -257,6 +257,10 @@ static void update_relative_valuators(XIAnyClassInfo
> **valuators, int n_valuator
>
> thread_data->x_rel_valuator.number = -1;
> thread_data->y_rel_valuator.number = -1;
> + thread_data->x_rel_valuator.accum = 0;
> + thread_data->y_rel_valuator.accum = 0;
> + thread_data->x_rel_valuator.raw_accum = 0;
> + thread_data->y_rel_valuator.raw_accum = 0;
>
> for (i = 0; i < n_valuators; i++)
> {
> @@ -1796,15 +1800,11 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
> input.u.mi.dwFlags = MOUSEEVENTF_MOVE;
> input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
> input.u.mi.dwExtraInfo = 0;
> - input.u.mi.dx = 0;
> - input.u.mi.dy = 0;
>
> raw_input.header.dwType = RIM_TYPEMOUSE;
> raw_input.data.mouse.u.usButtonFlags = 0;
> raw_input.data.mouse.u.usButtonData = 0;
> raw_input.data.mouse.ulExtraInformation = 0;
> - raw_input.data.mouse.lLastX = 0;
> - raw_input.data.mouse.lLastY = 0;
>
> virtual_rect = get_virtual_screen_rect();
>
> @@ -1815,40 +1815,72 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
> raw_val = *raw_values++;
> if (i == x_rel->number)
> {
> - input.u.mi.dx = dx = val;
> + dx = val;
> if (x_rel->min < x_rel->max)
> - input.u.mi.dx = val * (virtual_rect.right -
> virtual_rect.left)
> + dx = val * (virtual_rect.right - virtual_rect.left)
> / (x_rel->max - x_rel->min);
>
> - raw_input.data.mouse.lLastX = raw_dx = raw_val;
> + raw_dx = raw_val;
> }
> if (i == y_rel->number)
> {
> - input.u.mi.dy = dy = val;
> + dy = val;
> if (y_rel->min < y_rel->max)
> - input.u.mi.dy = val * (virtual_rect.bottom -
> virtual_rect.top)
> + dy = val * (virtual_rect.bottom - virtual_rect.top)
> / (y_rel->max - y_rel->min);
>
> - raw_input.data.mouse.lLastY = raw_dy = raw_val;
> + raw_dy = raw_val;
> }
> }
>
> if (broken_rawevents && is_old_motion_event( xev->serial ))
> {
> - TRACE( "pos %d,%d old serial %lu, ignoring\n", input.u.mi.dx,
> input.u.mi.dy, xev->serial );
> + TRACE( "pos %d,%d old serial %lu, ignoring\n", (LONG) dx, (LONG)
> dy, xev->serial );
> return FALSE;
> }
>
> - if (thread_data->xi2_state == xi_extra)
> + /* Accumulate the *double* motions so sub-pixel motions
> + * wont be lost when sent/cast to *LONG* target fields.
> + */
> +
> + x_rel->accum += dx;
> + y_rel->accum += dy;
> + if (fabs(x_rel->accum) < 1.0 && fabs(y_rel->accum) < 1.0)
> {
> - TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy,
> dx, dy );
> - __wine_send_input( 0, &input );
> + TRACE( "accumulating raw motion (event %f,%f, accum %f,%f)\n",
> dx, dy, x_rel->accum, y_rel->accum );
> }
> + else
> + {
> + input.u.mi.dx = x_rel->accum;
> + input.u.mi.dy = y_rel->accum;
> + x_rel->accum -= input.u.mi.dx;
> + y_rel->accum -= input.u.mi.dy;
>
> - if ( LIST_ENTRY(list_head(&g_x11_threads), struct x11drv_thread_data,
> entry) == thread_data)
> + if (thread_data->xi2_state == xi_extra)
> + {
> + TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx,
> input.u.mi.dy, dx, dy );
> + __wine_send_input( 0, &input );
> + }
> + }
> +
> + x_rel->raw_accum += raw_dx;
> + y_rel->raw_accum += raw_dy;
> + if (fabs(x_rel->raw_accum) < 1.0 && fabs(y_rel->raw_accum) < 1.0)
> + {
> + TRACE( "accumulating raw motion (event %f,%f, accum %f,%f)\n",
> raw_dx, raw_dy, x_rel->raw_accum, y_rel->raw_accum );
> + }
> + else
> {
> - TRACE("raw event %f,%f\n", raw_dx, raw_dy);
> - __wine_send_raw_input( &raw_input );
> + raw_input.data.mouse.lLastX = x_rel->raw_accum;
> + raw_input.data.mouse.lLastY = y_rel->raw_accum;
> + x_rel->raw_accum -= raw_input.data.mouse.lLastX;
> + y_rel->raw_accum -= raw_input.data.mouse.lLastY;
> +
> + if ( LIST_ENTRY(list_head(&g_x11_threads), struct
> x11drv_thread_data, entry) == thread_data)
> + {
> + TRACE("raw event %d,%d(event %f,%f)\n",
> raw_input.data.mouse.lLastX, raw_input.data.mouse.lLastY, raw_dx, raw_dy);
> + __wine_send_raw_input( &raw_input );
> + }
> }
>
> return TRUE;
> diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
> index 378c1d7508..06b09730ee 100644
> --- a/dlls/winex11.drv/x11drv.h
> +++ b/dlls/winex11.drv/x11drv.h
> @@ -320,6 +320,8 @@ struct x11drv_valuator_data
> double min;
> double max;
> int number;
> + double accum;
> + double raw_accum;
> };
>
> struct x11drv_thread_data
> --
> 2.22.0
>
>
July 17, 2019
Re: [PATCH v4 6/7] winex11.drv: Implement native mouse-movement raw-input using RawMotion.
by Derek Lesho
This is v4 of my 6th patch, it fixes a a major bug (not using list_head)
and re-formats the patch to look nicer.
On Tue, Jul 16, 2019 at 7:56 PM Derek Lesho <dereklesho52(a)gmail.com> wrote:
> Signed-off-by: Derek Lesho <dereklesho52(a)Gmail.com>
> ---
> dlls/winex11.drv/mouse.c | 88 +++++++++++++++++++++++++++-------
> dlls/winex11.drv/x11drv.h | 6 ++-
> dlls/winex11.drv/x11drv_main.c | 10 ++++
> 3 files changed, 86 insertions(+), 18 deletions(-)
>
> diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
> index f737a306a5..1ceac3d7f2 100644
> --- a/dlls/winex11.drv/mouse.c
> +++ b/dlls/winex11.drv/mouse.c
> @@ -284,11 +284,26 @@ static void update_relative_valuators(XIAnyClassInfo
> **valuators, int n_valuator
> }
> #endif
>
> +/***********************************************************************
> + * inform_wineserver
> + */
> +static void inform_wineserver(void)
> +{
> + static int once = 0;
> + if (!once)
> + {
> + RAWINPUT raw_input;
> + raw_input.header.dwType = RIM_ENABLE_NATIVE_MOUSE_MOVE;
> + __wine_send_raw_input(&raw_input);
> + once = 1;
> + }
> +}
> +
>
> /***********************************************************************
> - * enable_xinput2
> + * X11DRV_XInput2_Enable
> */
> -static void enable_xinput2(void)
> +void X11DRV_XInput2_Enable(void)
> {
> #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
> struct x11drv_thread_data *data = x11drv_thread_data();
> @@ -318,7 +333,6 @@ static void enable_xinput2(void)
> memset( mask_bits, 0, sizeof(mask_bits) );
> XISetMask( mask_bits, XI_DeviceChanged );
> XISetMask( mask_bits, XI_RawMotion );
> - XISetMask( mask_bits, XI_ButtonPress );
>
> pXISelectEvents( data->display, DefaultRootWindow( data->display ),
> &mask, 1 );
>
> @@ -337,19 +351,21 @@ static void enable_xinput2(void)
> data->xi2_current_slave = 0;
>
> data->xi2_state = xi_enabled;
> +
> + inform_wineserver();
> #endif
> }
>
> /***********************************************************************
> - * disable_xinput2
> + * X11DRV_XInput2_Disable
> */
> -static void disable_xinput2(void)
> +void X11DRV_XInput2_Disable(void)
> {
> #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
> struct x11drv_thread_data *data = x11drv_thread_data();
> XIEventMask mask;
>
> - if (data->xi2_state != xi_enabled) return;
> + if (data->xi2_state < xi_enabled) return;
>
> TRACE( "disabling\n" );
> data->xi2_state = xi_disabled;
> @@ -368,6 +384,21 @@ static void disable_xinput2(void)
> #endif
> }
>
> +static void use_xinput2_path(void)
> +{
> + struct x11drv_thread_data *thread_data = x11drv_thread_data();
> +
> + if (thread_data->xi2_state == xi_enabled)
> + thread_data->xi2_state = xi_extra;
> +}
> +
> +static void disable_xinput2_path(void)
> +{
> + struct x11drv_thread_data *thread_data = x11drv_thread_data();
> +
> + if (thread_data->xi2_state == xi_extra)
> + thread_data->xi2_state = xi_enabled;
> +}
>
> /***********************************************************************
> * grab_clipping_window
> @@ -393,9 +424,9 @@ static BOOL grab_clipping_window( const RECT *clip )
> return TRUE;
>
> /* enable XInput2 unless we are already clipping */
> - if (!data->clip_hwnd) enable_xinput2();
> + if (!data->clip_hwnd) use_xinput2_path();
>
> - if (data->xi2_state != xi_enabled)
> + if (data->xi2_state < xi_extra)
> {
> WARN( "XInput2 not supported, refusing to clip to %s\n",
> wine_dbgstr_rect(clip) );
> DestroyWindow( msg_hwnd );
> @@ -423,7 +454,7 @@ static BOOL grab_clipping_window( const RECT *clip )
>
> if (!clipping_cursor)
> {
> - disable_xinput2();
> + disable_xinput2_path();
> DestroyWindow( msg_hwnd );
> return FALSE;
> }
> @@ -489,7 +520,7 @@ LRESULT clip_cursor_notify( HWND hwnd, HWND
> new_clip_hwnd )
> TRACE( "clip hwnd reset from %p\n", hwnd );
> data->clip_hwnd = 0;
> data->clip_reset = GetTickCount();
> - disable_xinput2();
> + disable_xinput2_path();
> DestroyWindow( hwnd );
> }
> else if (hwnd == GetForegroundWindow()) /* request to clip */
> @@ -1724,16 +1755,18 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
> {
> XIRawEvent *event = xev->data;
> const double *values = event->valuators.values;
> + const double *raw_values = event->raw_values;
> RECT virtual_rect;
> INPUT input;
> + RAWINPUT raw_input;
> int i;
> - double dx = 0, dy = 0, val;
> + double dx = 0, dy = 0, raw_dx = 0, raw_dy = 0, val, raw_val;
> struct x11drv_thread_data *thread_data = x11drv_thread_data();
> struct x11drv_valuator_data *x_rel, *y_rel;
>
> if (thread_data->x_rel_valuator.number < 0 ||
> thread_data->y_rel_valuator.number < 0) return FALSE;
> if (!event->valuators.mask_len) return FALSE;
> - if (thread_data->xi2_state != xi_enabled) return FALSE;
> + if (thread_data->xi2_state < xi_enabled) return FALSE;
>
> /* If there is no slave currently detected, no previous motion nor
> device
> * change events were received. Look it up now on the device list in
> this
> @@ -1758,12 +1791,20 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
> x_rel = &thread_data->x_rel_valuator;
> y_rel = &thread_data->y_rel_valuator;
>
> + input.type = INPUT_MOUSE;
> input.u.mi.mouseData = 0;
> input.u.mi.dwFlags = MOUSEEVENTF_MOVE;
> input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
> input.u.mi.dwExtraInfo = 0;
> - input.u.mi.dx = 0;
> - input.u.mi.dy = 0;
> + input.u.mi.dx = 0;
> + input.u.mi.dy = 0;
> +
> + raw_input.header.dwType = RIM_TYPEMOUSE;
> + raw_input.data.mouse.u.usButtonFlags = 0;
> + raw_input.data.mouse.u.usButtonData = 0;
> + raw_input.data.mouse.ulExtraInformation = 0;
> + raw_input.data.mouse.lLastX = 0;
> + raw_input.data.mouse.lLastY = 0;
>
> virtual_rect = get_virtual_screen_rect();
>
> @@ -1771,12 +1812,15 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
> {
> if (!XIMaskIsSet( event->valuators.mask, i )) continue;
> val = *values++;
> + raw_val = *raw_values++;
> if (i == x_rel->number)
> {
> input.u.mi.dx = dx = val;
> if (x_rel->min < x_rel->max)
> input.u.mi.dx = val * (virtual_rect.right -
> virtual_rect.left)
> / (x_rel->max - x_rel->min);
> +
> + raw_input.data.mouse.lLastX = raw_dx = raw_val;
> }
> if (i == y_rel->number)
> {
> @@ -1784,6 +1828,8 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
> if (y_rel->min < y_rel->max)
> input.u.mi.dy = val * (virtual_rect.bottom -
> virtual_rect.top)
> / (y_rel->max - y_rel->min);
> +
> + raw_input.data.mouse.lLastY = raw_dy = raw_val;
> }
> }
>
> @@ -1793,10 +1839,18 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie
> *xev )
> return FALSE;
> }
>
> - TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx,
> dy );
> + if (thread_data->xi2_state == xi_extra)
> + {
> + TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy,
> dx, dy );
> + __wine_send_input( 0, &input );
> + }
> +
> + if ( LIST_ENTRY(list_head(&g_x11_threads), struct x11drv_thread_data,
> entry) == thread_data)
> + {
> + TRACE("raw event %f,%f\n", raw_dx, raw_dy);
> + __wine_send_raw_input( &raw_input );
> + }
>
> - input.type = INPUT_MOUSE;
> - __wine_send_input( 0, &input );
> return TRUE;
> }
>
> diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
> index a0308b0675..378c1d7508 100644
> --- a/dlls/winex11.drv/x11drv.h
> +++ b/dlls/winex11.drv/x11drv.h
> @@ -194,6 +194,8 @@ extern BOOL X11DRV_UnrealizePalette( HPALETTE hpal )
> DECLSPEC_HIDDEN;
>
> extern void X11DRV_Xcursor_Init(void) DECLSPEC_HIDDEN;
> extern void X11DRV_XInput2_Init(void) DECLSPEC_HIDDEN;
> +extern void X11DRV_XInput2_Enable(void) DECLSPEC_HIDDEN;
> +extern void X11DRV_XInput2_Disable(void) DECLSPEC_HIDDEN;
>
> extern DWORD copy_image_bits( BITMAPINFO *info, BOOL is_r8g8b8, XImage
> *image,
> const struct gdi_image_bits *src_bits,
> struct gdi_image_bits *dst_bits,
> @@ -335,14 +337,16 @@ struct x11drv_thread_data
> HWND clip_hwnd; /* message window stored in desktop
> while clipping is active */
> DWORD clip_reset; /* time when clipping was last reset */
> HKL kbd_layout; /* active keyboard layout */
> - enum { xi_unavailable = -1, xi_unknown, xi_disabled, xi_enabled }
> xi2_state; /* XInput2 state */
> + enum { xi_unavailable = -1, xi_unknown, xi_disabled, xi_enabled,
> xi_extra } xi2_state; /* XInput2 state */
> void *xi2_devices; /* list of XInput2 devices (valid when
> state is enabled) */
> int xi2_device_count;
> struct x11drv_valuator_data x_rel_valuator;
> struct x11drv_valuator_data y_rel_valuator;
> int xi2_core_pointer; /* XInput2 core pointer id */
> int xi2_current_slave; /* Current slave driving the Core
> pointer */
> + struct list entry; /* Entry in global list of setup X11
> threads */
> };
> +extern struct list g_x11_threads DECLSPEC_HIDDEN; /* Global list of setup
> X11 threads */
>
> extern struct x11drv_thread_data *x11drv_init_thread_data(void)
> DECLSPEC_HIDDEN;
> extern DWORD thread_data_tls_index DECLSPEC_HIDDEN;
> diff --git a/dlls/winex11.drv/x11drv_main.c
> b/dlls/winex11.drv/x11drv_main.c
> index e67a3c05a9..685b3dd0f4 100644
> --- a/dlls/winex11.drv/x11drv_main.c
> +++ b/dlls/winex11.drv/x11drv_main.c
> @@ -601,6 +601,9 @@ static BOOL process_attach(void)
> }
>
>
> +struct list g_x11_threads = LIST_INIT( g_x11_threads );
> +
> +
> /***********************************************************************
> * ThreadDetach (X11DRV.@)
> */
> @@ -610,6 +613,9 @@ void CDECL X11DRV_ThreadDetach(void)
>
> if (data)
> {
> + list_remove( &data->entry );
> + X11DRV_XInput2_Disable();
> +
> if (data->xim) XCloseIM( data->xim );
> if (data->font_set) XFreeFontSet( data->display, data->font_set );
> XCloseDisplay( data->display );
> @@ -680,6 +686,10 @@ struct x11drv_thread_data
> *x11drv_init_thread_data(void)
>
> if (use_xim) X11DRV_SetupXIM();
>
> + X11DRV_XInput2_Enable();
> +
> + list_add_tail( &g_x11_threads, &data->entry );
> +
> return data;
> }
>
> --
> 2.22.0
>
>
July 16, 2019
[PATCH v4 7/7] winex11.drv: Don't react to small slow mouse movements.
by Derek Lesho
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42631
From: Jordan Galby <gravemind2a+wine(a)gmail.com>
Signed-off-by: Derek Lesho <dereklesho52(a)Gmail.com>
---
dlls/winex11.drv/mouse.c | 66 +++++++++++++++++++++++++++++----------
dlls/winex11.drv/x11drv.h | 2 ++
2 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 1ceac3d7f2..e9cb591cb5 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -257,6 +257,10 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
thread_data->x_rel_valuator.number = -1;
thread_data->y_rel_valuator.number = -1;
+ thread_data->x_rel_valuator.accum = 0;
+ thread_data->y_rel_valuator.accum = 0;
+ thread_data->x_rel_valuator.raw_accum = 0;
+ thread_data->y_rel_valuator.raw_accum = 0;
for (i = 0; i < n_valuators; i++)
{
@@ -1796,15 +1800,11 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
input.u.mi.dwFlags = MOUSEEVENTF_MOVE;
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
input.u.mi.dwExtraInfo = 0;
- input.u.mi.dx = 0;
- input.u.mi.dy = 0;
raw_input.header.dwType = RIM_TYPEMOUSE;
raw_input.data.mouse.u.usButtonFlags = 0;
raw_input.data.mouse.u.usButtonData = 0;
raw_input.data.mouse.ulExtraInformation = 0;
- raw_input.data.mouse.lLastX = 0;
- raw_input.data.mouse.lLastY = 0;
virtual_rect = get_virtual_screen_rect();
@@ -1815,40 +1815,72 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
raw_val = *raw_values++;
if (i == x_rel->number)
{
- input.u.mi.dx = dx = val;
+ dx = val;
if (x_rel->min < x_rel->max)
- input.u.mi.dx = val * (virtual_rect.right - virtual_rect.left)
+ dx = val * (virtual_rect.right - virtual_rect.left)
/ (x_rel->max - x_rel->min);
- raw_input.data.mouse.lLastX = raw_dx = raw_val;
+ raw_dx = raw_val;
}
if (i == y_rel->number)
{
- input.u.mi.dy = dy = val;
+ dy = val;
if (y_rel->min < y_rel->max)
- input.u.mi.dy = val * (virtual_rect.bottom - virtual_rect.top)
+ dy = val * (virtual_rect.bottom - virtual_rect.top)
/ (y_rel->max - y_rel->min);
- raw_input.data.mouse.lLastY = raw_dy = raw_val;
+ raw_dy = raw_val;
}
}
if (broken_rawevents && is_old_motion_event( xev->serial ))
{
- TRACE( "pos %d,%d old serial %lu, ignoring\n", input.u.mi.dx, input.u.mi.dy, xev->serial );
+ TRACE( "pos %d,%d old serial %lu, ignoring\n", (LONG) dx, (LONG) dy, xev->serial );
return FALSE;
}
- if (thread_data->xi2_state == xi_extra)
+ /* Accumulate the *double* motions so sub-pixel motions
+ * wont be lost when sent/cast to *LONG* target fields.
+ */
+
+ x_rel->accum += dx;
+ y_rel->accum += dy;
+ if (fabs(x_rel->accum) < 1.0 && fabs(y_rel->accum) < 1.0)
{
- TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
- __wine_send_input( 0, &input );
+ TRACE( "accumulating raw motion (event %f,%f, accum %f,%f)\n", dx, dy, x_rel->accum, y_rel->accum );
}
+ else
+ {
+ input.u.mi.dx = x_rel->accum;
+ input.u.mi.dy = y_rel->accum;
+ x_rel->accum -= input.u.mi.dx;
+ y_rel->accum -= input.u.mi.dy;
- if ( LIST_ENTRY(list_head(&g_x11_threads), struct x11drv_thread_data, entry) == thread_data)
+ if (thread_data->xi2_state == xi_extra)
+ {
+ TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
+ __wine_send_input( 0, &input );
+ }
+ }
+
+ x_rel->raw_accum += raw_dx;
+ y_rel->raw_accum += raw_dy;
+ if (fabs(x_rel->raw_accum) < 1.0 && fabs(y_rel->raw_accum) < 1.0)
+ {
+ TRACE( "accumulating raw motion (event %f,%f, accum %f,%f)\n", raw_dx, raw_dy, x_rel->raw_accum, y_rel->raw_accum );
+ }
+ else
{
- TRACE("raw event %f,%f\n", raw_dx, raw_dy);
- __wine_send_raw_input( &raw_input );
+ raw_input.data.mouse.lLastX = x_rel->raw_accum;
+ raw_input.data.mouse.lLastY = y_rel->raw_accum;
+ x_rel->raw_accum -= raw_input.data.mouse.lLastX;
+ y_rel->raw_accum -= raw_input.data.mouse.lLastY;
+
+ if ( LIST_ENTRY(list_head(&g_x11_threads), struct x11drv_thread_data, entry) == thread_data)
+ {
+ TRACE("raw event %d,%d(event %f,%f)\n", raw_input.data.mouse.lLastX, raw_input.data.mouse.lLastY, raw_dx, raw_dy);
+ __wine_send_raw_input( &raw_input );
+ }
}
return TRUE;
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 378c1d7508..06b09730ee 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -320,6 +320,8 @@ struct x11drv_valuator_data
double min;
double max;
int number;
+ double accum;
+ double raw_accum;
};
struct x11drv_thread_data
--
2.22.0
July 16, 2019
[PATCH v4 6/7] winex11.drv: Implement native mouse-movement raw-input using RawMotion.
by Derek Lesho
Signed-off-by: Derek Lesho <dereklesho52(a)Gmail.com>
---
dlls/winex11.drv/mouse.c | 88 +++++++++++++++++++++++++++-------
dlls/winex11.drv/x11drv.h | 6 ++-
dlls/winex11.drv/x11drv_main.c | 10 ++++
3 files changed, 86 insertions(+), 18 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index f737a306a5..1ceac3d7f2 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -284,11 +284,26 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
}
#endif
+/***********************************************************************
+ * inform_wineserver
+ */
+static void inform_wineserver(void)
+{
+ static int once = 0;
+ if (!once)
+ {
+ RAWINPUT raw_input;
+ raw_input.header.dwType = RIM_ENABLE_NATIVE_MOUSE_MOVE;
+ __wine_send_raw_input(&raw_input);
+ once = 1;
+ }
+}
+
/***********************************************************************
- * enable_xinput2
+ * X11DRV_XInput2_Enable
*/
-static void enable_xinput2(void)
+void X11DRV_XInput2_Enable(void)
{
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
struct x11drv_thread_data *data = x11drv_thread_data();
@@ -318,7 +333,6 @@ static void enable_xinput2(void)
memset( mask_bits, 0, sizeof(mask_bits) );
XISetMask( mask_bits, XI_DeviceChanged );
XISetMask( mask_bits, XI_RawMotion );
- XISetMask( mask_bits, XI_ButtonPress );
pXISelectEvents( data->display, DefaultRootWindow( data->display ), &mask, 1 );
@@ -337,19 +351,21 @@ static void enable_xinput2(void)
data->xi2_current_slave = 0;
data->xi2_state = xi_enabled;
+
+ inform_wineserver();
#endif
}
/***********************************************************************
- * disable_xinput2
+ * X11DRV_XInput2_Disable
*/
-static void disable_xinput2(void)
+void X11DRV_XInput2_Disable(void)
{
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
struct x11drv_thread_data *data = x11drv_thread_data();
XIEventMask mask;
- if (data->xi2_state != xi_enabled) return;
+ if (data->xi2_state < xi_enabled) return;
TRACE( "disabling\n" );
data->xi2_state = xi_disabled;
@@ -368,6 +384,21 @@ static void disable_xinput2(void)
#endif
}
+static void use_xinput2_path(void)
+{
+ struct x11drv_thread_data *thread_data = x11drv_thread_data();
+
+ if (thread_data->xi2_state == xi_enabled)
+ thread_data->xi2_state = xi_extra;
+}
+
+static void disable_xinput2_path(void)
+{
+ struct x11drv_thread_data *thread_data = x11drv_thread_data();
+
+ if (thread_data->xi2_state == xi_extra)
+ thread_data->xi2_state = xi_enabled;
+}
/***********************************************************************
* grab_clipping_window
@@ -393,9 +424,9 @@ static BOOL grab_clipping_window( const RECT *clip )
return TRUE;
/* enable XInput2 unless we are already clipping */
- if (!data->clip_hwnd) enable_xinput2();
+ if (!data->clip_hwnd) use_xinput2_path();
- if (data->xi2_state != xi_enabled)
+ if (data->xi2_state < xi_extra)
{
WARN( "XInput2 not supported, refusing to clip to %s\n", wine_dbgstr_rect(clip) );
DestroyWindow( msg_hwnd );
@@ -423,7 +454,7 @@ static BOOL grab_clipping_window( const RECT *clip )
if (!clipping_cursor)
{
- disable_xinput2();
+ disable_xinput2_path();
DestroyWindow( msg_hwnd );
return FALSE;
}
@@ -489,7 +520,7 @@ LRESULT clip_cursor_notify( HWND hwnd, HWND new_clip_hwnd )
TRACE( "clip hwnd reset from %p\n", hwnd );
data->clip_hwnd = 0;
data->clip_reset = GetTickCount();
- disable_xinput2();
+ disable_xinput2_path();
DestroyWindow( hwnd );
}
else if (hwnd == GetForegroundWindow()) /* request to clip */
@@ -1724,16 +1755,18 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
{
XIRawEvent *event = xev->data;
const double *values = event->valuators.values;
+ const double *raw_values = event->raw_values;
RECT virtual_rect;
INPUT input;
+ RAWINPUT raw_input;
int i;
- double dx = 0, dy = 0, val;
+ double dx = 0, dy = 0, raw_dx = 0, raw_dy = 0, val, raw_val;
struct x11drv_thread_data *thread_data = x11drv_thread_data();
struct x11drv_valuator_data *x_rel, *y_rel;
if (thread_data->x_rel_valuator.number < 0 || thread_data->y_rel_valuator.number < 0) return FALSE;
if (!event->valuators.mask_len) return FALSE;
- if (thread_data->xi2_state != xi_enabled) return FALSE;
+ if (thread_data->xi2_state < xi_enabled) return FALSE;
/* If there is no slave currently detected, no previous motion nor device
* change events were received. Look it up now on the device list in this
@@ -1758,12 +1791,20 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
x_rel = &thread_data->x_rel_valuator;
y_rel = &thread_data->y_rel_valuator;
+ input.type = INPUT_MOUSE;
input.u.mi.mouseData = 0;
input.u.mi.dwFlags = MOUSEEVENTF_MOVE;
input.u.mi.time = EVENT_x11_time_to_win32_time( event->time );
input.u.mi.dwExtraInfo = 0;
- input.u.mi.dx = 0;
- input.u.mi.dy = 0;
+ input.u.mi.dx = 0;
+ input.u.mi.dy = 0;
+
+ raw_input.header.dwType = RIM_TYPEMOUSE;
+ raw_input.data.mouse.u.usButtonFlags = 0;
+ raw_input.data.mouse.u.usButtonData = 0;
+ raw_input.data.mouse.ulExtraInformation = 0;
+ raw_input.data.mouse.lLastX = 0;
+ raw_input.data.mouse.lLastY = 0;
virtual_rect = get_virtual_screen_rect();
@@ -1771,12 +1812,15 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
{
if (!XIMaskIsSet( event->valuators.mask, i )) continue;
val = *values++;
+ raw_val = *raw_values++;
if (i == x_rel->number)
{
input.u.mi.dx = dx = val;
if (x_rel->min < x_rel->max)
input.u.mi.dx = val * (virtual_rect.right - virtual_rect.left)
/ (x_rel->max - x_rel->min);
+
+ raw_input.data.mouse.lLastX = raw_dx = raw_val;
}
if (i == y_rel->number)
{
@@ -1784,6 +1828,8 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
if (y_rel->min < y_rel->max)
input.u.mi.dy = val * (virtual_rect.bottom - virtual_rect.top)
/ (y_rel->max - y_rel->min);
+
+ raw_input.data.mouse.lLastY = raw_dy = raw_val;
}
}
@@ -1793,10 +1839,18 @@ static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
return FALSE;
}
- TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
+ if (thread_data->xi2_state == xi_extra)
+ {
+ TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
+ __wine_send_input( 0, &input );
+ }
+
+ if ( LIST_ENTRY(list_head(&g_x11_threads), struct x11drv_thread_data, entry) == thread_data)
+ {
+ TRACE("raw event %f,%f\n", raw_dx, raw_dy);
+ __wine_send_raw_input( &raw_input );
+ }
- input.type = INPUT_MOUSE;
- __wine_send_input( 0, &input );
return TRUE;
}
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index a0308b0675..378c1d7508 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -194,6 +194,8 @@ extern BOOL X11DRV_UnrealizePalette( HPALETTE hpal ) DECLSPEC_HIDDEN;
extern void X11DRV_Xcursor_Init(void) DECLSPEC_HIDDEN;
extern void X11DRV_XInput2_Init(void) DECLSPEC_HIDDEN;
+extern void X11DRV_XInput2_Enable(void) DECLSPEC_HIDDEN;
+extern void X11DRV_XInput2_Disable(void) DECLSPEC_HIDDEN;
extern DWORD copy_image_bits( BITMAPINFO *info, BOOL is_r8g8b8, XImage *image,
const struct gdi_image_bits *src_bits, struct gdi_image_bits *dst_bits,
@@ -335,14 +337,16 @@ struct x11drv_thread_data
HWND clip_hwnd; /* message window stored in desktop while clipping is active */
DWORD clip_reset; /* time when clipping was last reset */
HKL kbd_layout; /* active keyboard layout */
- enum { xi_unavailable = -1, xi_unknown, xi_disabled, xi_enabled } xi2_state; /* XInput2 state */
+ enum { xi_unavailable = -1, xi_unknown, xi_disabled, xi_enabled, xi_extra } xi2_state; /* XInput2 state */
void *xi2_devices; /* list of XInput2 devices (valid when state is enabled) */
int xi2_device_count;
struct x11drv_valuator_data x_rel_valuator;
struct x11drv_valuator_data y_rel_valuator;
int xi2_core_pointer; /* XInput2 core pointer id */
int xi2_current_slave; /* Current slave driving the Core pointer */
+ struct list entry; /* Entry in global list of setup X11 threads */
};
+extern struct list g_x11_threads DECLSPEC_HIDDEN; /* Global list of setup X11 threads */
extern struct x11drv_thread_data *x11drv_init_thread_data(void) DECLSPEC_HIDDEN;
extern DWORD thread_data_tls_index DECLSPEC_HIDDEN;
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index e67a3c05a9..685b3dd0f4 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -601,6 +601,9 @@ static BOOL process_attach(void)
}
+struct list g_x11_threads = LIST_INIT( g_x11_threads );
+
+
/***********************************************************************
* ThreadDetach (X11DRV.@)
*/
@@ -610,6 +613,9 @@ void CDECL X11DRV_ThreadDetach(void)
if (data)
{
+ list_remove( &data->entry );
+ X11DRV_XInput2_Disable();
+
if (data->xim) XCloseIM( data->xim );
if (data->font_set) XFreeFontSet( data->display, data->font_set );
XCloseDisplay( data->display );
@@ -680,6 +686,10 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
if (use_xim) X11DRV_SetupXIM();
+ X11DRV_XInput2_Enable();
+
+ list_add_tail( &g_x11_threads, &data->entry );
+
return data;
}
--
2.22.0
July 16, 2019