summaryrefslogtreecommitdiff
path: root/src/mesa/main/arrayobj.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/arrayobj.c')
-rw-r--r--src/mesa/main/arrayobj.c137
1 files changed, 19 insertions, 118 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 1537178a1e4..e96aaabc91e 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -40,7 +40,7 @@
*/
-#include "glheader.h"
+#include "util/glheader.h"
#include "hash.h"
#include "image.h"
@@ -56,7 +56,7 @@
#include "util/u_atomic.h"
#include "util/u_math.h"
#include "util/u_memory.h"
-
+#include "api_exec_decl.h"
const GLubyte
_mesa_vao_attribute_map[ATTRIBUTE_MAP_MODE_MAX][VERT_ATTRIB_MAX] =
@@ -206,7 +206,7 @@ _mesa_lookup_vao(struct gl_context *ctx, GLuint id)
* the name of the vertex array object."
*/
if (id == 0) {
- if (ctx->API == API_OPENGL_COMPAT)
+ if (_mesa_is_desktop_gl_compat(ctx))
return ctx->Array.DefaultVAO;
return NULL;
@@ -218,7 +218,7 @@ _mesa_lookup_vao(struct gl_context *ctx, GLuint id)
vao = ctx->Array.LastLookedUpVAO;
} else {
vao = (struct gl_vertex_array_object *)
- _mesa_HashLookupLocked(ctx->Array.Objects, id);
+ _mesa_HashLookupLocked(&ctx->Array.Objects, id);
_mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, vao);
}
@@ -250,7 +250,7 @@ _mesa_lookup_vao_err(struct gl_context *ctx, GLuint id,
* the name of the vertex array object."
*/
if (id == 0) {
- if (is_ext_dsa || ctx->API == API_OPENGL_CORE) {
+ if (is_ext_dsa || _mesa_is_desktop_gl_core(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(zero is not valid vaobj name%s)",
caller,
@@ -267,7 +267,7 @@ _mesa_lookup_vao_err(struct gl_context *ctx, GLuint id,
vao = ctx->Array.LastLookedUpVAO;
} else {
vao = (struct gl_vertex_array_object *)
- _mesa_HashLookupLocked(ctx->Array.Objects, id);
+ _mesa_HashLookupLocked(&ctx->Array.Objects, id);
/* The ARB_direct_state_access specification says:
*
@@ -515,10 +515,12 @@ compute_vbo_offset_range(const struct gl_vertex_array_object *vao,
*/
void
_mesa_update_vao_derived_arrays(struct gl_context *ctx,
- struct gl_vertex_array_object *vao)
+ struct gl_vertex_array_object *vao,
+ bool display_list)
{
+ assert(display_list || !ctx->Const.UseVAOFastPath);
/* Make sure we do not run into problems with shared objects */
- assert(!vao->SharedAndImmutable || vao->NewArrays == 0);
+ assert(!vao->SharedAndImmutable);
/* Limit used for common binding scanning below. */
const GLsizeiptr MaxRelativeOffset =
@@ -541,22 +543,6 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx,
const GLbitfield enabled = vao->Enabled;
/* VBO array bits. */
const GLbitfield vbos = vao->VertexAttribBufferMask;
- const GLbitfield divisor_is_nonzero = vao->NonZeroDivisorMask;
-
- /* Compute and store effectively enabled and mapped vbo arrays */
- vao->_EffEnabledVBO = _mesa_vao_enable_to_vp_inputs(mode, enabled & vbos);
- vao->_EffEnabledNonZeroDivisor =
- _mesa_vao_enable_to_vp_inputs(mode, enabled & divisor_is_nonzero);
-
- /* Fast path when the VAO is updated too often. */
- if (vao->IsDynamic)
- return;
-
- /* More than 4 updates turn the VAO to dynamic. */
- if (ctx->Const.AllowDynamicVAOFastPath && ++vao->NumUpdates > 4) {
- vao->IsDynamic = true;
- return;
- }
/* Walk those enabled arrays that have a real vbo attached */
GLbitfield mask = enabled;
@@ -805,76 +791,6 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx,
}
-void
-_mesa_set_vao_immutable(struct gl_context *ctx,
- struct gl_vertex_array_object *vao)
-{
- _mesa_update_vao_derived_arrays(ctx, vao);
- vao->NewArrays = 0;
- vao->SharedAndImmutable = true;
-}
-
-
-bool
-_mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao)
-{
- /* Walk those enabled arrays that have the default vbo attached */
- GLbitfield 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 = ffs(mask) - 1;
- const struct gl_array_attributes *attrib_array =
- &vao->VertexAttrib[i];
- const struct gl_vertex_buffer_binding *buffer_binding =
- &vao->BufferBinding[attrib_array->BufferBindingIndex];
-
- /* We have already masked out vao->VertexAttribBufferMask */
- assert(!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 */
- GLbitfield mask = vao->Enabled & vao->VertexAttribBufferMask;
-
- while (mask) {
- const int i = ffs(mask) - 1;
- const struct gl_array_attributes *attrib_array =
- &vao->VertexAttrib[i];
- const struct gl_vertex_buffer_binding *buffer_binding =
- &vao->BufferBinding[attrib_array->BufferBindingIndex];
-
- /* We have already masked with vao->VertexAttribBufferMask */
- assert(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;
-}
-
-
/**
* Map buffer objects used in attribute arrays.
*/
@@ -895,7 +811,7 @@ _mesa_vao_map_arrays(struct gl_context *ctx, struct gl_vertex_array_object *vao,
if (_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
continue;
- ctx->Driver.MapBufferRange(ctx, 0, bo->Size, access, bo, MAP_INTERNAL);
+ _mesa_bufferobj_map_range(ctx, 0, bo->Size, access, bo, MAP_INTERNAL);
}
}
@@ -911,7 +827,7 @@ _mesa_vao_map(struct gl_context *ctx, struct gl_vertex_array_object *vao,
/* map the index buffer, if there is one, and not already mapped */
if (bo && !_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
- ctx->Driver.MapBufferRange(ctx, 0, bo->Size, access, bo, MAP_INTERNAL);
+ _mesa_bufferobj_map_range(ctx, 0, bo->Size, access, bo, MAP_INTERNAL);
_mesa_vao_map_arrays(ctx, vao, access);
}
@@ -937,7 +853,7 @@ _mesa_vao_unmap_arrays(struct gl_context *ctx,
if (!_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
continue;
- ctx->Driver.UnmapBuffer(ctx, bo, MAP_INTERNAL);
+ _mesa_bufferobj_unmap(ctx, bo, MAP_INTERNAL);
}
}
@@ -952,7 +868,7 @@ _mesa_vao_unmap(struct gl_context *ctx, struct gl_vertex_array_object *vao)
/* unmap the index buffer, if there is one, and still mapped */
if (bo && _mesa_bufferobj_mapped(bo, MAP_INTERNAL))
- ctx->Driver.UnmapBuffer(ctx, bo, MAP_INTERNAL);
+ _mesa_bufferobj_unmap(ctx, bo, MAP_INTERNAL);
_mesa_vao_unmap_arrays(ctx, vao);
}
@@ -998,24 +914,13 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, bool no_error)
newObj->EverBound = GL_TRUE;
}
- /* The _DrawArrays pointer is pointing at the VAO being unbound and
- * that VAO may be in the process of being deleted. If it's not going
- * to be deleted, this will have no effect, because the pointer needs
- * to be updated by the VBO module anyway.
- *
- * Before the VBO module can update the pointer, we have to set it
- * to NULL for drivers not to set up arrays which are not bound,
- * or to prevent a crash if the VAO being unbound is going to be
- * deleted.
- */
- _mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
-
_mesa_reference_vao(ctx, &ctx->Array.VAO, newObj);
+ _mesa_set_draw_vao(ctx, newObj);
/* Update the valid-to-render state if binding on unbinding default VAO
* if drawing with the default VAO is invalid.
*/
- if (ctx->API == API_OPENGL_CORE &&
+ if (_mesa_is_desktop_gl_core(ctx) &&
(oldObj == ctx->Array.DefaultVAO) != (newObj == ctx->Array.DefaultVAO))
_mesa_update_valid_to_render_state(ctx);
}
@@ -1066,12 +971,10 @@ delete_vertex_arrays(struct gl_context *ctx, GLsizei n, const GLuint *ids)
_mesa_BindVertexArray_no_error(0);
/* The ID is immediately freed for re-use */
- _mesa_HashRemoveLocked(ctx->Array.Objects, obj->Name);
+ _mesa_HashRemoveLocked(&ctx->Array.Objects, obj->Name);
if (ctx->Array.LastLookedUpVAO == obj)
_mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, NULL);
- if (ctx->Array._DrawVAO == obj)
- _mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
/* Unreference the array object.
* If refcount hits zero, the object will be deleted.
@@ -1123,7 +1026,7 @@ gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays,
if (!arrays)
return;
- _mesa_HashFindFreeKeys(ctx->Array.Objects, arrays, n);
+ _mesa_HashFindFreeKeys(&ctx->Array.Objects, arrays, n);
/* For the sake of simplicity we create the array objects in both
* the Gen* and Create* cases. The only difference is the value of
@@ -1138,7 +1041,7 @@ gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays,
return;
}
obj->EverBound = create;
- _mesa_HashInsertLocked(ctx->Array.Objects, obj->Name, obj, true);
+ _mesa_HashInsertLocked(&ctx->Array.Objects, obj->Name, obj);
}
}
@@ -1260,8 +1163,6 @@ vertex_array_element_buffer(struct gl_context *ctx, GLuint vaobj, GLuint buffer,
if (!bufObj)
return;
-
- bufObj->UsageHistory |= USAGE_ELEMENT_ARRAY_BUFFER;
} else {
bufObj = NULL;
}