[Mesa-dev] [PATCH] meta_blitframebuffer integer format corrections

Kevin Rogovin kevin.rogovin at intel.com
Mon Feb 10 03:55:31 PST 2014


Corrects the format for the temp texture used in
for the case where source framebuffer is an integer
texture when blitframebuffer_texture() cannot be used.
Note: Does NOT correct the underling blits, rather only
corrects the format of the temporary texture to be
an integer format.

---
 src/mesa/drivers/common/meta.c | 42 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index f12bcaa..b446053 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -356,6 +356,34 @@ static void meta_glsl_clear_cleanup(struct clear_state *clear);
 static void meta_glsl_generate_mipmap_cleanup(struct gen_mipmap_state *mipmap);
 static void meta_decompress_cleanup(struct decompress_state *decompress);
 static void meta_drawpix_cleanup(struct drawpix_state *drawpix);
+static GLenum meta_integer_suffixed_format(GLenum base_format);
+
+/**
+ * returns the base_format value suffixed with _INTEGER
+ */
+static GLenum 
+meta_integer_suffixed_format(GLenum base_format)
+{
+   switch(base_format) {
+   case GL_RED:
+      return GL_RED_INTEGER;
+   case GL_RG:
+      return GL_RG_INTEGER;
+   case GL_RGB:
+      return GL_RGB_INTEGER;
+   case GL_RGBA:
+      return GL_RGBA_INTEGER;
+   case GL_ALPHA:
+      return GL_ALPHA_INTEGER_EXT;
+   case GL_LUMINANCE:
+      return GL_LUMINANCE_INTEGER_EXT;
+   case GL_LUMINANCE_ALPHA:
+      return GL_LUMINANCE_ALPHA_INTEGER_EXT;
+   default:
+      return base_format;
+   }
+}
+
 
 static GLuint
 compile_shader_with_debug(struct gl_context *ctx, GLenum target, const GLcharARB *source)
@@ -1902,15 +1930,23 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
       const struct gl_renderbuffer *colorReadRb = readFb->_ColorReadBuffer;
       const GLenum rb_base_format =
          _mesa_base_tex_format(ctx, colorReadRb->InternalFormat);
+      const GLenum rb_datatype = 
+         _mesa_get_format_datatype(colorReadRb->Format);     
+      const GLenum rb_format = (rb_datatype==GL_INT 
+                                || rb_datatype==GL_UNSIGNED_INT) ?
+         meta_integer_suffixed_format(rb_base_format):
+         rb_base_format;
+                                                     
+      
 
-      /* Using  the exact source rectangle to create the texture does incorrect
+      /* Using the exact source rectangle to create the texture does incorrect
        * linear filtering along the edges. So, allocate the texture extended along
        * edges by one pixel in x, y directions.
        */
-      newTex = alloc_texture(tex, srcW + 2, srcH + 2, rb_base_format);
+      newTex = alloc_texture(tex, srcW + 2, srcH + 2, colorReadRb->InternalFormat);
       setup_copypix_texture(ctx, tex, newTex,
                             srcX - 1, srcY - 1, srcW + 2, srcH + 2,
-                            rb_base_format, filter);
+                            rb_format, filter);
       /* texcoords (after texture allocation!) */
       {
          verts[0].s = 1.0F;
-- 
1.8.1.2



More information about the mesa-dev mailing list