summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorAndres Rodriguez <[email protected]>2017-07-12 18:45:22 -0400
committerTimothy Arceri <[email protected]>2017-08-06 12:42:06 +1000
commite064d660205a04e7d9c63fdceebf3c293a6872ed (patch)
tree72b417606554511405171ac71e301f76ad122a8f /src/mesa/main
parent921bdf1b6d58b86de1f6e2d0ce05088f4c209132 (diff)
mesa: implement glGetUnsignedByte{v|i_v}
These are used by EXT_external_objects to present UUIDs for the device and the driver. v2 (Timothy Arceri): - remove extra break - use _mesa_problem() rather the _mesa_error() for unimplemented support for value types Signed-off-by: Andres Rodriguez <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/get.c174
1 files changed, 174 insertions, 0 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 982f64a08ac..75d77c80b0a 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1431,6 +1431,72 @@ static const int transpose[] = {
3, 7, 11, 15
};
+static GLsizei
+get_value_size(enum value_type type, const union value *v)
+{
+ switch (type) {
+ case TYPE_INVALID:
+ return 0;
+ case TYPE_CONST:
+ case TYPE_UINT:
+ case TYPE_INT:
+ return sizeof(GLint);
+ case TYPE_INT_2:
+ case TYPE_UINT_2:
+ return sizeof(GLint) * 2;
+ case TYPE_INT_3:
+ case TYPE_UINT_3:
+ return sizeof(GLint) * 3;
+ case TYPE_INT_4:
+ case TYPE_UINT_4:
+ return sizeof(GLint) * 4;
+ case TYPE_INT_N:
+ return sizeof(GLint) * v->value_int_n.n;
+ case TYPE_INT64:
+ return sizeof(GLint64);
+ break;
+ case TYPE_ENUM:
+ return sizeof(GLenum);
+ case TYPE_ENUM_2:
+ return sizeof(GLenum) * 2;
+ case TYPE_BOOLEAN:
+ return sizeof(GLboolean);
+ case TYPE_BIT_0:
+ case TYPE_BIT_1:
+ case TYPE_BIT_2:
+ case TYPE_BIT_3:
+ case TYPE_BIT_4:
+ case TYPE_BIT_5:
+ case TYPE_BIT_6:
+ case TYPE_BIT_7:
+ return 1;
+ case TYPE_FLOAT:
+ case TYPE_FLOATN:
+ return sizeof(GLfloat);
+ case TYPE_FLOAT_2:
+ case TYPE_FLOATN_2:
+ return sizeof(GLfloat) * 2;
+ case TYPE_FLOAT_3:
+ case TYPE_FLOATN_3:
+ return sizeof(GLfloat) * 3;
+ case TYPE_FLOAT_4:
+ case TYPE_FLOATN_4:
+ return sizeof(GLfloat) * 4;
+ case TYPE_FLOAT_8:
+ return sizeof(GLfloat) * 8;
+ case TYPE_DOUBLEN:
+ return sizeof(GLdouble);
+ case TYPE_DOUBLEN_2:
+ return sizeof(GLdouble) * 2;
+ case TYPE_MATRIX:
+ return sizeof (GLfloat) * 16;
+ case TYPE_MATRIX_T:
+ return sizeof (GLfloat) * 16;
+ default:
+ return -1;
+ }
+}
+
void GLAPIENTRY
_mesa_GetBooleanv(GLenum pname, GLboolean *params)
{
@@ -1949,7 +2015,69 @@ _mesa_GetDoublev(GLenum pname, GLdouble *params)
void GLAPIENTRY
_mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data)
{
+ const struct value_desc *d;
+ union value v;
+ int shift;
+ void *p;
+ GLsizei size;
+ const char *func = "glGetUnsignedBytevEXT";
+
+ GET_CURRENT_CONTEXT(ctx);
+ d = find_value(func, pname, &p, &v);
+ size = get_value_size(d->type, &v);
+ if (size >= 0) {
+ _mesa_problem(ctx, "invalid value type in GetUnsignedBytevEXT()");
+ }
+
+ switch (d->type) {
+ case TYPE_BIT_0:
+ case TYPE_BIT_1:
+ case TYPE_BIT_2:
+ case TYPE_BIT_3:
+ case TYPE_BIT_4:
+ case TYPE_BIT_5:
+ case TYPE_BIT_6:
+ case TYPE_BIT_7:
+ shift = d->type - TYPE_BIT_0;
+ data[0] = (*(GLbitfield *) p >> shift) & 1;
+ break;
+ case TYPE_CONST:
+ memcpy(data, &d->offset, size);
+ break;
+ case TYPE_INT_N:
+ memcpy(data, &v.value_int_n.ints, size);
+ break;
+ case TYPE_UINT:
+ case TYPE_INT:
+ case TYPE_INT_2:
+ case TYPE_UINT_2:
+ case TYPE_INT_3:
+ case TYPE_UINT_3:
+ case TYPE_INT_4:
+ case TYPE_UINT_4:
+ case TYPE_INT64:
+ case TYPE_ENUM:
+ case TYPE_ENUM_2:
+ case TYPE_BOOLEAN:
+ case TYPE_FLOAT:
+ case TYPE_FLOATN:
+ case TYPE_FLOAT_2:
+ case TYPE_FLOATN_2:
+ case TYPE_FLOAT_3:
+ case TYPE_FLOATN_3:
+ case TYPE_FLOAT_4:
+ case TYPE_FLOATN_4:
+ case TYPE_FLOAT_8:
+ case TYPE_DOUBLEN:
+ case TYPE_DOUBLEN_2:
+ case TYPE_MATRIX:
+ case TYPE_MATRIX_T:
+ memcpy(data, p, size);
+ break;
+ default:
+ break; /* nothing - GL error was recorded */
+ }
}
/**
@@ -2660,7 +2788,53 @@ _mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params)
void GLAPIENTRY
_mesa_GetUnsignedBytei_vEXT(GLenum target, GLuint index, GLubyte *data)
{
+ GLsizei size;
+ union value v;
+ enum value_type type;
+ const char *func = "glGetUnsignedBytei_vEXT";
+
+ GET_CURRENT_CONTEXT(ctx);
+ type = find_value_indexed(func, target, index, &v);
+ size = get_value_size(type, &v);
+ if (size <= 0) {
+ _mesa_problem(ctx, "invalid value type in GetUnsignedBytei_vEXT()");
+ }
+
+ switch (type) {
+ case TYPE_UINT:
+ case TYPE_INT:
+ case TYPE_INT_2:
+ case TYPE_UINT_2:
+ case TYPE_INT_3:
+ case TYPE_UINT_3:
+ case TYPE_INT_4:
+ case TYPE_UINT_4:
+ case TYPE_INT64:
+ case TYPE_ENUM:
+ case TYPE_ENUM_2:
+ case TYPE_BOOLEAN:
+ case TYPE_FLOAT:
+ case TYPE_FLOATN:
+ case TYPE_FLOAT_2:
+ case TYPE_FLOATN_2:
+ case TYPE_FLOAT_3:
+ case TYPE_FLOATN_3:
+ case TYPE_FLOAT_4:
+ case TYPE_FLOATN_4:
+ case TYPE_FLOAT_8:
+ case TYPE_DOUBLEN:
+ case TYPE_DOUBLEN_2:
+ case TYPE_MATRIX:
+ case TYPE_MATRIX_T:
+ memcpy(data, &v.value_int, size);
+ break;
+ case TYPE_INT_N:
+ memcpy(data, &v.value_int_n.ints, size);
+ break;
+ default:
+ break; /* nothing - GL error was recorded */
+ }
}
void GLAPIENTRY