@@ -96,25 +96,39 @@ static void WINAPI IWineD3DTextureImpl_P /* Override the IWineD3DResource PreLoad method */ unsigned int i; BOOL setGlTextureDesc = FALSE; + BOOL srgbChanged = FALSE; IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface; + BOOL currentSamplerSRGBmode = This->resource.wineD3DDevice->stateBlock->samplerState[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE]; TRACE("(%p) : About to load texture\n", This); if (This->baseTexture.textureName == 0) setGlTextureDesc = TRUE; IWineD3DTexture_BindTexture(iface); + + /* If no textures are bound, srgbChanged remains false and thus the texture will only reload + * if it is dirty */ + if (This->baseTexture.bindCount) { + srgbChanged = (This->baseTexture.textureIsSRGB != currentSamplerSRGBmode); + + /* Inform this texture of the value of the WINED3DSAMP_SRGBENABLE state of its current sampler */ + This->baseTexture.textureIsSRGB = currentSamplerSRGBmode; + } + ENTER_GL(); /* If were dirty then reload the surfaces */ - if(This->baseTexture.dirty) { + if(This->baseTexture.dirty || srgbChanged ) { for (i = 0; i < This->baseTexture.levels; i++) { if(setGlTextureDesc) IWineD3DSurface_SetGlTextureDesc(This->surfaces[i], This->baseTexture.textureName, IWineD3DTexture_GetTextureDimensions(iface)); - IWineD3DSurface_LoadTexture(This->surfaces[i]); + IWineD3DSurface_LoadTexture(This->surfaces[i], This->baseTexture.textureIsSRGB); } /* No longer dirty */ This->baseTexture.dirty = FALSE; + + /* Inform this texture of the value of the WINED3DSAMP_SRGBENABLE state of its current sampler */ } else { TRACE("(%p) Texture not dirty, nothing to do\n" , iface); }