summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2012-12-15 14:21:32 -0800
committerPaul Berry <[email protected]>2012-12-18 09:02:53 -0800
commit5b7099c74d7774dc59895536bad53bd1196e398c (patch)
tree5571409df894f68003491baa6f6476161ec898b7 /src/mesa/main
parent1ad516207d2297b14fe26627e5bb599a9f704ac5 (diff)
mesa: Make a function is_transform_feedback_active_and_unpaused.
The rather unweildy logic for determining this condition was repeated in a large number of places. This patch consolidates it to a single inline function. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/api_validate.c20
-rw-r--r--src/mesa/main/shaderapi.c8
-rw-r--r--src/mesa/main/transformfeedback.c5
-rw-r--r--src/mesa/main/transformfeedback.h9
4 files changed, 21 insertions, 21 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 16062820ef9..133fb637060 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -32,6 +32,7 @@
#include "mtypes.h"
#include "enums.h"
#include "vbo/vbo.h"
+#include "transformfeedback.h"
#include <stdbool.h>
@@ -252,8 +253,7 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
* current transform feedback state as given by table X.1.
*
*/
- if (ctx->TransformFeedback.CurrentObject->Active &&
- !ctx->TransformFeedback.CurrentObject->Paused) {
+ if (_mesa_is_xfb_active_and_unpaused(ctx)) {
GLboolean pass = GL_TRUE;
switch (mode) {
@@ -313,8 +313,6 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLint basevertex)
{
- struct gl_transform_feedback_object *xfb_obj
- = ctx->TransformFeedback.CurrentObject;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
FLUSH_CURRENT(ctx, 0);
@@ -325,7 +323,7 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
* DrawElementsInstanced, and DrawRangeElements while transform feedback
* is active and not paused, regardless of mode.
*/
- if (_mesa_is_gles3(ctx) && xfb_obj->Active && !xfb_obj->Paused) {
+ if (_mesa_is_gles3(ctx) && _mesa_is_xfb_active_and_unpaused(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawElements(transform feedback active)");
return GL_FALSE;
@@ -446,8 +444,6 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode,
GLsizei count, GLenum type,
const GLvoid *indices, GLint basevertex)
{
- struct gl_transform_feedback_object *xfb_obj
- = ctx->TransformFeedback.CurrentObject;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
FLUSH_CURRENT(ctx, 0);
@@ -458,7 +454,7 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode,
* DrawElementsInstanced, and DrawRangeElements while transform feedback
* is active and not paused, regardless of mode.
*/
- if (_mesa_is_gles3(ctx) && xfb_obj->Active && !xfb_obj->Paused) {
+ if (_mesa_is_gles3(ctx) && _mesa_is_xfb_active_and_unpaused(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawElements(transform feedback active)");
return GL_FALSE;
@@ -552,7 +548,7 @@ _mesa_validate_DrawArrays(struct gl_context *ctx,
* This is in contrast to the behaviour of desktop GL, where the extra
* primitives are silently dropped from the transform feedback buffer.
*/
- if (_mesa_is_gles3(ctx) && xfb_obj->Active && !xfb_obj->Paused) {
+ if (_mesa_is_gles3(ctx) && _mesa_is_xfb_active_and_unpaused(ctx)) {
size_t prim_count = vbo_count_tessellated_primitives(mode, count, 1);
if (xfb_obj->GlesRemainingPrims < prim_count) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -620,7 +616,7 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi
* This is in contrast to the behaviour of desktop GL, where the extra
* primitives are silently dropped from the transform feedback buffer.
*/
- if (_mesa_is_gles3(ctx) && xfb_obj->Active && !xfb_obj->Paused) {
+ if (_mesa_is_gles3(ctx) && _mesa_is_xfb_active_and_unpaused(ctx)) {
size_t prim_count
= vbo_count_tessellated_primitives(mode, count, numInstances);
if (xfb_obj->GlesRemainingPrims < prim_count) {
@@ -641,8 +637,6 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
const GLvoid *indices, GLsizei numInstances,
GLint basevertex)
{
- struct gl_transform_feedback_object *xfb_obj
- = ctx->TransformFeedback.CurrentObject;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
FLUSH_CURRENT(ctx, 0);
@@ -653,7 +647,7 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
* DrawElementsInstanced, and DrawRangeElements while transform feedback
* is active and not paused, regardless of mode.
*/
- if (_mesa_is_gles3(ctx) && xfb_obj->Active && !xfb_obj->Paused) {
+ if (_mesa_is_gles3(ctx) && _mesa_is_xfb_active_and_unpaused(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawElements(transform feedback active)");
return GL_FALSE;
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 53e9d0486d1..1f0002f6fa6 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -45,6 +45,7 @@
#include "main/mtypes.h"
#include "main/shaderapi.h"
#include "main/shaderobj.h"
+#include "main/transformfeedback.h"
#include "main/uniforms.h"
#include "program/program.h"
#include "program/prog_parameter.h"
@@ -1383,12 +1384,10 @@ _mesa_UseProgram(GLhandleARB program)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_shader_program *shProg;
- struct gl_transform_feedback_object *obj =
- ctx->TransformFeedback.CurrentObject;
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (obj->Active && !obj->Paused) {
+ if (_mesa_is_xfb_active_and_unpaused(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glUseProgram(transform feedback active)");
return;
@@ -1590,8 +1589,7 @@ _mesa_UseShaderProgramEXT(GLenum type, GLuint program)
return;
}
- if (ctx->TransformFeedback.CurrentObject->Active &&
- !ctx->TransformFeedback.CurrentObject->Paused) {
+ if (_mesa_is_xfb_active_and_unpaused(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glUseShaderProgramEXT(transform feedback is active)");
return;
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index 61f2f4f11d0..42f38e0cc4a 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -819,8 +819,7 @@ _mesa_BindTransformFeedback(GLenum target, GLuint name)
return;
}
- if (ctx->TransformFeedback.CurrentObject->Active &&
- !ctx->TransformFeedback.CurrentObject->Paused) {
+ if (_mesa_is_xfb_active_and_unpaused(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBindTransformFeedback(transform is active, or not paused)");
return;
@@ -890,7 +889,7 @@ _mesa_PauseTransformFeedback(void)
obj = ctx->TransformFeedback.CurrentObject;
- if (!obj->Active || obj->Paused) {
+ if (!_mesa_is_xfb_active_and_unpaused(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glPauseTransformFeedback(feedback not active or already paused)");
return;
diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h
index 3c03b7a2413..c128746b3ef 100644
--- a/src/mesa/main/transformfeedback.h
+++ b/src/mesa/main/transformfeedback.h
@@ -25,9 +25,11 @@
#ifndef TRANSFORM_FEEDBACK_H
#define TRANSFORM_FEEDBACK_H
+#include <stdbool.h>
#include "compiler.h"
#include "glheader.h"
#include "mfeatures.h"
+#include "mtypes.h"
struct _glapi_table;
struct dd_function_table;
@@ -111,4 +113,11 @@ _mesa_PauseTransformFeedback(void);
extern void GLAPIENTRY
_mesa_ResumeTransformFeedback(void);
+static inline bool
+_mesa_is_xfb_active_and_unpaused(const struct gl_context *ctx)
+{
+ return ctx->TransformFeedback.CurrentObject->Active &&
+ !ctx->TransformFeedback.CurrentObject->Paused;
+}
+
#endif /* TRANSFORM_FEEDBACK_H */