*
**************************************************************************/
+#include <stdio.h>
#include "main/glheader.h"
#include "main/context.h"
#include "main/state.h"
#include "main/enums.h"
#include "main/macros.h"
#include "main/transformfeedback.h"
+#include "main/sse_minmax.h"
+#include "x86/common_x86_asm.h"
#include "vbo_context.h"
}
}
else {
- for (i = 0; i < count; i++) {
- if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
- if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
+#if defined(USE_SSE41)
+ if (cpu_has_sse4_1) {
+ _mesa_uint_array_min_max(ui_indices, &min_ui, &max_ui, count);
}
+ else
+#endif
+ for (i = 0; i < count; i++) {
+ if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
+ if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
+ }
}
*min_index = min_ui;
*max_index = max_ui;
break;
}
default:
- assert(0);
- break;
+ unreachable("not reached");
}
if (_mesa_is_bufferobj(ib->obj)) {
{
struct gl_vertex_array_object *vao = ctx->Array.VAO;
const void *elemMap;
- GLint i, k;
+ GLint i;
+ GLuint k;
if (_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj)) {
elemMap = ctx->Driver.MapBufferRange(ctx, 0,
}
/* check element j of each enabled array */
- for (k = 0; k < Elements(vao->_VertexAttrib); k++) {
+ for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) {
check_array_data(ctx, &vao->_VertexAttrib[k], k, j);
}
}
MAP_INTERNAL);
}
- for (k = 0; k < Elements(vao->_VertexAttrib); k++) {
+ for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) {
unmap_array_buffer(ctx, &vao->_VertexAttrib[k]);
}
}
}
}
-
-/**
- * Handle a draw case that potentially has primitive restart enabled.
- *
- * If primitive restart is enabled, and PrimitiveRestartInSoftware is
- * set, then vbo_sw_primitive_restart is used to handle the primitive
- * restart case in software.
- */
-static void
-vbo_handle_primitive_restart(struct gl_context *ctx,
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLboolean index_bounds_valid,
- GLuint min_index,
- GLuint max_index)
-{
- struct vbo_context *vbo = vbo_context(ctx);
-
- if (ctx->Const.PrimitiveRestartInSoftware &&
- ctx->Array._PrimitiveRestart &&
- (ib != NULL)) {
- /* Handle primitive restart in software */
- vbo_sw_primitive_restart(ctx, prim, nr_prims, ib, NULL);
- } else {
- /* Call driver directly for draw_prims */
- vbo->draw_prims(ctx, prim, nr_prims, ib,
- index_bounds_valid, min_index, max_index, NULL, NULL);
- }
-}
-
-
/**
* Helper function called by the other DrawArrays() functions below.
* This is where we handle primitive restart for drawing non-indexed
prim[0].is_indirect = 0;
/* Implement the primitive restart index */
- if (ctx->Array.PrimitiveRestart && ctx->Array.RestartIndex < count) {
+ if (ctx->Array.PrimitiveRestart && !ctx->Array.PrimitiveRestartFixedIndex &&
+ ctx->Array.RestartIndex < count) {
GLuint primCount = 0;
if (ctx->Array.RestartIndex == start) {
_mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n",
_mesa_lookup_enum_by_nr(mode), start, count);
- if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
+ if (!_mesa_validate_DrawArrays(ctx, mode, count))
return;
if (0)
*/
check_buffers_are_unmapped(exec->array.inputs);
- vbo_handle_primitive_restart(ctx, prim, 1, &ib,
- index_bounds_valid, start, end);
+ vbo->draw_prims(ctx, prim, 1, &ib,
+ index_bounds_valid, start, end, NULL, NULL);
if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
_mesa_flush(ctx);
{
static GLuint warnCount = 0;
GLboolean index_bounds_valid = GL_TRUE;
- GLuint max_element;
+
+ /* This is only useful to catch invalid values in the "end" parameter
+ * like ~0.
+ */
+ GLuint max_element = 2 * 1000 * 1000 * 1000; /* just a big number */
+
GET_CURRENT_CONTEXT(ctx);
if (MESA_VERBOSE & VERBOSE_DRAW)
_mesa_lookup_enum_by_nr(mode), start, end, count,
_mesa_lookup_enum_by_nr(type), indices, basevertex);
- if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count,
- type, indices, basevertex ))
+ if (!_mesa_validate_DrawRangeElements(ctx, mode, start, end, count,
+ type, indices))
return;
- if (ctx->Const.CheckArrayBounds) {
- /* _MaxElement was computed, so we can use it.
- * This path is used for drivers which need strict bounds checking.
- */
- max_element = ctx->Array.VAO->_MaxElement;
- }
- else {
- /* Generally, hardware drivers don't need to know the buffer bounds
- * if all vertex attributes are in VBOs.
- * However, if none of vertex attributes are in VBOs, _MaxElement
- * is always set to some random big number anyway, so bounds checking
- * is mostly useless.
- *
- * This is only useful to catch invalid values in the "end" parameter
- * like ~0.
- */
- max_element = 2 * 1000 * 1000 * 1000; /* just a big number */
- }
-
if ((int) end + basevertex < 0 ||
start + basevertex >= max_element) {
/* The application requested we draw using a range of indices that's
_mesa_lookup_enum_by_nr(mode), count,
_mesa_lookup_enum_by_nr(type), indices);
- if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 ))
+ if (!_mesa_validate_DrawElements(ctx, mode, count, type, indices))
return;
vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
_mesa_lookup_enum_by_nr(mode), count,
_mesa_lookup_enum_by_nr(type), indices, basevertex);
- if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices,
- basevertex ))
+ if (!_mesa_validate_DrawElements(ctx, mode, count, type, indices))
return;
vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
_mesa_lookup_enum_by_nr(type), indices, numInstances);
if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
- numInstances, 0))
+ numInstances))
return;
vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
numInstances, basevertex);
if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
- numInstances, basevertex))
+ numInstances))
return;
vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
numInstances, baseInstance);
if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
- numInstances, 0))
+ numInstances))
return;
vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
numInstances, basevertex, baseInstance);
if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
- numInstances, basevertex))
+ numInstances))
return;
vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
}
check_buffers_are_unmapped(exec->array.inputs);
- vbo_handle_primitive_restart(ctx, prim, primcount, &ib,
- GL_FALSE, ~0, ~0);
+ vbo->draw_prims(ctx, prim, primcount, &ib,
+ false, ~0, ~0, NULL, NULL);
} else {
/* render one prim at a time */
for (i = 0; i < primcount; i++) {
prim[0].basevertex = 0;
check_buffers_are_unmapped(exec->array.inputs);
- vbo_handle_primitive_restart(ctx, prim, 1, &ib,
- GL_FALSE, ~0, ~0);
+ vbo->draw_prims(ctx, prim, 1, &ib,
+ false, ~0, ~0, NULL, NULL);
}
}
GET_CURRENT_CONTEXT(ctx);
if (!_mesa_validate_MultiDrawElements(ctx, mode, count, type, indices,
- primcount, NULL))
+ primcount))
return;
vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount,
GET_CURRENT_CONTEXT(ctx);
if (!_mesa_validate_MultiDrawElements(ctx, mode, count, type, indices,
- primcount, basevertex))
+ primcount))
return;
vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount,
if (ctx->Driver.GetTransformFeedbackVertexCount &&
(ctx->Const.AlwaysUseGetTransformFeedbackVertexCount ||
- (ctx->Const.PrimitiveRestartInSoftware &&
- ctx->Array._PrimitiveRestart) ||
!vbo_all_varyings_in_vbos(exec->array.inputs))) {
GLsizei n = ctx->Driver.GetTransformFeedbackVertexCount(ctx, obj, stream);
vbo_draw_arrays(ctx, mode, 0, n, numInstances, 0);