mesa: EXT_vertex_array_bgra fixes
1) Pass the correct format when calling update_array in
_mesa_VertexAttribPointerARB.
2) glVertexAttribPointerNV accepts GL_BGRA format too.
3) raise INVALID_VALUE error when format is BGRA and normalized is
false in glVertexAttribPointerARB
(cherry picked from commit 4adb190a16
)
This commit is contained in:
@@ -534,6 +534,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
|
|||||||
{
|
{
|
||||||
GLboolean normalized = GL_FALSE;
|
GLboolean normalized = GL_FALSE;
|
||||||
GLsizei elementSize;
|
GLsizei elementSize;
|
||||||
|
GLenum format;
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
@@ -557,6 +558,21 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (size == GL_BGRA) {
|
||||||
|
if (type != GL_UNSIGNED_BYTE) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||||
|
"glVertexAttribPointerNV(GL_BGRA/type)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
format = GL_BGRA;
|
||||||
|
size = 4;
|
||||||
|
normalized = GL_TRUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
format = GL_RGBA;
|
||||||
|
}
|
||||||
|
|
||||||
/* check for valid 'type' and compute StrideB right away */
|
/* check for valid 'type' and compute StrideB right away */
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GL_UNSIGNED_BYTE:
|
case GL_UNSIGNED_BYTE:
|
||||||
@@ -579,7 +595,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
|
|||||||
|
|
||||||
update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
|
update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
|
||||||
_NEW_ARRAY_ATTRIB(index),
|
_NEW_ARRAY_ATTRIB(index),
|
||||||
elementSize, size, type, GL_RGBA, stride, normalized, ptr);
|
elementSize, size, type, format, stride, normalized, ptr);
|
||||||
|
|
||||||
if (ctx->Driver.VertexAttribPointer)
|
if (ctx->Driver.VertexAttribPointer)
|
||||||
ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
|
ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
|
||||||
@@ -621,9 +637,14 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
|
|||||||
"glVertexAttribPointerARB(GL_BGRA/type)");
|
"glVertexAttribPointerARB(GL_BGRA/type)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (normalized != GL_TRUE) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||||
|
"glVertexAttribPointerARB(GL_BGRA/normalized)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
format = GL_BGRA;
|
format = GL_BGRA;
|
||||||
size = 4;
|
size = 4;
|
||||||
normalized = GL_TRUE;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
format = GL_RGBA;
|
format = GL_RGBA;
|
||||||
@@ -668,7 +689,7 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
|
|||||||
|
|
||||||
update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
|
update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
|
||||||
_NEW_ARRAY_ATTRIB(index),
|
_NEW_ARRAY_ATTRIB(index),
|
||||||
elementSize, size, type, GL_RGBA, stride, normalized, ptr);
|
elementSize, size, type, format, stride, normalized, ptr);
|
||||||
|
|
||||||
if (ctx->Driver.VertexAttribPointer)
|
if (ctx->Driver.VertexAttribPointer)
|
||||||
ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
|
ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
|
||||||
|
Reference in New Issue
Block a user