tests: Add tests for NULL event handles in SetEventOnCompletion().

Testing this before NULL event handling is patched results in a crash.
Based on a vkd3d-proton patch by Hans-Kristian Arntzen.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Conor McCarthy 2022-01-18 15:54:12 +10:00 committed by Alexandre Julliard
parent c965b7b213
commit 8727b9a435
2 changed files with 37 additions and 2 deletions

View File

@ -4418,11 +4418,14 @@ static void test_fence_values(void)
value = ID3D12Fence_GetCompletedValue(fence);
ok(value == next_value, "Got value %#"PRIx64", expected %#"PRIx64".\n", value, next_value);
for (i = 0; i < 100; ++i)
for (i = 0; i < 200; ++i)
{
++next_value;
queue_signal(queue, fence, next_value);
wait_queue_idle(device, queue);
if ((i * 11) & 8)
wait_queue_idle_no_event(device, queue);
else
wait_queue_idle(device, queue);
value = ID3D12Fence_GetCompletedValue(fence);
ok(value == next_value, "Got value %#"PRIx64", expected %#"PRIx64".\n", value, next_value);
}
@ -4459,6 +4462,11 @@ static void test_fence_values(void)
wait_queue_idle(device, queue);
value = ID3D12Fence_GetCompletedValue(fence);
ok(value == next_value, "Got value %#"PRIx64", expected %#"PRIx64".\n", value, next_value);
next_value <<= 1;
queue_signal(queue, fence, next_value);
wait_queue_idle_no_event(device, queue);
value = ID3D12Fence_GetCompletedValue(fence);
ok(value == next_value, "Got value %#"PRIx64", expected %#"PRIx64".\n", value, next_value);
next_value = 0;
queue_signal(queue, fence, next_value);
wait_queue_idle(device, queue);

View File

@ -28,6 +28,33 @@ struct vec4
static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue);
static ID3D12Device *create_device(void);
static inline HRESULT wait_for_fence_no_event(ID3D12Fence *fence, uint64_t value)
{
if (ID3D12Fence_GetCompletedValue(fence) >= value)
return S_OK;
/* This is defined to block on the value with infinite timeout. */
return ID3D12Fence_SetEventOnCompletion(fence, value, NULL);
}
#define wait_queue_idle_no_event(a, b) wait_queue_idle_no_event_(__LINE__, a, b)
static inline void wait_queue_idle_no_event_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue)
{
ID3D12Fence *fence;
HRESULT hr;
hr = ID3D12Device_CreateFence(device, 0, D3D12_FENCE_FLAG_NONE,
&IID_ID3D12Fence, (void **)&fence);
assert_that_(line)(hr == S_OK, "Failed to create fence, hr %#x.\n", hr);
hr = ID3D12CommandQueue_Signal(queue, fence, 1);
assert_that_(line)(hr == S_OK, "Failed to signal fence, hr %#x.\n", hr);
hr = wait_for_fence_no_event(fence, 1);
assert_that_(line)(hr == S_OK, "Failed to wait for fence, hr %#x.\n", hr);
ID3D12Fence_Release(fence);
}
static void set_rect(RECT *rect, int left, int top, int right, int bottom)
{
rect->left = left;