[Mesa-dev] [PATCH] mesa, st/mesa: implement GL_RGB565 from ARB_ES2_compatibility

Marek Olšák maraeo at gmail.com
Thu Jul 12 05:25:44 PDT 2012


This was not implemented, because the spec was changed just recently.

Everything has been in place already.

Gallium has PIPE_FORMAT_B5G6R5_UNORM, while Mesa has MESA_FORMAT_RGB565.
---
 src/mesa/main/fbobject.c                  |    3 +++
 src/mesa/main/image.c                     |    1 +
 src/mesa/main/texformat.c                 |   10 ++++++++++
 src/mesa/main/teximage.c                  |    9 +++++++++
 src/mesa/state_tracker/st_cb_drawpixels.c |    2 ++
 src/mesa/state_tracker/st_format.c        |    4 ++++
 6 files changed, 29 insertions(+)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index cfaea62..4370c72 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1296,6 +1296,9 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
 
    case GL_RGB10_A2UI:
       return ctx->Extensions.ARB_texture_rgb10_a2ui ? GL_RGBA : 0;
+
+   case GL_RGB565:
+      return ctx->Extensions.ARB_ES2_compatibility ? GL_RGB : 0;
    default:
       return 0;
    }
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index b6c2645..678dfeb 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -770,6 +770,7 @@ _mesa_is_color_format(GLenum format)
       case GL_R3_G3_B2:
       case GL_RGB4:
       case GL_RGB5:
+      case GL_RGB565:
       case GL_RGB8:
       case GL_RGB10:
       case GL_RGB12:
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 5fdc2ab..26bcbc1 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -258,6 +258,16 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
          ; /* fallthrough */
    }
 
+   if (ctx->Extensions.ARB_ES2_compatibility) {
+      switch (internalFormat) {
+         case GL_RGB565:
+            RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565);
+            break;
+         default:
+         ; /* fallthrough */
+      }
+   }
+
    if (ctx->Extensions.MESA_ycbcr_texture) {
       if (internalFormat == GL_YCBCR_MESA) {
          if (type == GL_UNSIGNED_SHORT_8_8_MESA)
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index b16baaf..126386e 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -138,6 +138,15 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
       }
    }
 
+   if (ctx->Extensions.ARB_ES2_compatibility) {
+      switch (internalFormat) {
+         case GL_RGB565:
+            return GL_RGB;
+         default:
+            ; /* fallthrough */
+      }
+   }
+
    if (ctx->Extensions.ARB_depth_texture) {
       switch (internalFormat) {
          case GL_DEPTH_COMPONENT:
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 10eaa84..c5f3631 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -403,6 +403,8 @@ internal_format(struct gl_context *ctx, GLenum format, GLenum type)
 
          case GL_UNSIGNED_SHORT_5_6_5:
          case GL_UNSIGNED_SHORT_5_6_5_REV:
+            return GL_RGB565;
+
          case GL_UNSIGNED_SHORT_5_5_5_1:
          case GL_UNSIGNED_SHORT_1_5_5_5_REV:
             return GL_RGB5_A1;
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 4265d14..57d3441 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -793,6 +793,10 @@ static const struct format_mapping format_map[] = {
       { PIPE_FORMAT_B5G6R5_UNORM, PIPE_FORMAT_B5G5R5A1_UNORM,
         DEFAULT_RGBA_FORMATS }
    },
+   {
+      { GL_RGB565 },
+      { PIPE_FORMAT_B5G6R5_UNORM, DEFAULT_RGBA_FORMATS }
+   },
 
    /* basic Alpha formats */
    {
-- 
1.7.9.5



More information about the mesa-dev mailing list