summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorZack Rusin <zackr@vmware.com>2010-03-31 22:16:09 -0400
committerZack Rusin <zackr@vmware.com>2010-03-31 22:16:09 -0400
commitb6d052e4fd83d923776320cf5fef66abcd4bf3d0 (patch)
treef68676e2c833965424ea82ef466ce83f8be25310 /src/mesa/main
parentae5487d4276007e466b6a7c783d6fb740f9539c5 (diff)
parent2fb655d1dbb3f8425aeff1597271262661ef206b (diff)
Merge remote branch 'origin/master' into gallium_draw_llvm
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/bufferobj.c7
-rw-r--r--src/mesa/main/config.h5
-rw-r--r--src/mesa/main/context.c8
-rw-r--r--src/mesa/main/enable.c16
-rw-r--r--src/mesa/main/extensions.c4
-rw-r--r--src/mesa/main/get.c152
-rw-r--r--src/mesa/main/get_gen.py33
-rw-r--r--src/mesa/main/mfeatures.h1
-rw-r--r--src/mesa/main/mtypes.h43
-rw-r--r--src/mesa/main/queryobj.c130
-rw-r--r--src/mesa/main/texcompress_s3tc.c2
-rw-r--r--src/mesa/main/transformfeedback.c427
-rw-r--r--src/mesa/main/transformfeedback.h71
13 files changed, 827 insertions, 72 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 11bf48622f..235cafcf1e 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -83,6 +83,13 @@ get_buffer_target(GLcontext *ctx, GLenum target)
return &ctx->CopyWriteBuffer;
}
break;
+#if FEATURE_EXT_transform_feedback
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ if (ctx->Extensions.EXT_transform_feedback) {
+ return &ctx->TransformFeedback.CurrentBuffer;
+ }
+ break;
+#endif
default:
return NULL;
}
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 2eac1cc2ed..30b48e4bd0 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -262,6 +262,11 @@
/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */
#define SUPPORTED_ATI_BUMP_UNITS 0xff
+/** For GL_EXT_transform_feedback */
+#define MAX_FEEDBACK_ATTRIBS 32
+
+
+
/**
* \name Mesa-specific parameters
*/
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 521b18e43e..2074b32b25 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -123,6 +123,7 @@
#include "stencil.h"
#include "texcompress_s3tc.h"
#include "texstate.h"
+#include "transformfeedback.h"
#include "mtypes.h"
#include "varray.h"
#include "version.h"
@@ -560,6 +561,11 @@ _mesa_init_constants(GLcontext *ctx)
/* GL_EXT_provoking_vertex */
ctx->Const.QuadsFollowProvokingVertexConvention = GL_TRUE;
+
+ /* GL_EXT_transform_feedback */
+ ctx->Const.MaxTransformFeedbackSeparateAttribs = MAX_FEEDBACK_ATTRIBS;
+ ctx->Const.MaxTransformFeedbackSeparateComponents = 4 * MAX_FEEDBACK_ATTRIBS;
+ ctx->Const.MaxTransformFeedbackInterleavedComponents = 4 * MAX_FEEDBACK_ATTRIBS;
}
@@ -684,6 +690,7 @@ init_attrib_groups(GLcontext *ctx)
_mesa_init_shader_state( ctx );
_mesa_init_stencil( ctx );
_mesa_init_transform( ctx );
+ _mesa_init_transform_feedback( ctx );
_mesa_init_varray( ctx );
_mesa_init_viewport( ctx );
@@ -969,6 +976,7 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_free_sync_data(ctx);
#endif
_mesa_free_varray_data(ctx);
+ _mesa_free_transform_feedback(ctx);
_mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj);
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index f5c88a63e6..f9decc31ab 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -982,6 +982,16 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
ctx->Texture.CubeMapSeamless = state;
break;
+#if FEATURE_EXT_transform_feedback
+ case GL_RASTERIZER_DISCARD:
+ CHECK_EXTENSION(EXT_transform_feedback, cap);
+ if (ctx->TransformFeedback.RasterDiscard != state) {
+ ctx->TransformFeedback.RasterDiscard = state;
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ }
+ break;
+#endif
+
default:
_mesa_error(ctx, GL_INVALID_ENUM,
"%s(0x%x)", state ? "glEnable" : "glDisable", cap);
@@ -1493,6 +1503,12 @@ _mesa_IsEnabled( GLenum cap )
CHECK_EXTENSION(ARB_seamless_cube_map);
return ctx->Texture.CubeMapSeamless;
+#if FEATURE_EXT_transform_feedback
+ case GL_RASTERIZER_DISCARD:
+ CHECK_EXTENSION(EXT_transform_feedback);
+ return ctx->TransformFeedback.RasterDiscard;
+#endif
+
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
return GL_FALSE;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index ca992d1261..f7b0e5abf5 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -146,6 +146,7 @@ static const struct {
{ OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) },
{ OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) },
{ OFF, "GL_EXT_timer_query", F(EXT_timer_query) },
+ { OFF, "GL_EXT_transform_feedback", F(EXT_transform_feedback) },
{ ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
{ OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) },
{ OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
@@ -319,6 +320,9 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
#endif
ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
+#if FEATURE_EXT_transform_feedback
+ ctx->Extensions.EXT_transform_feedback = GL_TRUE;
+#endif
ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
/*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
ctx->Extensions.MESA_pack_invert = GL_TRUE;
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 266fda40ec..eaa6d7f730 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1922,6 +1922,26 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
CHECK_EXT1(ARB_sync, "GetBooleanv");
params[0] = INT64_TO_BOOLEAN(ctx->Const.MaxServerWaitTimeout);
break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+ CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
+ params[0] = INT_TO_BOOLEAN(ctx->TransformFeedback.CurrentBuffer->Name);
+ break;
+ case GL_RASTERIZER_DISCARD:
+ CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
+ params[0] = ctx->TransformFeedback.RasterDiscard;
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
+ CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackInterleavedComponents);
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
+ CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackSeparateAttribs);
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
+ CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackSeparateComponents);
+ break;
case GL_NUM_EXTENSIONS:
params[0] = INT_TO_BOOLEAN(_mesa_get_extension_count(ctx));
break;
@@ -3793,6 +3813,26 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
CHECK_EXT1(ARB_sync, "GetFloatv");
params[0] = (GLfloat)(ctx->Const.MaxServerWaitTimeout);
break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+ CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
+ params[0] = (GLfloat)(ctx->TransformFeedback.CurrentBuffer->Name);
+ break;
+ case GL_RASTERIZER_DISCARD:
+ CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
+ params[0] = BOOLEAN_TO_FLOAT(ctx->TransformFeedback.RasterDiscard);
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
+ CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
+ params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackInterleavedComponents);
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
+ CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
+ params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackSeparateAttribs);
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
+ CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
+ params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackSeparateComponents);
+ break;
case GL_NUM_EXTENSIONS:
params[0] = (GLfloat)(_mesa_get_extension_count(ctx));
break;
@@ -5664,6 +5704,26 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
CHECK_EXT1(ARB_sync, "GetIntegerv");
params[0] = INT64_TO_INT(ctx->Const.MaxServerWaitTimeout);
break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+ CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
+ params[0] = ctx->TransformFeedback.CurrentBuffer->Name;
+ break;
+ case GL_RASTERIZER_DISCARD:
+ CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
+ params[0] = BOOLEAN_TO_INT(ctx->TransformFeedback.RasterDiscard);
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
+ CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
+ params[0] = ctx->Const.MaxTransformFeedbackInterleavedComponents;
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
+ CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
+ params[0] = ctx->Const.MaxTransformFeedbackSeparateAttribs;
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
+ CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
+ params[0] = ctx->Const.MaxTransformFeedbackSeparateComponents;
+ break;
case GL_NUM_EXTENSIONS:
params[0] = _mesa_get_extension_count(ctx);
break;
@@ -7536,6 +7596,26 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
CHECK_EXT1(ARB_sync, "GetInteger64v");
params[0] = ctx->Const.MaxServerWaitTimeout;
break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+ CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
+ params[0] = (GLint64)(ctx->TransformFeedback.CurrentBuffer->Name);
+ break;
+ case GL_RASTERIZER_DISCARD:
+ CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
+ params[0] = BOOLEAN_TO_INT64(ctx->TransformFeedback.RasterDiscard);
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
+ CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
+ params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackInterleavedComponents);
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
+ CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
+ params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackSeparateAttribs);
+ break;
+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
+ CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
+ params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackSeparateComponents);
+ break;
case GL_NUM_EXTENSIONS:
params[0] = (GLint64)(_mesa_get_extension_count(ctx));
break;
@@ -7606,6 +7686,30 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0);
params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0);
break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_START:
+ CHECK_EXT1(EXT_transform_feedback, "GetBooleanIndexedv");
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
+ return;
+ }
+ params[0] = INT64_TO_BOOLEAN(ctx->TransformFeedback.Offset[index]);
+ break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
+ CHECK_EXT1(EXT_transform_feedback, "GetBooleanIndexedv");
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
+ return;
+ }
+ params[0] = INT64_TO_BOOLEAN(ctx->TransformFeedback.Size[index]);
+ break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+ CHECK_EXT1(EXT_transform_feedback, "GetBooleanIndexedv");
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
+ return;
+ }
+ params[0] = INT_TO_BOOLEAN(ctx->TransformFeedback.Buffers[index]->Name);
+ break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanIndexedv(pname=0x%x)", pname);
}
@@ -7640,6 +7744,30 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
params[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0;
params[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0;
break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_START:
+ CHECK_EXT1(EXT_transform_feedback, "GetIntegerIndexedv");
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
+ return;
+ }
+ params[0] = INT64_TO_INT(ctx->TransformFeedback.Offset[index]);
+ break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
+ CHECK_EXT1(EXT_transform_feedback, "GetIntegerIndexedv");
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
+ return;
+ }
+ params[0] = INT64_TO_INT(ctx->TransformFeedback.Size[index]);
+ break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+ CHECK_EXT1(EXT_transform_feedback, "GetIntegerIndexedv");
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
+ return;
+ }
+ params[0] = ctx->TransformFeedback.Buffers[index]->Name;
+ break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerIndexedv(pname=0x%x)", pname);
}
@@ -7675,6 +7803,30 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
params[2] = (GLint64)(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0);
params[3] = (GLint64)(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0);
break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_START:
+ CHECK_EXT1(EXT_transform_feedback, "GetInteger64Indexedv");
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
+ return;
+ }
+ params[0] = ctx->TransformFeedback.Offset[index];
+ break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
+ CHECK_EXT1(EXT_transform_feedback, "GetInteger64Indexedv");
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
+ return;
+ }
+ params[0] = ctx->TransformFeedback.Size[index];
+ break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
+ CHECK_EXT1(EXT_transform_feedback, "GetInteger64Indexedv");
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
+ return;
+ }
+ params[0] = (GLint64)(ctx->TransformFeedback.Buffers[index]->Name);
+ break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64Indexedv(pname=0x%x)", pname);
}
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index cecb86d76a..bfaca1536d 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -1122,6 +1122,23 @@ StateVars = [
( "GL_MAX_SERVER_WAIT_TIMEOUT", GLint64, ["ctx->Const.MaxServerWaitTimeout"], "",
NoState, ["ARB_sync"] ),
+ # GL_EXT_transform_feedback
+ ( "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING", GLint,
+ ["ctx->TransformFeedback.CurrentBuffer->Name"], "",
+ NoState, ["EXT_transform_feedback"] ),
+ ( "GL_RASTERIZER_DISCARD", GLboolean,
+ ["ctx->TransformFeedback.RasterDiscard"], "",
+ NoState, ["EXT_transform_feedback"] ),
+ ( "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS", GLint,
+ ["ctx->Const.MaxTransformFeedbackInterleavedComponents"], "",
+ NoState, ["EXT_transform_feedback"] ),
+ ( "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", GLint,
+ ["ctx->Const.MaxTransformFeedbackSeparateAttribs"], "",
+ NoState, ["EXT_transform_feedback"] ),
+ ( "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS", GLint,
+ ["ctx->Const.MaxTransformFeedbackSeparateComponents"], "",
+ NoState, ["EXT_transform_feedback"] ),
+
# GL3
( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", NoState, NoExt ),
( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", NoState, NoExt ),
@@ -1134,6 +1151,7 @@ StateVars = [
# The tuples are the same as above, with one exception: the "optional"
# code field is instead the max legal index value.
IndexedStateVars = [
+ # GL_EXT_draw_buffers2 / GL3
( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"],
"ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ),
( "GL_COLOR_WRITEMASK", GLint,
@@ -1142,6 +1160,21 @@ IndexedStateVars = [
"ctx->Color.ColorMask[index][BCOMP] ? 1 : 0",
"ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ],
"ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ),
+
+ # GL_EXT_transform_feedback
+ ( "GL_TRANSFORM_FEEDBACK_BUFFER_START", GLint64,
+ ["ctx->TransformFeedback.Offset[index]"],
+ "ctx->Const.MaxTransformFeedbackSeparateAttribs",
+ NoState, ["EXT_transform_feedback"] ),
+ ( "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE", GLint64,
+ ["ctx->TransformFeedback.Size[index]"],
+ "ctx->Const.MaxTransformFeedbackSeparateAttribs",
+ NoState, ["EXT_transform_feedback"] ),
+ ( "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING", GLint,
+ ["ctx->TransformFeedback.Buffers[index]->Name"],
+ "ctx->Const.MaxTransformFeedbackSeparateAttribs",
+ NoState, ["EXT_transform_feedback"] ),
+
# XXX more to come...
]
diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h
index 54edf9e7f0..6ed05da7ac 100644
--- a/src/mesa/main/mfeatures.h
+++ b/src/mesa/main/mfeatures.h
@@ -135,6 +135,7 @@
#define FEATURE_EXT_framebuffer_object 1
#define FEATURE_EXT_pixel_buffer_object 1
#define FEATURE_EXT_texture_sRGB FEATURE_GL
+#define FEATURE_EXT_transform_feedback FEATURE_GL
#define FEATURE_APPLE_object_purgeable FEATURE_GL
#define FEATURE_ATI_fragment_shader FEATURE_GL
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 82e004f348..7657efb077 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1910,6 +1910,11 @@ struct gl_query_state
/** GL_NV_conditional_render */
struct gl_query_object *CondRenderQuery;
+
+ /** GL_EXT_transform_feedback */
+ struct gl_query_object *PrimitivesGenerated;
+ struct gl_query_object *PrimitivesWritten;
+
GLenum CondRenderMode;
};
@@ -1976,6 +1981,13 @@ struct gl_shader_program
/** User-defined attribute bindings (glBindAttribLocation) */
struct gl_program_parameter_list *Attributes;
+ /** Transform feedback varyings */
+ struct {
+ GLenum BufferMode;
+ GLuint NumVarying;
+ GLchar **VaryingNames; /**< Array [NumVarying] of char * */
+ } TransformFeedback;
+
/* post-link info: */
struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
@@ -2017,6 +2029,29 @@ struct gl_shader_state
/**
+ * Context state for transform feedback.
+ */
+struct gl_transform_feedback
+{
+ GLboolean Active; /**< Is transform feedback enabled? */
+ GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
+ /** Start of feedback data in dest buffer */
+ GLintptr Offset[MAX_FEEDBACK_ATTRIBS];
+ /** Max data to put into dest buffer (in bytes) */
+ GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS];
+ GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
+
+ /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
+ struct gl_buffer_object *CurrentBuffer;
+
+ /** The feedback buffers */
+ GLuint BufferNames[MAX_FEEDBACK_ATTRIBS];
+ struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS];
+};
+
+
+
+/**
* State which can be shared by multiple contexts:
*/
struct gl_shared_state
@@ -2388,6 +2423,11 @@ struct gl_constants
/**< OpenGL version 3.x */
GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
+
+ /** GL_EXT_transform_feedback */
+ GLuint MaxTransformFeedbackSeparateAttribs;
+ GLuint MaxTransformFeedbackSeparateComponents;
+ GLuint MaxTransformFeedbackInterleavedComponents;
};
@@ -2489,6 +2529,7 @@ struct gl_extensions
GLboolean EXT_texture_mirror_clamp;
GLboolean EXT_texture_sRGB;
GLboolean EXT_texture_swizzle;
+ GLboolean EXT_transform_feedback;
GLboolean EXT_timer_query;
GLboolean EXT_vertex_array;
GLboolean EXT_vertex_array_bgra;
@@ -2956,6 +2997,8 @@ struct __GLcontextRec
struct gl_query_state Query; /**< occlusion, timer queries */
+ struct gl_transform_feedback TransformFeedback;
+
struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
/*@}*/
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index e14511a388..a907dac836 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -130,6 +130,42 @@ _mesa_init_query_object_functions(struct dd_function_table *driver)
}
+/**
+ * Return pointer to the query object binding point for the given target.
+ * \return NULL if invalid target, else the address of binding point
+ */
+static struct gl_query_object **
+get_query_binding_point(GLcontext *ctx, GLenum target)
+{
+ switch (target) {
+ case GL_SAMPLES_PASSED_ARB:
+ if (ctx->Extensions.ARB_occlusion_query)
+ return &ctx->Query.CurrentOcclusionObject;
+ else
+ return NULL;
+ case GL_TIME_ELAPSED_EXT:
+ if (ctx->Extensions.EXT_timer_query)
+ return &ctx->Query.CurrentTimerObject;
+ else
+ return NULL;
+#if FEATURE_EXT_transform_feedback
+ case GL_PRIMITIVES_GENERATED:
+ if (ctx->Extensions.EXT_transform_feedback)
+ return &ctx->Query.PrimitivesGenerated;
+ else
+ return NULL;
+ case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
+ if (ctx->Extensions.EXT_transform_feedback)
+ return &ctx->Query.PrimitivesWritten;
+ else
+ return NULL;
+#endif
+ default:
+ return NULL;
+ }
+}
+
+
void GLAPIENTRY
_mesa_GenQueriesARB(GLsizei n, GLuint *ids)
{
@@ -214,36 +250,16 @@ _mesa_IsQueryARB(GLuint id)
static void GLAPIENTRY
_mesa_BeginQueryARB(GLenum target, GLuint id)
{
- struct gl_query_object *q;
+ struct gl_query_object *q, **bindpt;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
FLUSH_VERTICES(ctx, _NEW_DEPTH);
- switch (target) {
- case GL_SAMPLES_PASSED_ARB:
- if (!ctx->Extensions.ARB_occlusion_query) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)");
- return;
- }
- if (ctx->Query.CurrentOcclusionObject) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB");
- return;
- }
- break;
- case GL_TIME_ELAPSED_EXT:
- if (!ctx->Extensions.EXT_timer_query) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)");
- return;
- }
- if (ctx->Query.CurrentTimerObject) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB");
- return;
- }
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)");
- return;
+ bindpt = get_query_binding_point(ctx, target);
+ if (!bindpt) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)");
+ return;
}
if (id == 0) {
@@ -275,12 +291,8 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
q->Result = 0;
q->Ready = GL_FALSE;
- if (target == GL_SAMPLES_PASSED_ARB) {
- ctx->Query.CurrentOcclusionObject = q;
- }
- else if (target == GL_TIME_ELAPSED_EXT) {
- ctx->Query.CurrentTimerObject = q;
- }
+ /* XXX should probably refcount query objects */
+ *bindpt = q;
ctx->Driver.BeginQuery(ctx, q);
}
@@ -289,34 +301,22 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
static void GLAPIENTRY
_mesa_EndQueryARB(GLenum target)
{
- struct gl_query_object *q;
+ struct gl_query_object *q, **bindpt;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
FLUSH_VERTICES(ctx, _NEW_DEPTH);
- switch (target) {
- case GL_SAMPLES_PASSED_ARB:
- if (!ctx->Extensions.ARB_occlusion_query) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
- return;
- }
- q = ctx->Query.CurrentOcclusionObject;
- ctx->Query.CurrentOcclusionObject = NULL;
- break;
- case GL_TIME_ELAPSED_EXT:
- if (!ctx->Extensions.EXT_timer_query) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
- return;
- }
- q = ctx->Query.CurrentTimerObject;
- ctx->Query.CurrentTimerObject = NULL;
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
- return;
+ bindpt = get_query_binding_point(ctx, target);
+ if (!bindpt) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
+ return;
}
+ /* XXX should probably refcount query objects */
+ q = *bindpt;
+ *bindpt = NULL;
+
if (!q || !q->Active) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glEndQueryARB(no matching glBeginQueryARB)");
@@ -331,30 +331,18 @@ _mesa_EndQueryARB(GLenum target)
void GLAPIENTRY
_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params)
{
- struct gl_query_object *q;
+ struct gl_query_object *q, **bindpt;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- switch (target) {
- case GL_SAMPLES_PASSED_ARB:
- if (!ctx->Extensions.ARB_occlusion_query) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
- return;
- }
- q = ctx->Query.CurrentOcclusionObject;
- break;
- case GL_TIME_ELAPSED_EXT:
- if (!ctx->Extensions.EXT_timer_query) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
- return;
- }
- q = ctx->Query.CurrentTimerObject;
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(target)");
- return;
+ bindpt = get_query_binding_point(ctx, target);
+ if (!bindpt) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)");
+ return;
}
+ q = *bindpt;
+
switch (pname) {
case GL_QUERY_COUNTER_BITS_ARB:
*params = 8 * sizeof(q->Result);
diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
index fcd28a4b4e..12c2e903eb 100644
--- a/src/mesa/main/texcompress_s3tc.c
+++ b/src/mesa/main/texcompress_s3tc.c
@@ -48,7 +48,7 @@
#if FEATURE_texture_s3tc
-#ifdef __MINGW32__
+#if defined(_WIN32) || defined(WIN32)
#define DXTN_LIBNAME "dxtn.dll"
#define RTLD_LAZY 0
#define RTLD_GLOBAL 0
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
new file mode 100644
index 0000000000..3490110bae
--- /dev/null
+++ b/src/mesa/main/transformfeedback.c
@@ -0,0 +1,427 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2010 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * Vertex transform feedback support.
+ *
+ * Authors:
+ * Brian Paul
+ */
+
+
+#include "buffers.h"
+#include "bufferobj.h"
+#include "context.h"
+#include "enums.h"
+#include "transformfeedback.h"
+
+#include "shader/prog_parameter.h"
+#include "shader/shader_api.h"
+
+
+/**
+ * Check if the given primitive mode (as in glBegin(mode)) is compatible
+ * with the current transform feedback mode (if it's enabled).
+ * This is to be called from glBegin(), glDrawArrays(), glDrawElements(), etc.
+ *
+ * \return GL_TRUE if the mode is OK, GL_FALSE otherwise.
+ */
+GLboolean
+_mesa_validate_primitive_mode(GLcontext *ctx, GLenum mode)
+{
+ if (ctx->TransformFeedback.Active) {
+ switch (mode) {
+ case GL_POINTS:
+ return ctx->TransformFeedback.Mode == GL_POINTS;
+ case GL_LINES:
+ case GL_LINE_STRIP:
+ case GL_LINE_LOOP:
+ return ctx->TransformFeedback.Mode == GL_LINES;
+ default:
+ return ctx->TransformFeedback.Mode == GL_TRIANGLES;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Check that all the buffer objects currently bound for transform
+ * feedback actually exist. Raise a GL_INVALID_OPERATION error if
+ * any buffers are missing.
+ * \return GL_TRUE for success, GL_FALSE if error
+ */
+GLboolean
+_mesa_validate_transform_feedback_buffers(GLcontext *ctx)
+{
+
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Per-context init for transform feedback.
+ */
+void
+_mesa_init_transform_feedback(GLcontext *ctx)
+{
+ _mesa_reference_buffer_object(ctx,
+ &ctx->TransformFeedback.CurrentBuffer,
+ ctx->Shared->NullBufferObj);
+}
+
+
+/**
+ * Per-context free/clean-up for transform feedback.
+ */
+void
+_mesa_free_transform_feedback(GLcontext *ctx)
+{
+ _mesa_reference_buffer_object(ctx,
+ &ctx->TransformFeedback.CurrentBuffer,
+ NULL);
+}
+
+
+void GLAPIENTRY
+_mesa_BeginTransformFeedback(GLenum mode)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ switch (mode) {
+ case GL_POINTS:
+ case GL_LINES:
+ case GL_TRIANGLES:
+ /* legal */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBeginTransformFeedback(mode)");
+ return;
+ }
+
+ if (ctx->TransformFeedback.Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBeginTransformFeedback(already active)");
+ return;
+ }
+
+ ctx->TransformFeedback.Active = GL_TRUE;
+ ctx->TransformFeedback.Mode = mode;
+}
+
+
+void GLAPIENTRY
+_mesa_EndTransformFeedback(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->TransformFeedback.Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glEndTransformFeedback(not active)");
+ return;
+ }
+
+ ctx->TransformFeedback.Active = GL_FALSE;
+}
+
+
+/**
+ * Helper used by BindBufferRange() and BindBufferBase().
+ */
+static void
+bind_buffer_range(GLcontext *ctx, GLuint index,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size)
+{
+ /* The general binding point */
+ _mesa_reference_buffer_object(ctx,
+ &ctx->TransformFeedback.CurrentBuffer,
+ bufObj);
+
+ /* The per-attribute binding point */
+ _mesa_reference_buffer_object(ctx,
+ &ctx->TransformFeedback.Buffers[index],
+ bufObj);
+
+ ctx->TransformFeedback.BufferNames[index] = bufObj->Name;
+
+ ctx->TransformFeedback.Offset[index] = offset;
+ ctx->TransformFeedback.Size[index] = size;
+}
+
+
+/**
+ * Specify a buffer object to receive vertex shader results. Plus,
+ * specify the starting offset to place the results, and max size.
+ */
+void GLAPIENTRY
+_mesa_BindBufferRange(GLenum target, GLuint index,
+ GLuint buffer, GLintptr offset, GLsizeiptr size)
+{
+ struct gl_buffer_object *bufObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (target != GL_TRANSFORM_FEEDBACK_BUFFER) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)");
+ return;
+ }
+
+ if (ctx->TransformFeedback.Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindBufferRange(transform feedback active)");
+ return;
+ }
+
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d)", index);
+ return;
+ }
+
+ if ((size <= 0) || (size & 0x3)) {
+ /* must be positive and multiple of four */
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size%d)", size);
+ return;
+ }
+
+ if (offset & 0x3) {
+ /* must be multiple of four */
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glBindBufferRange(offset=%d)", offset);
+ return;
+ }
+
+ bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+ if (!bufObj) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindBufferRange(invalid buffer=%u)", buffer);
+ return;
+ }
+
+ if (offset + size >= bufObj->Size) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glBindBufferRange(offset + size > buffer size)", size);
+ return;
+ }
+
+ bind_buffer_range(ctx, index, bufObj, offset, size);
+}
+
+
+/**
+ * Specify a buffer object to receive vertex shader results.
+ * As above, but start at offset = 0.
+ */
+void GLAPIENTRY
+_mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer)
+{
+ struct gl_buffer_object *bufObj;
+ GET_CURRENT_CONTEXT(ctx);
+ GLsizeiptr size;
+
+ if (target != GL_TRANSFORM_FEEDBACK_BUFFER) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferBase(target)");
+ return;
+ }
+
+ if (ctx->TransformFeedback.Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindBufferRange(transform feedback active)");
+ return;
+ }
+
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index);
+ return;
+ }
+
+ bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+ if (!bufObj) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindBufferBase(invalid buffer=%u)", buffer);
+ return;
+ }
+
+ /* default size is the buffer size rounded down to nearest
+ * multiple of four.
+ */
+ size = bufObj->Size & ~0x3;
+
+ bind_buffer_range(ctx, index, bufObj, 0, size);
+}
+
+
+/**
+ * Specify a buffer object to receive vertex shader results, plus the
+ * offset in the buffer to start placing results.
+ * This function is part of GL_EXT_transform_feedback, but not GL3.
+ */
+void GLAPIENTRY
+_mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
+ GLintptr offset)
+{
+ struct gl_buffer_object *bufObj;
+ GET_CURRENT_CONTEXT(ctx);
+ GLsizeiptr size;
+
+ if (target != GL_TRANSFORM_FEEDBACK_BUFFER) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferOffsetEXT(target)");
+ return;
+ }
+
+ if (ctx->TransformFeedback.Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindBufferRange(transform feedback active)");
+ return;
+ }
+
+ if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glBindBufferOffsetEXT(index=%d)", index);
+ return;
+ }
+
+ bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+ if (!bufObj) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindBufferOffsetEXT(invalid buffer=%u)", buffer);
+ return;
+ }
+
+ /* default size is the buffer size rounded down to nearest
+ * multiple of four.
+ */
+ size = (bufObj->Size - offset) & ~0x3;
+
+ bind_buffer_range(ctx, index, bufObj, offset, size);
+}
+
+
+/**
+ * This function specifies the vertex shader outputs to be written
+ * to the feedback buffer(s), and in what order.
+ */
+void GLAPIENTRY
+_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
+ const GLchar **varyings, GLenum bufferMode)
+{
+ struct gl_shader_program *shProg;
+ GLuint i;
+ GET_CURRENT_CONTEXT(ctx);
+
+ switch (bufferMode) {
+ case GL_INTERLEAVED_ATTRIBS:
+ break;
+ case GL_SEPARATE_ATTRIBS:
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTransformFeedbackVaryings(bufferMode)");
+ return;
+ }
+
+ if (count < 0 || count > ctx->Const.MaxTransformFeedbackSeparateAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTransformFeedbackVaryings(count=%d)", count);
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program(ctx, program);
+ if (!shProg) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTransformFeedbackVaryings(program=%u)", program);
+ return;
+ }
+
+ /* free existing varyings, if any */
+ for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) {
+ free(shProg->TransformFeedback.VaryingNames[i]);
+ }
+ free(shProg->TransformFeedback.VaryingNames);
+
+ /* allocate new memory for varying names */
+ shProg->TransformFeedback.VaryingNames =
+ (GLchar **) malloc(count * sizeof(GLchar *));
+
+ if (!shProg->TransformFeedback.VaryingNames) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTransformFeedbackVaryings()");
+ return;
+ }
+
+ /* Save the new names and the count */
+ for (i = 0; i < (GLuint) count; i++) {
+ shProg->TransformFeedback.VaryingNames[i] = _mesa_strdup(varyings[i]);
+ }
+ shProg->TransformFeedback.NumVarying = count;
+
+ shProg->TransformFeedback.BufferMode = bufferMode;
+
+ /* The varyings won't be used until shader link time */
+}
+
+
+/**
+ * Get info about the vertex shader's outputs which are to be written
+ * to the feedback buffer(s).
+ */
+void GLAPIENTRY
+_mesa_GetTransformFeedbackVarying(GLuint program, GLuint index,
+ GLsizei bufSize, GLsizei *length,
+ GLsizei *size, GLenum *type, GLchar *name)
+{
+ const struct gl_shader_program *shProg;
+ const GLchar *varyingName;
+ GLint v;
+ GET_CURRENT_CONTEXT(ctx);
+
+ shProg = _mesa_lookup_shader_program(ctx, program);
+ if (!shProg) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetTransformFeedbackVaryings(program=%u)", program);
+ return;
+ }
+
+ if (index >= shProg->TransformFeedback.NumVarying) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetTransformFeedbackVaryings(index=%u)", index);
+ return;
+ }
+
+ varyingName = shProg->TransformFeedback.VaryingNames[index];
+
+ v = _mesa_lookup_parameter_index(shProg->Varying, -1, varyingName);
+ if (v >= 0) {
+ struct gl_program_parameter *param = &shProg->Varying->Parameters[v];
+
+ /* return the varying's name and length */
+ _mesa_copy_string(name, bufSize, length, varyingName);
+
+ /* return the datatype and value's size (in datatype units) */
+ if (type)
+ *type = param->Type;
+ if (size)
+ *size = param->Size;
+ }
+}
+
diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h
new file mode 100644
index 0000000000..e89cc41473
--- /dev/null
+++ b/src/mesa/main/transformfeedback.h
@@ -0,0 +1,71 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2010 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef TRANSFORM_FEEDBACK_H
+#define TRANSFORM_FEEDBACK_H
+
+#include "glheader.h"
+
+
+extern GLboolean
+_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 GLAPIENTRY
+_mesa_BeginTransformFeedback(GLenum mode);
+
+extern void GLAPIENTRY
+_mesa_EndTransformFeedback(void);
+
+extern void GLAPIENTRY
+_mesa_BindBufferRange(GLenum target, GLuint index,
+ GLuint buffer, GLintptr offset, GLsizeiptr size);
+
+extern void GLAPIENTRY
+_mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer);
+
+extern void GLAPIENTRY
+_mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
+ GLintptr offset);
+
+extern void GLAPIENTRY
+_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
+ const GLchar **varyings, GLenum bufferMode);
+
+extern void GLAPIENTRY
+_mesa_GetTransformFeedbackVarying(GLuint program, GLuint index,
+ GLsizei bufSize, GLsizei *length,
+ GLsizei *size, GLenum *type, GLchar *name);
+
+
+#endif /* TRANSFORM_FEEDBACK_H */