summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-05-22 15:47:00 +1000
committerTimothy Arceri <[email protected]>2017-05-30 08:03:32 +1000
commit3eb6d34dfc2c796174be15848f2d4fada2e01063 (patch)
treeb0dfd711cb35c4cc106c278f24daf0f30406d2ea
parent863b19ae213d2c8b147b436b197918d6e6af7a0e (diff)
mesa: convert mesa_bind_buffer_range_transform_feedback() to a validate function
This allows some tidy up and also makes it so we can add KHR_no_error support. Reviewed-by: Iago Toral Quiroga <[email protected]> Tested-by: Dieter Nützel <[email protected]>
-rw-r--r--src/mesa/main/bufferobj.c12
-rw-r--r--src/mesa/main/transformfeedback.c42
-rw-r--r--src/mesa/main/transformfeedback.h12
3 files changed, 35 insertions, 31 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index aa253ef9819..2d3e0f2602c 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -4029,10 +4029,14 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
switch (target) {
case GL_TRANSFORM_FEEDBACK_BUFFER:
- _mesa_bind_buffer_range_transform_feedback(ctx,
- ctx->TransformFeedback.CurrentObject,
- index, bufObj, offset, size,
- false);
+ if (!_mesa_validate_buffer_range_xfb(ctx,
+ ctx->TransformFeedback.CurrentObject,
+ index, bufObj, offset, size,
+ false))
+ return;
+
+ _mesa_bind_buffer_range_xfb(ctx, ctx->TransformFeedback.CurrentObject,
+ index, bufObj, offset, size);
return;
case GL_UNIFORM_BUFFER:
bind_buffer_range_uniform_buffer_err(ctx, index, bufObj, offset, size);
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index c3aa61c2f6e..fdc3152a091 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -541,19 +541,16 @@ bind_buffer_range(struct gl_context *ctx,
/**
- * Specify a buffer object to receive transform feedback results. Plus,
- * specify the starting offset to place the results, and max size.
+ * Validate the buffer object to receive transform feedback results. Plus,
+ * validate the starting offset to place the results, and max size.
* Called from the glBindBufferRange() and glTransformFeedbackBufferRange
* functions.
*/
-void
-_mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx,
- struct gl_transform_feedback_object *obj,
- GLuint index,
- struct gl_buffer_object *bufObj,
- GLintptr offset,
- GLsizeiptr size,
- bool dsa)
+bool
+_mesa_validate_buffer_range_xfb(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj,
+ GLuint index, struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size, bool dsa)
{
const char *gl_methd_name;
if (dsa)
@@ -565,7 +562,7 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx,
if (obj->Active) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(transform feedback active)",
gl_methd_name);
- return;
+ return false;
}
if (index >= ctx->Const.MaxTransformFeedbackBuffers) {
@@ -575,21 +572,21 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx,
*/
_mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%d out of bounds)",
gl_methd_name, index);
- return;
+ return false;
}
if (size & 0x3) {
/* OpenGL 4.5 core profile, 6.7, pdf page 103: multiple of 4 */
_mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d must be a multiple of "
"four)", gl_methd_name, (int) size);
- return;
+ return false;
}
if (offset & 0x3) {
/* OpenGL 4.5 core profile, 6.7, pdf page 103: multiple of 4 */
_mesa_error(ctx, GL_INVALID_VALUE, "%s(offset=%d must be a multiple "
"of four)", gl_methd_name, (int) offset);
- return;
+ return false;
}
if (offset < 0) {
@@ -602,7 +599,7 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx,
_mesa_error(ctx, GL_INVALID_VALUE, "%s(offset=%d must be >= 0)",
gl_methd_name,
(int) offset);
- return;
+ return false;
}
if (size <= 0 && (dsa || bufObj != ctx->Shared->NullBufferObj)) {
@@ -616,10 +613,10 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx,
*/
_mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d must be > 0)",
gl_methd_name, (int) size);
- return;
+ return false;
}
- bind_buffer_range(ctx, obj, index, bufObj, offset, size, dsa);
+ return true;
}
@@ -743,8 +740,13 @@ _mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer,
return;
}
- _mesa_bind_buffer_range_transform_feedback(ctx, obj, index, bufObj, offset,
- size, true);
+ if (!_mesa_validate_buffer_range_xfb(ctx, obj, index, bufObj, offset,
+ size, true))
+ return;
+
+ /* The per-attribute binding point */
+ _mesa_set_transform_feedback_binding(ctx, obj, index, bufObj, offset,
+ size);
}
/**
@@ -798,7 +800,7 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
return;
}
- bind_buffer_range(ctx, obj, index, bufObj, offset, 0, false);
+ _mesa_bind_buffer_range_xfb(ctx, obj, index, bufObj, offset, 0);
}
diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h
index 475f5f14944..cb3bb6754aa 100644
--- a/src/mesa/main/transformfeedback.h
+++ b/src/mesa/main/transformfeedback.h
@@ -63,13 +63,11 @@ _mesa_BeginTransformFeedback(GLenum mode);
extern void GLAPIENTRY
_mesa_EndTransformFeedback(void);
-extern void
-_mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx,
- struct gl_transform_feedback_object *obj,
- GLuint index,
- struct gl_buffer_object *bufObj,
- GLintptr offset,
- GLsizeiptr size, bool dsa);
+extern bool
+_mesa_validate_buffer_range_xfb(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj,
+ GLuint index, struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size, bool dsa);
extern void
_mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx,