diff options
Diffstat (limited to 'src/mesa/main')
34 files changed, 265 insertions, 252 deletions
diff --git a/src/mesa/main/accum.h b/src/mesa/main/accum.h index c2b74b23cb..4b628bafa0 100644 --- a/src/mesa/main/accum.h +++ b/src/mesa/main/accum.h @@ -42,11 +42,6 @@ #if FEATURE_accum -#define _MESA_INIT_ACCUM_FUNCTIONS(driver, impl) \ - do { \ - (driver)->Accum = impl ## Accum; \ - } while (0) - extern void GLAPIENTRY _mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); @@ -57,8 +52,6 @@ _mesa_init_accum_dispatch(struct _glapi_table *disp); #include "main/compiler.h" -#define _MESA_INIT_ACCUM_FUNCTIONS(driver, impl) do { } while (0) - static INLINE void _mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) { diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c index 82e1f0fdba..c3c710f5ef 100644 --- a/src/mesa/main/api_exec.c +++ b/src/mesa/main/api_exec.c @@ -101,9 +101,7 @@ #include "shaderapi.h" #include "uniforms.h" #endif -#if FEATURE_ARB_sync #include "syncobj.h" -#endif #include "main/dispatch.h" @@ -634,15 +632,7 @@ _mesa_create_exec_table(void) #endif /* GL_ARB_sync */ -#if FEATURE_ARB_sync - SET_IsSync(exec, _mesa_IsSync); - SET_DeleteSync(exec, _mesa_DeleteSync); - SET_FenceSync(exec, _mesa_FenceSync); - SET_ClientWaitSync(exec, _mesa_ClientWaitSync); - SET_WaitSync(exec, _mesa_WaitSync); - SET_GetInteger64v(exec, _mesa_GetInteger64v); - SET_GetSynciv(exec, _mesa_GetSynciv); -#endif + _mesa_init_sync_dispatch(exec); /* GL_ATI_fragment_shader */ _mesa_init_ati_fragment_shader_dispatch(exec); diff --git a/src/mesa/main/colortab.h b/src/mesa/main/colortab.h index 744f092d93..303c9fb302 100644 --- a/src/mesa/main/colortab.h +++ b/src/mesa/main/colortab.h @@ -31,13 +31,6 @@ #if FEATURE_colortable -#define _MESA_INIT_COLORTABLE_FUNCTIONS(driver, impl) \ - do { \ - (driver)->CopyColorTable = impl ## CopyColorTable; \ - (driver)->CopyColorSubTable = impl ## CopyColorSubTable; \ - (driver)->UpdateTexturePalette = impl ## UpdateTexturePalette; \ - } while (0) - extern void GLAPIENTRY _mesa_ColorTable( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, @@ -55,8 +48,6 @@ _mesa_init_colortable_dispatch(struct _glapi_table *disp); #include "main/compiler.h" -#define _MESA_INIT_COLORTABLE_FUNCTIONS(driver, impl) do { } while (0) - static INLINE void GLAPIENTRY _mesa_ColorTable( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index ded69c3106..800eb83900 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -224,6 +224,18 @@ extern "C" { # endif # endif #endif +#ifndef __func__ +# if (__STDC_VERSION__ >= 199901L) || \ + (defined(__SUNPRO_C) && defined(__C99FEATURES__)) + /* __func__ is part of C99 */ +# elif defined(_MSC_VER) +# if _MSC_VER >= 1300 +# define __func__ __FUNCTION__ +# else +# define __func__ "<unknown>" +# endif +# endif +#endif /** diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 8e34ec4124..b1f800f4c2 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -111,9 +111,7 @@ #include "points.h" #include "polygon.h" #include "queryobj.h" -#if FEATURE_ARB_sync #include "syncobj.h" -#endif #include "rastpos.h" #include "remap.h" #include "scissor.h" @@ -737,9 +735,7 @@ init_attrib_groups(GLcontext *ctx) _mesa_init_polygon( ctx ); _mesa_init_program( ctx ); _mesa_init_queryobj( ctx ); -#if FEATURE_ARB_sync _mesa_init_sync( ctx ); -#endif _mesa_init_rastpos( ctx ); _mesa_init_scissor( ctx ); _mesa_init_shader_state( ctx ); @@ -1100,9 +1096,7 @@ _mesa_free_context_data( GLcontext *ctx ) _mesa_free_program_data(ctx); _mesa_free_shader_state(ctx); _mesa_free_queryobj_data(ctx); -#if FEATURE_ARB_sync _mesa_free_sync_data(ctx); -#endif _mesa_free_varray_data(ctx); _mesa_free_transform_feedback(ctx); @@ -1300,6 +1294,9 @@ check_compatible(const GLcontext *ctx, const GLframebuffer *buffer) if (ctxvis == bufvis) return GL_TRUE; + if (buffer == _mesa_get_incomplete_framebuffer()) + return GL_TRUE; + #if 0 /* disabling this fixes the fgl_glxgears pbuffer demo */ if (ctxvis->doubleBufferMode && !bufvis->doubleBufferMode) diff --git a/src/mesa/main/convolve.h b/src/mesa/main/convolve.h index d1401885df..80caf942fb 100644 --- a/src/mesa/main/convolve.h +++ b/src/mesa/main/convolve.h @@ -33,12 +33,6 @@ #if FEATURE_convolve -#define _MESA_INIT_CONVOLVE_FUNCTIONS(driver, impl) \ - do { \ - (driver)->CopyConvolutionFilter1D = impl ## CopyConvolutionFilter1D; \ - (driver)->CopyConvolutionFilter2D = impl ## CopyConvolutionFilter2D; \ - } while (0) - extern void GLAPIENTRY _mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); @@ -72,8 +66,6 @@ _mesa_init_convolve_dispatch(struct _glapi_table *disp); #include "main/compiler.h" -#define _MESA_INIT_CONVOLVE_FUNCTIONS(driver, impl) do { } while (0) - static INLINE void GLAPIENTRY _mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 5042e14a54..d847d4d5d3 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -6818,7 +6818,7 @@ _mesa_compile_error(GLcontext *ctx, GLenum error, const char *s) if (ctx->CompileFlag) save_error(ctx, error, s); if (ctx->ExecuteFlag) - _mesa_error(ctx, error, s); + _mesa_error(ctx, error, "%s", s); } @@ -6885,7 +6885,7 @@ execute_list(GLcontext *ctx, GLuint list) else { switch (opcode) { case OPCODE_ERROR: - _mesa_error(ctx, n[1].e, (const char *) n[2].data); + _mesa_error(ctx, n[1].e, "%s", (const char *) n[2].data); break; case OPCODE_ACCUM: CALL_Accum(ctx->Exec, (n[1].e, n[2].f)); @@ -7917,7 +7917,7 @@ execute_list(GLcontext *ctx, GLuint list) char msg[1000]; _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", (int) opcode); - _mesa_problem(ctx, msg); + _mesa_problem(ctx, "%s", msg); } done = GL_TRUE; } @@ -8892,8 +8892,8 @@ exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) /* GL_EXT_multi_draw_arrays */ static void GLAPIENTRY -exec_MultiDrawArraysEXT(GLenum mode, GLint * first, - GLsizei * count, GLsizei primcount) +exec_MultiDrawArraysEXT(GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount) { GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0); diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h index d3f5c5cb4e..86bb132e56 100644 --- a/src/mesa/main/dlist.h +++ b/src/mesa/main/dlist.h @@ -38,16 +38,6 @@ #if FEATURE_dlist -#define _MESA_INIT_DLIST_FUNCTIONS(driver, impl) \ - do { \ - (driver)->NewList = impl ## NewList; \ - (driver)->EndList = impl ## EndList; \ - (driver)->BeginCallList = impl ## BeginCallList; \ - (driver)->EndCallList = impl ## EndCallList; \ - (driver)->SaveFlushVertices = impl ## SaveFlushVertices; \ - (driver)->NotifySaveBegin = impl ## NotifyBegin; \ - } while (0) - #define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) \ do { \ (vfmt)->CallList = impl ## CallList; \ @@ -83,7 +73,6 @@ extern void _mesa_init_dlist_dispatch(struct _glapi_table *disp); #include "main/compiler.h" -#define _MESA_INIT_DLIST_FUNCTIONS(driver, impl) do { } while (0) #define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) do { } while (0) static INLINE void diff --git a/src/mesa/main/drawpix.h b/src/mesa/main/drawpix.h index 8ffb1a6d88..1f95ff5294 100644 --- a/src/mesa/main/drawpix.h +++ b/src/mesa/main/drawpix.h @@ -31,20 +31,11 @@ #if FEATURE_drawpix -#define _MESA_INIT_DRAWPIX_FUNCTIONS(driver, impl) \ - do { \ - (driver)->DrawPixels = impl ## DrawPixels; \ - (driver)->CopyPixels = impl ## CopyPixels; \ - (driver)->Bitmap = impl ## Bitmap; \ - } while (0) - extern void _mesa_init_drawpix_dispatch(struct _glapi_table *disp); #else /* FEATURE_drawpix */ -#define _MESA_INIT_DRAWPIX_FUNCTIONS(driver, impl) do { } while (0) - static INLINE void _mesa_init_drawpix_dispatch(struct _glapi_table *disp) { diff --git a/src/mesa/main/drawtex.h b/src/mesa/main/drawtex.h index 95f4ac86f0..d7d507566b 100644 --- a/src/mesa/main/drawtex.h +++ b/src/mesa/main/drawtex.h @@ -30,11 +30,6 @@ #if FEATURE_OES_draw_texture -#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) \ - do { \ - (driver)->DrawTex = impl ## DrawTex; \ - } while (0) - extern void GLAPIENTRY _mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); @@ -59,10 +54,6 @@ _mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); extern void GLAPIENTRY _mesa_DrawTexxv(const GLfixed *coords); -#else /* FEATURE_OES_draw_texture */ - -#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) do { } while (0) - #endif /* FEATURE_OES_draw_texture */ diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index c9862ca29e..50b97f5113 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -58,7 +58,8 @@ static const struct { { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) }, { OFF, "GL_ARB_explicit_attrib_location", F(ARB_explicit_attrib_location) }, - { OFF, "GL_ARB_geometry_shader4", F(ARB_geometry_shader4) }, + /* TODO: reenable this when the new GLSL compiler actually supports them */ + /* { OFF, "GL_ARB_geometry_shader4", F(ARB_geometry_shader4) }, */ { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) }, { OFF, "GL_ARB_half_float_vertex", F(ARB_half_float_vertex) }, { OFF, "GL_ARB_imaging", F(ARB_imaging) }, diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index f80dd85993..5201f50252 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -71,6 +71,10 @@ static struct gl_framebuffer DummyFramebuffer; static struct gl_renderbuffer DummyRenderbuffer; +/* We bind this framebuffer when applications pass a NULL + * drawable/surface in make current. */ +static struct gl_framebuffer IncompleteFramebuffer; + #define IS_CUBE_FACE(TARGET) \ ((TARGET) >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && \ @@ -95,14 +99,16 @@ _mesa_init_fbobjects(GLcontext *ctx) { _glthread_INIT_MUTEX(DummyFramebuffer.Mutex); _glthread_INIT_MUTEX(DummyRenderbuffer.Mutex); + _glthread_INIT_MUTEX(IncompleteFramebuffer.Mutex); DummyFramebuffer.Delete = delete_dummy_framebuffer; DummyRenderbuffer.Delete = delete_dummy_renderbuffer; + IncompleteFramebuffer.Delete = delete_dummy_framebuffer; } struct gl_framebuffer * _mesa_get_incomplete_framebuffer(void) { - return &DummyFramebuffer; + return &IncompleteFramebuffer; } /** @@ -925,6 +931,12 @@ GLenum _mesa_base_fbo_format(GLcontext *ctx, GLenum internalFormat) { switch (internalFormat) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; case GL_RGB: case GL_R3_G3_B2: case GL_RGB4: @@ -1022,7 +1034,7 @@ renderbuffer_storage(GLenum target, GLenum internalFormat, rb = ctx->CurrentRenderbuffer; if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, func); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); return; } diff --git a/src/mesa/main/feedback.h b/src/mesa/main/feedback.h index 0762930044..c6354b97bc 100644 --- a/src/mesa/main/feedback.h +++ b/src/mesa/main/feedback.h @@ -32,11 +32,6 @@ #if FEATURE_feedback -#define _MESA_INIT_FEEDBACK_FUNCTIONS(driver, impl) \ - do { \ - (driver)->RenderMode = impl ## RenderMode; \ - } while (0) - extern void _mesa_feedback_vertex( GLcontext *ctx, const GLfloat win[4], @@ -65,8 +60,6 @@ _mesa_init_feedback_dispatch(struct _glapi_table *disp); #include "main/compiler.h" -#define _MESA_INIT_FEEDBACK_FUNCTIONS(driver, impl) do { } while (0) - static INLINE void _mesa_feedback_vertex( GLcontext *ctx, const GLfloat win[4], diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index a3cb5ec168..2062134a39 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -128,6 +128,7 @@ enum value_extra { EXTRA_VERSION_30, EXTRA_VERSION_31, EXTRA_VERSION_32, + EXTRA_VERSION_ES2, EXTRA_NEW_BUFFERS, EXTRA_VALID_DRAW_BUFFER, EXTRA_VALID_TEXTURE_UNIT, @@ -326,6 +327,13 @@ static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; +static const int +extra_ARB_vertex_program_version_es2[] = { + EXT(ARB_vertex_program), + EXTRA_VERSION_ES2, + EXTRA_END +}; + #define API_OPENGL_BIT (1 << API_OPENGL) #define API_OPENGLES_BIT (1 << API_OPENGLES) #define API_OPENGLES2_BIT (1 << API_OPENGLES2) @@ -661,7 +669,8 @@ static const struct value_desc values[] = { { GL_STENCIL_BACK_PASS_DEPTH_PASS, CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA }, { GL_MAX_VERTEX_ATTRIBS_ARB, - CONTEXT_INT(Const.VertexProgram.MaxAttribs), extra_ARB_vertex_program }, + CONTEXT_INT(Const.VertexProgram.MaxAttribs), + extra_ARB_vertex_program_version_es2 }, /* OES_texture_3D */ { GL_TEXTURE_BINDING_3D, LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA }, @@ -1678,6 +1687,12 @@ check_extra(GLcontext *ctx, const char *func, const struct value_desc *d) enabled++; } break; + case EXTRA_VERSION_ES2: + if (ctx->API == API_OPENGLES2) { + total++; + enabled++; + } + break; case EXTRA_NEW_BUFFERS: if (ctx->NewState & _NEW_BUFFERS) _mesa_update_state(ctx); diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index a4044ff5cb..45f7b55ad2 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -55,11 +55,11 @@ #include "GL/internal/glcore.h" -#ifndef GL_FIXED -#define GL_FIXED 0x140C +/** + * GL_FIXED is defined in glext.h version 64 but these typedefs aren't (yet). + */ typedef int GLfixed; typedef int GLclampx; -#endif #ifndef GL_OES_EGL_image @@ -122,10 +122,24 @@ typedef void *GLeglImageOES; #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD #endif + + /** - * Special, internal token + * Internal token to represent a GLSL shader program (a collection of + * one or more shaders that get linked together). Note that GLSL + * shaders and shader programs share one name space (one hash table) + * so we need a value that's different from any of the + * GL_VERTEX/FRAGMENT/GEOMETRY_PROGRAM tokens. */ #define GL_SHADER_PROGRAM_MESA 0x9999 +/** + * Internal token for geometry programs. + * Use the value for GL_GEOMETRY_PROGRAM_NV for now. + */ +#define MESA_GEOMETRY_PROGRAM 0x8c26 + + + #endif /* GLHEADER_H */ diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 5b87b8c8ac..43ae28c25a 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -599,7 +599,7 @@ _mesa_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, bitmask |= MAT_BIT_FRONT_INDEXES | MAT_BIT_BACK_INDEXES; break; default: - _mesa_error( ctx, GL_INVALID_ENUM, where ); + _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); return 0; } @@ -610,12 +610,12 @@ _mesa_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, bitmask &= BACK_MATERIAL_BITS; } else if (face != GL_FRONT_AND_BACK) { - _mesa_error( ctx, GL_INVALID_ENUM, where ); + _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); return 0; } if (bitmask & ~legal) { - _mesa_error( ctx, GL_INVALID_ENUM, where ); + _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); return 0; } diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h index 4e838abe03..92311ef7f0 100644 --- a/src/mesa/main/mfeatures.h +++ b/src/mesa/main/mfeatures.h @@ -42,9 +42,6 @@ /** * A feature can be anything. But most of them share certain characteristics. * - * When a feature defines driver entries, they can be initialized by - * _MESA_INIT_<FEATURE>_FUNCTIONS - * * When a feature defines vtxfmt entries, they can be initialized and * installed by * _MESA_INIT_<FEATURE>_VTXFMT diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d44eff69cc..864805af0e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -41,13 +41,14 @@ #include "math/m_matrix.h" /* GLmatrix */ #include "main/simple_list.h" /* struct simple_node */ -/** - * Internal token - * Must be simply different than GL_VERTEX_PROGRAM - * and GL_FRAGMENT_PROGRAM_ARB - * FIXME: this will have to be a real GL extension +/* Shader stages. Note that these will become 5 with tessellation. + * These MUST have the same values as PIPE_SHADER_* */ -#define MESA_GEOMETRY_PROGRAM 0x9999 +#define MESA_SHADER_VERTEX 0 +#define MESA_SHADER_FRAGMENT 1 +#define MESA_SHADER_GEOMETRY 2 +#define MESA_SHADER_TYPES 3 + /** * Color channel data type. @@ -2166,23 +2167,35 @@ struct gl_shader_program struct gl_shader_state { struct gl_shader_program *CurrentProgram; /**< The user-bound program */ + void *MemPool; + + GLbitfield Flags; /**< Mask of GLSL_x flags */ +}; + +/** + * Compiler options for a single GLSL shaders type + */ +struct gl_shader_compiler_options +{ /** Driver-selectable options: */ - GLboolean EmitHighLevelInstructions; /**< IF/ELSE/ENDIF vs. BRA, etc. */ - GLboolean EmitContReturn; /**< Emit CONT/RET opcodes? */ GLboolean EmitCondCodes; /**< Use condition codes? */ - GLboolean EmitComments; /**< Annotated instructions */ GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ /** * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't * support control flow. */ GLboolean EmitNoIfs; - void *MemPool; - GLbitfield Flags; /**< Mask of GLSL_x flags */ + GLboolean EmitNoLoops; + GLboolean EmitNoFunctions; + GLboolean EmitNoCont; /**< Emit CONT opcode? */ + GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ + GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ + + GLuint MaxUnrollIterations; + struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ }; - /** * Transform feedback object state */ @@ -2585,7 +2598,8 @@ struct gl_constants GLuint MaxVarying; /**< Number of float[4] varying parameters */ - GLbitfield SupportedBumpUnits; /**> units supporting GL_ATI_envmap_bumpmap as targets */ + /** Which texture units support GL_ATI_envmap_bumpmap as targets */ + GLbitfield SupportedBumpUnits; /** * Maximum amount of time, measured in nanseconds, that the server can wait. @@ -3202,6 +3216,7 @@ struct __GLcontextRec struct gl_ati_fragment_shader_state ATIFragmentShader; struct gl_shader_state Shader; /**< GLSL shader object state */ + struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES]; struct gl_query_state Query; /**< occlusion, timer queries */ diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c index 100ff2c4ab..3a570b7dda 100644 --- a/src/mesa/main/nvprogram.c +++ b/src/mesa/main/nvprogram.c @@ -516,8 +516,10 @@ _mesa_emit_nv_temp_initialization(GLcontext *ctx, { struct prog_instruction *inst; GLuint i; + struct gl_shader_compiler_options* options = + &ctx->ShaderCompilerOptions[_mesa_program_target_to_index(program->Target)]; - if (!ctx->Shader.EmitNVTempInitialization) + if (!options->EmitNVTempInitialization) return; /* We'll swizzle up a zero temporary so we can use it for the diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h index b044c0d5d4..8746ed15e9 100644 --- a/src/mesa/main/queryobj.h +++ b/src/mesa/main/queryobj.h @@ -33,17 +33,6 @@ #if FEATURE_queryobj -#define _MESA_INIT_QUERYOBJ_FUNCTIONS(driver, impl) \ - do { \ - (driver)->NewQueryObject = impl ## NewQueryObject; \ - (driver)->DeleteQuery = impl ## DeleteQuery; \ - (driver)->BeginQuery = impl ## BeginQuery; \ - (driver)->EndQuery = impl ## EndQuery; \ - (driver)->WaitQuery = impl ## WaitQuery; \ - (driver)->CheckQuery = impl ## CheckQuery; \ - } while (0) - - static INLINE struct gl_query_object * _mesa_lookup_query_object(GLcontext *ctx, GLuint id) { @@ -78,8 +67,6 @@ _mesa_init_queryobj_dispatch(struct _glapi_table *disp); #else /* FEATURE_queryobj */ -#define _MESA_INIT_QUERYOBJ_FUNCTIONS(driver, impl) do { } while (0) - static INLINE struct gl_query_object * _mesa_lookup_query_object(GLcontext *ctx, GLuint id) { diff --git a/src/mesa/main/rastpos.h b/src/mesa/main/rastpos.h index b2127225b6..4994616d40 100644 --- a/src/mesa/main/rastpos.h +++ b/src/mesa/main/rastpos.h @@ -37,18 +37,11 @@ #if FEATURE_rastpos -#define _MESA_INIT_RASTPOS_FUNCTIONS(driver, impl) \ - do { \ - (driver)->RasterPos = impl ## RasterPos; \ - } while (0) - extern void _mesa_init_rastpos_dispatch(struct _glapi_table *disp); #else /* FEATURE_rastpos */ -#define _MESA_INIT_RASTPOS_FUNCTIONS(driver, impl) do { } while (0) - static INLINE void _mesa_init_rastpos_dispatch(struct _glapi_table *disp) { diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index cc350c93b9..c25d2a1974 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -94,18 +94,19 @@ _mesa_init_shader_state(GLcontext *ctx) /* Device drivers may override these to control what kind of instructions * are generated by the GLSL compiler. */ - ctx->Shader.EmitHighLevelInstructions = GL_TRUE; - ctx->Shader.EmitContReturn = GL_TRUE; - ctx->Shader.EmitCondCodes = GL_FALSE; - ctx->Shader.EmitComments = GL_FALSE; - ctx->Shader.EmitNoIfs = GL_FALSE; - ctx->Shader.Flags = get_shader_flags(); + struct gl_shader_compiler_options options; + GLuint i; + + memset(&options, 0, sizeof(options)); + options.MaxUnrollIterations = 32; /* Default pragma settings */ - ctx->Shader.DefaultPragmas.IgnoreOptimize = GL_FALSE; - ctx->Shader.DefaultPragmas.IgnoreDebug = GL_FALSE; - ctx->Shader.DefaultPragmas.Optimize = GL_TRUE; - ctx->Shader.DefaultPragmas.Debug = GL_FALSE; + options.DefaultPragmas.Optimize = GL_TRUE; + + for(i = 0; i < MESA_SHADER_TYPES; ++i) + memcpy(&ctx->ShaderCompilerOptions[i], &options, sizeof(options)); + + ctx->Shader.Flags = get_shader_flags(); } @@ -789,13 +790,16 @@ static void compile_shader(GLcontext *ctx, GLuint shaderObj) { struct gl_shader *sh; + struct gl_shader_compiler_options *options; sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader"); if (!sh) return; + options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)]; + /* set default pragma state for shader */ - sh->Pragmas = ctx->Shader.DefaultPragmas; + sh->Pragmas = options->DefaultPragmas; /* this call will set the sh->CompileStatus field to indicate if * compilation was successful. diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index 59198d788b..2de8f27981 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -156,18 +156,18 @@ struct gl_shader * _mesa_lookup_shader_err(GLcontext *ctx, GLuint name, const char *caller) { if (!name) { - _mesa_error(ctx, GL_INVALID_VALUE, caller); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); return NULL; } else { struct gl_shader *sh = (struct gl_shader *) _mesa_HashLookup(ctx->Shared->ShaderObjects, name); if (!sh) { - _mesa_error(ctx, GL_INVALID_VALUE, caller); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); return NULL; } if (sh->Type == GL_SHADER_PROGRAM_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, caller); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); return NULL; } return sh; @@ -377,18 +377,18 @@ _mesa_lookup_shader_program_err(GLcontext *ctx, GLuint name, const char *caller) { if (!name) { - _mesa_error(ctx, GL_INVALID_VALUE, caller); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); return NULL; } else { struct gl_shader_program *shProg = (struct gl_shader_program *) _mesa_HashLookup(ctx->Shared->ShaderObjects, name); if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, caller); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); return NULL; } if (shProg->Type != GL_SHADER_PROGRAM_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, caller); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); return NULL; } return shProg; diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h index 4800046375..cbe7ae7b06 100644 --- a/src/mesa/main/shaderobj.h +++ b/src/mesa/main/shaderobj.h @@ -96,6 +96,37 @@ _mesa_init_shader_state(GLcontext *ctx); extern void _mesa_free_shader_state(GLcontext *ctx); +static INLINE GLuint +_mesa_shader_type_to_index(GLenum v) +{ + switch(v) + { + case GL_VERTEX_SHADER: + return MESA_SHADER_VERTEX; + case GL_FRAGMENT_SHADER: + return MESA_SHADER_FRAGMENT; + case GL_GEOMETRY_SHADER: + return MESA_SHADER_GEOMETRY; + default: + ASSERT(0); + return ~0; + } +} + +static INLINE GLenum +_mesa_shader_index_to_type(GLuint i) +{ + GLenum enums[MESA_SHADER_TYPES] = { + GL_VERTEX_SHADER, + GL_FRAGMENT_SHADER, + GL_GEOMETRY_SHADER , + }; + if(i >= MESA_SHADER_TYPES) + return 0; + else + return enums[i]; +} + #ifdef __cplusplus } #endif diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index ea7e503cf3..a56c70fa7f 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -40,9 +40,7 @@ #include "program/program.h" #include "dlist.h" #include "shaderobj.h" -#if FEATURE_ARB_sync #include "syncobj.h" -#endif /** * Allocate and initialize a shared context state structure. @@ -122,9 +120,7 @@ _mesa_alloc_shared_state(GLcontext *ctx) shared->RenderBuffers = _mesa_NewHashTable(); #endif -#if FEATURE_ARB_sync make_empty_list(& shared->SyncObjects); -#endif return shared; } @@ -337,7 +333,6 @@ free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL); #endif -#if FEATURE_ARB_sync { struct simple_node *node; struct simple_node *temp; @@ -346,7 +341,6 @@ free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) _mesa_unref_sync_object(ctx, (struct gl_sync_object *) node); } } -#endif /* * Free texture objects (after FBOs since some textures might have diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index 1bff308177..ac948cc1ef 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -59,6 +59,8 @@ #include "imports.h" #include "context.h" #include "macros.h" +#include "get.h" +#include "dispatch.h" #if FEATURE_ARB_sync #include "syncobj.h" @@ -136,6 +138,19 @@ _mesa_init_sync_object_functions(struct dd_function_table *driver) } +void +_mesa_init_sync_dispatch(struct _glapi_table *disp) +{ + SET_IsSync(disp, _mesa_IsSync); + SET_DeleteSync(disp, _mesa_DeleteSync); + SET_FenceSync(disp, _mesa_FenceSync); + SET_ClientWaitSync(disp, _mesa_ClientWaitSync); + SET_WaitSync(disp, _mesa_WaitSync); + SET_GetInteger64v(disp, _mesa_GetInteger64v); + SET_GetSynciv(disp, _mesa_GetSynciv); +} + + /** * Allocate/init the context state related to sync objects. */ diff --git a/src/mesa/main/syncobj.h b/src/mesa/main/syncobj.h index c53511995b..82e141d408 100644 --- a/src/mesa/main/syncobj.h +++ b/src/mesa/main/syncobj.h @@ -31,15 +31,19 @@ #ifndef SYNCOBJ_H #define SYNCOBJ_H -#include "glheader.h" -#include "mtypes.h" +#include "main/mtypes.h" struct dd_function_table; +#if FEATURE_ARB_sync + extern void _mesa_init_sync_object_functions(struct dd_function_table *driver); extern void +_mesa_init_sync_dispatch(struct _glapi_table *disp); + +extern void _mesa_init_sync(GLcontext *); extern void @@ -70,4 +74,42 @@ extern void GLAPIENTRY _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#else /* FEATURE_ARB_sync */ + +#include "main/compiler.h" + +static INLINE void +_mesa_init_sync_object_functions(struct dd_function_table *driver) +{ +} + +static INLINE void +_mesa_init_sync_dispatch(struct _glapi_table *disp) +{ +} + +static INLINE void +_mesa_init_sync(GLcontext *ctx) +{ +} + +static INLINE void +_mesa_free_sync_data(GLcontext *ctx) +{ +} + +static INLINE void +_mesa_ref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) +{ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_unref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) +{ + ASSERT_NO_FEATURE(); +} + +#endif /* FEATURE_ARB_sync */ + #endif /* SYNCOBJ_H */ diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c index 4442fb8cf8..3a55128c73 100644 --- a/src/mesa/main/texenv.c +++ b/src/mesa/main/texenv.c @@ -196,57 +196,34 @@ set_combiner_source(GLcontext *ctx, /* * Translate pname to (term, alpha). + * + * The enums were given sequential values for a reason. */ switch (pname) { case GL_SOURCE0_RGB: - term = 0; - alpha = GL_FALSE; - break; case GL_SOURCE1_RGB: - term = 1; - alpha = GL_FALSE; - break; case GL_SOURCE2_RGB: - term = 2; - alpha = GL_FALSE; - break; case GL_SOURCE3_RGB_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - term = 3; - alpha = GL_FALSE; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } + term = pname - GL_SOURCE0_RGB; + alpha = GL_FALSE; break; case GL_SOURCE0_ALPHA: - term = 0; - alpha = GL_TRUE; - break; case GL_SOURCE1_ALPHA: - term = 1; - alpha = GL_TRUE; - break; case GL_SOURCE2_ALPHA: - term = 2; - alpha = GL_TRUE; - break; case GL_SOURCE3_ALPHA_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - term = 3; - alpha = GL_TRUE; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } + term = pname - GL_SOURCE0_ALPHA; + alpha = GL_TRUE; break; default: TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); return; } + if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + assert(term < MAX_COMBINER_TERMS); /* @@ -310,68 +287,33 @@ set_combiner_operand(GLcontext *ctx, return; } + /* The enums were given sequential values for a reason. + */ switch (pname) { case GL_OPERAND0_RGB: - term = 0; - alpha = GL_FALSE; - break; case GL_OPERAND1_RGB: - term = 1; - alpha = GL_FALSE; - break; case GL_OPERAND2_RGB: - if (ctx->Extensions.ARB_texture_env_combine) { - term = 2; - alpha = GL_FALSE; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - break; case GL_OPERAND3_RGB_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - term = 3; - alpha = GL_FALSE; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } + term = pname - GL_OPERAND0_RGB; + alpha = GL_FALSE; break; case GL_OPERAND0_ALPHA: - term = 0; - alpha = GL_TRUE; - break; case GL_OPERAND1_ALPHA: - term = 1; - alpha = GL_TRUE; - break; case GL_OPERAND2_ALPHA: - if (ctx->Extensions.ARB_texture_env_combine) { - term = 2; - alpha = GL_TRUE; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - break; case GL_OPERAND3_ALPHA_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - term = 3; - alpha = GL_TRUE; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } + term = pname - GL_OPERAND0_ALPHA; + alpha = GL_TRUE; break; default: TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); return; } + if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + assert(term < MAX_COMBINER_TERMS); /* @@ -380,10 +322,23 @@ set_combiner_operand(GLcontext *ctx, switch (param) { case GL_SRC_COLOR: case GL_ONE_MINUS_SRC_COLOR: - legal = !alpha; + /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT + * version. In the ARB and NV versions they can be used for any RGB + * operand. + */ + legal = !alpha + && ((term < 2) || ctx->Extensions.ARB_texture_env_combine + || ctx->Extensions.NV_texture_env_combine4); break; - case GL_SRC_ALPHA: case GL_ONE_MINUS_SRC_ALPHA: + /* GL_ONE_MINUS_SRC_ALPHA can only be used with + * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version. In the ARB and NV + * versions it can be used for any operand. + */ + legal = (term < 2) || ctx->Extensions.ARB_texture_env_combine + || ctx->Extensions.NV_texture_env_combine4; + break; + case GL_SRC_ALPHA: legal = GL_TRUE; break; default: diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 9fa8f02a8b..20f02cefe9 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -907,7 +907,7 @@ static struct ureg get_zero( struct texenv_fragment_program *p ) static void program_error( struct texenv_fragment_program *p, const char *msg ) { - _mesa_problem(NULL, msg); + _mesa_problem(NULL, "%s", msg); p->error = 1; } diff --git a/src/mesa/main/texgen.h b/src/mesa/main/texgen.h index 2224a93761..9ed8023836 100644 --- a/src/mesa/main/texgen.h +++ b/src/mesa/main/texgen.h @@ -35,11 +35,6 @@ struct _glapi_table; #if FEATURE_texgen -#define _MESA_INIT_TEXGEN_FUNCTIONS(driver, impl) \ - do { \ - (driver)->TexGen = impl ## TexGen; \ - } while (0) - extern void GLAPIENTRY _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); @@ -68,8 +63,6 @@ _es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params); #else /* FEATURE_texgen */ -#define _MESA_INIT_TEXGEN_FUNCTIONS(driver, impl) do { } while (0) - static void _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) { diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 9b7a021561..ca1bd6096e 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1405,7 +1405,7 @@ texture_error_check( GLcontext *ctx, GLenum target, char message[100]; _mesa_snprintf(message, sizeof(message), "glTexImage%dD(format/type YCBCR mismatch", dimensions); - _mesa_error(ctx, GL_INVALID_ENUM, message); + _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); return GL_TRUE; /* error */ } if (target != GL_TEXTURE_2D && @@ -1422,7 +1422,7 @@ texture_error_check( GLcontext *ctx, GLenum target, _mesa_snprintf(message, sizeof(message), "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", dimensions, border); - _mesa_error(ctx, GL_INVALID_VALUE, message); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); } return GL_TRUE; } diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 6c0cfc4e32..d19de7ff62 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1256,8 +1256,8 @@ _mesa_UnlockArraysEXT( void ) /* GL_EXT_multi_draw_arrays */ /* Somebody forgot to spec the first and count parameters as const! <sigh> */ void GLAPIENTRY -_mesa_MultiDrawArraysEXT( GLenum mode, GLint *first, - GLsizei *count, GLsizei primcount ) +_mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount ) { GET_CURRENT_CONTEXT(ctx); GLint i; diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index 26889f5ad4..c7c3e3ec70 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -159,8 +159,8 @@ _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); extern void GLAPIENTRY -_mesa_MultiDrawArraysEXT( GLenum mode, GLint *first, - GLsizei *count, GLsizei primcount ); +_mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount ); extern void GLAPIENTRY _mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index d833a160e9..9e1f5f2a4f 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -260,11 +260,15 @@ compute_version_es2(GLcontext *ctx) /** * Set the context's VersionMajor, VersionMinor, VersionString fields. - * This should only be called once as part of context initialization. + * This should only be called once as part of context initialization + * or to perform version check for GLX_ARB_create_context_profile. */ void _mesa_compute_version(GLcontext *ctx) { + if (ctx->VersionMajor) + return; + switch (ctx->API) { case API_OPENGL: compute_version(ctx); |
