ENTER_GL and ActivateContext question
Stefan Dösinger
stefan at codeweavers.com
Thu Dec 13 15:00:09 CST 2007
Hi,
You are right, there is some problem here.
I think that the code originates from times when this codepath in colorfill
was only entered when iface == device->render_targets[0], or when Clear
didn't set any draw buffer itself. But you have spotted correctly, if iface
is the device's front buffer, then the colorfill will fail.
device-isInDraw is not correct for this, because Clear() can never be called
during a draw; DrawPrimitive doesn't call it, and another thread can't call
it because the critical section is held. Installing a similar variable is
possible, but hacky.
Another way would be to reverse the mapping, and make Clear() call colorfill;
That would run through the whole find-the-surface code however, and be more
overhead than a SetRenderTarget; Furthermore it is un-d3d9ish. Also, Clear()
takes a few parameters into account that colorfill doesn't
GetRenderTarget and SetRenderTarget is a useable way to solve this.
SetRenderTarget currently calls ActivateContext itself, but this call should
be removed. I added it during the context management introduction to lower
the propability of regressions.
A lot of code in WineD3D avoids the getters and setters, and just accesses the
implementation structure. While any object oriented programmer screams when
doing that, we need it for performance reasons. Currently we spend 10 to 20
per cent of the CPU time spent in WineD3D just in surface::GetContainer and
its callees, if we'd use Getters and Setters everywhere then goodbye
performance(I want to replace GetContainer somewhen). However,
GetRenderTarget and SetRenderTarget do a bit of setup and refcounting, so
bypassing that certainly has an impact on maintainability. I'd be fine with
direct impl access in this case, but it is a corner case.
A last option is to move the biggest part of Clear() into a subroutine, call
the ActivateContext in Clear and BltOverride, and perform the rest of the job
in the subroutine. The drawback of this is that d3d8 and d3d9 clears run
through an extra call, but it avoids the SetRenderTarget/GetRenderTarget
overhead and direct implementation access. The function could be inlined as
well, but I am not sure if that works across .c files.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20071213/37cbcb18/attachment.pgp
More information about the wine-devel
mailing list