Module: wine Branch: master Commit: d49c9bbcbe5b2461ca685f45da740b8f0ff400c8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d49c9bbcbe5b2461ca685f45da...
Author: Stefan Dösinger stefan@codeweavers.com Date: Mon Feb 11 01:18:06 2008 +0100
wined3d: Do not change the texture unit when binding surfaces.
Changing the texture unit when binding a surface for loading can break the state manager in the way that it changes the currently active texture unit while it is setting up a texture that has to be loaded. Instead find out the current unit to dirtify the correct sampler.
---
dlls/wined3d/surface.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 5f8fd93..be464eb 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -38,13 +38,21 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4] static inline void clear_unused_channels(IWineD3DSurfaceImpl *This);
static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This) { - /* Make sure that a proper texture unit is selected, bind the texture - * and dirtify the sampler to restore the texture on the next draw. */ + GLint active_texture; + + /* We don't need a specific texture unit, but after binding the texture the current unit is dirty. + * Read the unit back instead of switching to 0, this avoids messing around with the state manager's + * gl states. The current texture unit should always be a valid one. + * + * TODO: Track the current active texture per GL context instead of using glGet + */ if (GL_SUPPORT(ARB_MULTITEXTURE)) { - GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB)); - checkGLcall("glActiveTextureARB"); + glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); + active_texture -= GL_TEXTURE0_ARB; + } else { + active_texture = 0; } - IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(0)); + IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_texture)); IWineD3DSurface_BindTexture((IWineD3DSurface *)This); }