[PATCH 2/4] d3d9/tests: Test that Direct3D9 doesn't modify the pixel format of the window it targets. (try 4)

Ken Thomases ken at codeweavers.com
Tue Feb 18 21:30:07 CST 2014


On Feb 18, 2014, at 7:53 PM, Ken Thomases wrote:

> This fixes it, although it may be more crude than we'd like:

> -    else if (context->restore_ctx)
> +    else if (context->restore_ctx || context->pixel_format != GetPixelFormat(wglGetCurrentDC()))

On second thought, that would be unreliable.  It depends on the app's DC still being valid, which it may not be.

We'd have to check using a DC for the window that would actually be used if the context were to be made current.  (I think we can ignore the swapchain backup DC, since that's used when the pixel format can't be set on context->hdc and the condition will be true, which is what we want.)  So:

    else if (context->restore_ctx || context->pixel_format != GetPixelFormat(context->hdc))

I guess this may be less efficient than we'd want.  Ideally, as little WGL state as possible would be checked other than when context->level transitions from 0 to 1.  context_enter() could check it at that time.  Rather than using restore_ctx being non-NULL as a proxy for whether the context needs to be set, we'd use a separate, explicit flag:

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 4679b25..a0d078c 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1109,6 +1109,7 @@ void context_release(struct wined3d_context *context)
             context->restore_ctx = NULL;
             context->restore_dc = NULL;
         }
+        context->needs_set = 0;
     }
 }
 
@@ -1127,7 +1128,10 @@ static void context_enter(struct wined3d_context *context)
                     current_gl, wglGetCurrentDC());
             context->restore_ctx = current_gl;
             context->restore_dc = wglGetCurrentDC();
+            context->needs_set = 1;
         }
+        else if (context->pixel_format != GetPixelFormat(context->hdc))
+            context->needs_set = 1;
     }
 }
 
@@ -3051,7 +3055,7 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str
         if (!context_set_current(context))
             ERR("Failed to activate the new context.\n");
     }
-    else if (context->restore_ctx)
+    else if (context->needs_set)
     {
         context_set_gl_context(context);
     }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0a1511b..0ceb6f1 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1085,7 +1085,8 @@ struct wined3d_context
     DWORD fixed_function_usage_map : 8; /* MAX_TEXTURES, 8 */
     DWORD lowest_disabled_stage : 4;    /* Max MAX_TEXTURES, 8 */
     DWORD rebind_fbo : 1;
-    DWORD padding : 19;
+    DWORD needs_set : 1;
+    DWORD padding : 18;
     DWORD shader_update_mask;
     DWORD constant_update_mask;
     DWORD                   numbered_array_mask;


-Ken




More information about the wine-devel mailing list