[PATCH] wined3d: Display state in state_undefined

Henri Verbeet hverbeet at gmail.com
Wed Feb 17 02:16:57 CST 2010


On 17 February 2010 00:28, Stefan Dösinger <stefan at codeweavers.com> wrote:
> No, the pipeline part that would implement this(vertex) should set a state
> handler that prints a WARN for each defined but unimplemented stage.
Sure, but that doesn't mean you can't catch undefined states as well.
E.g. something along the lines of the attached patch. The main use
would be simplifying reporting bugs. The earlier posted debugging
patch is more extensive of course, but that would require people to
build with special compile flags if it ever enters wined3d in some
form.
-------------- next part --------------
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 578d8e4..a36784a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2699,6 +2699,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, W
 
     TRACE("(%p)->state = %s(%d), value = %d\n", This, debug_d3drenderstate(State), State, Value);
 
+    if (State < 1 || State > WINEHIGHEST_RENDER_STATE)
+    {
+        WARN("Tried to set invalid render state %#x.\n", State);
+        return WINED3D_OK;
+    }
+
     This->updateStateBlock->changed.renderState[State >> 5] |= 1 << (State & 0x1f);
     This->updateStateBlock->renderState[State] = Value;
 
@@ -2711,8 +2717,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, W
     /* Compared here and not before the assignment to allow proper stateblock recording */
     if(Value == oldValue) {
         TRACE("Application is setting the old value over, nothing to do\n");
-    } else {
-        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(State));
+    }
+    else
+    {
+        if (!This->StateTable[STATE_RENDER(State)].representative)
+        {
+            FIXME("State %s is invalid.\n", debug_d3drenderstate(State));
+        }
+        else IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(State));
     }
 
     return WINED3D_OK;


More information about the wine-devel mailing list