Mesa (7.11): st/mesa: handle float formats in st_format_datatype

Marek Olšák mareko at kemper.freedesktop.org
Fri Jul 8 04:26:46 PDT 2011


Module: Mesa
Branch: 7.11
Commit: b0a4f34ea8f471bbfba133eb2b54996ad28b0244
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0a4f34ea8f471bbfba133eb2b54996ad28b0244

Author: Marek Olšák <maraeo at gmail.com>
Date:   Mon Jun 27 18:57:59 2011 +0200

st/mesa: handle float formats in st_format_datatype

NOTE: This is a candidate for the 7.11 branch.

Reviewed-by: Brian Paul <brianp at vmware.com>
(cherry picked from commit 7de28e80dcd4239a780b0f5fdc6e61e6e56a68aa)

---

 src/mesa/state_tracker/st_format.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 3260297..d1995f1 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -85,6 +85,10 @@ st_format_datatype(enum pipe_format format)
           format == PIPE_FORMAT_B5G6R5_UNORM) {
          return GL_UNSIGNED_SHORT;
       }
+      else if (format == PIPE_FORMAT_R11G11B10_FLOAT ||
+               format == PIPE_FORMAT_R9G9B9E5_FLOAT) {
+         return GL_FLOAT;
+      }
       else if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
                format == PIPE_FORMAT_S8_USCALED_Z24_UNORM ||
                format == PIPE_FORMAT_Z24X8_UNORM ||
@@ -105,18 +109,26 @@ st_format_datatype(enum pipe_format format)
                return GL_BYTE;
          }
          else if (size == 16) {
+            if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+               return GL_HALF_FLOAT;
             if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
                return GL_UNSIGNED_SHORT;
             else
                return GL_SHORT;
          }
-         else {
-            assert( size <= 32 );
+         else if (size <= 32) {
+            if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+               return GL_FLOAT;
             if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
                return GL_UNSIGNED_INT;
             else
                return GL_INT;
          }
+         else {
+            assert(size == 64);
+            assert(desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT);
+            return GL_DOUBLE;
+         }
       }
    }
    else if (format == PIPE_FORMAT_UYVY) {



More information about the mesa-commit mailing list