[PATCH] wined3d: Display state in state_undefined

Henri Verbeet hverbeet at gmail.com
Tue Feb 16 13:46:26 CST 2010


On 16 February 2010 19:32, Christian Costa <titan.costa at wanadoo.fr> wrote:
> So we should never enter this function at all. Right ?
Yes.

> And what do you mean by "something is broken" ? Are you talking about
> wined3d code ?
It means there's code that marks a state dirty that doesn't exist.
Typically that's because the code doing that should check some limit
or if certain features are available.

> That said I don't understand why we should not display the state. The fact
> is we entered this code
> and it seems, according to you, that knowing the state which produces the
> error message makes the difference.
>
Yes, but you can't check that here, the state is always 0. You should
check "rep" for zero in IWineD3DDeviceImpl_MarkStateDirty() and
Context_MarkStateDirty(), and get a backtrace if it is. I.e.,
something like the attached patch. We can't add DebugBreak()'s like
that to wined3d, and often the error is mostly harmless, but I've been
thinking about adding extra validation code like that for e.g. the
state table and locking behind some debugging define in order to share
debugging/validation code.
-------------- next part --------------
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 0878985..0e79b66 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -920,6 +920,13 @@ static void Context_MarkStateDirty(struct wined3d_context *context, DWORD state,
     DWORD idx;
     BYTE shift;
 
+    if (!rep || !StateTable[rep].representative)
+    {
+        ERR("Tried to make state %s (%#x) without rep dirty.\n",
+            debug_d3dstate(state), state);
+        DebugBreak();
+    }
+
     if (isStateDirty(context, rep)) return;
 
     context->dirtyArray[context->numDirtyEntries++] = rep;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 578d8e4..a11fb50 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -7087,6 +7087,13 @@ void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) {
     BYTE shift;
     UINT i;
 
+    if (!rep || !This->StateTable[rep].representative)
+    {
+        ERR("Tried to make state %s (%#x) without rep dirty.\n",
+            debug_d3dstate(state), state);
+        DebugBreak();
+    }
+
     for(i = 0; i < This->numContexts; i++) {
         context = This->contexts[i];
         if(isStateDirty(context, rep)) continue;


More information about the wine-devel mailing list