[PATCH 4/5] wined3d: If the format is not FBO attachable disable sRGB writes only.
Matteo Bruni
mbruni at codeweavers.com
Fri Jan 27 12:52:55 CST 2017
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
I kept this as a separate patch to make it easier to see what the
changes are and to make it possible to e.g. sign-off only the first
one. It could also be merged into the previous patch though.
dlls/wined3d/texture.c | 4 ++--
dlls/wined3d/utils.c | 4 ++--
dlls/wined3d/wined3d_private.h | 31 ++++++++++++++++++-------------
3 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index b4267ed..63577d7 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -572,7 +572,7 @@ void wined3d_texture_bind(struct wined3d_texture *texture,
TRACE("texture %p, context %p, srgb %#x.\n", texture, context, srgb);
- if (!needs_separate_srgb_gl_texture(context))
+ if (!needs_separate_srgb_gl_texture(context, texture))
srgb = FALSE;
/* sRGB mode cache for preload() calls outside drawprim. */
@@ -912,7 +912,7 @@ void wined3d_texture_load(struct wined3d_texture *texture,
TRACE("texture %p, context %p, srgb %#x.\n", texture, context, srgb);
- if (!needs_separate_srgb_gl_texture(context))
+ if (!needs_separate_srgb_gl_texture(context, texture))
srgb = FALSE;
if (srgb)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 1976bc6..4f063b4 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -2389,7 +2389,7 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
{
WARN("Format %s's sRGB format is not FBO attachable, type %u.\n",
debug_d3dformat(format->id), type);
- format_clear_flag(format, WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
+ format_clear_flag(format, WINED3DFMT_FLAG_SRGB_WRITE);
}
}
else if (status == GL_FRAMEBUFFER_COMPLETE)
@@ -2533,7 +2533,7 @@ static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx)
{
WARN("Format %s's sRGB format is not FBO attachable, resource type %u.\n",
debug_d3dformat(format->id), type);
- format_clear_flag(format, WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
+ format_clear_flag(format, WINED3DFMT_FLAG_SRGB_WRITE);
}
}
else if (format->flags[type] & WINED3DFMT_FLAG_FBO_ATTACHABLE)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 051836c..eaf54b1 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2949,12 +2949,6 @@ struct wined3d_surface
struct list overlay_entry;
};
-static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context)
-{
- return !context->gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
- && context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL;
-}
-
static inline unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
{
return surface->texture_layer * surface->container->level_count + surface->texture_level;
@@ -2965,13 +2959,6 @@ static inline struct wined3d_texture_sub_resource *surface_get_sub_resource(stru
return &surface->container->sub_resources[surface_get_sub_resource_idx(surface)];
}
-static inline GLuint surface_get_texture_name(const struct wined3d_surface *surface,
- const struct wined3d_context *context, BOOL srgb)
-{
- return srgb && needs_separate_srgb_gl_texture(context)
- ? surface->container->texture_srgb.name : surface->container->texture_rgb.name;
-}
-
HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect,
struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
@@ -3842,6 +3829,17 @@ static inline void context_apply_state(struct wined3d_context *context,
state_table[rep].apply(context, state, rep);
}
+static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context,
+ const struct wined3d_texture *texture)
+{
+ unsigned int flags = texture->resource.format_flags;
+
+ return (!context->gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
+ || (flags & (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE))
+ != (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE))
+ && context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL;
+}
+
static inline BOOL needs_srgb_write(const struct wined3d_context *context,
const struct wined3d_state *state, const struct wined3d_fb_state *fb)
{
@@ -3850,6 +3848,13 @@ static inline BOOL needs_srgb_write(const struct wined3d_context *context,
&& fb->render_targets[0] && fb->render_targets[0]->format_flags & WINED3DFMT_FLAG_SRGB_WRITE;
}
+static inline GLuint surface_get_texture_name(const struct wined3d_surface *surface,
+ const struct wined3d_context *context, BOOL srgb)
+{
+ return srgb && needs_separate_srgb_gl_texture(context, surface->container)
+ ? surface->container->texture_srgb.name : surface->container->texture_rgb.name;
+}
+
static inline BOOL can_use_texture_swizzle(const struct wined3d_gl_info *gl_info, const struct wined3d_format *format)
{
return gl_info->supported[ARB_TEXTURE_SWIZZLE] && !is_complex_fixup(format->color_fixup)
--
2.10.2
More information about the wine-patches
mailing list