Commit d49c9bbc authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

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.
parent b1e1df51
......@@ -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);
}
......
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