Commit 8eb2a2cf authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Disable strict draw ordering by default.

While some performance hit from the extra flushes was expected and would be acceptable, the performance hit can be over 50% on some configurations, which clearly isn't acceptable. This patch introduces a "StrictDrawOrdering" registry key for applications affected by this, until we have a more structural solution.
parent ab80e973
...@@ -6899,8 +6899,8 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_ ...@@ -6899,8 +6899,8 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect_in, enum blit_operation blit_op, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect_in, enum blit_operation blit_op,
DWORD Filter) DWORD Filter)
{ {
IWineD3DSwapChainImpl *dst_swapchain;
struct wined3d_context *context; struct wined3d_context *context;
IWineD3DSwapChainImpl *dst_swapchain = NULL;
RECT dst_rect = *dst_rect_in; RECT dst_rect = *dst_rect_in;
/* Now load the surface */ /* Now load the surface */
...@@ -6913,10 +6913,8 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_ ...@@ -6913,10 +6913,8 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
* while OpenGL coordinates are window relative. * while OpenGL coordinates are window relative.
* Also beware of the origin difference(top left vs bottom left). * Also beware of the origin difference(top left vs bottom left).
* Also beware that the front buffer's surface size is screen width x screen height, * Also beware that the front buffer's surface size is screen width x screen height,
* whereas the real gl drawable size is the size of the window. * whereas the real gl drawable size is the size of the window. */
*/ dst_swapchain = (dst_surface->Flags & SFLAG_SWAPCHAIN) ? (IWineD3DSwapChainImpl *)dst_surface->container : NULL;
IWineD3DSurface_GetContainer((IWineD3DSurface *)dst_surface, &IID_IWineD3DSwapChain, (void **)&dst_swapchain);
if (dst_swapchain) IWineD3DSwapChain_Release((IWineD3DSwapChain *)dst_swapchain);
if (dst_swapchain && (IWineD3DSurface *)dst_surface == dst_swapchain->frontBuffer) if (dst_swapchain && (IWineD3DSurface *)dst_surface == dst_swapchain->frontBuffer)
{ {
RECT windowsize; RECT windowsize;
...@@ -6942,7 +6940,10 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_ ...@@ -6942,7 +6940,10 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
/* Leave the opengl state valid for blitting */ /* Leave the opengl state valid for blitting */
arbfp_blit_unset((IWineD3DDevice *)device); arbfp_blit_unset((IWineD3DDevice *)device);
wglFlush(); /* Flush to ensure ordering across contexts. */ if (wined3d_settings.strict_draw_ordering || (dst_swapchain
&& ((IWineD3DSurface *)dst_surface == dst_swapchain->frontBuffer
|| dst_swapchain->num_contexts > 1)))
wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
......
...@@ -4496,7 +4496,9 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfac ...@@ -4496,7 +4496,9 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfac
LEAVE_GL(); LEAVE_GL();
wglFlush(); /* Flush to ensure ordering across contexts. */ if (wined3d_settings.strict_draw_ordering || ((target->Flags & SFLAG_SWAPCHAIN)
&& ((IWineD3DSwapChainImpl *)target->container)->frontBuffer == (IWineD3DSurface *)target))
wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
...@@ -5467,7 +5469,7 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, ...@@ -5467,7 +5469,7 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface,
LEAVE_GL(); LEAVE_GL();
wglFlush(); /* Flush to ensure ordering across contexts. */ if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
} }
...@@ -5811,7 +5813,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const ...@@ -5811,7 +5813,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
LEAVE_GL(); LEAVE_GL();
wglFlush(); /* Flush to ensure ordering across contexts. */ if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
......
...@@ -694,7 +694,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT ...@@ -694,7 +694,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
wined3d_event_query_issue(This->buffer_queries[i], This); wined3d_event_query_issue(This->buffer_queries[i], This);
} }
wglFlush(); /* Flush to ensure ordering across contexts. */ if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
......
...@@ -3406,7 +3406,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine ...@@ -3406,7 +3406,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
LEAVE_GL(); LEAVE_GL();
wglFlush(); /* Flush to ensure ordering across contexts. */ if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
...@@ -3793,7 +3793,10 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -3793,7 +3793,10 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
/* Leave the opengl state valid for blitting */ /* Leave the opengl state valid for blitting */
myDevice->blitter->unset_shader((IWineD3DDevice *) myDevice); myDevice->blitter->unset_shader((IWineD3DDevice *) myDevice);
wglFlush(); /* Flush to ensure ordering across contexts. */ if (wined3d_settings.strict_draw_ordering || (dstSwapchain
&& ((IWineD3DSurface *)This == dstSwapchain->frontBuffer
|| dstSwapchain->num_contexts > 1)))
wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
...@@ -4266,7 +4269,7 @@ void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *co ...@@ -4266,7 +4269,7 @@ void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *co
LEAVE_GL(); LEAVE_GL();
wglFlush(); /* Flush to ensure ordering across contexts. */ if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
} }
else else
{ {
...@@ -4287,7 +4290,7 @@ void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *co ...@@ -4287,7 +4290,7 @@ void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *co
LEAVE_GL(); LEAVE_GL();
wglFlush(); /* Flush to ensure ordering across contexts. */ if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
} }
else else
{ {
...@@ -4357,6 +4360,7 @@ static void WINAPI IWineD3DSurfaceImpl_ModifyLocation(IWineD3DSurface *iface, DW ...@@ -4357,6 +4360,7 @@ static void WINAPI IWineD3DSurfaceImpl_ModifyLocation(IWineD3DSurface *iface, DW
static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT *rect_in) static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT *rect_in)
{ {
IWineD3DDeviceImpl *device = This->resource.device; IWineD3DDeviceImpl *device = This->resource.device;
IWineD3DSwapChainImpl *swapchain;
struct wined3d_context *context; struct wined3d_context *context;
RECT src_rect, dst_rect; RECT src_rect, dst_rect;
...@@ -4383,7 +4387,11 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT ...@@ -4383,7 +4387,11 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
device->blitter->set_shader((IWineD3DDevice *) device, This); device->blitter->set_shader((IWineD3DDevice *) device, This);
wglFlush(); /* Flush to ensure ordering across contexts. */ swapchain = (This->Flags & SFLAG_SWAPCHAIN) ? (IWineD3DSwapChainImpl *)This->container : NULL;
if (wined3d_settings.strict_draw_ordering || (swapchain
&& ((IWineD3DSurface *)This == swapchain->frontBuffer
|| swapchain->num_contexts > 1)))
wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
} }
......
...@@ -72,7 +72,8 @@ wined3d_settings_t wined3d_settings = ...@@ -72,7 +72,8 @@ wined3d_settings_t wined3d_settings =
PCI_DEVICE_NONE,/* PCI Device ID */ PCI_DEVICE_NONE,/* PCI Device ID */
0, /* The default of memory is set in FillGLCaps */ 0, /* The default of memory is set in FillGLCaps */
NULL, /* No wine logo by default */ NULL, /* No wine logo by default */
FALSE /* Disable multisampling for now due to Nvidia driver bugs which happens for some users */ FALSE, /* Disable multisampling for now due to Nvidia driver bugs which happens for some users */
FALSE, /* No strict draw ordering. */
}; };
IWineD3D * WINAPI WineDirect3DCreate(UINT version, IUnknown *parent) IWineD3D * WINAPI WineDirect3DCreate(UINT version, IUnknown *parent)
...@@ -319,6 +320,12 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL) ...@@ -319,6 +320,12 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
wined3d_settings.allow_multisampling = TRUE; wined3d_settings.allow_multisampling = TRUE;
} }
} }
if (!get_config_key(hkey, appkey, "StrictDrawOrdering", buffer, size)
&& !strcmp(buffer,"enabled"))
{
TRACE("Enforcing strict draw ordering.\n");
wined3d_settings.strict_draw_ordering = TRUE;
}
} }
if (wined3d_settings.vs_mode == VS_HW) if (wined3d_settings.vs_mode == VS_HW)
TRACE("Allow HW vertex shaders\n"); TRACE("Allow HW vertex shaders\n");
......
...@@ -268,6 +268,7 @@ typedef struct wined3d_settings_s { ...@@ -268,6 +268,7 @@ typedef struct wined3d_settings_s {
unsigned int emulated_textureram; unsigned int emulated_textureram;
char *logo; char *logo;
int allow_multisampling; int allow_multisampling;
BOOL strict_draw_ordering;
} wined3d_settings_t; } wined3d_settings_t;
extern wined3d_settings_t wined3d_settings DECLSPEC_HIDDEN; extern wined3d_settings_t wined3d_settings DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment