[PATCH 3/5] wined3d: Handle sRGB_decode when reading the sampler state.

Stefan Dösinger stefan at codeweavers.com
Mon Oct 7 17:27:08 CDT 2013


---
 dlls/wined3d/context.c         |  7 +++++--
 dlls/wined3d/state.c           |  7 ++++++-
 dlls/wined3d/surface.c         |  8 --------
 dlls/wined3d/texture.c         | 12 ++++--------
 dlls/wined3d/wined3d_private.h |  3 +--
 5 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index b1f2f8a..0bc26d1 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2808,12 +2808,15 @@ static void context_preload_texture(struct wined3d_context *context,
         const struct wined3d_state *state, unsigned int idx)
 {
     struct wined3d_texture *texture;
-    enum WINED3DSRGB srgb;
+    enum WINED3DSRGB srgb = SRGB_RGB;
+    const struct wined3d_gl_info *gl_info = context->gl_info;
 
     if (!(texture = state->textures[idx]))
         return;
 
-    srgb = state->sampler_states[idx][WINED3D_SAMP_SRGB_TEXTURE] ? SRGB_SRGB : SRGB_RGB;
+    if (!gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
+            && state->sampler_states[idx][WINED3D_SAMP_SRGB_TEXTURE])
+        srgb = SRGB_SRGB;
     texture->texture_ops->texture_preload(texture, context, srgb);
 }
 
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 159fe86..c6b0b90 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3642,7 +3642,12 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
     if (state->textures[sampler])
     {
         struct wined3d_texture *texture = state->textures[sampler];
-        BOOL srgb = state->sampler_states[sampler][WINED3D_SAMP_SRGB_TEXTURE];
+        BOOL srgb;
+
+        if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
+            srgb = FALSE;
+        else
+            srgb = state->sampler_states[sampler][WINED3D_SAMP_SRGB_TEXTURE];
 
         texture->texture_ops->texture_bind(texture, context, srgb);
         wined3d_texture_apply_state_changes(texture, state->sampler_states[sampler], gl_info);
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 52eac16..eb8ca7e 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -5608,8 +5608,6 @@ HRESULT surface_load_location(struct wined3d_surface *surface, DWORD location, c
         }
     }
 
-    if (location == SFLAG_INSRGBTEX && gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
-        location = SFLAG_INTEXTURE;
 
     if (surface->flags & location)
     {
@@ -5671,12 +5669,6 @@ HRESULT surface_load_location(struct wined3d_surface *surface, DWORD location, c
             surface_evict_sysmem(surface);
     }
 
-    if (surface->flags & (SFLAG_INTEXTURE | SFLAG_INSRGBTEX)
-            && gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
-    {
-        surface->flags |= (SFLAG_INTEXTURE | SFLAG_INSRGBTEX);
-    }
-
     return WINED3D_OK;
 }
 
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 56d13f6..0953563 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -612,17 +612,15 @@ static HRESULT texture2d_bind(struct wined3d_texture *texture,
     if (set_gl_texture_desc && SUCCEEDED(hr))
     {
         UINT sub_count = texture->level_count * texture->layer_count;
-        BOOL srgb_tex = !context->gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
-                && (texture->flags & WINED3D_TEXTURE_IS_SRGB);
         struct gl_texture *gl_tex;
         UINT i;
 
-        gl_tex = wined3d_texture_get_gl_texture(texture, context->gl_info, srgb_tex);
+        gl_tex = wined3d_texture_get_gl_texture(texture, context->gl_info, srgb);
 
         for (i = 0; i < sub_count; ++i)
         {
             struct wined3d_surface *surface = surface_from_resource(texture->sub_resources[i]);
-            surface_set_texture_name(surface, gl_tex->name, srgb_tex);
+            surface_set_texture_name(surface, gl_tex->name, srgb);
         }
 
         /* Conditinal non power of two textures use a different clamping
@@ -676,7 +674,6 @@ static void texture2d_preload(struct wined3d_texture *texture,
         struct wined3d_context *context, enum WINED3DSRGB srgb)
 {
     UINT sub_count = texture->level_count * texture->layer_count;
-    const struct wined3d_gl_info *gl_info = context->gl_info;
     BOOL srgb_mode;
     DWORD flag;
     UINT i;
@@ -684,7 +681,7 @@ static void texture2d_preload(struct wined3d_texture *texture,
     TRACE("texture %p, srgb %#x.\n", texture, srgb);
 
     srgb_mode = texture_srgb_mode(texture, srgb);
-    if (srgb_mode && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
+    if (srgb_mode)
         flag = WINED3D_TEXTURE_SRGB_VALID;
     else
         flag = WINED3D_TEXTURE_RGB_VALID;
@@ -1049,7 +1046,6 @@ static void texture3d_preload(struct wined3d_texture *texture,
         struct wined3d_context *context, enum WINED3DSRGB srgb)
 {
     UINT sub_count = texture->level_count * texture->layer_count;
-    const struct wined3d_gl_info *gl_info = context->gl_info;
     BOOL srgb_mode;
     DWORD flag;
     UINT i;
@@ -1057,7 +1053,7 @@ static void texture3d_preload(struct wined3d_texture *texture,
     TRACE("texture %p, srgb %#x.\n", texture, srgb);
 
     srgb_mode = texture_srgb_mode(texture, srgb);
-    if (srgb_mode && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
+    if (srgb_mode)
         flag = WINED3D_TEXTURE_SRGB_VALID;
     else
         flag = WINED3D_TEXTURE_RGB_VALID;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 1caf7ad..4c5ba3c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2109,8 +2109,7 @@ static inline struct wined3d_texture *wined3d_texture_from_resource(struct wined
 static inline struct gl_texture *wined3d_texture_get_gl_texture(struct wined3d_texture *texture,
         const struct wined3d_gl_info *gl_info, BOOL srgb)
 {
-    return srgb && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
-            ? &texture->texture_srgb : &texture->texture_rgb;
+    return srgb ? &texture->texture_srgb : &texture->texture_rgb;
 }
 
 void wined3d_texture_apply_state_changes(struct wined3d_texture *texture,
-- 
1.8.1.5




More information about the wine-patches mailing list