Commit 225fdc35 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

wined3d: Only use the LSB of the _SAMP_SRGB_TEXTURE state value.

parent 17325e6e
......@@ -3719,7 +3719,7 @@ static void context_preload_texture(struct wined3d_context *context,
if (!(texture = state->textures[idx]))
return;
wined3d_texture_load(texture, context, state->sampler_states[idx][WINED3D_SAMP_SRGB_TEXTURE]);
wined3d_texture_load(texture, context, is_srgb_enabled(state->sampler_states[idx]));
}
/* Context activation is done by the caller. */
......
......@@ -3574,7 +3574,7 @@ static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
desc->max_anisotropy = 1;
desc->compare = texture_gl->t.resource.format_flags & WINED3DFMT_FLAG_SHADOW;
desc->comparison_func = WINED3D_CMP_LESSEQUAL;
desc->srgb_decode = sampler_states[WINED3D_SAMP_SRGB_TEXTURE];
desc->srgb_decode = is_srgb_enabled(sampler_states);
if (!(texture_gl->t.resource.format_flags & WINED3DFMT_FLAG_FILTERING))
{
......@@ -3615,9 +3615,9 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
if (state->textures[sampler_idx])
{
struct wined3d_texture_gl *texture_gl = wined3d_texture_gl(state->textures[sampler_idx]);
BOOL srgb = state->sampler_states[sampler_idx][WINED3D_SAMP_SRGB_TEXTURE];
const DWORD *sampler_states = state->sampler_states[sampler_idx];
struct wined3d_device *device = context->device;
BOOL srgb = is_srgb_enabled(sampler_states);
struct wined3d_sampler_desc desc;
struct wined3d_sampler *sampler;
struct wine_rb_entry *entry;
......
......@@ -4591,6 +4591,18 @@ static inline void context_apply_state(struct wined3d_context *context,
state_table[rep].apply(context, state, rep);
}
static inline BOOL is_srgb_enabled(const DWORD *sampler_states)
{
/* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
* the behaviour of the AMD Windows driver.
*
* Might & Magic: Heroes VI - Shades of Darkness sets
* WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
* pointer—presumably by accident—and expects sRGB decoding to be
* disabled. */
return sampler_states[WINED3D_SAMP_SRGB_TEXTURE] & 0x1;
}
static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context,
const struct wined3d_texture *texture)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment