DirectX9 and Halflife2

Roderick Colenbrander thunderbird2k at gmx.net
Mon Oct 24 15:41:58 CDT 2005


>
> This patch should fix the problem with Queries
> http://www.winehq.org/pipermail/wine-devel/2005-October/041237.html
>

This patch is not the same as the problem for halflife2. In case ppQuery is 
NULL applications can detect if a certain query Type is supported. This 
should indeed fail for unsupported types. In case of halflife2 ppQuery isn't 
NULL and right D3D_OK is returned while it are unsupported types. Returning 
D3DERR_NOTAVAILABLE seems to be right to me. (the attached patch implements 
what I mean; the patch is on top of the other patch you showed me)

Second I believe CreateQuery of d3d9 isn't correct. MSDN states that ppQuery 
can be NULL as explained above. Right now d3d9's CreateQuery returns 
D3DERR_INVALIDCALL when ppQuery is NULL. Further I'm not sure if wined3d's 
CreateQuery is correctly called from d3d9 as ppQuery isn't passed to it but 
some other object which isn't NULL if I'm right.

> > When the Query mechanism isn't available halflife2 moves over to a
> > different backend (I think). Suddenly the screen becomes black and you
> > see hundreds of lines like this:
> > fixme:d3d_surface:IWineD3DSurfaceImpl_UnlockRect unsupported unlocking to
> > surface surf at 0x7fe1d810 usage(512)
> >

When I let CreateQuery 'fail' as it should in my opinion for unsupported query 
types then halflife2 stops working. It prints those unlockrect lines and it 
seems to get out of video memory. I think the d3d bug stuff should be handled 
here and if it is correct, the hl2 breaking caused by patches like this 
should be handled in bugzilla.

Roderick


-------------- next part --------------
cvs diff: Diffing .
Index: device.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/device.c,v
retrieving revision 1.89
diff -u -r1.89 device.c
--- device.c	29 Sep 2005 10:47:59 -0000	1.89
+++ device.c	24 Oct 2005 20:05:58 -0000
@@ -1054,12 +1054,19 @@
 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 = D3DERR_NOTAVAILABLE;
 
     if (NULL == ppQuery) {
         /* Just a check to see if we support this type of query */
-        HRESULT hr = D3DERR_NOTAVAILABLE;
         /* Lie and say everything is good (we can return ok fake data from a stub) */
         switch(Type) {
+        case WINED3DQUERYTYPE_OCCLUSION:
+            TRACE("(%p) occlusion query\n", This);
+            if (GL_SUPPORT(ARB_OCCLUSION_QUERY) || GL_SUPPORT(NV_OCCLUSION_QUERY))
+                hr = D3D_OK;
+            else
+                WARN("Not supported: ARB_OCCLUSION_QUERY/NV_OCCLUSION_QUERY\n");
+            break;
         case WINED3DQUERYTYPE_VCACHE:
         case WINED3DQUERYTYPE_RESOURCEMANAGER:
         case WINED3DQUERYTYPE_VERTEXSTATS:
@@ -1073,12 +1080,6 @@
         case WINED3DQUERYTYPE_PIXELTIMINGS:
         case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
         case WINED3DQUERYTYPE_CACHEUTILIZATION:
-        break;
-        case WINED3DQUERYTYPE_OCCLUSION:
-            TRACE("(%p) occlusion query\n", This);
-            if (GL_SUPPORT(ARB_OCCLUSION_QUERY) || GL_SUPPORT(NV_OCCLUSION_QUERY))
-                hr = D3D_OK;
-        break;
         default:
             FIXME("(%p) Unhandled query type %d\n",This , Type);
         }
@@ -1094,6 +1095,7 @@
         if(GL_SUPPORT(ARB_OCCLUSION_QUERY) || GL_SUPPORT(NV_OCCLUSION_QUERY)) {
             TRACE("(%p) Allocating data for an occlusion query\n", This);
             object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryOcclusionData));
+			hr = D3D_OK;
             break;
         }
     case D3DQUERYTYPE_VCACHE:
@@ -1114,7 +1116,7 @@
         FIXME("(%p) Unhandled query type %d\n",This , Type);
     }
     TRACE("(%p) : Created Query %p\n", This, object);
-    return D3D_OK;
+    return hr;
 }
 
 /* example at http://www.fairyengine.com/articles/dxmultiviews.htm */


More information about the wine-devel mailing list