[7/10] WineD3D: Test for supported queries
Stefan Dösinger
stefan at codeweavers.com
Thu Feb 15 06:51:24 CST 2007
-------------- next part --------------
From e3d75153f82393a370f98e5c982173e446772494 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Sat, 10 Feb 2007 14:04:56 +0100
Subject: [PATCH] WineD3D: Test for supported queries
This test contains a table of known supported / known unsupported
queries. In theory wined3d could just report the queries it supports,
but applications may make some assumtions regarding supported /
unsupported queries and stop working if they find a query unexpectadely
supported or unsupported. It also tests what is supposed to happen if an
unsupported query is created.
---
dlls/d3d9/tests/Makefile.in | 1 +
dlls/d3d9/tests/query.c | 169 +++++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/device.c | 54 +++++++-------
3 files changed, 197 insertions(+), 27 deletions(-)
diff --git a/dlls/d3d9/tests/Makefile.in b/dlls/d3d9/tests/Makefile.in
index cab2eee..0151ee3 100644
--- a/dlls/d3d9/tests/Makefile.in
+++ b/dlls/d3d9/tests/Makefile.in
@@ -8,6 +8,7 @@ EXTRALIBS = -ldxerr9 -luuid -ldxguid
CTESTS = \
device.c \
+ query.c \
shader.c \
stateblock.c \
surface.c \
diff --git a/dlls/d3d9/tests/query.c b/dlls/d3d9/tests/query.c
new file mode 100644
index 0000000..72e1018
--- /dev/null
+++ b/dlls/d3d9/tests/query.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2006-2007 Stefan Dösinger(For CodeWeavers)
+ *
+ * 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
+ */
+
+#define COBJMACROS
+#include <d3d9.h>
+#include <dxerr9.h>
+#include "wine/test.h"
+
+static IDirect3D9 *(WINAPI *pDirect3DCreate9)(UINT);
+
+struct queryInfo
+{
+ D3DQUERYTYPE type; /* Query to test */
+ BOOL foundSupported; /* If at least one windows driver has been found supporting this query */
+ BOOL foundUnsupported; /* If at least one windows driver has been found which does not support this query */
+};
+
+/* When running running this test on windows reveals any differences regarding known supported / unsupported queries,
+ * change this table.
+ *
+ * When marking a query known supported or known unsupported please write one card which supports / does not support
+ * the query.
+ */
+static struct queryInfo queries[] =
+{
+ {D3DQUERYTYPE_VCACHE, TRUE /* geforce 6600 */, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_RESOURCEMANAGER, FALSE, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_VERTEXSTATS, FALSE, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_EVENT, TRUE /* geforce 2 mx */, TRUE /* ati mach64 */ },
+ {D3DQUERYTYPE_OCCLUSION, TRUE /* radeon M9 */, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_TIMESTAMP, TRUE /* geforce 6600 */, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_TIMESTAMPDISJOINT, TRUE /* geforce 6600 */, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_TIMESTAMPFREQ, TRUE /* geforce 6600 */, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_PIPELINETIMINGS, FALSE, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_INTERFACETIMINGS, FALSE, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_VERTEXTIMINGS, FALSE, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_PIXELTIMINGS, FALSE, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_BANDWIDTHTIMINGS, FALSE, TRUE /* geforce 2 mx */ },
+ {D3DQUERYTYPE_CACHEUTILIZATION, FALSE, TRUE /* geforce 2 mx */ },
+};
+
+static const char *queryName(D3DQUERYTYPE type)
+{
+ switch(type)
+ {
+ case D3DQUERYTYPE_VCACHE: return "D3DQUERYTYPE_VCACHE";
+ case D3DQUERYTYPE_RESOURCEMANAGER: return "D3DQUERYTYPE_RESOURCEMANAGER";
+ case D3DQUERYTYPE_VERTEXSTATS: return "D3DQUERYTYPE_VERTEXSTATS";
+ case D3DQUERYTYPE_EVENT: return "D3DQUERYTYPE_EVENT";
+ case D3DQUERYTYPE_OCCLUSION: return "D3DQUERYTYPE_OCCLUSION";
+ case D3DQUERYTYPE_TIMESTAMP: return "D3DQUERYTYPE_TIMESTAMP";
+ case D3DQUERYTYPE_TIMESTAMPDISJOINT: return "D3DQUERYTYPE_TIMESTAMPDISJOINT";
+ case D3DQUERYTYPE_TIMESTAMPFREQ: return "D3DQUERYTYPE_TIMESTAMPFREQ";
+ case D3DQUERYTYPE_PIPELINETIMINGS: return "D3DQUERYTYPE_PIPELINETIMINGS";
+ case D3DQUERYTYPE_INTERFACETIMINGS: return "D3DQUERYTYPE_INTERFACETIMINGS";
+ case D3DQUERYTYPE_VERTEXTIMINGS: return "D3DQUERYTYPE_VERTEXTIMINGS";
+ case D3DQUERYTYPE_PIXELTIMINGS: return "D3DQUERYTYPE_PIXELTIMINGS";
+ case D3DQUERYTYPE_BANDWIDTHTIMINGS: return "D3DQUERYTYPE_BANDWIDTHTIMINGS";
+ case D3DQUERYTYPE_CACHEUTILIZATION: return "D3DQUERYTYPE_CACHEUTILIZATION";
+ default: return "Unexpected query type";
+ }
+}
+
+static void test_query_support(IDirect3D9 *pD3d, HWND hwnd)
+{
+
+ HRESULT hr;
+
+ IDirect3DDevice9 *pDevice = NULL;
+ D3DPRESENT_PARAMETERS d3dpp;
+ D3DDISPLAYMODE d3ddm;
+ int i;
+ IDirect3DQuery9 *pQuery = NULL;
+ BOOL supported;
+
+ IDirect3D9_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm );
+ ZeroMemory( &d3dpp, sizeof(d3dpp) );
+ d3dpp.Windowed = TRUE;
+ d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
+ d3dpp.BackBufferFormat = d3ddm.Format;
+
+ hr = IDirect3D9_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice );
+ ok(SUCCEEDED(hr), "Failed to create IDirect3D9Device (%s)\n", DXGetErrorString9(hr));
+ if (FAILED(hr)) goto cleanup;
+
+ for(i = 0; i < sizeof(queries) / sizeof(queries[0]); i++)
+ {
+ hr = IDirect3DDevice9_CreateQuery(pDevice, queries[i].type, NULL);
+ ok(hr == D3D_OK || D3DERR_NOTAVAILABLE,
+ "IDirect3DDevice9_CreateQuery returned unexpected return value %s for query %s\n", DXGetErrorString9(hr), queryName(queries[i].type));
+
+ supported = (hr == D3D_OK ? TRUE : FALSE);
+ trace("query %s is %s\n", queryName(queries[i].type), supported ? "supported" : "not supported");
+
+ ok(!(supported == TRUE && queries[i].foundSupported == FALSE),
+ "Query %s is supported on this system, but was not found supported before\n",
+ queryName(queries[i].type));
+ ok(!(supported == FALSE && queries[i].foundUnsupported == FALSE),
+ "Query %s is not supported on this system, but was found to be supported on all other systems tested before\n",
+ queryName(queries[i].type));
+
+ hr = IDirect3DDevice9_CreateQuery(pDevice, queries[i].type, &pQuery);
+ ok(hr == D3D_OK || D3DERR_NOTAVAILABLE,
+ "IDirect3DDevice9_CreateQuery returned unexpected return value %s for query %s\n", DXGetErrorString9(hr), queryName(queries[i].type));
+ ok(!(supported && !pQuery), "Query %s was claimed to be supported, but can't be created\n", queryName(queries[i].type));
+ ok(!(!supported && pQuery), "Query %s was claimed not to be supported, but can be created\n", queryName(queries[i].type));
+ if(pQuery)
+ {
+ IDirect3DQuery9_Release(pQuery);
+ pQuery = NULL;
+ }
+ }
+
+ cleanup:
+ if(pDevice) IDirect3DDevice9_Release(pDevice);
+}
+
+START_TEST(query)
+{
+ HMODULE d3d9_handle = LoadLibraryA( "d3d9.dll" );
+ if (!d3d9_handle)
+ {
+ skip("Could not load d3d9.dll\n");
+ return;
+ }
+
+ pDirect3DCreate9 = (void *)GetProcAddress( d3d9_handle, "Direct3DCreate9" );
+ ok(pDirect3DCreate9 != NULL, "Failed to get address of Direct3DCreate9\n");
+ if (pDirect3DCreate9)
+ {
+ IDirect3D9 *pD3d = NULL;
+ HWND hwnd = NULL;
+
+ pD3d = pDirect3DCreate9( D3D_SDK_VERSION );
+ if(!pD3d)
+ {
+ skip("Failed to create Direct3D9 object, not running tests\n");
+ return;
+ }
+ hwnd = CreateWindow( "static", "d3d9_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
+ if(!hwnd)
+ {
+ skip("Failed to create window\n");
+ IDirect3D9_Release(pD3d);
+ return;
+ }
+
+ test_query_support(pD3d, hwnd);
+
+ DestroyWindow(hwnd);
+ IDirect3D9_Release(pD3d);
+ }
+}
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 4bfc07d..1512a07 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1077,34 +1077,34 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUERYTYPE Type, IWineD3DQuery **ppQuery, IUnknown* parent) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DQueryImpl *object; /*NOTE: impl ref allowed since this is a create function */
+ HRESULT hr = WINED3DERR_NOTAVAILABLE;
- if (NULL == ppQuery) {
- /* Just a check to see if we support this type of query */
- HRESULT hr = WINED3DERR_NOTAVAILABLE;
- switch(Type) {
- case WINED3DQUERYTYPE_OCCLUSION:
- TRACE("(%p) occlusion query\n", This);
- if (GL_SUPPORT(ARB_OCCLUSION_QUERY))
- hr = WINED3D_OK;
- else
- WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY/NV_OCCLUSION_QUERY\n");
- break;
- case WINED3DQUERYTYPE_VCACHE:
- case WINED3DQUERYTYPE_RESOURCEMANAGER:
- case WINED3DQUERYTYPE_VERTEXSTATS:
- case WINED3DQUERYTYPE_EVENT:
- case WINED3DQUERYTYPE_TIMESTAMP:
- case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
- case WINED3DQUERYTYPE_TIMESTAMPFREQ:
- case WINED3DQUERYTYPE_PIPELINETIMINGS:
- case WINED3DQUERYTYPE_INTERFACETIMINGS:
- case WINED3DQUERYTYPE_VERTEXTIMINGS:
- case WINED3DQUERYTYPE_PIXELTIMINGS:
- case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
- case WINED3DQUERYTYPE_CACHEUTILIZATION:
- default:
- FIXME("(%p) Unhandled query type %d\n", This, Type);
- }
+ /* Just a check to see if we support this type of query */
+ switch(Type) {
+ case WINED3DQUERYTYPE_OCCLUSION:
+ TRACE("(%p) occlusion query\n", This);
+ if (GL_SUPPORT(ARB_OCCLUSION_QUERY))
+ hr = WINED3D_OK;
+ else
+ WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY/NV_OCCLUSION_QUERY\n");
+ break;
+ case WINED3DQUERYTYPE_VCACHE:
+ case WINED3DQUERYTYPE_RESOURCEMANAGER:
+ case WINED3DQUERYTYPE_VERTEXSTATS:
+ case WINED3DQUERYTYPE_EVENT:
+ case WINED3DQUERYTYPE_TIMESTAMP:
+ case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
+ case WINED3DQUERYTYPE_TIMESTAMPFREQ:
+ case WINED3DQUERYTYPE_PIPELINETIMINGS:
+ case WINED3DQUERYTYPE_INTERFACETIMINGS:
+ case WINED3DQUERYTYPE_VERTEXTIMINGS:
+ case WINED3DQUERYTYPE_PIXELTIMINGS:
+ case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
+ case WINED3DQUERYTYPE_CACHEUTILIZATION:
+ default:
+ FIXME("(%p) Unhandled query type %d\n", This, Type);
+ }
+ if(NULL == ppQuery || hr != WINED3D_OK) {
return hr;
}
--
1.4.4.3
More information about the wine-patches
mailing list