[Mesa-stable] [PATCH] i965: Preserve the internal format of the dri image

Jordan Justen jordan.l.justen at intel.com
Thu Jun 23 06:22:52 UTC 2016


Since the OpenGLES API is strict about the internal format matching
the for many operations, we need to preserve it.

See _mesa_es3_error_check_format_and_type in
src/mesa/main/glformats.c.

Fixes ES2-CTS.gtf.GL2ExtensionTests.egl_image.egl_image

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96351
Reported-by: Mark Janes <mark.a.janes at intel.com>
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Cc: Kristian Høgsberg <krh at bitplanet.net>
Cc: Chad Versace <chad.versace at intel.com>
Cc: "12.0" <mesa-stable at lists.freedesktop.org>
---
 src/mesa/drivers/dri/i965/intel_tex_image.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 9cc426c..958f8bd 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -138,10 +138,10 @@ intelTexImage(struct gl_context * ctx,
 static void
 intel_set_texture_image_mt(struct brw_context *brw,
                            struct gl_texture_image *image,
+                           GLenum internal_format,
                            struct intel_mipmap_tree *mt)
 
 {
-   const uint32_t internal_format = _mesa_get_format_base_format(mt->format);
    struct gl_texture_object *texobj = image->TexObject;
    struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
    struct intel_texture_image *intel_image = intel_texture_image(image);
@@ -264,6 +264,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
    struct gl_texture_image *texImage;
    mesa_format texFormat = MESA_FORMAT_NONE;
    struct intel_mipmap_tree *mt;
+   GLenum internal_format = 0;
 
    texObj = _mesa_get_current_tex_object(ctx, target);
 
@@ -283,12 +284,15 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
 
    if (rb->mt->cpp == 4) {
       if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
+         internal_format = GL_RGB;
          texFormat = MESA_FORMAT_B8G8R8X8_UNORM;
       }
       else {
+         internal_format = GL_RGBA;
          texFormat = MESA_FORMAT_B8G8R8A8_UNORM;
       }
    } else if (rb->mt->cpp == 2) {
+      internal_format = GL_RGB;
       texFormat = MESA_FORMAT_B5G6R5_UNORM;
    }
 
@@ -305,7 +309,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
 
    _mesa_lock_texture(&brw->ctx, texObj);
    texImage = _mesa_get_tex_image(ctx, texObj, target, 0);
-   intel_set_texture_image_mt(brw, texImage, mt);
+   intel_set_texture_image_mt(brw, texImage, internal_format, mt);
    intel_miptree_release(&mt);
    _mesa_unlock_texture(&brw->ctx, texObj);
 }
@@ -399,7 +403,10 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
    struct intel_texture_object *intel_texobj = intel_texture_object(texObj);
    intel_texobj->planar_format = image->planar_format;
 
-   intel_set_texture_image_mt(brw, texImage, mt);
+   const GLenum internal_format =
+      image->internal_format != 0 ?
+      image->internal_format : _mesa_get_format_base_format(mt->format);
+   intel_set_texture_image_mt(brw, texImage, internal_format, mt);
    intel_miptree_release(&mt);
 }
 
-- 
2.8.1



More information about the mesa-stable mailing list