mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
cogl: Set LOD bias to -0.5 for single mipmap modes
So that whenever forced to choose between two levels of detail (two mipmaps) we will land on the sharpest looking one (highest resolution). That's the mipmap level equal to the floor of the current level of detail requested. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5920 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2644>
This commit is contained in:
parent
28982ade94
commit
cc19547b8c
@ -57,6 +57,7 @@ typedef enum
|
||||
COGL_PRIVATE_FEATURE_ALPHA_TEXTURES,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_LOD_BIAS,
|
||||
COGL_PRIVATE_FEATURE_OES_EGL_SYNC,
|
||||
/* If this is set then the winsys is responsible for queueing dirty
|
||||
* events. Otherwise a dirty event will be queued when the onscreen
|
||||
|
@ -682,6 +682,22 @@ _cogl_sampler_gl_init (CoglContext *context, CoglSamplerCacheEntry *entry)
|
||||
GE (context, glSamplerParameteri (entry->sampler_object,
|
||||
GL_TEXTURE_WRAP_T,
|
||||
entry->wrap_mode_t) );
|
||||
|
||||
/* While COGL_PRIVATE_FEATURE_SAMPLER_OBJECTS implies support for
|
||||
* GL_TEXTURE_LOD_BIAS in GL, the same is not true in GLES. So check,
|
||||
* and also only apply GL_TEXTURE_LOD_BIAS in mipmap modes:
|
||||
*/
|
||||
if (_cogl_has_private_feature (context,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_LOD_BIAS) &&
|
||||
entry->min_filter != GL_NEAREST &&
|
||||
entry->min_filter != GL_LINEAR)
|
||||
{
|
||||
GLfloat bias = _cogl_texture_min_filter_get_lod_bias (entry->min_filter);
|
||||
|
||||
GE (context, glSamplerParameterf (entry->sampler_object,
|
||||
GL_TEXTURE_LOD_BIAS,
|
||||
bias));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -470,6 +470,15 @@ _cogl_texture_2d_gl_flush_legacy_texobj_filters (CoglTexture *tex,
|
||||
tex_2d->gl_texture);
|
||||
GE( ctx, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter) );
|
||||
GE( ctx, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter) );
|
||||
|
||||
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_LOD_BIAS) &&
|
||||
min_filter != GL_NEAREST &&
|
||||
min_filter != GL_LINEAR)
|
||||
{
|
||||
GLfloat bias = _cogl_texture_min_filter_get_lod_bias (min_filter);
|
||||
|
||||
GE (ctx, glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, bias));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -62,4 +62,11 @@ _cogl_texture_gl_generate_mipmaps (CoglTexture *texture);
|
||||
GLenum
|
||||
_cogl_texture_gl_get_format (CoglTexture *texture);
|
||||
|
||||
static inline GLfloat
|
||||
_cogl_texture_min_filter_get_lod_bias (GLenum min_filter)
|
||||
{
|
||||
return (min_filter == GL_NEAREST_MIPMAP_NEAREST ||
|
||||
min_filter == GL_LINEAR_MIPMAP_NEAREST) ? -0.5f : 0.0f;
|
||||
}
|
||||
|
||||
#endif /* _COGL_TEXTURE_GL_PRIVATE_H_ */
|
||||
|
@ -250,4 +250,8 @@ cogl_gl_get_gpu_time_ns (CoglContext *context);
|
||||
#define GL_QUERY_RESULT 0x8866
|
||||
#endif
|
||||
|
||||
#ifndef GL_TEXTURE_LOD_BIAS
|
||||
#define GL_TEXTURE_LOD_BIAS 0x8501
|
||||
#endif
|
||||
|
||||
#endif /* _COGL_UTIL_GL_PRIVATE_H_ */
|
||||
|
@ -526,6 +526,13 @@ _cogl_driver_update_features (CoglContext *ctx,
|
||||
COGL_FLAGS_SET (private_features,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL, TRUE);
|
||||
|
||||
if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 3, 1) ||
|
||||
_cogl_check_extension ("GL_EXT_texture_lod_bias", gl_extensions))
|
||||
{
|
||||
COGL_FLAGS_SET (private_features,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_LOD_BIAS, TRUE);
|
||||
}
|
||||
|
||||
if (ctx->glFenceSync)
|
||||
COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_FENCE, TRUE);
|
||||
|
||||
|
@ -437,6 +437,12 @@ _cogl_driver_update_features (CoglContext *context,
|
||||
COGL_FEATURE_ID_TEXTURE_RG,
|
||||
TRUE);
|
||||
|
||||
if (_cogl_check_extension ("GL_EXT_texture_lod_bias", gl_extensions))
|
||||
{
|
||||
COGL_FLAGS_SET (private_features,
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_LOD_BIAS, TRUE);
|
||||
}
|
||||
|
||||
if (context->glGenQueries && context->glQueryCounter && context->glGetInteger64v)
|
||||
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TIMESTAMP_QUERY, TRUE);
|
||||
|
||||
|
@ -178,6 +178,10 @@ COGL_EXT_FUNCTION (void, glSamplerParameteri,
|
||||
(GLuint sampler,
|
||||
GLenum pname,
|
||||
GLint param))
|
||||
COGL_EXT_FUNCTION (void, glSamplerParameterf,
|
||||
(GLuint sampler,
|
||||
GLenum pname,
|
||||
GLfloat param))
|
||||
COGL_EXT_END ()
|
||||
|
||||
COGL_EXT_BEGIN (only_gl3, 3, 0,
|
||||
|
@ -174,6 +174,8 @@ COGL_EXT_FUNCTION (void, glTexImage2D,
|
||||
const GLvoid* pixels))
|
||||
COGL_EXT_FUNCTION (void, glTexParameteri,
|
||||
(GLenum target, GLenum pname, GLint param))
|
||||
COGL_EXT_FUNCTION (void, glTexParameterf,
|
||||
(GLenum target, GLenum pname, GLfloat param))
|
||||
COGL_EXT_FUNCTION (void, glTexParameteriv,
|
||||
(GLenum target, GLenum pname, const GLint* params))
|
||||
COGL_EXT_FUNCTION (void, glTexSubImage2D,
|
||||
|
Loading…
Reference in New Issue
Block a user