[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
Wed Feb 19 12:25:07 CST 2014


On Feb 19, 2014, at 4:36 AM, Henri Verbeet wrote:

> On 19 February 2014 04:30, Ken Thomases <ken at codeweavers.com> wrote:
> 
>> @@ -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);
>>     }

> I think that mostly works, but you'll probably want to clear needs_set
> in context_set_gl_context() instead of in context_release().

Hmm.  The old logic had context_acquire() doing context_set_gl_context() each time if context_enter() had set restore_ctx at the outmost level.  I didn't want to change that because I wasn't confident it was superfluous.

> I think
> there's also an argument somewhere that context_update_window() should
> set needs_set instead of calling context_set_pixel_format() and
> context_set_gl_context().

Yeah, it could do that.  Actually, looking at the current code, context_acquire() calls context_update_window() before context_enter().  Couldn't that screw up context_enter()'s ability to a) notice that it needs to restore the context, or b) record the proper context to restore?


I have to say that my approach would be to record the state to restore at exactly the place where it is changed.  So, the old WGL context and DC would be remembered at the call to wglMakeCurrent() or wglMakeContextCurrentARB().  In my pixel format patch, the old pixel format is remembered at the call to SetPixelFormat().  Etc.  You'd check to make sure that something isn't already remembered, of course, so you don't overwrite the remembered app-set state with wined3d-set state.

My approach can be less efficient because you check the state too often.  The current code uses the context->level transition from 0 to 1 to limit it.  But we can use flags (something like "restore_ctx_valid", for example) to remember if we've checked since that transition and avoid checking again (even though restore_ctx itself may remain NULL).

-Ken




More information about the wine-devel mailing list