Commit 980711a8 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Handle texture LOD in wined3d_sampler_desc_from_sampler_states().

parent bf9c544e
...@@ -5920,7 +5920,7 @@ static void apply_texture_blit_state(const struct wined3d_gl_info *gl_info, stru ...@@ -5920,7 +5920,7 @@ static void apply_texture_blit_state(const struct wined3d_gl_info *gl_info, stru
texture->sampler_desc.address_u = WINED3D_TADDRESS_CLAMP; texture->sampler_desc.address_u = WINED3D_TADDRESS_CLAMP;
texture->sampler_desc.address_v = WINED3D_TADDRESS_CLAMP; texture->sampler_desc.address_v = WINED3D_TADDRESS_CLAMP;
texture->sampler_desc.srgb_decode = FALSE; texture->sampler_desc.srgb_decode = FALSE;
texture->base_level = level; texture->sampler_desc.mip_base_level = level;
} }
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
......
...@@ -307,24 +307,16 @@ static void texture_gl_apply_base_level(struct wined3d_texture_gl *texture_gl, ...@@ -307,24 +307,16 @@ static void texture_gl_apply_base_level(struct wined3d_texture_gl *texture_gl,
const struct wined3d_sampler_desc *desc, const struct wined3d_gl_info *gl_info) const struct wined3d_sampler_desc *desc, const struct wined3d_gl_info *gl_info)
{ {
struct gl_texture *gl_tex; struct gl_texture *gl_tex;
unsigned int base_level;
if (texture_gl->t.flags & WINED3D_TEXTURE_COND_NP2)
base_level = 0;
else if (desc->mip_filter == WINED3D_TEXF_NONE)
base_level = texture_gl->t.lod;
else
base_level = min(max(desc->mip_base_level, texture_gl->t.lod), texture_gl->t.level_count - 1);
gl_tex = wined3d_texture_gl_get_gl_texture(texture_gl, texture_gl->t.flags & WINED3D_TEXTURE_IS_SRGB); gl_tex = wined3d_texture_gl_get_gl_texture(texture_gl, texture_gl->t.flags & WINED3D_TEXTURE_IS_SRGB);
if (base_level != gl_tex->base_level) if (desc->mip_base_level != gl_tex->sampler_desc.mip_base_level)
{ {
/* Note that WINED3D_SAMP_MAX_MIP_LEVEL specifies the largest mipmap /* Note that WINED3D_SAMP_MAX_MIP_LEVEL specifies the largest mipmap
* (default 0), while GL_TEXTURE_MAX_LEVEL specifies the smallest * (default 0), while GL_TEXTURE_MAX_LEVEL specifies the smallest
* mipmap used (default 1000). So WINED3D_SAMP_MAX_MIP_LEVEL * mipmap used (default 1000). So WINED3D_SAMP_MAX_MIP_LEVEL
* corresponds to GL_TEXTURE_BASE_LEVEL. */ * corresponds to GL_TEXTURE_BASE_LEVEL. */
gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, base_level); gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, desc->mip_base_level);
gl_tex->base_level = base_level; gl_tex->sampler_desc.mip_base_level = desc->mip_base_level;
} }
} }
......
...@@ -3499,7 +3499,15 @@ static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc ...@@ -3499,7 +3499,15 @@ static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
desc->lod_bias = lod_bias.f; desc->lod_bias = lod_bias.f;
desc->min_lod = -1000.0f; desc->min_lod = -1000.0f;
desc->max_lod = 1000.0f; desc->max_lod = 1000.0f;
desc->mip_base_level = sampler_states[WINED3D_SAMP_MAX_MIP_LEVEL];
/* 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]; desc->max_anisotropy = sampler_states[WINED3D_SAMP_MAX_ANISOTROPY];
if ((sampler_states[WINED3D_SAMP_MAG_FILTER] != WINED3D_TEXF_ANISOTROPIC if ((sampler_states[WINED3D_SAMP_MAG_FILTER] != WINED3D_TEXF_ANISOTROPIC
&& sampler_states[WINED3D_SAMP_MIN_FILTER] != WINED3D_TEXF_ANISOTROPIC && sampler_states[WINED3D_SAMP_MIN_FILTER] != WINED3D_TEXF_ANISOTROPIC
......
...@@ -1319,7 +1319,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, ...@@ -1319,7 +1319,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
gl_tex->sampler_desc.srgb_decode = TRUE; gl_tex->sampler_desc.srgb_decode = TRUE;
else else
gl_tex->sampler_desc.srgb_decode = srgb; gl_tex->sampler_desc.srgb_decode = srgb;
gl_tex->base_level = 0; gl_tex->sampler_desc.mip_base_level = 0;
wined3d_texture_set_dirty(&texture_gl->t); wined3d_texture_set_dirty(&texture_gl->t);
wined3d_context_gl_bind_texture(context_gl, target, gl_tex->name); wined3d_context_gl_bind_texture(context_gl, target, gl_tex->name);
...@@ -1757,8 +1757,8 @@ unsigned int CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, unsi ...@@ -1757,8 +1757,8 @@ unsigned int CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, unsi
wined3d_resource_wait_idle(resource); wined3d_resource_wait_idle(resource);
texture->lod = lod; texture->lod = lod;
wined3d_texture_gl(texture)->texture_rgb.base_level = ~0u; wined3d_texture_gl(texture)->texture_rgb.sampler_desc.mip_base_level = ~0u;
wined3d_texture_gl(texture)->texture_srgb.base_level = ~0u; wined3d_texture_gl(texture)->texture_srgb.sampler_desc.mip_base_level = ~0u;
if (resource->bind_count) if (resource->bind_count)
wined3d_device_context_emit_set_sampler_state(&device->cs->c, texture->sampler, WINED3D_SAMP_MAX_MIP_LEVEL, 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]); device->cs->c.state->sampler_states[texture->sampler][WINED3D_SAMP_MAX_MIP_LEVEL]);
......
...@@ -1350,7 +1350,7 @@ void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resou ...@@ -1350,7 +1350,7 @@ void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resou
if (!view_gl->gl_view.name) if (!view_gl->gl_view.name)
{ {
gl_tex->base_level = base_level; gl_tex->sampler_desc.mip_base_level = base_level;
gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target,
GL_TEXTURE_MAX_LEVEL, texture_gl->t.level_count - 1); GL_TEXTURE_MAX_LEVEL, texture_gl->t.level_count - 1);
} }
......
...@@ -943,7 +943,6 @@ static inline void wined3d_context_gl_reference_buffer(struct wined3d_context_gl ...@@ -943,7 +943,6 @@ static inline void wined3d_context_gl_reference_buffer(struct wined3d_context_gl
struct gl_texture struct gl_texture
{ {
struct wined3d_sampler_desc sampler_desc; struct wined3d_sampler_desc sampler_desc;
unsigned int base_level;
GLuint name; GLuint name;
}; };
......
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