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 --- tests/d3d12.c | 12 ++++++++++-- tests/d3d12_crosstest.h | 26 ++++++++++++++++++++++++++ tests/d3d12_test_utils.h | 2 ++ 3 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index b973ad9c..9c5f84ef 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -4412,11 +4412,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); } @@ -4453,6 +4456,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); diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index 0b77bdee..557d0430 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -226,6 +226,15 @@ static HRESULT wait_for_fence(ID3D12Fence *fence, uint64_t value) return ret == WAIT_OBJECT_0 ? S_OK : E_FAIL; }
+static 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); +} + static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue) { ID3D12Fence *fence; @@ -243,6 +252,23 @@ static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12Comm ID3D12Fence_Release(fence); }
+static 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 bool use_warp_device; static unsigned int use_adapter_idx;
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index c8287cf3..48156b81 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -26,6 +26,8 @@ struct vec4
#define wait_queue_idle(a, b) wait_queue_idle_(__LINE__, a, b) static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue); +#define wait_queue_idle_no_event(a, b) wait_queue_idle_no_event_(__LINE__, a, b) +static void wait_queue_idle_no_event_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue); static ID3D12Device *create_device(void);
static void set_rect(RECT *rect, int left, int top, int right, int bottom)