Commit b9d0cec5 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

d3d9/tests: Factor out wait_query() function.

parent 717109ce
......@@ -25,7 +25,7 @@
#define WINVER 0x0602 /* for CURSOR_SUPPRESSED */
#define COBJMACROS
#include <d3d9.h>
#include "wine/test.h"
#include "utils.h"
struct vec3
{
......@@ -5947,13 +5947,8 @@ static void test_occlusion_query(void)
hr = IDirect3DQuery9_Issue(query, D3DISSUE_END);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
wait_query(query);
memset(&data, 0xff, sizeof(data));
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);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
wait_query(query);
memset(&data, 0xff, sizeof(data));
hr = IDirect3DQuery9_GetData(query, &data, sizeof(data), D3DGETDATA_FLUSH);
......@@ -6085,13 +6074,7 @@ static void test_occlusion_query(void)
hr = IDirect3DDevice9_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) == S_OK)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
wait_query(query);
memset(&data, 0xff, sizeof(data));
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,
};
IDirect3DQuery9 *query, *disjoint_query, *freq_query;
unsigned int data_size, i;
IDirect3DDevice9 *device;
unsigned int data_size;
IDirect3D9 *d3d9;
ULONG refcount;
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);
hr = IDirect3DQuery9_Issue(freq_query, D3DISSUE_END);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{
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);
wait_query(freq_query);
memset(freq, 0xff, sizeof(freq));
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);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
wait_query(query);
memset(timestamp, 0xff, sizeof(timestamp));
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);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{
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);
wait_query(disjoint_query);
memset(disjoint, 0xff, sizeof(disjoint));
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);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < 500; ++i)
{
if ((hr = IDirect3DQuery9_GetData(query, NULL, 0, D3DGETDATA_FLUSH)) != S_FALSE)
break;
Sleep(10);
}
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
wait_query(query);
hr = IDirect3DQuery9_GetData(query, timestamp, sizeof(timestamp), D3DGETDATA_FLUSH);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
......
/*
* 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment