[Mesa-dev] [PATCH 2/2] glcpp: Don't treat undefined macros as zero for GLES3

Ian Romanick idr at freedesktop.org
Mon Nov 26 10:36:25 PST 2012


On 11/22/2012 08:57 AM, Carl Worth wrote:
> The specification is clear that an undefined macro in an #if or #elif should
> cause an error. This is distinct from the behavior required for recent desktop
> OpenGL.
>
> FIXME: This commit isn't compiling for me since I don't have any API_OPENGLES3
> symbol in my environment. I'm seeking guidance on how to get such a sumbol or
> otherwise what should be changed in this condition.
> ---
>   src/glsl/glcpp/glcpp-parse.y |   16 +++++++++++++++-
>   src/glsl/glcpp/glcpp.h       |    1 +
>   2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
> index 38fe44a..70dec84 100644
> --- a/src/glsl/glcpp/glcpp-parse.y
> +++ b/src/glsl/glcpp/glcpp-parse.y
> @@ -281,9 +281,21 @@ control_line:
>   		if (parser->skip_stack == NULL ||
>   		    parser->skip_stack->type == SKIP_NO_SKIP)
>   		{
> +			int undefined_macro_mode = UNDEFINED_MACRO_IS_ZERO;
> +
> +			/* Page 11 (page 17 of the PDF) of the OpenGL
> +			 * ES Shading Language 3.00 spec says:
> +			 *
> +			 * "Undefined identifiers not consumed by the
> +			 * defined operator do not default to '0'. Use
> +			 * of such identifiers causes an error."
> +			 */
> +			if (parser->api == API_OPENGLES3)

There isn't one.  We treat OpenGL ES 3 as version 30 of API_OPENGLES2. 
There's a utility function _mesa_is_gles3 to check this.  See 
src/mesa/main/context.h.

> +				undefined_macro_mode = UNDEFINED_MACRO_IS_IDENTIFIER;
> +			
>   			_glcpp_parser_expand_and_lex_from (parser,
>   							   IF_EXPANDED, $2,
> -							   UNDEFINED_MACRO_IS_ZERO);
> +							   undefined_macro_mode);
>   		}	
>   		else
>   		{
> @@ -1151,6 +1163,8 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
>   	parser->has_new_source_number = 0;
>   	parser->new_source_number = 0;
>
> +	parser->api = api;
> +
>   	/* Add pre-defined macros. */
>   	if (extensions != NULL) {
>   	   if (extensions->OES_EGL_image_external)
> diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h
> index a459289..7a528dd 100644
> --- a/src/glsl/glcpp/glcpp.h
> +++ b/src/glsl/glcpp/glcpp.h
> @@ -182,6 +182,7 @@ struct glcpp_parser {
>   	int new_line_number;
>   	bool has_new_source_number;
>   	int new_source_number;
> +	int api;
>   };
>
>   struct gl_extensions;
>



More information about the mesa-dev mailing list