[PATCH 5/5] wined3d: Ignore wined3d_sampler_desc.srgb_decode if WINED3D_SRGB_READ_WRITE_CONTROL is not set.

Henri Verbeet hverbeet at codeweavers.com
Fri Feb 12 04:06:09 CST 2016


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/sampler.c         |  3 ++-
 dlls/wined3d/state.c           |  5 ++---
 dlls/wined3d/texture.c         | 10 ++++++----
 dlls/wined3d/wined3d_private.h |  2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/dlls/wined3d/sampler.c b/dlls/wined3d/sampler.c
index ffa1155..865198b 100644
--- a/dlls/wined3d/sampler.c
+++ b/dlls/wined3d/sampler.c
@@ -96,7 +96,8 @@ static void wined3d_sampler_init(struct wined3d_sampler *sampler, struct wined3d
         GL_EXTCALL(glSamplerParameteri(sampler->name, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE));
     GL_EXTCALL(glSamplerParameteri(sampler->name, GL_TEXTURE_COMPARE_FUNC,
             wined3d_gl_compare_func(desc->comparison_func)));
-    if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE] && !desc->srgb_decode)
+    if ((context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
+            && gl_info->supported[EXT_TEXTURE_SRGB_DECODE] && !desc->srgb_decode)
         GL_EXTCALL(glSamplerParameteri(sampler->name, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT));
     checkGLcall("sampler creation");
 
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 903f0d4..58d2fed 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3513,8 +3513,7 @@ static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
         desc->max_anisotropy = 1;
     desc->compare = texture->resource.format_flags & WINED3DFMT_FLAG_SHADOW;
     desc->comparison_func = WINED3D_CMP_LESSEQUAL;
-    desc->srgb_decode = !(context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
-            || sampler_states[WINED3D_SAMP_SRGB_TEXTURE];
+    desc->srgb_decode = sampler_states[WINED3D_SAMP_SRGB_TEXTURE];
 
     if (!(texture->resource.format_flags & WINED3DFMT_FLAG_FILTERING))
     {
@@ -3569,7 +3568,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
         wined3d_texture_bind(texture, context, srgb);
         if (!gl_info->supported[ARB_SAMPLER_OBJECTS])
         {
-            wined3d_texture_apply_sampler_desc(texture, &desc, gl_info);
+            wined3d_texture_apply_sampler_desc(texture, &desc, context);
         }
         else
         {
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 58ff5aa..b4c8bb2 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -289,13 +289,14 @@ void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
 /* Context activation is done by the caller (state handler). */
 /* This function relies on the correct texture being bound and loaded. */
 void wined3d_texture_apply_sampler_desc(struct wined3d_texture *texture,
-        const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_gl_info *gl_info)
+        const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context *context)
 {
+    const struct wined3d_gl_info *gl_info = context->gl_info;
     GLenum target = texture->target;
     struct gl_texture *gl_tex;
     DWORD state;
 
-    TRACE("texture %p, sampler_desc %p, gl_info %p.\n", texture, sampler_desc, gl_info);
+    TRACE("texture %p, sampler_desc %p, context %p.\n", texture, sampler_desc, context);
 
     gl_tex = wined3d_texture_get_gl_texture(texture, texture->flags & WINED3D_TEXTURE_IS_SRGB);
 
@@ -357,8 +358,9 @@ void wined3d_texture_apply_sampler_desc(struct wined3d_texture *texture,
         gl_tex->sampler_desc.max_anisotropy = state;
     }
 
-    /* These should always be the same unless EXT_texture_sRGB_decode is supported. */
-    if (!sampler_desc->srgb_decode != !gl_tex->sampler_desc.srgb_decode)
+    if (!sampler_desc->srgb_decode != !gl_tex->sampler_desc.srgb_decode
+            && (context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
+            && gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
     {
         gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
                 sampler_desc->srgb_decode ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 1b8d0f3..2df8cd3 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2396,7 +2396,7 @@ static inline struct gl_texture *wined3d_texture_get_gl_texture(struct wined3d_t
 }
 
 void wined3d_texture_apply_sampler_desc(struct wined3d_texture *texture,
-        const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
+        const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context *context) DECLSPEC_HIDDEN;
 void wined3d_texture_bind(struct wined3d_texture *texture,
         struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
 void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
-- 
2.1.4




More information about the wine-patches mailing list