From 3778fab34bc00334edec4f845d0c6d43440f265a Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Wed, 14 May 2014 23:08:17 +0200 Subject: [PATCH 1/3] glamor: Fix no-mipmap allocations With GL_TEXTURE_MIN_FILTER, we configure not to use mipmaps, but there's no real way until GL_ARB_texture_storage to dictate whether memory should be allocated for mipmap levels or not. GL_TEXTURE_MAX_LEVEL is a stronger hint to the driver than the filtering that we really don't want mipmap allocations. Stops VARM wasting warnings from the nvidia driver. Signed-off-by: Markus Wick Signed-off-by: Eric Anholt Reviewed-by: Eric Anholt Reviewed-by: Keith Packard --- glamor/glamor_fbo.c | 1 + glamor/glamor_font.c | 1 + glamor/glamor_pixmap.c | 1 + 3 files changed, 3 insertions(+) diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c index 552168381..090dfd8e7 100644 --- a/glamor/glamor_fbo.c +++ b/glamor/glamor_fbo.c @@ -347,6 +347,7 @@ _glamor_create_tex(glamor_screen_private *glamor_priv, glamor_make_current(glamor_priv); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, diff --git a/glamor/glamor_font.c b/glamor/glamor_font.c index f747d59a1..57c607dc2 100644 --- a/glamor/glamor_font.c +++ b/glamor/glamor_font.c @@ -95,6 +95,7 @@ glamor_font_get(ScreenPtr screen, FontPtr font) glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, glamor_font->texture_id); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c index 54b414bc2..789d3772e 100644 --- a/glamor/glamor_pixmap.c +++ b/glamor/glamor_pixmap.c @@ -717,6 +717,7 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex, } glBindTexture(GL_TEXTURE_2D, *tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); From 8da1e4e2bf28c3610cdbe1770a57be89578d37f5 Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Wed, 14 May 2014 23:08:18 +0200 Subject: [PATCH 2/3] glamor: Choose max fbo size by texture + viewport size The max size of renderbuffers and texture often match by accident, but as we always use textures, we should check for the right flag. Also check for viewport size as this may be lower and we want to render to almost every pixmap. Signed-off-by: Markus Wick Signed-off-by: Eric Anholt Reviewed-by: Eric Anholt --- glamor/glamor.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glamor/glamor.c b/glamor/glamor.c index 08f6ba174..c398807f1 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -316,6 +316,7 @@ glamor_init(ScreenPtr screen, unsigned int flags) { glamor_screen_private *glamor_priv; int gl_version; + int max_viewport_size; #ifdef RENDER PictureScreenPtr ps = GetPictureScreenIfSet(screen); @@ -406,7 +407,9 @@ glamor_init(ScreenPtr screen, unsigned int flags) epoxy_has_gl_extension("GL_ARB_map_buffer_range"); glamor_priv->has_buffer_storage = epoxy_has_gl_extension("GL_ARB_buffer_storage"); - glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size); + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glamor_priv->max_fbo_size); + glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &max_viewport_size); + glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size); #ifdef MAX_FBO_SIZE glamor_priv->max_fbo_size = MAX_FBO_SIZE; #endif From a11bbd875f3f90a3d02d727778cb1d3524cf59fd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 30 May 2014 10:39:30 -0700 Subject: [PATCH 3/3] glamor: Don't leak a prepare_access_gc() in putimage fallbacks. It turns out putimage doesn't use the GC tile or stipple anyway, so there's no need to do this. Signed-off-by: Eric Anholt Reviewed-by: Keith Packard --- glamor/glamor_image.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/glamor/glamor_image.c b/glamor/glamor_image.c index 4791d089f..b38b41212 100644 --- a/glamor/glamor_image.c +++ b/glamor/glamor_image.c @@ -88,8 +88,7 @@ static void glamor_put_image_bail(DrawablePtr drawable, GCPtr gc, int depth, int x, int y, int w, int h, int leftPad, int format, char *bits) { - if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) && - glamor_prepare_access_gc(gc)) + if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) fbPutImage(drawable, gc, depth, x, y, w, h, leftPad, format, bits); glamor_finish_access(drawable); }