*
* \param VAO Storage for vertex array object handle. If 0, a new VAO
* will be created.
- * \param VBO Storage for vertex buffer object handle. If 0, a new VBO
+ * \param buf_obj Storage for vertex buffer object pointer. If \c NULL, a new VBO
* will be created. The new VBO will have storage for 4
* \c vertex structures.
* \param use_generic_attributes Should generic attributes 0 and 1 be used,
*/
void
_mesa_meta_setup_vertex_objects(struct gl_context *ctx,
- GLuint *VAO, GLuint *VBO,
+ GLuint *VAO, struct gl_buffer_object **buf_obj,
bool use_generic_attributes,
unsigned vertex_size, unsigned texcoord_size,
unsigned color_size)
{
+ GLuint VBO;
+
if (*VAO == 0) {
- assert(*VBO == 0);
+ assert(*buf_obj == NULL);
/* create vertex array object */
_mesa_GenVertexArrays(1, VAO);
_mesa_BindVertexArray(*VAO);
/* create vertex array buffer */
- _mesa_GenBuffers(1, VBO);
- _mesa_BindBuffer(GL_ARRAY_BUFFER, *VBO);
+ _mesa_GenBuffers(1, &VBO);
+ _mesa_BindBuffer(GL_ARRAY_BUFFER, VBO);
+ *buf_obj = _mesa_lookup_bufferobj(ctx, VBO);
+
+ /* _mesa_lookup_bufferobj only returns NULL if name is 0. If the object
+ * does not yet exist (i.e., hasn't been bound) it will return a dummy
+ * object that you can't do anything with.
+ */
+ assert(*buf_obj != NULL && (*buf_obj)->Name == VBO);
+ assert(*buf_obj == ctx->Array.ArrayBufferObj);
+
_mesa_BufferData(GL_ARRAY_BUFFER, 4 * sizeof(struct vertex), NULL,
GL_DYNAMIC_DRAW);
+ assert((*buf_obj)->Size == 4 * sizeof(struct vertex));
+
/* setup vertex arrays */
if (use_generic_attributes) {
assert(color_size == 0);
void
_mesa_meta_setup_ff_tnl_for_blit(struct gl_context *ctx,
- GLuint *VAO, GLuint *VBO,
+ GLuint *VAO, struct gl_buffer_object **buf_obj,
unsigned texcoord_size)
{
- _mesa_meta_setup_vertex_objects(ctx, VAO, VBO, false, 2, texcoord_size, 0);
+ _mesa_meta_setup_vertex_objects(ctx, VAO, buf_obj, false, 2, texcoord_size,
+ 0);
/* setup projection matrix */
_mesa_MatrixMode(GL_PROJECTION);
GLuint vs, fs;
bool has_integer_textures;
- _mesa_meta_setup_vertex_objects(ctx, &clear->VAO, &clear->VBO, true,
+ _mesa_meta_setup_vertex_objects(ctx, &clear->VAO, &clear->buf_obj, true,
3, 0, 0);
if (clear->ShaderProg != 0)
return;
_mesa_DeleteVertexArrays(1, &clear->VAO);
clear->VAO = 0;
- _mesa_DeleteBuffers(1, &clear->VBO);
- clear->VBO = 0;
+ _mesa_DeleteBuffers(1, &clear->buf_obj->Name);
+ clear->buf_obj = NULL;
_mesa_DeleteProgram(clear->ShaderProg);
clear->ShaderProg = 0;
y1 = ((float) fb->_Ymax / fb->Height) * 2.0f - 1.0f;
z = -invert_z(ctx->Depth.Clear);
} else {
- _mesa_meta_setup_vertex_objects(ctx, &clear->VAO, &clear->VBO, false,
+ _mesa_meta_setup_vertex_objects(ctx, &clear->VAO, &clear->buf_obj, false,
3, 0, 4);
x0 = (float) fb->_Xmin;
}
/* upload new vertex data */
- _mesa_NamedBufferData(clear->VBO, sizeof(verts), verts, GL_DYNAMIC_DRAW);
+ _mesa_buffer_data(ctx, clear->buf_obj, GL_NONE, sizeof(verts), verts,
+ GL_DYNAMIC_DRAW, __func__);
/* draw quad(s) */
if (fb->MaxNumLayers > 0) {
MESA_META_VERTEX |
MESA_META_VIEWPORT));
- _mesa_meta_setup_vertex_objects(ctx, ©pix->VAO, ©pix->VBO, false,
+ _mesa_meta_setup_vertex_objects(ctx, ©pix->VAO, ©pix->buf_obj, false,
3, 2, 0);
/* Silence valgrind warnings about reading uninitialized stack. */
verts[3].tex[1] = tex->Ttop;
/* upload new vertex data */
- _mesa_NamedBufferSubData(copypix->VBO, 0, sizeof(verts), verts);
+ _mesa_buffer_sub_data(ctx, copypix->buf_obj, 0, sizeof(verts), verts,
+ __func__);
}
_mesa_set_enable(ctx, tex->Target, GL_TRUE);
_mesa_DeleteVertexArrays(1, &drawpix->VAO);
drawpix->VAO = 0;
- _mesa_DeleteBuffers(1, &drawpix->VBO);
- drawpix->VBO = 0;
+ _mesa_DeleteBuffers(1, &drawpix->buf_obj->Name);
+ drawpix->buf_obj = NULL;
}
if (drawpix->StencilFP != 0) {
newTex = _mesa_meta_alloc_texture(tex, width, height, texIntFormat);
- _mesa_meta_setup_vertex_objects(ctx, &drawpix->VAO, &drawpix->VBO, false,
+ _mesa_meta_setup_vertex_objects(ctx, &drawpix->VAO, &drawpix->buf_obj, false,
3, 2, 0);
/* Silence valgrind warnings about reading uninitialized stack. */
}
/* upload new vertex data */
- _mesa_NamedBufferData(drawpix->VBO, sizeof(verts), verts, GL_DYNAMIC_DRAW);
+ _mesa_buffer_data(ctx, drawpix->buf_obj, GL_NONE, sizeof(verts), verts,
+ GL_DYNAMIC_DRAW, __func__);
/* set given unpack params */
ctx->Unpack = *unpack;
MESA_META_VERTEX |
MESA_META_VIEWPORT));
- _mesa_meta_setup_vertex_objects(ctx, &bitmap->VAO, &bitmap->VBO, false,
+ _mesa_meta_setup_vertex_objects(ctx, &bitmap->VAO, &bitmap->buf_obj, false,
3, 2, 4);
newTex = _mesa_meta_alloc_texture(tex, width, height, texIntFormat);
}
/* upload new vertex data */
- _mesa_NamedBufferSubData(bitmap->VBO, 0, sizeof(verts), verts);
+ _mesa_buffer_sub_data(ctx, bitmap->buf_obj, 0, sizeof(verts), verts,
+ __func__);
}
/* choose different foreground/background alpha values */
if (decompress->VAO != 0) {
_mesa_DeleteVertexArrays(1, &decompress->VAO);
- _mesa_DeleteBuffers(1, &decompress->VBO);
+ _mesa_DeleteBuffers(1, &decompress->buf_obj->Name);
}
if (decompress->Sampler != 0)
}
if (use_glsl_version) {
- _mesa_meta_setup_vertex_objects(ctx, &decompress->VAO, &decompress->VBO, true,
+ _mesa_meta_setup_vertex_objects(ctx, &decompress->VAO,
+ &decompress->buf_obj, true,
2, 4, 0);
_mesa_meta_setup_blit_shader(ctx, target, false, &decompress->shaders);
} else {
- _mesa_meta_setup_ff_tnl_for_blit(ctx, &decompress->VAO, &decompress->VBO, 3);
+ _mesa_meta_setup_ff_tnl_for_blit(ctx, &decompress->VAO,
+ &decompress->buf_obj, 3);
}
if (!decompress->Sampler) {
_mesa_set_viewport(ctx, 0, 0, 0, width, height);
/* upload new vertex data */
- _mesa_NamedBufferSubData(decompress->VBO, 0, sizeof(verts), verts);
+ _mesa_buffer_sub_data(ctx, decompress->buf_obj, 0, sizeof(verts), verts,
+ __func__);
/* setup texture state */
_mesa_BindTexture(target, texObj->Name);