X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Farrayobj.c;h=2d3b69cd8de3a81e16e3d633dca9789ff4e21d00;hb=bc5be5323f14c4f790ecaf29991158be1f5435b0;hp=28851434133afc18dfe3f466e143a04c6e911c5c;hpb=005c8e01062e8e88a86904b955d5422742bd32e7;p=mesa.git diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 28851434133..2d3b69cd8de 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -52,6 +52,7 @@ #include "mtypes.h" #include "varray.h" #include "main/dispatch.h" +#include "util/bitscan.h" /** @@ -149,9 +150,6 @@ unbind_array_object_vbos(struct gl_context *ctx, struct gl_vertex_array_object * /** * Allocate and initialize a new vertex array object. - * - * This function is intended to be called via - * \c dd_function_table::NewArrayObject. */ struct gl_vertex_array_object * _mesa_new_vao(struct gl_context *ctx, GLuint name) @@ -165,9 +163,6 @@ _mesa_new_vao(struct gl_context *ctx, GLuint name) /** * Delete an array object. - * - * This function is intended to be called via - * \c dd_function_table::DeleteArrayObject. */ void _mesa_delete_vao(struct gl_context *ctx, struct gl_vertex_array_object *obj) @@ -203,10 +198,8 @@ _mesa_reference_vao_(struct gl_context *ctx, deleteFlag = (oldObj->RefCount == 0); mtx_unlock(&oldObj->Mutex); - if (deleteFlag) { - assert(ctx->Driver.DeleteArrayObject); - ctx->Driver.DeleteArrayObject(ctx, oldObj); - } + if (deleteFlag) + _mesa_delete_vao(ctx, oldObj); *ptr = NULL; } @@ -350,13 +343,12 @@ _mesa_update_vao_client_arrays(struct gl_context *ctx, GLbitfield64 arrays = vao->NewArrays; while (arrays) { + const int attrib = u_bit_scan64(&arrays); + struct gl_client_array *client_array; struct gl_vertex_attrib_array *attrib_array; struct gl_vertex_buffer_binding *buffer_binding; - GLint attrib = ffsll(arrays) - 1; - arrays ^= BITFIELD64_BIT(attrib); - attrib_array = &vao->VertexAttrib[attrib]; buffer_binding = &vao->VertexBinding[attrib_array->VertexBinding]; client_array = &vao->_VertexAttrib[attrib]; @@ -367,6 +359,69 @@ _mesa_update_vao_client_arrays(struct gl_context *ctx, } +bool +_mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao) +{ + /* Walk those enabled arrays that have the default vbo attached */ + GLbitfield64 mask = vao->_Enabled & ~vao->VertexAttribBufferMask; + + while (mask) { + /* Do not use u_bit_scan64 as we can walk multiple + * attrib arrays at once + */ + const int i = ffsll(mask) - 1; + const struct gl_vertex_attrib_array *attrib_array = + &vao->VertexAttrib[i]; + const struct gl_vertex_buffer_binding *buffer_binding = + &vao->VertexBinding[attrib_array->VertexBinding]; + + /* Only enabled arrays shall appear in the _Enabled bitmask */ + assert(attrib_array->Enabled); + /* We have already masked out vao->VertexAttribBufferMask */ + assert(!_mesa_is_bufferobj(buffer_binding->BufferObj)); + + /* Bail out once we find the first non vbo with a non zero stride */ + if (buffer_binding->Stride != 0) + return false; + + /* Note that we cannot use the xor variant since the _BoundArray mask + * may contain array attributes that are bound but not enabled. + */ + mask &= ~buffer_binding->_BoundArrays; + } + + return true; +} + +bool +_mesa_all_buffers_are_unmapped(const struct gl_vertex_array_object *vao) +{ + /* Walk the enabled arrays that have a vbo attached */ + GLbitfield64 mask = vao->_Enabled & vao->VertexAttribBufferMask; + + while (mask) { + const int i = ffsll(mask) - 1; + const struct gl_vertex_attrib_array *attrib_array = + &vao->VertexAttrib[i]; + const struct gl_vertex_buffer_binding *buffer_binding = + &vao->VertexBinding[attrib_array->VertexBinding]; + + /* Only enabled arrays shall appear in the _Enabled bitmask */ + assert(attrib_array->Enabled); + /* We have already masked with vao->VertexAttribBufferMask */ + assert(_mesa_is_bufferobj(buffer_binding->BufferObj)); + + /* Bail out once we find the first disallowed mapping */ + if (_mesa_check_disallowed_mapping(buffer_binding->BufferObj)) + return false; + + /* We have handled everything that is bound to this buffer_binding. */ + mask &= ~buffer_binding->_BoundArrays; + } + + return true; +} + /**********************************************************************/ /* API Functions */ /**********************************************************************/ @@ -408,7 +463,7 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired) } /* For APPLE version, generate a new array object now */ - newObj = (*ctx->Driver.NewArrayObject)(ctx, id); + newObj = _mesa_new_vao(ctx, id); if (!newObj) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindVertexArrayAPPLE"); return; @@ -446,10 +501,6 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired) ctx->NewState |= _NEW_ARRAY; _mesa_reference_vao(ctx, &ctx->Array.VAO, newObj); - - /* Pass BindVertexArray call to device driver */ - if (ctx->Driver.BindArrayObject && newObj) - ctx->Driver.BindArrayObject(ctx, newObj); } @@ -565,7 +616,7 @@ gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays, struct gl_vertex_array_object *obj; GLuint name = first + i; - obj = (*ctx->Driver.NewArrayObject)( ctx, name ); + obj = _mesa_new_vao(ctx, name); if (!obj) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); return;