X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmesa%2Fmain%2Fvarray.c;h=b73a396e25d269dd47febb01fe097bd41b7dc0c5;hb=917db0bc3dfdec1536018d96aab261e485b8d872;hp=b0e02865b1de965e8f6b954dc6b0e71ee6e0d43d;hpb=59b01ca252bd6706f08cd80a864819d71dfe741c;p=mesa.git diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index b0e02865b1d..b73a396e25d 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -60,6 +60,7 @@ #define FIXED_GL_BIT 0x800 #define UNSIGNED_INT_2_10_10_10_REV_BIT 0x1000 #define INT_2_10_10_10_REV_BIT 0x2000 +#define UNSIGNED_INT_10F_11F_11F_REV_BIT 0x4000 /** Convert GL datatype enum into a _BIT value seen above */ @@ -96,6 +97,8 @@ type_to_bit(const struct gl_context *ctx, GLenum type) return UNSIGNED_INT_2_10_10_10_REV_BIT; case GL_INT_2_10_10_10_REV: return INT_2_10_10_10_REV_BIT; + case GL_UNSIGNED_INT_10F_11F_11F_REV: + return UNSIGNED_INT_10F_11F_11F_REV_BIT; default: return 0; } @@ -206,7 +209,7 @@ update_array_format(struct gl_context *ctx, GLenum format = GL_RGBA; if (_mesa_is_gles(ctx)) { - legalTypesMask &= ~(FIXED_GL_BIT | DOUBLE_BIT); + legalTypesMask &= ~(FIXED_GL_BIT | DOUBLE_BIT | UNSIGNED_INT_10F_11F_11F_REV_BIT); /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or @@ -236,6 +239,9 @@ update_array_format(struct gl_context *ctx, if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT | INT_2_10_10_10_REV_BIT); + + if (!ctx->Extensions.ARB_vertex_type_10f_11f_11f_rev) + legalTypesMask &= ~UNSIGNED_INT_10F_11F_11F_REV_BIT; } typeBit = type_to_bit(ctx, type); @@ -309,7 +315,13 @@ update_array_format(struct gl_context *ctx, "%s(relativeOffset=%d > " "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET)", func, relativeOffset); - return GL_FALSE; + return false; + } + + if (ctx->Extensions.ARB_vertex_type_10f_11f_11f_rev && + type == GL_UNSIGNED_INT_10F_11F_11F_REV && size != 3) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(size=%d)", func, size); + return false; } ASSERT(size <= 4); @@ -378,11 +390,6 @@ update_array(struct gl_context *ctx, return; } - if (!update_array_format(ctx, func, attrib, legalTypesMask, sizeMin, sizeMax, - size, type, normalized, integer, 0)) { - return; - } - if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride ); return; @@ -406,6 +413,11 @@ update_array(struct gl_context *ctx, return; } + if (!update_array_format(ctx, func, attrib, legalTypesMask, sizeMin, + sizeMax, size, type, normalized, integer, 0)) { + return; + } + /* Reset the vertex attrib binding */ vertex_attrib_binding(ctx, attrib, attrib); @@ -605,10 +617,11 @@ _mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type, HALF_BIT | FLOAT_BIT | DOUBLE_BIT | FIXED_ES_BIT | FIXED_GL_BIT | UNSIGNED_INT_2_10_10_10_REV_BIT | - INT_2_10_10_10_REV_BIT); + INT_2_10_10_10_REV_BIT | + UNSIGNED_INT_10F_11F_11F_REV_BIT); GET_CURRENT_CONTEXT(ctx); - if (index >= ctx->Const.VertexProgram.MaxAttribs) { + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)"); return; } @@ -636,7 +649,7 @@ _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, const GLboolean integer = GL_TRUE; GET_CURRENT_CONTEXT(ctx); - if (index >= ctx->Const.VertexProgram.MaxAttribs) { + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribIPointer(index)"); return; } @@ -654,7 +667,7 @@ _mesa_EnableVertexAttribArray(GLuint index) struct gl_array_object *arrayObj; GET_CURRENT_CONTEXT(ctx); - if (index >= ctx->Const.VertexProgram.MaxAttribs) { + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glEnableVertexAttribArrayARB(index)"); return; @@ -680,7 +693,7 @@ _mesa_DisableVertexAttribArray(GLuint index) struct gl_array_object *arrayObj; GET_CURRENT_CONTEXT(ctx); - if (index >= ctx->Const.VertexProgram.MaxAttribs) { + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glDisableVertexAttribArrayARB(index)"); return; @@ -712,7 +725,7 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname, const struct gl_array_object *arrayObj = ctx->Array.ArrayObj; const struct gl_vertex_attrib_array *array; - if (index >= ctx->Const.VertexProgram.MaxAttribs) { + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", caller, index); return 0; } @@ -747,6 +760,16 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname, return arrayObj->VertexBinding[array->VertexBinding].InstanceDivisor; } goto error; + case GL_VERTEX_ATTRIB_BINDING: + if (_mesa_is_desktop_gl(ctx)) { + return array->VertexBinding - VERT_ATTRIB_GENERIC0; + } + goto error; + case GL_VERTEX_ATTRIB_RELATIVE_OFFSET: + if (_mesa_is_desktop_gl(ctx)) { + return array->RelativeOffset; + } + goto error; default: ; /* fall-through */ } @@ -772,7 +795,7 @@ get_current_attrib(struct gl_context *ctx, GLuint index, const char *function) return NULL; } } - else if (index >= ctx->Const.VertexProgram.MaxAttribs) { + else if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(index>=GL_MAX_VERTEX_ATTRIBS)", function); return NULL; @@ -890,7 +913,7 @@ _mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer) { GET_CURRENT_CONTEXT(ctx); - if (index >= ctx->Const.VertexProgram.MaxAttribs) { + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)"); return; } @@ -1285,7 +1308,7 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor) return; } - if (index >= ctx->Const.VertexProgram.MaxAttribs) { + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribDivisor(index = %u)", index); return; @@ -1341,9 +1364,10 @@ void GLAPIENTRY _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset, GLsizei stride) { + GET_CURRENT_CONTEXT(ctx); + const struct gl_array_object *arrayObj = ctx->Array.ArrayObj; struct gl_buffer_object *vbo; - GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); /* The ARB_vertex_attrib_binding spec says: @@ -1388,7 +1412,9 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset, return; } - if (buffer != 0) { + if (buffer == arrayObj->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj->Name) { + vbo = arrayObj->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj; + } else if (buffer != 0) { vbo = _mesa_lookup_bufferobj(ctx, buffer); /* From the GL_ARB_vertex_attrib_array spec: @@ -1428,7 +1454,8 @@ _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type, HALF_BIT | FLOAT_BIT | DOUBLE_BIT | FIXED_GL_BIT | UNSIGNED_INT_2_10_10_10_REV_BIT | - INT_2_10_10_10_REV_BIT); + INT_2_10_10_10_REV_BIT | + UNSIGNED_INT_10F_11F_11F_REV_BIT); GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -1452,7 +1479,7 @@ _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type, * "The error INVALID_VALUE is generated if index is greater than or equal * to the value of MAX_VERTEX_ATTRIBS." */ - if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) { + if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribFormat(attribindex=%u > " "GL_MAX_VERTEX_ATTRIBS)", @@ -1499,7 +1526,7 @@ _mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type, * "The error INVALID_VALUE is generated if index is greater than * or equal to the value of MAX_VERTEX_ATTRIBS." */ - if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) { + if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribIFormat(attribindex=%u > " "GL_MAX_VERTEX_ATTRIBS)", @@ -1547,7 +1574,7 @@ _mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type, * "The error INVALID_VALUE is generated if is greater than * or equal to the value of MAX_VERTEX_ATTRIBS." */ - if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) { + if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribLFormat(attribindex=%u > " "GL_MAX_VERTEX_ATTRIBS)", @@ -1589,7 +1616,7 @@ _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) * MAX_VERTEX_ATTRIB_BINDINGS, otherwise the error INVALID_VALUE * is generated." */ - if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) { + if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribBinding(attribindex=%u >= " "GL_MAX_VERTEX_ATTRIBS)",