/*
* Mesa 3-D graphics library
- * Version: 7.6
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*/
#include "hash.h"
#include "image.h"
#include "macros.h"
-#include "mfeatures.h"
#include "mtypes.h"
#include "varray.h"
#include "arrayobj.h"
}
if (_mesa_is_gles(ctx)) {
- /* Once Mesa gets support for GL_OES_vertex_half_float this mask will
- * change. Adding support for this extension isn't quite as trivial as
- * we'd like because ES uses a different enum value for GL_HALF_FLOAT.
- */
- legalTypesMask &= ~(FIXED_GL_BIT | HALF_BIT | DOUBLE_BIT);
+ legalTypesMask &= ~(FIXED_GL_BIT | DOUBLE_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
- * GL_OES_vertex_type_10_10_10_2.
+ * GL_OES_vertex_type_10_10_10_2. GL_HALF_FLOAT data is not allowed
+ * until 3.0 or with the GL_OES_vertex_half float extension, which isn't
+ * quite as trivial as we'd like because it uses a different enum value
+ * for GL_HALF_FLOAT_OES.
*/
if (ctx->Version < 30) {
legalTypesMask &= ~(UNSIGNED_INT_BIT
| INT_BIT
| UNSIGNED_INT_2_10_10_10_REV_BIT
- | INT_2_10_10_10_REV_BIT);
+ | INT_2_10_10_10_REV_BIT
+ | HALF_BIT);
}
/* BGRA ordering is not supported in ES contexts.
if (ctx->Extensions.EXT_vertex_array_bgra &&
sizeMax == BGRA_OR_4 &&
size == GL_BGRA) {
+ /* Page 298 of the PDF of the OpenGL 4.3 (Core Profile) spec says:
+ *
+ * "An INVALID_OPERATION error is generated under any of the following
+ * conditions:
+ * ...
+ * • size is BGRA and type is not UNSIGNED_BYTE, INT_2_10_10_10_REV
+ * or UNSIGNED_INT_2_10_10_10_REV;
+ * ...
+ * • size is BGRA and normalized is FALSE;"
+ */
GLboolean bgra_error = GL_FALSE;
if (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) {
bgra_error = GL_TRUE;
if (bgra_error) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(GL_BGRA/GLubyte)", func);
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(size=GL_BGRA and type=%s)",
+ func, _mesa_lookup_enum_by_nr(type));
return;
}
+
+ if (!normalized) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(size=GL_BGRA and normalized=GL_FALSE)", func);
+ return;
+ }
+
format = GL_BGRA;
size = 4;
}
return;
}
- elementSize = _mesa_sizeof_type(type) * size;
+ elementSize = _mesa_bytes_per_vertex_attrib(size, type);
+ assert(elementSize != -1);
array = &ctx->Array.ArrayObj->VertexAttrib[attrib];
array->Size = size;
ctx->Array.ArrayBufferObj);
ctx->NewState |= _NEW_ARRAY;
- ctx->Array.ArrayObj->NewArrays |= VERT_BIT(attrib);
}
DOUBLE_BIT | HALF_BIT |
UNSIGNED_INT_2_10_10_10_REV_BIT |
INT_2_10_10_10_REV_BIT);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
update_array(ctx, "glVertexPointer", VERT_ATTRIB_POS,
legalTypes, 2, 4,
HALF_BIT | FLOAT_BIT | DOUBLE_BIT |
UNSIGNED_INT_2_10_10_10_REV_BIT |
INT_2_10_10_10_REV_BIT);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
update_array(ctx, "glNormalPointer", VERT_ATTRIB_NORMAL,
legalTypes, 3, 3,
UNSIGNED_INT_2_10_10_10_REV_BIT |
INT_2_10_10_10_REV_BIT);
const GLint sizeMin = (ctx->API == API_OPENGLES) ? 4 : 3;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
update_array(ctx, "glColorPointer", VERT_ATTRIB_COLOR0,
legalTypes, sizeMin, BGRA_OR_4,
void GLAPIENTRY
-_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
+_mesa_FogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
{
const GLbitfield legalTypes = (HALF_BIT | FLOAT_BIT | DOUBLE_BIT);
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
update_array(ctx, "glFogCoordPointer", VERT_ATTRIB_FOG,
legalTypes, 1, 1,
const GLbitfield legalTypes = (UNSIGNED_BYTE_BIT | SHORT_BIT | INT_BIT |
FLOAT_BIT | DOUBLE_BIT);
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
update_array(ctx, "glIndexPointer", VERT_ATTRIB_COLOR_INDEX,
legalTypes, 1, 1,
void GLAPIENTRY
-_mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
+_mesa_SecondaryColorPointer(GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr)
{
const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT |
UNSIGNED_INT_2_10_10_10_REV_BIT |
INT_2_10_10_10_REV_BIT);
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
update_array(ctx, "glSecondaryColorPointer", VERT_ATTRIB_COLOR1,
legalTypes, 3, BGRA_OR_4,
INT_2_10_10_10_REV_BIT);
const GLint sizeMin = (ctx->API == API_OPENGLES) ? 2 : 1;
const GLuint unit = ctx->Array.ActiveTexture;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
update_array(ctx, "glTexCoordPointer", VERT_ATTRIB_TEX(unit),
legalTypes, sizeMin, 4,
/* see table 2.4 edits in GL_EXT_gpu_shader4 spec: */
const GLboolean integer = GL_TRUE;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
update_array(ctx, "glEdgeFlagPointer", VERT_ATTRIB_EDGEFLAG,
legalTypes, 1, 1,
void GLAPIENTRY
-_mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr)
+_mesa_PointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *ptr)
{
const GLbitfield legalTypes = (FLOAT_BIT | FIXED_ES_BIT);
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
if (ctx->API != API_OPENGLES) {
_mesa_error(ctx, GL_INVALID_OPERATION,
}
-/**
- * Set a vertex attribute array.
- * Note that these arrays DO alias the conventional GL vertex arrays
- * (position, normal, color, fog, texcoord, etc).
- * The generic attribute slots at #16 and above are not touched.
- */
-void GLAPIENTRY
-_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
- GLsizei stride, const GLvoid *ptr)
-{
- const GLbitfield legalTypes = (UNSIGNED_BYTE_BIT | SHORT_BIT |
- FLOAT_BIT | DOUBLE_BIT);
- GLboolean normalized = GL_FALSE;
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)");
- return;
- }
-
- if (type == GL_UNSIGNED_BYTE && size != 4) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)");
- return;
- }
-
- update_array(ctx, "glVertexAttribPointerNV", VERT_ATTRIB_GENERIC(index),
- legalTypes, 1, BGRA_OR_4,
- size, type, stride, normalized, GL_FALSE, ptr);
-}
-
-
-#if FEATURE_ARB_vertex_program
/**
* Set a generic vertex attribute array.
* Note that these arrays DO NOT alias the conventional GL vertex arrays
* (position, normal, color, fog, texcoord, etc).
*/
void GLAPIENTRY
-_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
+_mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type,
GLboolean normalized,
GLsizei stride, const GLvoid *ptr)
{
UNSIGNED_INT_2_10_10_10_REV_BIT |
INT_2_10_10_10_REV_BIT);
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (index >= ctx->Const.VertexProgram.MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)");
legalTypes, 1, BGRA_OR_4,
size, type, stride, normalized, GL_FALSE, ptr);
}
-#endif
/**
const GLboolean normalized = GL_FALSE;
const GLboolean integer = GL_TRUE;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (index >= ctx->Const.VertexProgram.MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribIPointer(index)");
void GLAPIENTRY
-_mesa_EnableVertexAttribArrayARB(GLuint index)
+_mesa_EnableVertexAttribArray(GLuint index)
{
struct gl_array_object *arrayObj;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (index >= ctx->Const.VertexProgram.MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
FLUSH_VERTICES(ctx, _NEW_ARRAY);
arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE;
arrayObj->_Enabled |= VERT_BIT_GENERIC(index);
- arrayObj->NewArrays |= VERT_BIT_GENERIC(index);
}
}
void GLAPIENTRY
-_mesa_DisableVertexAttribArrayARB(GLuint index)
+_mesa_DisableVertexAttribArray(GLuint index)
{
struct gl_array_object *arrayObj;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (index >= ctx->Const.VertexProgram.MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
FLUSH_VERTICES(ctx, _NEW_ARRAY);
arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE;
arrayObj->_Enabled &= ~VERT_BIT_GENERIC(index);
- arrayObj->NewArrays |= VERT_BIT_GENERIC(index);
}
}
}
void GLAPIENTRY
-_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
+_mesa_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
const GLfloat *v = get_current_attrib(ctx, index, "glGetVertexAttribfv");
void GLAPIENTRY
-_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params)
+_mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
const GLfloat *v = get_current_attrib(ctx, index, "glGetVertexAttribdv");
void GLAPIENTRY
-_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params)
+_mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
const GLfloat *v = get_current_attrib(ctx, index, "glGetVertexAttribiv");
_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
- const GLfloat *v =
+ const GLint *v = (const GLint *)
get_current_attrib(ctx, index, "glGetVertexAttribIiv");
if (v != NULL) {
- /* XXX we don't have true integer-valued vertex attribs yet */
- params[0] = (GLint) v[0];
- params[1] = (GLint) v[1];
- params[2] = (GLint) v[2];
- params[3] = (GLint) v[3];
+ COPY_4V(params, v);
}
}
else {
_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
- const GLfloat *v =
+ const GLuint *v = (const GLuint *)
get_current_attrib(ctx, index, "glGetVertexAttribIuiv");
if (v != NULL) {
- /* XXX we don't have true integer-valued vertex attribs yet */
- params[0] = (GLuint) v[0];
- params[1] = (GLuint) v[1];
- params[2] = (GLuint) v[2];
- params[3] = (GLuint) v[3];
+ COPY_4V(params, v);
}
}
else {
void GLAPIENTRY
-_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
+_mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (index >= ctx->Const.VertexProgram.MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)");
GLint defstride; /* default stride */
GLint c, f;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ FLUSH_VERTICES(ctx, 0);
f = sizeof(GLfloat);
c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f);
_mesa_LockArraysEXT(GLint first, GLsizei count)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glLockArrays %d %d\n", first, count);
_mesa_UnlockArraysEXT( void )
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glUnlockArrays\n");
/* GL_EXT_multi_draw_arrays */
void GLAPIENTRY
-_mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first,
+_mesa_MultiDrawArrays( GLenum mode, const GLint *first,
const GLsizei *count, GLsizei primcount )
{
GET_CURRENT_CONTEXT(ctx);
GLint i;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ FLUSH_VERTICES(ctx, 0);
for (i = 0; i < primcount; i++) {
if (count[i] > 0) {
GET_CURRENT_CONTEXT(ctx);
GLint i;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ FLUSH_VERTICES(ctx, 0);
for ( i = 0 ; i < primcount ; i++ ) {
if ( count[i] > 0 ) {
GET_CURRENT_CONTEXT(ctx);
GLint i;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ FLUSH_VERTICES(ctx, 0);
/* XXX not sure about ARB_vertex_buffer_object handling here */
return;
}
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
if (ctx->Array.RestartIndex != index) {
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
ctx->Array.RestartIndex = index;
{
struct gl_client_array *array;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
if (!ctx->Extensions.ARB_instanced_arrays) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glVertexAttribDivisor()");
}
if (index >= ctx->Const.VertexProgram.MaxAttribs) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glVertexAttribDivisor(index = %u)",
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribDivisor(index = %u)",
index);
return;
}
if (array->InstanceDivisor != divisor) {
FLUSH_VERTICES(ctx, _NEW_ARRAY);
array->InstanceDivisor = divisor;
- ctx->Array.ArrayObj->NewArrays |= VERT_BIT(VERT_ATTRIB_GENERIC(index));
}
}
+unsigned
+_mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type)
+{
+ /* From the OpenGL 4.3 core specification, page 302:
+ * "If both PRIMITIVE_RESTART and PRIMITIVE_RESTART_FIXED_INDEX are
+ * enabled, the index value determined by PRIMITIVE_RESTART_FIXED_INDEX
+ * is used."
+ */
+ if (ctx->Array.PrimitiveRestartFixedIndex) {
+ switch (ib_type) {
+ case GL_UNSIGNED_BYTE:
+ return 0xff;
+ case GL_UNSIGNED_SHORT:
+ return 0xffff;
+ case GL_UNSIGNED_INT:
+ return 0xffffffff;
+ default:
+ assert(!"_mesa_primitive_restart_index: Invalid index buffer type.");
+ }
+ }
+
+ return ctx->Array.RestartIndex;
+}
+
/**
* Copy one client vertex array to another.