Comments below. On 07/18/2011 11:37 AM, Paul Berry wrote: > This function is used by main.cpp to initialize a context to a default > configuration for use in compiling builtins. Moved the bulk of it to > glsl_parser_extras.cpp so that it can be re-used in testing. > --- > src/glsl/glsl_parser_extras.cpp | 33 +++++++++++++++++++++++++++++++++ > src/glsl/glsl_parser_extras.h | 11 +++++++++++ > src/glsl/main.cpp | 25 +------------------------ > 3 files changed, 45 insertions(+), 24 deletions(-) > > diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp > index cc78137..936dbcc 100644 > --- a/src/glsl/glsl_parser_extras.cpp > +++ b/src/glsl/glsl_parser_extras.cpp > @@ -926,6 +926,39 @@ do_common_optimization(exec_list *ir, bool linked, > unsigned max_unroll_iteration > return progress; > } > > +void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) > +{ > + memset(ctx, 0, sizeof(*ctx)); > + > + ctx->API = api; > + > + ctx->Extensions.ARB_ES2_compatibility = GL_TRUE; > + ctx->Extensions.ARB_draw_buffers = GL_TRUE; > + ctx->Extensions.ARB_draw_instanced = GL_TRUE; > + ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; > + ctx->Extensions.EXT_texture_array = GL_TRUE; > + ctx->Extensions.NV_texture_rectangle = GL_TRUE; > + ctx->Extensions.EXT_texture3D = GL_TRUE; > + > + ctx->Const.GLSLVersion = 120; > + > + /* 1.10 minimums. */ > + ctx->Const.MaxLights = 8;
There is conflict here. The GLSL vrsion is 1.20, but the comment says 1.10. The minimum values below are identical for both versions, so I can't determine which is correct---1.10 or 1.20. > + ctx->Const.MaxClipPlanes = 6; > + ctx->Const.MaxTextureUnits = 2; > + ctx->Const.MaxTextureCoordUnits = 2; > + ctx->Const.VertexProgram.MaxAttribs = 16; > + > + ctx->Const.VertexProgram.MaxUniformComponents = 512; > + ctx->Const.MaxVarying = 8; > + ctx->Const.MaxVertexTextureImageUnits = 0; > + ctx->Const.MaxCombinedTextureImageUnits = 2; > + ctx->Const.MaxTextureImageUnits = 2; > + ctx->Const.FragmentProgram.MaxUniformComponents = 64; > + > + ctx->Const.MaxDrawBuffers = 2; ^^^^^^^^^^^^^^^^^^^ For GLSL 1.10 and 1.20, the minimum gl_MaxDrawBuffers is 1. Is there a reason why you chose 2? If so, it should be documented why you deviated from the minimum value. > +} > + > extern "C" { > > /** > diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h > index 2f4d3cb..3f88abd 100644 > --- a/src/glsl/glsl_parser_extras.h > +++ b/src/glsl/glsl_parser_extras.h > @@ -33,6 +33,7 @@ > > #include <stdlib.h> > #include "glsl_symbol_table.h" > +#include "main/mtypes.h" > > enum _mesa_glsl_parser_targets { > vertex_shader, > @@ -258,6 +259,16 @@ extern bool _mesa_glsl_process_extension(const char > *name, YYLTYPE *name_locp, > extern const char * > _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target); > > +/** > + * Initialize the given gl_context structure to a reasonable set of > + * defaults representing the minimum capabilities required by the > + * OpenGL spec. > + * > + * This is used when compiling builtin functions and in testing, when > + * we don't have a connection to an actual driver. > + */ > +void initialize_context_to_defaults(struct gl_context *ctx, gl_api api); > + > > #endif /* __cplusplus */ > > diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp > index 7952bb1..4cfcf0c 100644 > --- a/src/glsl/main.cpp > +++ b/src/glsl/main.cpp > @@ -66,43 +66,20 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, > GLenum type) > static void > initialize_context(struct gl_context *ctx, gl_api api) > { > - memset(ctx, 0, sizeof(*ctx)); > - > - ctx->API = api; > - > - ctx->Extensions.ARB_ES2_compatibility = GL_TRUE; > - ctx->Extensions.ARB_draw_buffers = GL_TRUE; > - ctx->Extensions.ARB_draw_instanced = GL_TRUE; > - ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; > - ctx->Extensions.EXT_texture_array = GL_TRUE; > - ctx->Extensions.NV_texture_rectangle = GL_TRUE; > - ctx->Extensions.EXT_texture3D = GL_TRUE; > + initialize_context_to_defaults(ctx, api); > > /* GLSL 1.30 isn't fully supported, but we need to advertise 1.30 so that > * the built-in functions for 1.30 can be built. > */ > ctx->Const.GLSLVersion = 130; > > - /* 1.10 minimums. */ > - ctx->Const.MaxLights = 8; > ctx->Const.MaxClipPlanes = 8; > - ctx->Const.MaxTextureUnits = 2; > > /* More than the 1.10 minimum to appease parser tests taken from > * apps that (hopefully) already checked the number of coords. > */ > ctx->Const.MaxTextureCoordUnits = 4; > > - ctx->Const.VertexProgram.MaxAttribs = 16; > - ctx->Const.VertexProgram.MaxUniformComponents = 512; > - ctx->Const.MaxVarying = 8; > - ctx->Const.MaxVertexTextureImageUnits = 0; > - ctx->Const.MaxCombinedTextureImageUnits = 2; > - ctx->Const.MaxTextureImageUnits = 2; > - ctx->Const.FragmentProgram.MaxUniformComponents = 64; > - > - ctx->Const.MaxDrawBuffers = 2; > - > ctx->Driver.NewShader = _mesa_new_shader; > } > -- Chad Versace c...@chad-versace.us
signature.asc
Description: OpenPGP digital signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev