/**
* Looks up the array object for the given ID.
*
- * Unlike _mesa_lookup_vao, this function generates a GL_INVALID_OPERATION
+ * While _mesa_lookup_vao doesn't generate an error if the object does not
+ * exist, this function comes in two variants.
+ * If is_ext_dsa is false, this function generates a GL_INVALID_OPERATION
* error if the array object does not exist. It also returns the default
* array object when ctx is a compatibility profile context and id is zero.
+ * If is_ext_dsa is true, 0 is not a valid name. If the name exists but
+ * the object has never been bound, it is initialized.
*/
struct gl_vertex_array_object *
-_mesa_lookup_vao_err(struct gl_context *ctx, GLuint id, const char *caller)
+_mesa_lookup_vao_err(struct gl_context *ctx, GLuint id,
+ bool is_ext_dsa, const char *caller)
{
/* The ARB_direct_state_access specification says:
*
* the name of the vertex array object."
*/
if (id == 0) {
- if (ctx->API == API_OPENGL_CORE) {
+ if (is_ext_dsa || ctx->API == API_OPENGL_CORE) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(zero is not valid vaobj name in a core profile "
- "context)", caller);
+ "%s(zero is not valid vaobj name%s)",
+ caller,
+ is_ext_dsa ? "" : " in a core profile context");
return NULL;
}
* [compatibility profile: zero or] the name of an existing
* vertex array object."
*/
- if (!vao || !vao->EverBound) {
+ if (!vao || (!is_ext_dsa && !vao->EverBound)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(non-existent vaobj=%u)", caller, id);
return NULL;
}
+ /* The EXT_direct_state_access specification says:
+ *
+ * "If the vertex array object named by the vaobj parameter has not
+ * been previously bound but has been generated (without subsequent
+ * deletion) by GenVertexArrays, the GL first creates a new state
+ * vector in the same manner as when BindVertexArray creates a new
+ * vertex array object."
+ */
+ if (vao && is_ext_dsa && !vao->EverBound)
+ vao->EverBound = true;
+
_mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, vao);
}
* VertexArrayElementBuffer if <vaobj> is not [compatibility profile:
* zero or] the name of an existing vertex array object."
*/
- vao =_mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayElementBuffer");
+ vao =_mesa_lookup_vao_err(ctx, vaobj, false, "glVertexArrayElementBuffer");
if (!vao)
return;
} else {
* [compatibility profile: zero or] the name of an existing
* vertex array object."
*/
- vao =_mesa_lookup_vao_err(ctx, vaobj, "glGetVertexArrayiv");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, false, "glGetVertexArrayiv");
if (!vao)
return;
_mesa_lookup_vao(struct gl_context *ctx, GLuint id);
extern struct gl_vertex_array_object *
-_mesa_lookup_vao_err(struct gl_context *ctx, GLuint id, const char *caller);
+_mesa_lookup_vao_err(struct gl_context *ctx, GLuint id,
+ bool is_ext_dsa, const char *caller);
extern struct gl_vertex_array_object *
_mesa_new_vao(struct gl_context *ctx, GLuint name);
* [compatibility profile: zero or] the name of an existing vertex
* array object."
*/
- vao = _mesa_lookup_vao_err(ctx, vaobj, "glEnableVertexArrayAttrib");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, false, "glEnableVertexArrayAttrib");
if (!vao)
return;
* [compatibility profile: zero or] the name of an existing vertex
* array object."
*/
- vao = _mesa_lookup_vao_err(ctx, vaobj, "glDisableVertexArrayAttrib");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, false, "glDisableVertexArrayAttrib");
if (!vao)
return;
* [compatibility profile: zero or] the name of an existing
* vertex array object."
*/
- vao = _mesa_lookup_vao_err(ctx, vaobj, "glGetVertexArrayIndexediv");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, false, "glGetVertexArrayIndexediv");
if (!vao)
return;
* [compatibility profile: zero or] the name of an existing
* vertex array object."
*/
- vao = _mesa_lookup_vao_err(ctx, vaobj, "glGetVertexArrayIndexed64iv");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, false, "glGetVertexArrayIndexed64iv");
if (!vao)
return;
* if <vaobj> is not [compatibility profile: zero or] the name of an
* existing vertex array object."
*/
- vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayVertexBuffer");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, false, "glVertexArrayVertexBuffer");
if (!vao)
return;
* if <vaobj> is not [compatibility profile: zero or] the name of an
* existing vertex array object."
*/
- vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayVertexBuffers");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, false, "glVertexArrayVertexBuffers");
if (!vao)
return;
* VertexArrayAttrib*Format if <vaobj> is not [compatibility profile:
* zero or] the name of an existing vertex array object."
*/
- vao = _mesa_lookup_vao_err(ctx, vaobj, func);
+ vao = _mesa_lookup_vao_err(ctx, false, vaobj, func);
if (!vao)
return;
* if <vaobj> is not [compatibility profile: zero or] the name of an
* existing vertex array object."
*/
- vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayAttribBinding");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, false, "glVertexArrayAttribBinding");
if (!vao)
return;
* if <vaobj> is not [compatibility profile: zero or] the name of an
* existing vertex array object."
*/
- vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayBindingDivisor");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, false, "glVertexArrayBindingDivisor");
if (!vao)
return;