mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
cogl: Add new function cogl_pipeline_set_layer_max_mipmap_level()
To configure an exact value of `GL_TEXTURE_MAX_LEVEL` clamped to within the range of possible levels. https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
This commit is contained in:
parent
f4301b77fa
commit
c5fbab6bad
@ -1361,6 +1361,17 @@ cogl_pipeline_set_layer_filters (CoglPipeline *pipeline,
|
||||
sampler_state);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_pipeline_set_layer_max_mipmap_level (CoglPipeline *pipeline,
|
||||
int layer,
|
||||
int max_level)
|
||||
{
|
||||
CoglTexture *texture = cogl_pipeline_get_layer_texture (pipeline, layer);
|
||||
|
||||
if (texture != NULL)
|
||||
cogl_texture_set_max_level (texture, max_level);
|
||||
}
|
||||
|
||||
const CoglSamplerCacheEntry *
|
||||
_cogl_pipeline_layer_get_sampler_state (CoglPipelineLayer *layer)
|
||||
{
|
||||
|
@ -568,6 +568,11 @@ cogl_pipeline_add_layer_snippet (CoglPipeline *pipeline,
|
||||
int layer,
|
||||
CoglSnippet *snippet);
|
||||
|
||||
COGL_EXPORT void
|
||||
cogl_pipeline_set_layer_max_mipmap_level (CoglPipeline *pipeline,
|
||||
int layer,
|
||||
int max_level);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_PIPELINE_LAYER_STATE_H__ */
|
||||
|
@ -205,6 +205,7 @@ struct _CoglTexture
|
||||
CoglTextureLoader *loader;
|
||||
GList *framebuffers;
|
||||
int max_level_set;
|
||||
int max_level_requested;
|
||||
int width;
|
||||
int height;
|
||||
gboolean allocated;
|
||||
@ -377,6 +378,10 @@ _cogl_texture_needs_premult_conversion (CoglPixelFormat src_format,
|
||||
int
|
||||
_cogl_texture_get_n_levels (CoglTexture *texture);
|
||||
|
||||
void
|
||||
cogl_texture_set_max_level (CoglTexture *texture,
|
||||
int max_level);
|
||||
|
||||
void
|
||||
_cogl_texture_get_level_size (CoglTexture *texture,
|
||||
int level,
|
||||
|
@ -116,6 +116,7 @@ _cogl_texture_init (CoglTexture *texture,
|
||||
{
|
||||
texture->context = context;
|
||||
texture->max_level_set = 0;
|
||||
texture->max_level_requested = 1000; /* OpenGL default GL_TEXTURE_MAX_LEVEL */
|
||||
texture->width = width;
|
||||
texture->height = height;
|
||||
texture->allocated = FALSE;
|
||||
@ -229,8 +230,16 @@ _cogl_texture_get_n_levels (CoglTexture *texture)
|
||||
int width = cogl_texture_get_width (texture);
|
||||
int height = cogl_texture_get_height (texture);
|
||||
int max_dimension = MAX (width, height);
|
||||
int n_levels = _cogl_util_fls (max_dimension);
|
||||
|
||||
return _cogl_util_fls (max_dimension);
|
||||
return MIN (n_levels, texture->max_level_requested + 1);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_texture_set_max_level (CoglTexture *texture,
|
||||
int max_level)
|
||||
{
|
||||
texture->max_level_requested = max_level;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -137,7 +137,7 @@ _cogl_texture_gl_generate_mipmaps (CoglTexture *texture)
|
||||
GLuint gl_handle;
|
||||
GLenum gl_target;
|
||||
|
||||
if (texture->max_level_set < n_levels - 1)
|
||||
if (texture->max_level_set != n_levels - 1)
|
||||
cogl_texture_gl_set_max_level (texture, n_levels - 1);
|
||||
|
||||
cogl_texture_get_gl_texture (texture, &gl_handle, &gl_target);
|
||||
|
Loading…
Reference in New Issue
Block a user