mesa/st: add support for 2101010 vertex format conversion.
authorDave Airlie <airlied@redhat.com>
Sat, 19 Feb 2011 21:04:19 +0000 (07:04 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 6 Sep 2011 09:18:18 +0000 (10:18 +0100)
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_extensions.c

index 5040c6fa5ab9ebfb084a9a5979824c7455af12df..39a947df70a736a688b5a30f8de45bc8ab284211 100644 (file)
@@ -187,11 +187,44 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
                       GLboolean normalized)
 {
    assert((type >= GL_BYTE && type <= GL_DOUBLE) ||
-          type == GL_FIXED || type == GL_HALF_FLOAT);
+          type == GL_FIXED || type == GL_HALF_FLOAT ||
+          type == GL_INT_2_10_10_10_REV ||
+          type == GL_UNSIGNED_INT_2_10_10_10_REV);
    assert(size >= 1);
    assert(size <= 4);
    assert(format == GL_RGBA || format == GL_BGRA);
 
+   if (type == GL_INT_2_10_10_10_REV ||
+       type == GL_UNSIGNED_INT_2_10_10_10_REV) {
+      assert(size == 4);
+
+      if (format == GL_BGRA) {
+         if (type == GL_INT_2_10_10_10_REV) {
+            if (normalized)
+               return PIPE_FORMAT_B10G10R10A2_SNORM;
+            else
+               return PIPE_FORMAT_B10G10R10A2_SSCALED;
+         } else {
+            if (normalized)
+               return PIPE_FORMAT_B10G10R10A2_UNORM;
+            else
+               return PIPE_FORMAT_B10G10R10A2_USCALED;
+         }
+      } else {
+         if (type == GL_INT_2_10_10_10_REV) {
+            if (normalized)
+               return PIPE_FORMAT_R10G10B10A2_SNORM;
+            else
+               return PIPE_FORMAT_R10G10B10A2_SSCALED;
+         } else {
+            if (normalized)
+               return PIPE_FORMAT_R10G10B10A2_UNORM;
+            else
+               return PIPE_FORMAT_R10G10B10A2_USCALED;
+         }
+      }
+   }
+
    if (format == GL_BGRA) {
       /* this is an odd-ball case */
       assert(type == GL_UNSIGNED_BYTE);
index 76e84ebe3073bce8333dc201061e510303025fc2..a41e9e87261009cc37e673178433504964583f40 100644 (file)
@@ -535,6 +535,33 @@ void st_init_extensions(struct st_context *st)
       ctx->Extensions.ARB_ES2_compatibility = GL_TRUE;
    }
 
+   if (screen->is_format_supported(screen, PIPE_FORMAT_R10G10B10A2_UNORM,
+                                   PIPE_BUFFER, 0,
+                                   PIPE_BIND_VERTEX_BUFFER) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_B10G10R10A2_UNORM,
+                                   PIPE_BUFFER, 0,
+                                   PIPE_BIND_VERTEX_BUFFER) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_R10G10B10A2_SNORM,
+                                   PIPE_BUFFER, 0,
+                                   PIPE_BIND_VERTEX_BUFFER) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_B10G10R10A2_SNORM,
+                                   PIPE_BUFFER, 0,
+                                   PIPE_BIND_VERTEX_BUFFER) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_R10G10B10A2_USCALED,
+                                   PIPE_BUFFER, 0,
+                                   PIPE_BIND_VERTEX_BUFFER) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_B10G10R10A2_USCALED,
+                                   PIPE_BUFFER, 0,
+                                   PIPE_BIND_VERTEX_BUFFER) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_R10G10B10A2_SSCALED,
+                                   PIPE_BUFFER, 0,
+                                   PIPE_BIND_VERTEX_BUFFER) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_B10G10R10A2_SSCALED,
+                                   PIPE_BUFFER, 0,
+                                   PIPE_BIND_VERTEX_BUFFER)) {
+      ctx->Extensions.ARB_vertex_type_2_10_10_10_rev = GL_TRUE;
+   }
+
    if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
 #if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */
       ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;