summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-05-31 12:35:25 +0200
committerSamuel Pitoiset <[email protected]>2017-06-07 11:03:40 +0200
commita11c7e3fb51ff185675220083d4d33c7ee6a58c5 (patch)
tree7fdbf5e66b9e6dc31019497c504d80ffe5db2829 /src/mesa/main
parentf075c2bc0b249efe59a818c89de20de81279e3d9 (diff)
mesa: add vertex_array_vertex_buffers_err() helper
This also adds a 'no_error' parameter to vertex_array_vertex_buffer() to be used in a following patch. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/varray.c108
1 files changed, 61 insertions, 47 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 47528ba2a79..c2c771c173c 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -2117,29 +2117,14 @@ _mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
}
-static void
+static ALWAYS_INLINE void
vertex_array_vertex_buffers(struct gl_context *ctx,
struct gl_vertex_array_object *vao,
GLuint first, GLsizei count, const GLuint *buffers,
const GLintptr *offsets, const GLsizei *strides,
- const char *func)
+ bool no_error, const char *func)
{
- GLuint i;
-
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- /* The ARB_multi_bind spec says:
- *
- * "An INVALID_OPERATION error is generated if <first> + <count>
- * is greater than the value of MAX_VERTEX_ATTRIB_BINDINGS."
- */
- if (first + count > ctx->Const.MaxVertexAttribBindings) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(first=%u + count=%d > the value of "
- "GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)",
- func, first, count, ctx->Const.MaxVertexAttribBindings);
- return;
- }
+ GLint i;
if (!buffers) {
/**
@@ -2184,31 +2169,33 @@ vertex_array_vertex_buffers(struct gl_context *ctx,
for (i = 0; i < count; i++) {
struct gl_buffer_object *vbo;
- /* The ARB_multi_bind spec says:
- *
- * "An INVALID_VALUE error is generated if any value in
- * <offsets> or <strides> is negative (per binding)."
- */
- if (offsets[i] < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(offsets[%u]=%" PRId64 " < 0)",
- func, i, (int64_t) offsets[i]);
- continue;
- }
+ if (!no_error) {
+ /* The ARB_multi_bind spec says:
+ *
+ * "An INVALID_VALUE error is generated if any value in
+ * <offsets> or <strides> is negative (per binding)."
+ */
+ if (offsets[i] < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(offsets[%u]=%" PRId64 " < 0)",
+ func, i, (int64_t) offsets[i]);
+ continue;
+ }
- if (strides[i] < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(strides[%u]=%d < 0)",
- func, i, strides[i]);
- continue;
- }
+ if (strides[i] < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(strides[%u]=%d < 0)",
+ func, i, strides[i]);
+ continue;
+ }
- if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
- strides[i] > ctx->Const.MaxVertexAttribStride) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(strides[%u]=%d > "
- "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, i, strides[i]);
- continue;
+ if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
+ strides[i] > ctx->Const.MaxVertexAttribStride) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(strides[%u]=%d > "
+ "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, i, strides[i]);
+ continue;
+ }
}
if (buffers[i]) {
@@ -2234,6 +2221,33 @@ vertex_array_vertex_buffers(struct gl_context *ctx,
}
+static void
+vertex_array_vertex_buffers_err(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint first, GLsizei count,
+ const GLuint *buffers, const GLintptr *offsets,
+ const GLsizei *strides, const char *func)
+{
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ /* The ARB_multi_bind spec says:
+ *
+ * "An INVALID_OPERATION error is generated if <first> + <count>
+ * is greater than the value of MAX_VERTEX_ATTRIB_BINDINGS."
+ */
+ if (first + count > ctx->Const.MaxVertexAttribBindings) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(first=%u + count=%d > the value of "
+ "GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)",
+ func, first, count, ctx->Const.MaxVertexAttribBindings);
+ return;
+ }
+
+ vertex_array_vertex_buffers(ctx, vao, first, count, buffers, offsets,
+ strides, false, func);
+}
+
+
void GLAPIENTRY
_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
const GLintptr *offsets, const GLsizei *strides)
@@ -2252,9 +2266,9 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
return;
}
- vertex_array_vertex_buffers(ctx, ctx->Array.VAO, first, count,
- buffers, offsets, strides,
- "glBindVertexBuffers");
+ vertex_array_vertex_buffers_err(ctx, ctx->Array.VAO, first, count,
+ buffers, offsets, strides,
+ "glBindVertexBuffers");
}
@@ -2276,9 +2290,9 @@ _mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count,
if (!vao)
return;
- vertex_array_vertex_buffers(ctx, vao, first, count,
- buffers, offsets, strides,
- "glVertexArrayVertexBuffers");
+ vertex_array_vertex_buffers_err(ctx, vao, first, count,
+ buffers, offsets, strides,
+ "glVertexArrayVertexBuffers");
}