st: add support for GL_EXT_vertex_array_bgra
authorBrian Paul <brianp@vmware.com>
Thu, 21 May 2009 14:15:22 +0000 (08:15 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 21 May 2009 14:15:54 +0000 (08:15 -0600)
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_draw.h
src/mesa/state_tracker/st_draw_feedback.c
src/mesa/state_tracker/st_extensions.c

index 225541a30ba2deccbde328e258bf281e33716f8b..8e036223c65a5e5dfb9fa9f9405fec7b8c954f57 100644 (file)
@@ -159,12 +159,21 @@ static GLuint fixed_types[4] = {
  * Return a PIPE_FORMAT_x for the given GL datatype and size.
  */
 GLuint
-st_pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized)
+st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
+                      GLboolean normalized)
 {
    assert((type >= GL_BYTE && type <= GL_DOUBLE) ||
           type == GL_FIXED);
    assert(size >= 1);
    assert(size <= 4);
+   assert(format == GL_RGBA || format == GL_BGRA);
+
+   if (format == GL_BGRA) {
+      /* this is an odd-ball case */
+      assert(type == GL_UNSIGNED_BYTE);
+      assert(normalized);
+      return PIPE_FORMAT_B8G8R8A8_UNORM;
+   }
 
    if (normalized) {
       switch (type) {
@@ -392,6 +401,7 @@ setup_interleaved_attribs(GLcontext *ctx,
       velements[attr].src_format =
          st_pipe_vertex_format(arrays[mesaAttr]->Type,
                                arrays[mesaAttr]->Size,
+                               arrays[mesaAttr]->Format,
                                arrays[mesaAttr]->Normalized);
       assert(velements[attr].src_format);
    }
@@ -479,6 +489,7 @@ setup_non_interleaved_attribs(GLcontext *ctx,
       velements[attr].src_format
          = st_pipe_vertex_format(arrays[mesaAttr]->Type,
                                  arrays[mesaAttr]->Size,
+                                 arrays[mesaAttr]->Format,
                                  arrays[mesaAttr]->Normalized);
       assert(velements[attr].src_format);
    }
index da04fce8e24bfb832b851129a40b344c1999aa19..dcfe7e15361dba21f9355d66b77b8b386751b6cf 100644 (file)
@@ -62,7 +62,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
 /* Internal function:
  */
 extern GLuint
-st_pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized);
+st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
+                      GLboolean normalized);
 
 
 /**
index 32502a9cda4752951d8fc77b65477a7bfa83ef25..2712c131c0da0a99ebaa34bcf6d580447ab0c77d 100644 (file)
@@ -178,6 +178,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
       velements[attr].src_format = 
          st_pipe_vertex_format(arrays[mesaAttr]->Type,
                                arrays[mesaAttr]->Size,
+                               arrays[mesaAttr]->Format,
                                arrays[mesaAttr]->Normalized);
       assert(velements[attr].src_format);
 
index d526dfcf52eba37e9fcac9794023de565054d1b5..efa88c2481fdf785ad2325329b0338d092949a07 100644 (file)
@@ -167,6 +167,7 @@ void st_init_extensions(struct st_context *st)
    ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
    ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
    ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
+   ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
 
    ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;