aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/get.c
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-12-17 19:55:53 -0800
committerKenneth Graunke <[email protected]>2016-12-19 11:33:40 -0800
commit9f93afb9a5586cb90e127ba7d63de3b416d08821 (patch)
treec094498968eef87b494e8acaf39c62d26353bc86 /src/mesa/main/get.c
parent78a391ed8311fc5215347f8775bf0aa29568b78d (diff)
mesa/get: Add TYPE_UINT for casting through a GLuint.
The "State Tables" section of the OpenGL specification lists many values as belonging to Z+ (non-negative integers), not Z (all integers). For ordinary glGetInteger queries, this doesn't matter. However, when accessing Z+ values via glGetFloat or glGetInteger64, we need to treat the source value as an unsigned value. Otherwise, we'll produce a negative number when bit 31 is set. This commit merely adds the plumbing. It doesn't convert any values. v2: Gotta catch 'em all (add missing cases caught by Ilia) Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/mesa/main/get.c')
-rw-r--r--src/mesa/main/get.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 12f937a01a9..10b40d405d2 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -95,6 +95,10 @@ enum value_type {
TYPE_INT_3,
TYPE_INT_4,
TYPE_INT_N,
+ TYPE_UINT,
+ TYPE_UINT_2,
+ TYPE_UINT_3,
+ TYPE_UINT_4,
TYPE_INT64,
TYPE_ENUM,
TYPE_ENUM_2,
@@ -205,6 +209,7 @@ union value {
#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
+#define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
@@ -1458,13 +1463,17 @@ _mesa_GetBooleanv(GLenum pname, GLboolean *params)
break;
case TYPE_INT_4:
+ case TYPE_UINT_4:
params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]);
case TYPE_INT_3:
+ case TYPE_UINT_3:
params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]);
case TYPE_INT_2:
+ case TYPE_UINT_2:
case TYPE_ENUM_2:
params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]);
case TYPE_INT:
+ case TYPE_UINT:
case TYPE_ENUM:
params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]);
break;
@@ -1567,6 +1576,16 @@ _mesa_GetFloatv(GLenum pname, GLfloat *params)
params[i] = (GLfloat) v.value_int_n.ints[i];
break;
+ case TYPE_UINT_4:
+ params[3] = (GLfloat) (((GLuint *) p)[3]);
+ case TYPE_UINT_3:
+ params[2] = (GLfloat) (((GLuint *) p)[2]);
+ case TYPE_UINT_2:
+ params[1] = (GLfloat) (((GLuint *) p)[1]);
+ case TYPE_UINT:
+ params[0] = (GLfloat) (((GLuint *) p)[0]);
+ break;
+
case TYPE_INT64:
params[0] = (GLfloat) (((GLint64 *) p)[0]);
break;
@@ -1650,13 +1669,17 @@ _mesa_GetIntegerv(GLenum pname, GLint *params)
break;
case TYPE_INT_4:
+ case TYPE_UINT_4:
params[3] = ((GLint *) p)[3];
case TYPE_INT_3:
+ case TYPE_UINT_3:
params[2] = ((GLint *) p)[2];
case TYPE_INT_2:
+ case TYPE_UINT_2:
case TYPE_ENUM_2:
params[1] = ((GLint *) p)[1];
case TYPE_INT:
+ case TYPE_UINT:
case TYPE_ENUM:
params[0] = ((GLint *) p)[0];
break;
@@ -1765,6 +1788,16 @@ _mesa_GetInteger64v(GLenum pname, GLint64 *params)
params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
break;
+ case TYPE_UINT_4:
+ params[3] = ((GLuint *) p)[3];
+ case TYPE_UINT_3:
+ params[2] = ((GLuint *) p)[2];
+ case TYPE_UINT_2:
+ params[1] = ((GLuint *) p)[1];
+ case TYPE_UINT:
+ params[0] = ((GLuint *) p)[0];
+ break;
+
case TYPE_INT64:
params[0] = ((GLint64 *) p)[0];
break;
@@ -1858,6 +1891,16 @@ _mesa_GetDoublev(GLenum pname, GLdouble *params)
params[i] = v.value_int_n.ints[i];
break;
+ case TYPE_UINT_4:
+ params[3] = ((GLuint *) p)[3];
+ case TYPE_UINT_3:
+ params[2] = ((GLuint *) p)[2];
+ case TYPE_UINT_2:
+ params[1] = ((GLuint *) p)[1];
+ case TYPE_UINT:
+ params[0] = ((GLuint *) p)[0];
+ break;
+
case TYPE_INT64:
params[0] = (GLdouble) (((GLint64 *) p)[0]);
break;
@@ -2334,9 +2377,11 @@ _mesa_GetBooleani_v( GLenum pname, GLuint index, GLboolean *params )
switch (type) {
case TYPE_INT:
+ case TYPE_UINT:
params[0] = INT_TO_BOOLEAN(v.value_int);
break;
case TYPE_INT_4:
+ case TYPE_UINT_4:
params[0] = INT_TO_BOOLEAN(v.value_int_4[0]);
params[1] = INT_TO_BOOLEAN(v.value_int_4[1]);
params[2] = INT_TO_BOOLEAN(v.value_int_4[2]);
@@ -2379,9 +2424,11 @@ _mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params )
break;
case TYPE_INT:
+ case TYPE_UINT:
params[0] = v.value_int;
break;
case TYPE_INT_4:
+ case TYPE_UINT_4:
params[0] = v.value_int_4[0];
params[1] = v.value_int_4[1];
params[2] = v.value_int_4[2];
@@ -2412,6 +2459,15 @@ _mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params )
params[2] = v.value_int_4[2];
params[3] = v.value_int_4[3];
break;
+ case TYPE_UINT:
+ params[0] = (GLuint) v.value_int;
+ break;
+ case TYPE_UINT_4:
+ params[0] = (GLuint) v.value_int_4[0];
+ params[1] = (GLuint) v.value_int_4[1];
+ params[2] = (GLuint) v.value_int_4[2];
+ params[3] = (GLuint) v.value_int_4[3];
+ break;
case TYPE_INT64:
params[0] = v.value_int64;
break;
@@ -2467,6 +2523,16 @@ _mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params)
params[i] = (GLfloat) v.value_int_n.ints[i];
break;
+ case TYPE_UINT_4:
+ params[3] = (GLfloat) ((GLuint) v.value_int_4[3]);
+ case TYPE_UINT_3:
+ params[2] = (GLfloat) ((GLuint) v.value_int_4[2]);
+ case TYPE_UINT_2:
+ params[1] = (GLfloat) ((GLuint) v.value_int_4[1]);
+ case TYPE_UINT:
+ params[0] = (GLfloat) ((GLuint) v.value_int_4[0]);
+ break;
+
case TYPE_INT64:
params[0] = (GLfloat) v.value_int64;
break;
@@ -2539,6 +2605,16 @@ _mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params)
params[i] = (GLdouble) v.value_int_n.ints[i];
break;
+ case TYPE_UINT_4:
+ params[3] = (GLdouble) ((GLuint) v.value_int_4[3]);
+ case TYPE_UINT_3:
+ params[2] = (GLdouble) ((GLuint) v.value_int_4[2]);
+ case TYPE_UINT_2:
+ params[1] = (GLdouble) ((GLuint) v.value_int_4[1]);
+ case TYPE_UINT:
+ params[0] = (GLdouble) ((GLuint) v.value_int_4[0]);
+ break;
+
case TYPE_INT64:
params[0] = (GLdouble) v.value_int64;
break;
@@ -2602,13 +2678,17 @@ _mesa_GetFixedv(GLenum pname, GLfixed *params)
break;
case TYPE_INT_4:
+ case TYPE_UINT_4:
params[3] = INT_TO_FIXED(((GLint *) p)[3]);
case TYPE_INT_3:
+ case TYPE_UINT_3:
params[2] = INT_TO_FIXED(((GLint *) p)[2]);
case TYPE_INT_2:
+ case TYPE_UINT_2:
case TYPE_ENUM_2:
params[1] = INT_TO_FIXED(((GLint *) p)[1]);
case TYPE_INT:
+ case TYPE_UINT:
case TYPE_ENUM:
params[0] = INT_TO_FIXED(((GLint *) p)[0]);
break;