diff options
author | Zack Rusin <[email protected]> | 2010-03-31 22:16:09 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2010-03-31 22:16:09 -0400 |
commit | b6d052e4fd83d923776320cf5fef66abcd4bf3d0 (patch) | |
tree | f68676e2c833965424ea82ef466ce83f8be25310 /src/mesa | |
parent | ae5487d4276007e466b6a7c783d6fb740f9539c5 (diff) | |
parent | 2fb655d1dbb3f8425aeff1597271262661ef206b (diff) |
Merge remote branch 'origin/master' into gallium_draw_llvm
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/SConscript | 1 | ||||
-rw-r--r-- | src/mesa/main/bufferobj.c | 7 | ||||
-rw-r--r-- | src/mesa/main/config.h | 5 | ||||
-rw-r--r-- | src/mesa/main/context.c | 8 | ||||
-rw-r--r-- | src/mesa/main/enable.c | 16 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 4 | ||||
-rw-r--r-- | src/mesa/main/get.c | 152 | ||||
-rw-r--r-- | src/mesa/main/get_gen.py | 33 | ||||
-rw-r--r-- | src/mesa/main/mfeatures.h | 1 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 43 | ||||
-rw-r--r-- | src/mesa/main/queryobj.c | 130 | ||||
-rw-r--r-- | src/mesa/main/texcompress_s3tc.c | 2 | ||||
-rw-r--r-- | src/mesa/main/transformfeedback.c | 427 | ||||
-rw-r--r-- | src/mesa/main/transformfeedback.h | 71 | ||||
-rw-r--r-- | src/mesa/shader/shader_api.c | 54 | ||||
-rw-r--r-- | src/mesa/shader/shader_api.h | 6 | ||||
-rw-r--r-- | src/mesa/sources.mak | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_rasterizer.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_fbo.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_readpixels.c | 10 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_extensions.c | 8 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 46 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 6 |
24 files changed, 927 insertions, 124 deletions
diff --git a/src/mesa/SConscript b/src/mesa/SConscript index c85085434e4..5a04dfd68fb 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -103,6 +103,7 @@ if env['platform'] != 'winddk': 'main/texrender.c', 'main/texstate.c', 'main/texstore.c', + 'main/transformfeedback.c', 'main/varray.c', 'main/version.c', 'main/viewport.c', diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 11bf48622fd..235cafcf1ed 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 2eac1cc2ed9..30b48e4bd08 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 521b18e43ed..2074b32b250 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 f5c88a63e6e..f9decc31ab7 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 ca992d12613..f7b0e5abf59 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 266fda40ec5..eaa6d7f7307 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 cecb86d76a1..bfaca1536d1 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 54edf9e7f01..6ed05da7ac8 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 82e004f3486..7657efb0773 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 e14511a3883..a907dac836b 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 fcd28a4b4e5..12c2e903eb5 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 00000000000..3490110baef --- /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 00000000000..e89cc414736 --- /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 */ diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 940fe2d03ce..36fe0a1bb72 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -123,6 +123,14 @@ _mesa_free_shader_program_data(GLcontext *ctx, free(shProg->InfoLog); shProg->InfoLog = NULL; } + + /* Transform feedback varying vars */ + for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { + free(shProg->TransformFeedback.VaryingNames[i]); + } + free(shProg->TransformFeedback.VaryingNames); + shProg->TransformFeedback.VaryingNames = NULL; + shProg->TransformFeedback.NumVarying = 0; } @@ -397,6 +405,25 @@ get_shader_flags(void) /** + * Find the length of the longest transform feedback varying name + * which was specified with glTransformFeedbackVaryings(). + */ +static GLint +longest_feedback_varying_name(const struct gl_shader_program *shProg) +{ + GLuint i; + GLint max = 0; + for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { + GLint len = strlen(shProg->TransformFeedback.VaryingNames[i]); + if (len > max) + max = len; + } + return max; +} + + + +/** * Initialize context's shader state. */ void @@ -437,8 +464,9 @@ _mesa_free_shader_state(GLcontext *ctx) * \param length returns number of chars copied * \param dst the string destination */ -static void -copy_string(GLchar *dst, GLsizei maxLength, GLsizei *length, const GLchar *src) +void +_mesa_copy_string(GLchar *dst, GLsizei maxLength, + GLsizei *length, const GLchar *src) { GLsizei len; for (len = 0; len < maxLength - 1 && src && src[len]; len++) @@ -879,7 +907,8 @@ _mesa_get_active_attrib(GLcontext *ctx, GLuint program, GLuint index, return; } - copy_string(nameOut, maxLength, length, attribs->Parameters[index].Name); + _mesa_copy_string(nameOut, maxLength, length, + attribs->Parameters[index].Name); if (size) *size = attribs->Parameters[index].Size @@ -954,7 +983,7 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index, param = &prog->Parameters->Parameters[progPos]; if (nameOut) { - copy_string(nameOut, maxLength, length, param->Name); + _mesa_copy_string(nameOut, maxLength, length, param->Name); } if (size) { @@ -1063,6 +1092,17 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program, case GL_PROGRAM_BINARY_LENGTH_OES: *params = 0; break; +#if FEATURE_EXT_transform_feedback + case GL_TRANSFORM_FEEDBACK_VARYINGS: + *params = shProg->TransformFeedback.NumVarying; + break; + case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: + *params = longest_feedback_varying_name(shProg) + 1; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: + *params = shProg->TransformFeedback.BufferMode; + break; +#endif default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); return; @@ -1112,7 +1152,7 @@ _mesa_get_program_info_log(GLcontext *ctx, GLuint program, GLsizei bufSize, _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)"); return; } - copy_string(infoLog, bufSize, length, shProg->InfoLog); + _mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog); } @@ -1125,7 +1165,7 @@ _mesa_get_shader_info_log(GLcontext *ctx, GLuint shader, GLsizei bufSize, _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)"); return; } - copy_string(infoLog, bufSize, length, sh->InfoLog); + _mesa_copy_string(infoLog, bufSize, length, sh->InfoLog); } @@ -1141,7 +1181,7 @@ _mesa_get_shader_source(GLcontext *ctx, GLuint shader, GLsizei maxLength, if (!sh) { return; } - copy_string(sourceOut, maxLength, length, sh->Source); + _mesa_copy_string(sourceOut, maxLength, length, sh->Source); } diff --git a/src/mesa/shader/shader_api.h b/src/mesa/shader/shader_api.h index d08d47373e1..3ed52747cdb 100644 --- a/src/mesa/shader/shader_api.h +++ b/src/mesa/shader/shader_api.h @@ -42,6 +42,12 @@ _mesa_init_shader_state(GLcontext * ctx); extern void _mesa_free_shader_state(GLcontext *ctx); + +extern void +_mesa_copy_string(GLchar *dst, GLsizei maxLength, + GLsizei *length, const GLchar *src); + + /* extern struct gl_shader_program * _mesa_new_shader_program(GLcontext *ctx, GLuint name); diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index d6ae696e395..996172d9a50 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -80,6 +80,7 @@ MAIN_SOURCES = \ main/texrender.c \ main/texstate.c \ main/texstore.c \ + main/transformfeedback.c \ main/varray.c \ main/version.c \ main/viewport.c \ diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 9c9a99bcfc6..5669b1f82af 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -209,7 +209,7 @@ static void update_raster_state( struct st_context *st ) */ if (vertProg) { if (vertProg->Base.Id == 0) { - if (vertProg->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { + if (vertProg->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_PSIZ)) { /* generated program which emits point size */ raster->point_size_per_vertex = TRUE; } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index c9d1e9c6c4b..85570541ef0 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -735,14 +735,14 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* now pack the stencil (and Z) values in the dest format */ switch (pt->texture->format) { - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: { ubyte *dest = stmap + spanY * pt->stride + spanX; assert(usage == PIPE_TRANSFER_WRITE); memcpy(dest, sValues, spanWidth); } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: if (format == GL_DEPTH_STENCIL) { uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLint k; @@ -760,7 +760,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: if (format == GL_DEPTH_STENCIL) { uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLint k; @@ -913,7 +913,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, src = buffer + i * width; switch (ptDraw->texture->format) { - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: { uint *dst4 = (uint *) dst; int j; @@ -924,7 +924,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: { uint *dst4 = (uint *) dst; int j; @@ -935,7 +935,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } break; - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: assert(usage == PIPE_TRANSFER_WRITE); memcpy(dst, src, width); break; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 84c2474038d..542ab38a50e 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -255,13 +255,13 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) case PIPE_FORMAT_Z32_UNORM: strb->Base.InternalFormat = GL_DEPTH_COMPONENT32; break; - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_Z24X8_UNORM: case PIPE_FORMAT_X8Z24_UNORM: strb->Base.InternalFormat = GL_DEPTH24_STENCIL8_EXT; break; - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT; break; case PIPE_FORMAT_R16G16B16A16_SNORM: diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 7afb275fe2f..10795ee9e4a 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -103,13 +103,13 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* get stencil (and Z) values */ switch (pt->texture->format) { - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: { const ubyte *src = stmap + srcY * pt->stride; memcpy(sValues, src, width); } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: if (format == GL_DEPTH_STENCIL) { const uint *src = (uint *) (stmap + srcY * pt->stride); const GLfloat scale = 1.0f / (0xffffff); @@ -127,7 +127,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: if (format == GL_DEPTH_STENCIL) { const uint *src = (uint *) (stmap + srcY * pt->stride); const GLfloat scale = 1.0f / (0xffffff); @@ -437,7 +437,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width, format, type); - if (trans->texture->format == PIPE_FORMAT_Z24S8_UNORM || + if (trans->texture->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || trans->texture->format == PIPE_FORMAT_Z24X8_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { @@ -469,7 +469,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } } - else if (trans->texture->format == PIPE_FORMAT_S8Z24_UNORM || + else if (trans->texture->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM || trans->texture->format == PIPE_FORMAT_X8Z24_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 290ee36b0fe..0118c600f09 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -281,18 +281,18 @@ void st_init_extensions(struct st_context *st) /* GL_EXT_packed_depth_stencil requires both the ability to render to * a depth/stencil buffer and texture from depth/stencil source. */ - if (screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, + if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) && - screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, + screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } - else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM, + else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) && - screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM, + screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 9ae0c9f9bab..ecc08762bb2 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -76,8 +76,8 @@ st_format_datatype(enum pipe_format format) format == PIPE_FORMAT_B5G6R5_UNORM) { return GL_UNSIGNED_SHORT; } - else if (format == PIPE_FORMAT_Z24S8_UNORM || - format == PIPE_FORMAT_S8Z24_UNORM) { + else if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || + format == PIPE_FORMAT_S8_USCALED_Z24_UNORM) { return GL_UNSIGNED_INT_24_8; } else { @@ -151,9 +151,9 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_Z32: return PIPE_FORMAT_Z32_UNORM; case MESA_FORMAT_Z24_S8: - return PIPE_FORMAT_S8Z24_UNORM; + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; case MESA_FORMAT_S8_Z24: - return PIPE_FORMAT_Z24S8_UNORM; + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; case MESA_FORMAT_YCBCR: return PIPE_FORMAT_UYVY; #if FEATURE_texture_s3tc @@ -224,7 +224,7 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_L8; case PIPE_FORMAT_I8_UNORM: return MESA_FORMAT_I8; - case PIPE_FORMAT_S8_UNORM: + case PIPE_FORMAT_S8_USCALED: return MESA_FORMAT_S8; case PIPE_FORMAT_R16G16B16A16_SNORM: @@ -234,13 +234,13 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_Z16; case PIPE_FORMAT_Z32_UNORM: return MESA_FORMAT_Z32; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: return MESA_FORMAT_Z24_S8; case PIPE_FORMAT_X8Z24_UNORM: return MESA_FORMAT_Z24_X8; case PIPE_FORMAT_Z24X8_UNORM: return MESA_FORMAT_X8_Z24; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: return MESA_FORMAT_S8_Z24; case PIPE_FORMAT_UYVY: @@ -393,8 +393,8 @@ default_depth_format(struct pipe_screen *screen, static const enum pipe_format zFormats[] = { PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_S8Z24_UNORM + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM }; uint i; for (i = 0; i < Elements(zFormats); i++) { @@ -546,10 +546,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return PIPE_FORMAT_Z16_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT24: - if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_Z24S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags )) + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT32: if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, target, tex_usage, geom_flags )) @@ -563,20 +563,20 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_STENCIL_INDEX4_EXT: case GL_STENCIL_INDEX8_EXT: case GL_STENCIL_INDEX16_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_S8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_Z24S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8_USCALED; + if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags )) + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; return PIPE_FORMAT_NONE; case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_Z24S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags )) + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; return PIPE_FORMAT_NONE; case GL_SRGB_EXT: diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 7f8677d400c..6e8c446f783 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -121,7 +121,7 @@ st_prepare_vertex_program(struct st_context *st, /* Compute mapping of vertex program outputs to slots. */ for (attr = 0; attr < VERT_RESULT_MAX; attr++) { - if ((stvp->Base.Base.OutputsWritten & (1 << attr)) == 0) { + if ((stvp->Base.Base.OutputsWritten & BITFIELD64_BIT(attr)) == 0) { stvp->result_to_output[attr] = ~0; } else { @@ -388,7 +388,7 @@ st_translate_fragment_program(struct st_context *st, GLbitfield64 outputsWritten = stfp->Base.Base.OutputsWritten; /* if z is written, emit that first */ - if (outputsWritten & (1 << FRAG_RESULT_DEPTH)) { + if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) { fs_output_semantic_name[fs_num_outputs] = TGSI_SEMANTIC_POSITION; fs_output_semantic_index[fs_num_outputs] = 0; outputMapping[FRAG_RESULT_DEPTH] = fs_num_outputs; @@ -398,7 +398,7 @@ st_translate_fragment_program(struct st_context *st, /* handle remaning outputs (color) */ for (attr = 0; attr < FRAG_RESULT_MAX; attr++) { - if (outputsWritten & (1 << attr)) { + if (outputsWritten & BITFIELD64_BIT(attr)) { switch (attr) { case FRAG_RESULT_DEPTH: /* handled above */ |