mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
d3d10core/tests: Port test_timestamp_query() from d3d9.
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:
parent
a9f09cf060
commit
93f589df0d
1 changed files with 155 additions and 0 deletions
|
@ -3443,6 +3443,160 @@ static void test_create_query(void)
|
|||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
static void test_timestamp_query(void)
|
||||
{
|
||||
static const struct vec4 red = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
D3D10_QUERY_DATA_TIMESTAMP_DISJOINT disjoint, prev_disjoint;
|
||||
ID3D10Query *timestamp_query, *timestamp_disjoint_query;
|
||||
struct d3d10core_test_context test_context;
|
||||
D3D10_QUERY_DESC query_desc;
|
||||
unsigned int data_size, i;
|
||||
ID3D10Device *device;
|
||||
UINT64 timestamp;
|
||||
HRESULT hr;
|
||||
|
||||
if (!init_test_context(&test_context))
|
||||
return;
|
||||
|
||||
device = test_context.device;
|
||||
|
||||
query_desc.Query = D3D10_QUERY_TIMESTAMP;
|
||||
query_desc.MiscFlags = 0;
|
||||
hr = ID3D10Device_CreateQuery(device, &query_desc, ×tamp_query);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
data_size = ID3D10Query_GetDataSize(timestamp_query);
|
||||
ok(data_size == sizeof(UINT64), "Got unexpected data size %u.\n", data_size);
|
||||
|
||||
query_desc.Query = D3D10_QUERY_TIMESTAMP_DISJOINT;
|
||||
query_desc.MiscFlags = 0;
|
||||
hr = ID3D10Device_CreateQuery(device, &query_desc, ×tamp_disjoint_query);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
data_size = ID3D10Query_GetDataSize(timestamp_disjoint_query);
|
||||
ok(data_size == sizeof(disjoint), "Got unexpected data size %u.\n", data_size);
|
||||
|
||||
/* Test a TIMESTAMP_DISJOINT query. */
|
||||
ID3D10Query_Begin(timestamp_disjoint_query);
|
||||
ID3D10Query_End(timestamp_disjoint_query);
|
||||
for (i = 0; i < 500; ++i)
|
||||
{
|
||||
if ((hr = ID3D10Query_GetData(timestamp_disjoint_query, NULL, 0, 0)) != S_FALSE)
|
||||
break;
|
||||
Sleep(10);
|
||||
}
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
disjoint.Frequency = 0xdeadbeef;
|
||||
disjoint.Disjoint = 0xff;
|
||||
hr = ID3D10Query_GetData(timestamp_disjoint_query, &disjoint, sizeof(disjoint), 0);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(disjoint.Frequency != 0xdeadbeef, "Frequency data was not modified.\n");
|
||||
ok(disjoint.Disjoint == TRUE || disjoint.Disjoint == FALSE, "Got unexpected disjoint %#x.\n", disjoint.Disjoint);
|
||||
|
||||
prev_disjoint = disjoint;
|
||||
|
||||
disjoint.Frequency = 0xdeadbeef;
|
||||
disjoint.Disjoint = 0xff;
|
||||
hr = ID3D10Query_GetData(timestamp_disjoint_query, &disjoint, sizeof(disjoint) - 1, 0);
|
||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D10Query_GetData(timestamp_disjoint_query, &disjoint, sizeof(disjoint) + 1, 0);
|
||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D10Query_GetData(timestamp_disjoint_query, &disjoint, sizeof(disjoint) / 2, 0);
|
||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D10Query_GetData(timestamp_disjoint_query, &disjoint, sizeof(disjoint) * 2, 0);
|
||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
ok(disjoint.Frequency == 0xdeadbeef, "Frequency data was modified.\n");
|
||||
ok(disjoint.Disjoint == 0xff, "Disjoint data was modified.\n");
|
||||
|
||||
hr = ID3D10Query_GetData(timestamp_disjoint_query, NULL, 0, 0);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D10Query_GetData(timestamp_disjoint_query, &disjoint, sizeof(disjoint), D3D10_ASYNC_GETDATA_DONOTFLUSH);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(!memcmp(&disjoint, &prev_disjoint, sizeof(disjoint)), "Disjoint data mismatch.\n");
|
||||
|
||||
hr = ID3D10Query_GetData(timestamp_query, NULL, 0, 0);
|
||||
todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D10Query_GetData(timestamp_query, ×tamp, sizeof(timestamp), 0);
|
||||
todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
/* Test a TIMESTAMP query inside a TIMESTAMP_DISJOINT query. */
|
||||
ID3D10Query_Begin(timestamp_disjoint_query);
|
||||
|
||||
hr = ID3D10Query_GetData(timestamp_query, ×tamp, sizeof(timestamp), 0);
|
||||
todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
draw_color_quad(&test_context, &red);
|
||||
|
||||
ID3D10Query_End(timestamp_query);
|
||||
for (i = 0; i < 500; ++i)
|
||||
{
|
||||
if ((hr = ID3D10Query_GetData(timestamp_query, NULL, 0, 0)) != S_FALSE)
|
||||
break;
|
||||
Sleep(10);
|
||||
}
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
timestamp = 0xdeadbeef;
|
||||
hr = ID3D10Query_GetData(timestamp_query, ×tamp, sizeof(timestamp) / 2, 0);
|
||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
ok(timestamp == 0xdeadbeef, "Timestamp was modified.\n");
|
||||
|
||||
hr = ID3D10Query_GetData(timestamp_query, ×tamp, sizeof(timestamp), 0);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(timestamp != 0xdeadbeef, "Timestamp was not modified.\n");
|
||||
|
||||
timestamp = 0xdeadbeef;
|
||||
hr = ID3D10Query_GetData(timestamp_query, ×tamp, sizeof(timestamp) - 1, 0);
|
||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D10Query_GetData(timestamp_query, ×tamp, sizeof(timestamp) + 1, 0);
|
||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D10Query_GetData(timestamp_query, ×tamp, sizeof(timestamp) / 2, 0);
|
||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D10Query_GetData(timestamp_query, ×tamp, sizeof(timestamp) * 2, 0);
|
||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
ok(timestamp == 0xdeadbeef, "Timestamp was modified.\n");
|
||||
|
||||
ID3D10Query_End(timestamp_disjoint_query);
|
||||
for (i = 0; i < 500; ++i)
|
||||
{
|
||||
if ((hr = ID3D10Query_GetData(timestamp_disjoint_query, NULL, 0, 0)) != S_FALSE)
|
||||
break;
|
||||
Sleep(10);
|
||||
}
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
disjoint.Frequency = 0xdeadbeef;
|
||||
disjoint.Disjoint = 0xff;
|
||||
hr = ID3D10Query_GetData(timestamp_disjoint_query, &disjoint, sizeof(disjoint), 0);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(disjoint.Frequency != 0xdeadbeef, "Frequency data was not modified.\n");
|
||||
ok(disjoint.Disjoint == TRUE || disjoint.Disjoint == FALSE, "Got unexpected disjoint %#x.\n", disjoint.Disjoint);
|
||||
|
||||
/* It's not strictly necessary for the TIMESTAMP query to be inside a TIMESTAMP_DISJOINT query. */
|
||||
ID3D10Query_Release(timestamp_query);
|
||||
query_desc.Query = D3D10_QUERY_TIMESTAMP;
|
||||
query_desc.MiscFlags = 0;
|
||||
hr = ID3D10Device_CreateQuery(device, &query_desc, ×tamp_query);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
draw_color_quad(&test_context, &red);
|
||||
|
||||
ID3D10Query_End(timestamp_query);
|
||||
for (i = 0; i < 500; ++i)
|
||||
{
|
||||
if ((hr = ID3D10Query_GetData(timestamp_query, NULL, 0, 0)) != S_FALSE)
|
||||
break;
|
||||
Sleep(10);
|
||||
}
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D10Query_GetData(timestamp_query, ×tamp, sizeof(timestamp), 0);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
ID3D10Query_Release(timestamp_query);
|
||||
ID3D10Query_Release(timestamp_disjoint_query);
|
||||
release_test_context(&test_context);
|
||||
}
|
||||
|
||||
static void test_device_removed_reason(void)
|
||||
{
|
||||
ID3D10Device *device;
|
||||
|
@ -8257,6 +8411,7 @@ START_TEST(device)
|
|||
test_create_depthstencil_state();
|
||||
test_create_rasterizer_state();
|
||||
test_create_query();
|
||||
test_timestamp_query();
|
||||
test_device_removed_reason();
|
||||
test_scissor();
|
||||
test_clear_state();
|
||||
|
|
Loading…
Reference in a new issue