diff options
author | Chia-I Wu <[email protected]> | 2010-07-06 16:27:20 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2010-07-06 17:03:32 +0800 |
commit | 32a9b2799e5e1254fdf84af8248ea86e234d6dd4 (patch) | |
tree | d512548a6b2b6bfb0cb6f0bd4e428c3c515b8a66 | |
parent | f2aa361f3b58a91780c9358b3f8716f6434074c7 (diff) |
mesa: Always initialize transform feedback state.
Assert ctx->Driver.NewTransformFeedback if the feature is enabled; Use
the default callbacks otherwise. The rest of core mesa expects the
state to be initialized.
-rw-r--r-- | src/mesa/main/transformfeedback.c | 50 | ||||
-rw-r--r-- | src/mesa/main/transformfeedback.h | 22 |
2 files changed, 48 insertions, 24 deletions
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 26a3a4b3d0d..f86f1911d1d 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -134,10 +134,8 @@ _mesa_validate_transform_feedback_buffers(GLcontext *ctx) void _mesa_init_transform_feedback(GLcontext *ctx) { - if (!ctx->Driver.NewTransformFeedback) { - /* this feature/extension may not be supported by the driver */ - return; - } + /* core mesa expects this, even a dummy one, to be available */ + ASSERT(ctx->Driver.NewTransformFeedback); ctx->TransformFeedback.DefaultObject = ctx->Driver.NewTransformFeedback(ctx, 0); @@ -178,10 +176,8 @@ delete_cb(GLuint key, void *data, void *userData) void _mesa_free_transform_feedback(GLcontext *ctx) { - if (!ctx->Driver.NewTransformFeedback) { - /* this feature/extension may not be supported by the driver */ - return; - } + /* core mesa expects this, even a dummy one, to be available */ + ASSERT(ctx->Driver.NewTransformFeedback); _mesa_reference_buffer_object(ctx, &ctx->TransformFeedback.CurrentBuffer, @@ -200,6 +196,40 @@ _mesa_free_transform_feedback(GLcontext *ctx) } +#else /* FEATURE_EXT_transform_feedback */ + +/* forward declarations */ +static struct gl_transform_feedback_object * +new_transform_feedback(GLcontext *ctx, GLuint name); + +static void +delete_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj); + +/* dummy per-context init/clean-up for transform feedback */ +void +_mesa_init_transform_feedback(GLcontext *ctx) +{ + ctx->TransformFeedback.DefaultObject = new_transform_feedback(ctx, 0); + ctx->TransformFeedback.CurrentObject = ctx->TransformFeedback.DefaultObject; + _mesa_reference_buffer_object(ctx, + &ctx->TransformFeedback.CurrentBuffer, + ctx->Shared->NullBufferObj); +} + +void +_mesa_free_transform_feedback(GLcontext *ctx) +{ + _mesa_reference_buffer_object(ctx, + &ctx->TransformFeedback.CurrentBuffer, + NULL); + ctx->TransformFeedback.CurrentObject = NULL; + delete_transform_feedback(ctx, ctx->TransformFeedback.DefaultObject); +} + +#endif /* FEATURE_EXT_transform_feedback */ + + /** Default fallback for ctx->Driver.NewTransformFeedback() */ static struct gl_transform_feedback_object * new_transform_feedback(GLcontext *ctx, GLuint name) @@ -227,6 +257,10 @@ delete_transform_feedback(GLcontext *ctx, free(obj); } + +#if FEATURE_EXT_transform_feedback + + /** Default fallback for ctx->Driver.BeginTransformFeedback() */ static void begin_transform_feedback(GLcontext *ctx, GLenum mode, diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h index b806488abdd..4d38522d6d9 100644 --- a/src/mesa/main/transformfeedback.h +++ b/src/mesa/main/transformfeedback.h @@ -28,6 +28,12 @@ #include "main/mtypes.h" +extern void +_mesa_init_transform_feedback(GLcontext *ctx); + +extern void +_mesa_free_transform_feedback(GLcontext *ctx); + #if FEATURE_EXT_transform_feedback extern GLboolean @@ -36,12 +42,6 @@ _mesa_validate_primitive_mode(GLcontext *ctx, GLenum mode); extern GLboolean _mesa_validate_transform_feedback_buffers(GLcontext *ctx); -extern void -_mesa_init_transform_feedback(GLcontext *ctx); - -extern void -_mesa_free_transform_feedback(GLcontext *ctx); - extern void _mesa_init_transform_feedback_functions(struct dd_function_table *driver); @@ -118,16 +118,6 @@ _mesa_validate_transform_feedback_buffers(GLcontext *ctx) } static INLINE void -_mesa_init_transform_feedback(GLcontext *ctx) -{ -} - -static INLINE void -_mesa_free_transform_feedback(GLcontext *ctx) -{ -} - -static INLINE void _mesa_init_transform_feedback_functions(struct dd_function_table *driver) { } |