2011/1/18 Brian Paul <brian.e.p...@gmail.com>:
>
> Before we commit this stuff can you develop a piglit test to test it?
>

The problem for me is that piglit is GL-only atm. so its not trival to
write a simple gles2 test-program, as changes to piglit-util would be
needed.
It would be important for people wanting to contribute to wayland
(without having an intel driver, which already advertises
texture_format_bgra8888) that this is added to mesa without having a
piglit test yet.

I attach the 3 patches (that were already sent in a bit different
form) in correct order + 1 Patch that ensures internalFormat==format
in gles' glTexImage2D.
From c32e2399cbda229c3e5fb0943c45dcb5ef89ba32 Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <benjaminfran...@googlemail.com>
Date: Fri, 21 Jan 2011 14:24:11 +0100
Subject: [PATCH 1/4] mesa: allow internalFormat=GL_BGRA_EXT in TexImage2D

---
 src/mesa/main/teximage.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 47d5093..c3cd6b6 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -183,6 +183,15 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
          ; /* fallthrough */
    }
 
+   if (ctx->Extensions.EXT_texture_format_BGRA8888) {
+      switch (internalFormat) {
+         case GL_BGRA_EXT:
+            return GL_RGBA;
+         default:
+            ; /* fallthrough */
+      }
+   }
+
    if (ctx->Extensions.EXT_paletted_texture) {
       switch (internalFormat) {
          case GL_COLOR_INDEX:
-- 
1.7.3.4

From d7e4cbf1e74c29128b737bb0c72d6cfa30a4156d Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <benjaminfran...@googlemail.com>
Date: Fri, 21 Jan 2011 14:26:09 +0100
Subject: [PATCH 2/4] mesa/esrequireuire internalFormat==format in TexImage2D

---
 src/mesa/main/APIspec.xml |   61 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index 50446a9..0f82d0a 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -379,15 +379,68 @@
 		<value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
 	</desc>
 
-	<desc name="internalFormat" error="GL_INVALID_VALUE">
+	<desc name="internalFormat">
 		<value name="GL_ALPHA"/>
+
+		<desc name="format" error="GL_INVALID_VALUE">
+			<value name="GL_ALPHA"/>
+		</desc>
+	</desc>
+
+	<desc name="internalFormat">
 		<value name="GL_RGB"/>
+
+		<desc name="format" error="GL_INVALID_VALUE">
+			<value name="GL_RGB"/>
+		</desc>
+	</desc>
+
+	<desc name="internalFormat">
 		<value name="GL_RGBA"/>
-		<value name="GL_BGRA_EXT"/>
+
+		<desc name="format" error="GL_INVALID_VALUE">
+			<value name="GL_RGBA"/>
+		</desc>
+	</desc>
+
+	<desc name="internalFormat">
 		<value name="GL_LUMINANCE"/>
+
+		<desc name="format" error="GL_INVALID_VALUE">
+			<value name="GL_LUMINANCE"/>
+		</desc>
+	</desc>
+
+	<desc name="internalFormat">
 		<value name="GL_LUMINANCE_ALPHA"/>
-		<value name="GL_DEPTH_COMPONENT" category="OES_depth_texture"/>
-		<value name="GL_DEPTH_STENCIL_OES" category="OES_packed_depth_stencil"/>
+
+		<desc name="format" error="GL_INVALID_VALUE">
+			<value name="GL_LUMINANCE_ALPHA"/>
+		</desc>
+	</desc>
+
+	<desc name="internalFormat" category="OES_depth_texture">
+		<value name="GL_DEPTH_COMPONENT"/>
+
+		<desc name="format" error="GL_INVALID_VALUE">
+			<value name="GL_DEPTH_COMPONENT"/>
+		</desc>
+	</desc>
+
+	<desc name="internalFormat" category="OES_packed_depth_stencil">
+		<value name="GL_DEPTH_STENCIL_OES"/>
+
+		<desc name="format" error="GL_INVALID_VALUE">
+			<value name="GL_DEPTH_STENCIL_OES"/>
+		</desc>
+	</desc>
+
+	<desc name="internalFormat" category="EXT_texture_format_BGRA8888">
+		<value name="GL_BGRA_EXT"/>
+
+		<desc name="format" error="GL_INVALID_VALUE">
+			<value name="GL_BGRA_EXT"/>
+		</desc>
 	</desc>
 
 	<desc name="border" error="GL_INVALID_VALUE">
-- 
1.7.3.4

From afba50dabade850738c1f3f0563f2cfc9e65a6a5 Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <benjaminfran...@googlemail.com>
Date: Fri, 21 Jan 2011 14:29:06 +0100
Subject: [PATCH 3/4] st/mesa: support internalFormat=GL_BGRA in TexImage2D

---
 src/mesa/state_tracker/st_format.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 2e0a664..a532e08 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -511,6 +511,14 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
       return default_rgba_format( screen, target, sample_count, bindings,
                                   geom_flags );
 
+   case GL_BGRA:
+      if (screen->is_format_supported( screen, PIPE_FORMAT_B8G8R8A8_UNORM,
+                                       target, sample_count, bindings,
+                                       geom_flags ))
+         return PIPE_FORMAT_B8G8R8A8_UNORM;
+      return default_rgba_format( screen, target, sample_count, bindings,
+                                  geom_flags );
+
    case 3:
    case GL_RGB:
    case GL_RGB8:
@@ -1032,7 +1040,8 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLint internalFormat,
    boolean want_renderable =
       internalFormat == 3 || internalFormat == 4 ||
       internalFormat == GL_RGB || internalFormat == GL_RGBA ||
-      internalFormat == GL_RGB8 || internalFormat == GL_RGBA8;
+      internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 ||
+      internalFormat == GL_BGRA;
 
    return st_ChooseTextureFormat_renderable(ctx, internalFormat,
 					    format, type, want_renderable);
-- 
1.7.3.4

From 77ed38dfd9efaf7d388ee3e47aaf3e3437e7a25f Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <benjaminfran...@googlemail.com>
Date: Fri, 21 Jan 2011 14:29:32 +0100
Subject: [PATCH 4/4] st/mesa: Enable EXT_texture_format_BGRA8888 for gles1/2

---
 src/mesa/state_tracker/st_extensions.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index d240cab..9534cc9 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -260,6 +260,8 @@ void st_init_extensions(struct st_context *st)
    ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
    ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
    ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
+   if (ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2)
+	   ctx->Extensions.EXT_texture_format_BGRA8888 = GL_TRUE;
 
    ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
 
-- 
1.7.3.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to