[Mesa-dev] [PATCH v2 1/3] main/get: support const normalized float values

Jordan Justen jordan.l.justen at intel.com
Sun Jan 26 10:48:53 PST 2014


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/mesa/main/get.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 16dce5b..4435c09 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -116,7 +116,8 @@ enum value_type {
    TYPE_DOUBLEN_2,
    TYPE_MATRIX,
    TYPE_MATRIX_T,
-   TYPE_CONST
+   TYPE_CONST,
+   TYPE_NORM_CONST
 };
 
 enum value_location {
@@ -186,6 +187,8 @@ union value {
 #undef CONST /* already defined through windows.h */
 #define CONST(value) \
    LOC_CONTEXT, TYPE_CONST, value
+#define NORM_CONST(value) \
+   LOC_CONTEXT, TYPE_NORM_CONST, FLOAT_TO_INT(value)
 
 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
@@ -1232,6 +1235,9 @@ _mesa_GetBooleanv(GLenum pname, GLboolean *params)
    case TYPE_CONST:
       params[0] = INT_TO_BOOLEAN(d->offset);
       break;
+   case TYPE_NORM_CONST:
+      params[0] = FLOAT_TO_BOOLEAN(INT_TO_FLOAT(d->offset));
+      break;
 
    case TYPE_FLOAT_4:
    case TYPE_FLOATN_4:
@@ -1320,6 +1326,9 @@ _mesa_GetFloatv(GLenum pname, GLfloat *params)
    case TYPE_CONST:
       params[0] = (GLfloat) d->offset;
       break;
+   case TYPE_NORM_CONST:
+      params[0] = INT_TO_FLOAT(d->offset);
+      break;
 
    case TYPE_FLOAT_4:
    case TYPE_FLOATN_4:
@@ -1408,6 +1417,9 @@ _mesa_GetIntegerv(GLenum pname, GLint *params)
    case TYPE_CONST:
       params[0] = d->offset;
       break;
+   case TYPE_NORM_CONST:
+      params[0] = IROUND(INT_TO_FLOAT(d->offset));
+      break;
 
    case TYPE_FLOAT_4:
       params[3] = IROUND(((GLfloat *) p)[3]);
@@ -1502,6 +1514,9 @@ _mesa_GetInteger64v(GLenum pname, GLint64 *params)
    case TYPE_CONST:
       params[0] = d->offset;
       break;
+   case TYPE_NORM_CONST:
+      params[0] = IROUND64(INT_TO_FLOAT(d->offset));
+      break;
 
    case TYPE_FLOAT_4:
       params[3] = IROUND64(((GLfloat *) p)[3]);
@@ -1596,6 +1611,9 @@ _mesa_GetDoublev(GLenum pname, GLdouble *params)
    case TYPE_CONST:
       params[0] = d->offset;
       break;
+   case TYPE_NORM_CONST:
+      params[0] = INT_TO_FLOAT(d->offset);
+      break;
 
    case TYPE_FLOAT_4:
    case TYPE_FLOATN_4:
@@ -2196,6 +2214,9 @@ _mesa_GetFixedv(GLenum pname, GLfixed *params)
    case TYPE_CONST:
       params[0] = INT_TO_FIXED(d->offset);
       break;
+   case TYPE_NORM_CONST:
+      params[0] = FLOAT_TO_FIXED(INT_TO_FLOAT(d->offset));
+      break;
 
    case TYPE_FLOAT_4:
    case TYPE_FLOATN_4:
-- 
1.8.5.3



More information about the mesa-dev mailing list