Ejemplo n.º 1
0
int
glcpp_preprocess(void *ralloc_ctx, const char **shader, char **info_log,
                 glcpp_extension_iterator extensions, void *state,
                 struct gl_context *gl_ctx)
{
	int errors;
	glcpp_parser_t *parser =
		glcpp_parser_create(&gl_ctx->Extensions, extensions, state, gl_ctx->API);

	if (! gl_ctx->Const.DisableGLSLLineContinuations)
		*shader = remove_line_continuations(parser, *shader);

	glcpp_lex_set_source_string (parser, *shader);

	glcpp_parser_parse (parser);

	if (parser->skip_stack)
		glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");

	glcpp_parser_resolve_implicit_version(parser);

	ralloc_strcat(info_log, parser->info_log->buf);

	/* Crimp the buffer first, to conserve memory */
	_mesa_string_buffer_crimp_to_fit(parser->output);

	ralloc_steal(ralloc_ctx, parser->output->buf);
	*shader = parser->output->buf;

	errors = parser->error;
	glcpp_parser_destroy (parser);
	return errors;
}
Ejemplo n.º 2
0
int
preprocess(void *ralloc_ctx, const char **shader, char **info_log)
{
	int errors;
	glcpp_parser_t *parser = glcpp_parser_create ();
	*shader = remove_line_continuations(parser, *shader);

	glcpp_lex_set_source_string (parser, *shader);

	glcpp_parser_parse (parser);

	if (parser->skip_stack)
		glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");

	ralloc_strcat(info_log, parser->info_log);

	*shader = ralloc_strdup(ralloc_ctx, parser->output);

	errors = parser->error;
	glcpp_parser_destroy (parser);
	return errors;
}