i965: enable GL_EXT_vertex_array_bgra
authorBrian Paul <brianp@vmware.com>
Fri, 23 Jan 2009 18:27:42 +0000 (11:27 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 23 Jan 2009 18:27:42 +0000 (11:27 -0700)
Simply a matter of choosing the right surface/vertex format for GLubyte/GL_BGRA arrays.

src/mesa/drivers/dri/i965/brw_draw_upload.c
src/mesa/drivers/dri/intel/intel_context.c

index 73d6dea01ee8e59450b8a6d625022585da8b1e6c..f89c0c2ba48c6ac7b6e4dc5ad334f503bfa5cdbf 100644 (file)
@@ -156,7 +156,13 @@ static GLuint byte_types_scale[5] = {
 };
 
 
-static GLuint get_surface_type( GLenum type, GLuint size, GLboolean normalized )
+/**
+ * Given vertex array type/size/format/normalized info, return
+ * the appopriate hardware surface type.
+ * Format will be GL_RGBA or possibly GL_BGRA for GLubyte[4] color arrays.
+ */
+static GLuint get_surface_type( GLenum type, GLuint size,
+                                GLenum format, GLboolean normalized )
 {
    if (INTEL_DEBUG & DEBUG_VERTS)
       _mesa_printf("type %s size %d normalized %d\n", 
@@ -171,11 +177,20 @@ static GLuint get_surface_type( GLenum type, GLuint size, GLboolean normalized )
       case GL_BYTE: return byte_types_norm[size];
       case GL_UNSIGNED_INT: return uint_types_norm[size];
       case GL_UNSIGNED_SHORT: return ushort_types_norm[size];
-      case GL_UNSIGNED_BYTE: return ubyte_types_norm[size];
+      case GL_UNSIGNED_BYTE:
+         if (format == GL_BGRA) {
+            /* See GL_EXT_vertex_array_bgra */
+            assert(size == 4);
+            return BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
+         }
+         else {
+            return ubyte_types_norm[size];
+         }
       default: assert(0); return 0;
       }      
    }
    else {
+      assert(format == GL_RGBA); /* sanity check */
       switch (type) {
       case GL_DOUBLE: return double_types[size];
       case GL_FLOAT: return float_types[size];
@@ -484,6 +499,7 @@ static void brw_emit_vertices(struct brw_context *brw)
       struct brw_vertex_element *input = enabled[i];
       uint32_t format = get_surface_type(input->glarray->Type,
                                         input->glarray->Size,
+                                        input->glarray->Format,
                                         input->glarray->Normalized);
       uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC;
       uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC;
index fda880829c8d240403f8a12a337cf6bea3711a96..a43e6be0d9d5d843341bbd25c6e6bb1834ccda95 100644 (file)
@@ -414,6 +414,7 @@ static const struct dri_extension brw_extensions[] = {
    { "GL_ARB_vertex_shader",              GL_ARB_vertex_shader_functions },
    { "GL_EXT_shadow_funcs",               NULL },
    { "GL_EXT_texture_sRGB",              NULL },
+   { "GL_EXT_vertex_array_bgra",         NULL },
    { "GL_ATI_separate_stencil",           GL_ATI_separate_stencil_functions },
    { "GL_ATI_texture_env_combine3",       NULL },
    { NULL,                                NULL }