glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.
Also define it if #version 100 is encountered.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,9 @@
|
||||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.3. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "glcpp.h"
|
||||
#include "main/core.h" /* for struct gl_extensions */
|
||||
#include "main/mtypes.h" /* for gl_api enum */
|
||||
|
||||
#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
|
||||
#define glcpp_printf(stream, fmt, args, ...) \
|
||||
@@ -309,6 +310,9 @@ control_line:
|
||||
_glcpp_parser_skip_stack_pop (parser, & @1);
|
||||
}
|
||||
| HASH_VERSION integer_constant NEWLINE {
|
||||
if ($2 == 100)
|
||||
add_builtin_define (parser, "GL_ES", 1);
|
||||
|
||||
macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
|
||||
if (macro) {
|
||||
hash_table_remove (parser->defines, "__VERSION__");
|
||||
@@ -1048,7 +1052,7 @@ static void add_builtin_define(glcpp_parser_t *parser,
|
||||
}
|
||||
|
||||
glcpp_parser_t *
|
||||
glcpp_parser_create (const struct gl_extensions *extensions)
|
||||
glcpp_parser_create (const struct gl_extensions *extensions, int api)
|
||||
{
|
||||
glcpp_parser_t *parser;
|
||||
int language_version;
|
||||
@@ -1078,6 +1082,9 @@ glcpp_parser_create (const struct gl_extensions *extensions)
|
||||
add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
|
||||
add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
|
||||
|
||||
if (api == API_OPENGLES2)
|
||||
add_builtin_define(parser, "GL_ES", 1);
|
||||
|
||||
if (extensions != NULL) {
|
||||
if (extensions->EXT_texture_array) {
|
||||
add_builtin_define(parser, "GL_EXT_texture_array", 1);
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "glcpp.h"
|
||||
#include "main/mtypes.h"
|
||||
|
||||
extern int yydebug;
|
||||
|
||||
@@ -111,7 +112,7 @@ main (int argc, char *argv[])
|
||||
if (shader == NULL)
|
||||
return 1;
|
||||
|
||||
ret = preprocess(ctx, &shader, &info_log, NULL);
|
||||
ret = preprocess(ctx, &shader, &info_log, NULL, API_OPENGL);
|
||||
|
||||
printf("%s", shader);
|
||||
fprintf(stderr, "%s", info_log);
|
||||
|
@@ -180,7 +180,7 @@ struct glcpp_parser {
|
||||
struct gl_extensions;
|
||||
|
||||
glcpp_parser_t *
|
||||
glcpp_parser_create (const struct gl_extensions *extensions);
|
||||
glcpp_parser_create (const struct gl_extensions *extensions, int api);
|
||||
|
||||
int
|
||||
glcpp_parser_parse (glcpp_parser_t *parser);
|
||||
@@ -190,7 +190,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser);
|
||||
|
||||
int
|
||||
preprocess(void *talloc_ctx, const char **shader, char **info_log,
|
||||
const struct gl_extensions *extensions);
|
||||
const struct gl_extensions *extensions, int api);
|
||||
|
||||
/* Functions for writing to the info log */
|
||||
|
||||
|
@@ -143,10 +143,10 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
|
||||
|
||||
int
|
||||
preprocess(void *talloc_ctx, const char **shader, char **info_log,
|
||||
const struct gl_extensions *extensions)
|
||||
const struct gl_extensions *extensions, int api)
|
||||
{
|
||||
int errors;
|
||||
glcpp_parser_t *parser = glcpp_parser_create (extensions);
|
||||
glcpp_parser_t *parser = glcpp_parser_create (extensions, api);
|
||||
*shader = remove_line_continuations(parser, *shader);
|
||||
|
||||
glcpp_lex_set_source_string (parser, *shader);
|
||||
|
Reference in New Issue
Block a user