From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/context.c | 2 +- dlls/wined3d/cs.c | 40 ++------- dlls/wined3d/sampler.c | 4 - dlls/wined3d/state.c | 110 ++--------------------- dlls/wined3d/stateblock.c | 155 ++++++++++++++++++++++++++++----- dlls/wined3d/texture.c | 10 +-- dlls/wined3d/wined3d_private.h | 18 +--- 7 files changed, 153 insertions(+), 186 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index cc583fc8d26..ce3c18be4f1 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -368,7 +368,7 @@ static void context_preload_texture(struct wined3d_context *context, || (state->fb.depth_stencil && state->fb.depth_stencil->resource == &texture->resource)) context->uses_fbo_attached_resources = 1;
- wined3d_texture_load(texture, context, is_srgb_enabled(state->sampler_states[texture_idx])); + wined3d_texture_load(texture, context, state->sampler[shader_type][idx]->desc.srgb_decode); }
/* Context activation is done by the caller. */ diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index aa011ea7714..3004f308843 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -114,7 +114,6 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_DEPTH_BOUNDS, WINED3D_CS_OP_SET_RENDER_STATE, WINED3D_CS_OP_SET_TEXTURE_STATE, - WINED3D_CS_OP_SET_SAMPLER_STATE, WINED3D_CS_OP_SET_TRANSFORM, WINED3D_CS_OP_SET_CLIP_PLANE, WINED3D_CS_OP_SET_COLOR_KEY, @@ -365,14 +364,6 @@ struct wined3d_cs_set_texture_state DWORD value; };
-struct wined3d_cs_set_sampler_state -{ - enum wined3d_cs_op opcode; - UINT sampler_idx; - enum wined3d_sampler_state state; - DWORD value; -}; - struct wined3d_cs_set_transform { enum wined3d_cs_op opcode; @@ -604,7 +595,6 @@ static const char *debug_cs_op(enum wined3d_cs_op op) WINED3D_TO_STR(WINED3D_CS_OP_SET_DEPTH_BOUNDS); WINED3D_TO_STR(WINED3D_CS_OP_SET_RENDER_STATE); WINED3D_TO_STR(WINED3D_CS_OP_SET_TEXTURE_STATE); - WINED3D_TO_STR(WINED3D_CS_OP_SET_SAMPLER_STATE); WINED3D_TO_STR(WINED3D_CS_OP_SET_TRANSFORM); WINED3D_TO_STR(WINED3D_CS_OP_SET_CLIP_PLANE); WINED3D_TO_STR(WINED3D_CS_OP_SET_COLOR_KEY); @@ -1649,8 +1639,15 @@ static void wined3d_cs_exec_set_samplers(struct wined3d_cs *cs, const void *data unsigned int i;
for (i = 0; i < op->count; ++i) + { cs->state.sampler[op->type][op->start_idx + i] = op->samplers[i];
+ if (op->type == WINED3D_SHADER_TYPE_PIXEL && i < WINED3D_MAX_FRAGMENT_SAMPLERS) + device_invalidate_state(cs->c.device, STATE_SAMPLER(i)); + else if (op->type == WINED3D_SHADER_TYPE_VERTEX && i < WINED3D_MAX_VERTEX_SAMPLERS) + device_invalidate_state(cs->c.device, STATE_SAMPLER(WINED3D_VERTEX_SAMPLER_OFFSET + i)); + } + if (op->type != WINED3D_SHADER_TYPE_COMPUTE) device_invalidate_state(cs->c.device, STATE_GRAPHICS_SHADER_RESOURCE_BINDING); else @@ -1845,28 +1842,6 @@ void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); }
-static void wined3d_cs_exec_set_sampler_state(struct wined3d_cs *cs, const void *data) -{ - const struct wined3d_cs_set_sampler_state *op = data; - - cs->state.sampler_states[op->sampler_idx][op->state] = op->value; - device_invalidate_state(cs->c.device, STATE_SAMPLER(op->sampler_idx)); -} - -void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context *context, unsigned int sampler_idx, - enum wined3d_sampler_state state, unsigned int value) -{ - struct wined3d_cs_set_sampler_state *op; - - op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); - op->opcode = WINED3D_CS_OP_SET_SAMPLER_STATE; - op->sampler_idx = sampler_idx; - op->state = state; - op->value = value; - - wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); -} - static void wined3d_cs_exec_set_transform(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_set_transform *op = data; @@ -2918,7 +2893,6 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_SET_DEPTH_BOUNDS */ wined3d_cs_exec_set_depth_bounds, /* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state, /* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state, - /* WINED3D_CS_OP_SET_SAMPLER_STATE */ wined3d_cs_exec_set_sampler_state, /* WINED3D_CS_OP_SET_TRANSFORM */ wined3d_cs_exec_set_transform, /* WINED3D_CS_OP_SET_CLIP_PLANE */ wined3d_cs_exec_set_clip_plane, /* WINED3D_CS_OP_SET_COLOR_KEY */ wined3d_cs_exec_set_color_key, diff --git a/dlls/wined3d/sampler.c b/dlls/wined3d/sampler.c index cebb7400631..afd26a527f9 100644 --- a/dlls/wined3d/sampler.c +++ b/dlls/wined3d/sampler.c @@ -311,10 +311,6 @@ static void texture_gl_apply_base_level(struct wined3d_texture_gl *texture_gl, gl_tex = wined3d_texture_gl_get_gl_texture(texture_gl, texture_gl->t.flags & WINED3D_TEXTURE_IS_SRGB); if (desc->mip_base_level != gl_tex->sampler_desc.mip_base_level) { - /* Note that WINED3D_SAMP_MAX_MIP_LEVEL specifies the largest mipmap - * (default 0), while GL_TEXTURE_MAX_LEVEL specifies the smallest - * mipmap used (default 1000). So WINED3D_SAMP_MAX_MIP_LEVEL - * corresponds to GL_TEXTURE_BASE_LEVEL. */ gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, desc->mip_base_level); gl_tex->sampler_desc.mip_base_level = desc->mip_base_level; } diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 8005e62b79b..cd352cba488 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3451,83 +3451,6 @@ static void sampler_texmatrix(struct wined3d_context *context, const struct wine } }
-static enum wined3d_texture_address wined3d_texture_address_mode(const struct wined3d_texture *texture, - enum wined3d_texture_address t) -{ - if (t < WINED3D_TADDRESS_WRAP || t > WINED3D_TADDRESS_MIRROR_ONCE) - { - FIXME("Unrecognized or unsupported texture address mode %#x.\n", t); - return WINED3D_TADDRESS_WRAP; - } - - /* Cubemaps are always set to clamp, regardless of the sampler state. */ - if ((texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP) - || ((texture->flags & WINED3D_TEXTURE_COND_NP2) && t == WINED3D_TADDRESS_WRAP)) - return WINED3D_TADDRESS_CLAMP; - - return t; -} - -static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc *desc, - const uint32_t *sampler_states, const struct wined3d_texture *texture) -{ - union - { - float f; - DWORD d; - } lod_bias; - - desc->address_u = wined3d_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_U]); - desc->address_v = wined3d_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_V]); - desc->address_w = wined3d_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_W]); - wined3d_color_from_d3dcolor((struct wined3d_color *)desc->border_color, - sampler_states[WINED3D_SAMP_BORDER_COLOR]); - if (sampler_states[WINED3D_SAMP_MAG_FILTER] > WINED3D_TEXF_ANISOTROPIC) - FIXME("Unrecognized or unsupported WINED3D_SAMP_MAG_FILTER %#x.\n", - sampler_states[WINED3D_SAMP_MAG_FILTER]); - desc->mag_filter = min(max(sampler_states[WINED3D_SAMP_MAG_FILTER], WINED3D_TEXF_POINT), WINED3D_TEXF_LINEAR); - if (sampler_states[WINED3D_SAMP_MIN_FILTER] > WINED3D_TEXF_ANISOTROPIC) - FIXME("Unrecognized or unsupported WINED3D_SAMP_MIN_FILTER %#x.\n", - sampler_states[WINED3D_SAMP_MIN_FILTER]); - desc->min_filter = min(max(sampler_states[WINED3D_SAMP_MIN_FILTER], WINED3D_TEXF_POINT), WINED3D_TEXF_LINEAR); - if (sampler_states[WINED3D_SAMP_MIP_FILTER] > WINED3D_TEXF_ANISOTROPIC) - FIXME("Unrecognized or unsupported WINED3D_SAMP_MIP_FILTER %#x.\n", - sampler_states[WINED3D_SAMP_MIP_FILTER]); - desc->mip_filter = min(max(sampler_states[WINED3D_SAMP_MIP_FILTER], WINED3D_TEXF_NONE), WINED3D_TEXF_LINEAR); - lod_bias.d = sampler_states[WINED3D_SAMP_MIPMAP_LOD_BIAS]; - desc->lod_bias = lod_bias.f; - desc->min_lod = -1000.0f; - desc->max_lod = 1000.0f; - - /* The LOD is already clamped to texture->level_count in wined3d_texture_set_lod(). */ - if (texture->flags & WINED3D_TEXTURE_COND_NP2) - desc->mip_base_level = 0; - else if (desc->mip_filter == WINED3D_TEXF_NONE) - desc->mip_base_level = texture->lod; - else - desc->mip_base_level = min(max(sampler_states[WINED3D_SAMP_MAX_MIP_LEVEL], texture->lod), texture->level_count - 1); - - desc->max_anisotropy = sampler_states[WINED3D_SAMP_MAX_ANISOTROPY]; - if ((sampler_states[WINED3D_SAMP_MAG_FILTER] != WINED3D_TEXF_ANISOTROPIC - && sampler_states[WINED3D_SAMP_MIN_FILTER] != WINED3D_TEXF_ANISOTROPIC - && sampler_states[WINED3D_SAMP_MIP_FILTER] != WINED3D_TEXF_ANISOTROPIC) - || (texture->flags & WINED3D_TEXTURE_COND_NP2)) - desc->max_anisotropy = 1; - desc->compare = texture->resource.format_caps & WINED3D_FORMAT_CAP_SHADOW; - desc->comparison_func = WINED3D_CMP_LESSEQUAL; - desc->srgb_decode = is_srgb_enabled(sampler_states); - - if (!(texture->resource.format_caps & WINED3D_FORMAT_CAP_FILTERING)) - { - desc->mag_filter = WINED3D_TEXF_POINT; - desc->min_filter = WINED3D_TEXF_POINT; - desc->mip_filter = WINED3D_TEXF_NONE; - } - - if (texture->flags & WINED3D_TEXTURE_COND_NP2) - desc->mip_filter = WINED3D_TEXF_NONE; -} - /* Enabling and disabling texture dimensions is done by texture stage state / * pixel shader setup, this function only has to bind textures and set the per * texture states. */ @@ -3553,36 +3476,19 @@ 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]); - const uint32_t *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; + enum wined3d_shader_type shader_type = WINED3D_SHADER_TYPE_PIXEL; + unsigned int bind_idx = sampler_idx; struct wined3d_sampler *sampler; - struct wine_rb_entry *entry; - - wined3d_sampler_desc_from_sampler_states(&desc, sampler_states, &texture_gl->t);
- wined3d_texture_gl_bind(texture_gl, context_gl, srgb); - - if ((entry = wine_rb_get(&device->samplers, &desc))) + if (sampler_idx >= WINED3D_VERTEX_SAMPLER_OFFSET) { - sampler = WINE_RB_ENTRY_VALUE(entry, struct wined3d_sampler, entry); - } - else - { - if (FAILED(wined3d_sampler_create(device, &desc, NULL, &wined3d_null_parent_ops, &sampler))) - { - ERR("Failed to create sampler.\n"); - return; - } - if (wine_rb_put(&device->samplers, &desc, &sampler->entry) == -1) - { - ERR("Failed to insert sampler.\n"); - wined3d_sampler_decref(sampler); - return; - } + bind_idx -= WINED3D_VERTEX_SAMPLER_OFFSET; + shader_type = WINED3D_SHADER_TYPE_VERTEX; }
+ sampler = state->sampler[shader_type][bind_idx]; + + wined3d_texture_gl_bind(texture_gl, context_gl, sampler->desc.srgb_decode); wined3d_sampler_gl_bind(wined3d_sampler_gl(sampler), mapped_stage, texture_gl, context_gl);
/* Trigger shader constant reloading (for NP2 texcoord fixup) */ diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 3972ba0abba..9cb9916d462 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1997,8 +1997,6 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d init_default_texture_state(i, state->texture_states[i]); }
- init_default_sampler_states(state->sampler_states); - state->blend_factor.r = 1.0f; state->blend_factor.g = 1.0f; state->blend_factor.b = 1.0f; @@ -2532,22 +2530,6 @@ static void wined3d_device_set_texture_stage_state(struct wined3d_device *device wined3d_device_context_emit_set_texture_state(&device->cs->c, stage, state, value); }
-static void wined3d_device_set_sampler_state(struct wined3d_device *device, - unsigned int sampler_idx, enum wined3d_sampler_state state, unsigned int value) -{ - TRACE("device %p, sampler_idx %u, state %s, value %#x.\n", - device, sampler_idx, debug_d3dsamplerstate(state), value); - - if (value == device->cs->c.state->sampler_states[sampler_idx][state]) - { - TRACE("Application is setting the old value over, nothing to do.\n"); - return; - } - - device->cs->c.state->sampler_states[sampler_idx][state] = value; - wined3d_device_context_emit_set_sampler_state(&device->cs->c, sampler_idx, state, value); -} - static void wined3d_device_set_texture(struct wined3d_device *device, unsigned int stage, struct wined3d_texture *texture) { @@ -2610,6 +2592,84 @@ static void wined3d_device_set_transform(struct wined3d_device *device, wined3d_device_context_emit_set_transform(&device->cs->c, state, matrix); }
+static enum wined3d_texture_address get_texture_address_mode(const struct wined3d_texture *texture, + enum wined3d_texture_address t) +{ + if (t < WINED3D_TADDRESS_WRAP || t > WINED3D_TADDRESS_MIRROR_ONCE) + { + FIXME("Unrecognized or unsupported texture address mode %#x.\n", t); + return WINED3D_TADDRESS_WRAP; + } + + /* Cubemaps are always set to clamp, regardless of the sampler state. */ + if ((texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP) + || ((texture->flags & WINED3D_TEXTURE_COND_NP2) && t == WINED3D_TADDRESS_WRAP)) + return WINED3D_TADDRESS_CLAMP; + + return t; +} + +static void sampler_desc_from_sampler_states(struct wined3d_sampler_desc *desc, + const uint32_t *sampler_states, const struct wined3d_texture *texture) +{ + desc->address_u = get_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_U]); + desc->address_v = get_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_V]); + desc->address_w = get_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_W]); + wined3d_color_from_d3dcolor((struct wined3d_color *)desc->border_color, + sampler_states[WINED3D_SAMP_BORDER_COLOR]); + if (sampler_states[WINED3D_SAMP_MAG_FILTER] > WINED3D_TEXF_ANISOTROPIC) + FIXME("Unrecognized or unsupported WINED3D_SAMP_MAG_FILTER %#x.\n", + sampler_states[WINED3D_SAMP_MAG_FILTER]); + desc->mag_filter = min(max(sampler_states[WINED3D_SAMP_MAG_FILTER], WINED3D_TEXF_POINT), WINED3D_TEXF_LINEAR); + if (sampler_states[WINED3D_SAMP_MIN_FILTER] > WINED3D_TEXF_ANISOTROPIC) + FIXME("Unrecognized or unsupported WINED3D_SAMP_MIN_FILTER %#x.\n", + sampler_states[WINED3D_SAMP_MIN_FILTER]); + desc->min_filter = min(max(sampler_states[WINED3D_SAMP_MIN_FILTER], WINED3D_TEXF_POINT), WINED3D_TEXF_LINEAR); + if (sampler_states[WINED3D_SAMP_MIP_FILTER] > WINED3D_TEXF_ANISOTROPIC) + FIXME("Unrecognized or unsupported WINED3D_SAMP_MIP_FILTER %#x.\n", + sampler_states[WINED3D_SAMP_MIP_FILTER]); + desc->mip_filter = min(max(sampler_states[WINED3D_SAMP_MIP_FILTER], WINED3D_TEXF_NONE), WINED3D_TEXF_LINEAR); + desc->lod_bias = int_to_float(sampler_states[WINED3D_SAMP_MIPMAP_LOD_BIAS]); + desc->min_lod = -1000.0f; + desc->max_lod = 1000.0f; + + /* The LOD is already clamped to texture->level_count in wined3d_texture_set_lod(). */ + if (texture->flags & WINED3D_TEXTURE_COND_NP2) + desc->mip_base_level = 0; + else if (desc->mip_filter == WINED3D_TEXF_NONE) + desc->mip_base_level = texture->lod; + else + desc->mip_base_level = min(max(sampler_states[WINED3D_SAMP_MAX_MIP_LEVEL], texture->lod), texture->level_count - 1); + + desc->max_anisotropy = sampler_states[WINED3D_SAMP_MAX_ANISOTROPY]; + if ((sampler_states[WINED3D_SAMP_MAG_FILTER] != WINED3D_TEXF_ANISOTROPIC + && sampler_states[WINED3D_SAMP_MIN_FILTER] != WINED3D_TEXF_ANISOTROPIC + && sampler_states[WINED3D_SAMP_MIP_FILTER] != WINED3D_TEXF_ANISOTROPIC) + || (texture->flags & WINED3D_TEXTURE_COND_NP2)) + desc->max_anisotropy = 1; + desc->compare = texture->resource.format_caps & WINED3D_FORMAT_CAP_SHADOW; + desc->comparison_func = WINED3D_CMP_LESSEQUAL; + + /* 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. */ + desc->srgb_decode = sampler_states[WINED3D_SAMP_SRGB_TEXTURE] & 0x1; + + if (!(texture->resource.format_caps & WINED3D_FORMAT_CAP_FILTERING)) + { + desc->mag_filter = WINED3D_TEXF_POINT; + desc->min_filter = WINED3D_TEXF_POINT; + desc->mip_filter = WINED3D_TEXF_NONE; + } + + if (texture->flags & WINED3D_TEXTURE_COND_NP2) + desc->mip_filter = WINED3D_TEXF_NONE; +} + void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock) { @@ -3162,11 +3222,43 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
for (i = 0; i < ARRAY_SIZE(changed->samplerState); ++i) { - map = changed->samplerState[i]; - while (map) + enum wined3d_shader_type shader_type = WINED3D_SHADER_TYPE_PIXEL; + struct wined3d_sampler_desc desc; + struct wined3d_texture *texture; + struct wined3d_sampler *sampler; + unsigned int bind_index = i; + struct wine_rb_entry *entry; + + if (!changed->samplerState[i] && !(changed->textures & (1u << i))) + continue; + + if (!(texture = state->textures[i])) + continue; + + memset(&desc, 0, sizeof(desc)); + sampler_desc_from_sampler_states(&desc, state->sampler_states[i], texture); + + if (i >= WINED3D_VERTEX_SAMPLER_OFFSET) { - j = wined3d_bit_scan(&map); - wined3d_device_set_sampler_state(device, i, j, state->sampler_states[i][j]); + shader_type = WINED3D_SHADER_TYPE_VERTEX; + bind_index -= WINED3D_VERTEX_SAMPLER_OFFSET; + } + + if ((entry = wine_rb_get(&device->samplers, &desc))) + { + sampler = WINE_RB_ENTRY_VALUE(entry, struct wined3d_sampler, entry); + + wined3d_device_context_set_samplers(context, shader_type, bind_index, 1, &sampler); + } + else if (SUCCEEDED(wined3d_sampler_create(device, &desc, NULL, &wined3d_null_parent_ops, &sampler))) + { + wined3d_device_context_set_samplers(context, shader_type, bind_index, 1, &sampler); + + if (wine_rb_put(&device->samplers, &desc, &sampler->entry) == -1) + { + ERR("Failed to insert sampler.\n"); + wined3d_sampler_decref(sampler); + } } }
@@ -3223,3 +3315,22 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
TRACE("Applied stateblock %p.\n", stateblock); } + +void wined3d_stateblock_invalidate_texture_lod(struct wined3d_stateblock *stateblock, struct wined3d_texture *texture) +{ + unsigned int i; + + for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i) + { + /* Mark the texture as changed. The next time the appplication draws + * from this texture, wined3d_device_apply_stateblock() will recompute + * the texture LOD. + * + * We only need to do this for the primary stateblock. If a recording + * stateblock uses a texture whose LOD is changed, that texture will be + * invalidated on the primary stateblock anyway when the recording + * stateblock is applied. */ + if (stateblock->stateblock_state.textures[i] == texture) + stateblock->changed.textures |= (1u << i); + } +} diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 82d1fe3cda5..c32b458fe56 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1757,16 +1757,8 @@ unsigned int CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, unsi
if (texture->lod != lod) { - struct wined3d_device *device = resource->device; - - wined3d_resource_wait_idle(resource); texture->lod = lod; - - wined3d_texture_gl(texture)->texture_rgb.sampler_desc.mip_base_level = ~0u; - wined3d_texture_gl(texture)->texture_srgb.sampler_desc.mip_base_level = ~0u; - if (resource->bind_count) - wined3d_device_context_emit_set_sampler_state(&device->cs->c, texture->sampler, WINED3D_SAMP_MAX_MIP_LEVEL, - device->cs->c.state->sampler_states[texture->sampler][WINED3D_SAMP_MAX_MIP_LEVEL]); + wined3d_stateblock_invalidate_texture_lod(resource->device->primary_stateblock, texture); }
return old; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3d75660ad05..cdc33525307 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2884,7 +2884,6 @@ struct wined3d_state struct wined3d_unordered_access_view *unordered_access_view[WINED3D_PIPELINE_COUNT][MAX_UNORDERED_ACCESS_VIEWS];
struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS]; - uint32_t sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; uint32_t texture_states[WINED3D_MAX_FFP_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1]; @@ -3719,8 +3718,6 @@ void wined3d_device_context_emit_set_rendertarget_views(struct wined3d_device_co unsigned int count, struct wined3d_rendertarget_view *const *views) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers) DECLSPEC_HIDDEN; -void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context *context, unsigned int sampler_idx, - enum wined3d_sampler_state state, unsigned int value) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context *context, unsigned int rect_count, const RECT *rects) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, @@ -4556,6 +4553,9 @@ uint32_t wined3d_format_pack(const struct wined3d_format *format, const struct w BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1, enum wined3d_format_id format2) DECLSPEC_HIDDEN;
+void wined3d_stateblock_invalidate_texture_lod(struct wined3d_stateblock *stateblock, + struct wined3d_texture *texture) DECLSPEC_HIDDEN; + BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
static inline BOOL wined3d_format_is_typeless(const struct wined3d_format *format) @@ -4593,18 +4593,6 @@ static inline void context_apply_state(struct wined3d_context *context, state_table[rep].apply(context, state, rep); }
-static inline BOOL is_srgb_enabled(const uint32_t *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) {