All pastes #289911 Raw Edit

Something

public text v1 · immutable
#289911 ·published 2006-12-23 14:56 UTC
rendered paste body
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index e9a78cc..5105120 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -96,25 +96,36 @@ 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);
+
     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], currentSamplerSRGBmode);
         }

         /* No longer dirty */
         This->baseTexture.dirty = FALSE;
+
+	/* Inform this texture of the value of the WINED3DSAMP_SRGBENABLE state of its current sampler */
+        This->baseTexture.textureIsSRGB = currentSamplerSRGBmode;
     } else {
         TRACE("(%p) Texture not dirty, nothing to do\n" , iface);
     }