static bool brw_fast_clear_init(struct brw_context *brw) { struct brw_fast_clear_state *clear; if (brw->fast_clear_state) { clear = brw->fast_clear_state; _mesa_BindVertexArray(clear->vao); _mesa_BindBuffer(GL_ARRAY_BUFFER, clear->vbo); return true; } brw->fast_clear_state = clear = malloc(sizeof *clear); if (clear == NULL) return false; memset(clear, 0, sizeof *clear); _mesa_GenVertexArrays(1, &clear->vao); _mesa_BindVertexArray(clear->vao); _mesa_GenBuffers(1, &clear->vbo); _mesa_BindBuffer(GL_ARRAY_BUFFER, clear->vbo); _mesa_VertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0); _mesa_EnableVertexAttribArray(0); return true; }
/** * Delete a set of array objects. * * \param n Number of array objects to delete. * \param ids Array of \c n array object IDs. */ void GLAPIENTRY _mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids) { GET_CURRENT_CONTEXT(ctx); GLsizei i; if (n < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteVertexArray(n)"); return; } for (i = 0; i < n; i++) { struct gl_vertex_array_object *obj = _mesa_lookup_vao(ctx, ids[i]); if ( obj != NULL ) { ASSERT( obj->Name == ids[i] ); /* If the array object is currently bound, the spec says "the binding * for that object reverts to zero and the default vertex array * becomes current." */ if ( obj == ctx->Array.VAO ) { _mesa_BindVertexArray(0); } /* The ID is immediately freed for re-use */ remove_array_object(ctx, obj); /* Unreference the array object. * If refcount hits zero, the object will be deleted. */ _mesa_reference_vao(ctx, &obj, NULL); } } }
static bool brw_fast_clear_init(struct brw_context *brw) { struct brw_fast_clear_state *clear; struct gl_context *ctx = &brw->ctx; if (brw->fast_clear_state) { clear = brw->fast_clear_state; _mesa_BindVertexArray(clear->vao); return true; } brw->fast_clear_state = clear = malloc(sizeof *clear); if (clear == NULL) return false; memset(clear, 0, sizeof *clear); _mesa_GenVertexArrays(1, &clear->vao); _mesa_BindVertexArray(clear->vao); clear->buf_obj = ctx->Driver.NewBufferObject(ctx, 0xDEADBEEF); if (clear->buf_obj == NULL) return false; clear->array_obj = _mesa_lookup_vao(ctx, clear->vao); assert(clear->array_obj != NULL); _mesa_update_array_format(ctx, clear->array_obj, VERT_ATTRIB_GENERIC(0), 2, GL_FLOAT, GL_RGBA, GL_FALSE, GL_FALSE, GL_FALSE, 0, true); _mesa_bind_vertex_buffer(ctx, clear->array_obj, VERT_ATTRIB_GENERIC(0), clear->buf_obj, 0, sizeof(float) * 2); _mesa_enable_vertex_array_attrib(ctx, clear->array_obj, VERT_ATTRIB_GENERIC(0)); return true; }