d3d9/tests: Factor out wait_query() function.

Signed-off-by: Paul Gofman <gofmanp@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2019-10-23 19:44:57 +03:00 committed by Alexandre Julliard
parent 717109ce79
commit b9d0cec5f2
2 changed files with 54 additions and 52 deletions

View File

@ -25,7 +25,7 @@
#define WINVER 0x0602 /* for CURSOR_SUPPRESSED */ #define WINVER 0x0602 /* for CURSOR_SUPPRESSED */
#define COBJMACROS #define COBJMACROS
#include <d3d9.h> #include <d3d9.h>
#include "wine/test.h" #include "utils.h"
struct vec3 struct vec3
{ {
@ -5947,13 +5947,8 @@ static void test_occlusion_query(void)
hr = IDirect3DQuery9_Issue(query, D3DISSUE_END); hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{ wait_query(query);
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
memset(&data, 0xff, sizeof(data)); memset(&data, 0xff, sizeof(data));
hr = IDirect3DQuery9_GetData(query, &data, data_size, D3DGETDATA_FLUSH); hr = IDirect3DQuery9_GetData(query, &data, data_size, D3DGETDATA_FLUSH);
@ -6057,13 +6052,7 @@ static void test_occlusion_query(void)
hr = IDirect3DQuery9_Issue(query, D3DISSUE_END); hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i) wait_query(query);
{
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
memset(&data, 0xff, sizeof(data)); memset(&data, 0xff, sizeof(data));
hr = IDirect3DQuery9_GetData(query, &data, sizeof(data), D3DGETDATA_FLUSH); hr = IDirect3DQuery9_GetData(query, &data, sizeof(data), D3DGETDATA_FLUSH);
@ -6085,13 +6074,7 @@ static void test_occlusion_query(void)
hr = IDirect3DDevice9_EndScene(device); hr = IDirect3DDevice9_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
for (i = 0; i < 500; ++i) wait_query(query);
{
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) == S_OK)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
memset(&data, 0xff, sizeof(data)); memset(&data, 0xff, sizeof(data));
hr = IDirect3DQuery9_GetData(query, &data, sizeof(data), D3DGETDATA_FLUSH); hr = IDirect3DQuery9_GetData(query, &data, sizeof(data), D3DGETDATA_FLUSH);
@ -6119,8 +6102,8 @@ static void test_timestamp_query(void)
1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f,
}; };
IDirect3DQuery9 *query, *disjoint_query, *freq_query; IDirect3DQuery9 *query, *disjoint_query, *freq_query;
unsigned int data_size, i;
IDirect3DDevice9 *device; IDirect3DDevice9 *device;
unsigned int data_size;
IDirect3D9 *d3d9; IDirect3D9 *d3d9;
ULONG refcount; ULONG refcount;
HWND window; HWND window;
@ -6183,14 +6166,8 @@ static void test_timestamp_query(void)
ok(data_size == sizeof(UINT64), "Query data size is %u, 8 expected.\n", data_size); ok(data_size == sizeof(UINT64), "Query data size is %u, 8 expected.\n", data_size);
hr = IDirect3DQuery9_Issue(freq_query, D3DISSUE_END); hr = IDirect3DQuery9_Issue(freq_query, D3DISSUE_END);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i) wait_query(freq_query);
{
if ((hr = IDirect3DQuery9_GetData(freq_query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
memset(freq, 0xff, sizeof(freq)); memset(freq, 0xff, sizeof(freq));
hr = IDirect3DQuery9_GetData(freq_query, freq, sizeof(DWORD), D3DGETDATA_FLUSH); hr = IDirect3DQuery9_GetData(freq_query, freq, sizeof(DWORD), D3DGETDATA_FLUSH);
@ -6235,13 +6212,8 @@ static void test_timestamp_query(void)
hr = IDirect3DQuery9_Issue(query, D3DISSUE_END); hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{ wait_query(query);
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
memset(timestamp, 0xff, sizeof(timestamp)); memset(timestamp, 0xff, sizeof(timestamp));
hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(DWORD), D3DGETDATA_FLUSH); hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(DWORD), D3DGETDATA_FLUSH);
@ -6259,13 +6231,8 @@ static void test_timestamp_query(void)
hr = IDirect3DQuery9_Issue(disjoint_query, D3DISSUE_END); hr = IDirect3DQuery9_Issue(disjoint_query, D3DISSUE_END);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{ wait_query(disjoint_query);
if ((hr = IDirect3DQuery9_GetData(disjoint_query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
memset(disjoint, 0xff, sizeof(disjoint)); memset(disjoint, 0xff, sizeof(disjoint));
hr = IDirect3DQuery9_GetData(disjoint_query, disjoint, sizeof(WORD), D3DGETDATA_FLUSH); hr = IDirect3DQuery9_GetData(disjoint_query, disjoint, sizeof(WORD), D3DGETDATA_FLUSH);
@ -6287,13 +6254,9 @@ static void test_timestamp_query(void)
hr = IDirect3DQuery9_Issue(query, D3DISSUE_END); hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{ wait_query(query);
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(timestamp), D3DGETDATA_FLUSH); hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(timestamp), D3DGETDATA_FLUSH);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);

39
dlls/d3d9/tests/utils.h Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright 2019 Paul Gofman
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_D3D9_TESTS_UTILS_H
#define __WINE_D3D9_TESTS_UTILS_H
#include "wine/test.h"
#define wait_query(a) wait_query_(__FILE__, __LINE__, a)
static inline void wait_query_(const char *file, unsigned int line, IDirect3DQuery9 *query)
{
unsigned int i;
HRESULT hr;
for (i = 0; i < 500; ++i)
{
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) == S_OK)
break;
Sleep(10);
}
ok_(file, line)(hr == S_OK, "Got unexpected hr %#x.\n", hr);
}
#endif