Commit Graph

113 Commits

Author SHA1 Message Date
Kenneth Graunke
d3073f58c1 Convert everything from the talloc API to the ralloc API. 2011-01-31 10:17:09 -08:00
Carl Worth
2a18d1950c Revert "glcpp: Demote "macro redefined" from an error to a warning"
This reverts commit d3df641f0a.

The original commit had sat unpushed on my machine for months. By the
time I found it again, I had forgotten that we had decided not to use
this change after all, (the relevant test was removed long ago).
2011-01-29 08:21:05 +10:00
Carl Worth
d3df641f0a glcpp: Demote "macro redefined" from an error to a warning
The GLSL specification is vague here, (just says "as is standard for
C++"), though the C specifications seem quite clear that this should
be an error.

However, an existing piglit test (CorrectPreprocess11.frag) expects
this to be a warning, not an error, so we change this, and document in
README the deviation from the specification.
2011-01-28 15:16:36 +10:00
Chad Versace
39cad66a88 glsl: Refresh autogenerated parser files
For commits titled:
glcpp: Conditionally define macro GL_AMD_conservative_depth
glsl: Add support for AMD_conservative_depth to parser
2011-01-26 16:37:44 -08:00
Chad Versace
0423f24eb8 glcpp: Conditionally define macro GL_AMD_conservative_depth
Define macro GL_AMD_conservative_depth to 1 when its extension is
enabled.
2011-01-26 16:37:44 -08:00
Kenneth Graunke
0db3161036 glcpp: Regenerate parser files. 2011-01-21 15:41:19 -08:00
Kenneth Graunke
6ecee54a9a glcpp: Remove use of talloc reference counting.
We almost always want to simply steal; we only need to copy when copying
a token list (in which case we're already cloning stuff anyway).
2011-01-21 15:41:19 -08:00
Ian Romanick
a302d740bd glcpp: Refresh autogenerated lexer and parser files.
For the previous commit.
2011-01-10 17:38:56 -08:00
Ian Romanick
9ca5300b6e glcpp: Generate an error for division by zero
When GCC encounters a division by zero in a preprocessor directive, it
generates an error.  Since the GLSL spec says that the GLSL
preprocessor behaves like the C preprocessor, we should generate that
same error.

It's worth noting that I cannot find any text in the C99 spec that
says this should be an error.  The only text that I can find is line 5
on page 82 (section 6.5.5 Multiplicative Opertors), which says,

    "The result of the / operator is the quotient from the division of
    the first operand by the second; the result of the % operator is
    the remainder. In both operations, if the value of the second
    operand is zero, the behavior is undefined."

Fixes 093-divide-by-zero.c test and bugzilla #32831.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-01-10 17:37:51 -08:00
Chad Versace
4e09a786d2 glcpp: Regenerate glcpp-parse.c 2011-01-10 17:28:24 -08:00
Chad Versace
4fff52f1c9 glcpp: Fix segfault when validating macro redefinitions
In _token_list_equal_ignoring_space(token_list_t*, token_list_t*), add
a guard that prevents dereferncing a null token list.

This fixes test src/glsl/glcpp/tests/092-redefine-macro-error-2.c and
Bugzilla #32695.
2011-01-10 17:28:24 -08:00
Vinson Lee
5a3f31575b glcpp: Add test for recursive #define. 2011-01-04 16:39:19 -08:00
Vinson Lee
6530944b50 glcpp: Add division by zero test cases. 2011-01-04 13:18:19 -08:00
Vinson Lee
f3319561a4 glcpp: Add negative tests for redefintions with valueless macros. 2010-12-27 23:20:35 -08:00
Kenneth Graunke
bd74101aeb Refresh autogenerated glcpp parser. 2010-12-07 10:52:59 -08:00
Kenneth Graunke
800eed6765 glcpp: Don't emit SPACE tokens in conditional_tokens production.
Fixes glslparsertest defined-01.vert.

Reported-by: José Fonseca <jfonseca@vmware.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2010-12-07 10:52:36 -08:00
Kenneth Graunke
302fe4049c Regenerate glcpp parser. 2010-11-17 12:53:07 -08:00
Kenneth Graunke
d719bf8fb4 glsl: Unconditionally define GL_FRAGMENT_PRECISION_HIGH in ES2 shaders.
This is really supposed to be defined only if the driver supports highp
in the fragment shader - but all of our current ES2 implementations do.
So, just define it.  In the future, we'll need to add a flag to
gl_context and only define the macro if the flag is set.

"Fixes" freedesktop.org bug #31673.
2010-11-17 12:50:35 -08:00
Kenneth Graunke
bee901a1cf Refresh autogenerated glcpp parser. 2010-11-16 16:22:13 -08:00
Kenneth Graunke
3fb83038a0 glcpp: Define GL_FRAGMENT_PRECISION_HIGH if GLSL version >= 1.30.
Per section 4.5.4 of the GLSL 1.30 specification.
2010-11-16 16:22:12 -08:00
Benjamin Franzke
46c1970067 r600g: implement texture_get_handle (needed for eglExportDRMImageMESA) 2010-11-08 13:44:54 -05:00
Kenneth Graunke
94a36faed7 glcpp: Refresh autogenerated lexer file. 2010-10-21 00:13:33 -07:00
Kenneth Graunke
bd55ba568b glcpp: Return NEWLINE token for newlines inside multi-line comments.
This is necessary for the main compiler to get correct line numbers.
2010-10-21 00:13:33 -07:00
Ian Romanick
3322fbaf3b glsl: Slightly change the semantic of _LinkedShaders
Previously _LinkedShaders was a compact array of the linked shaders
for each shader stage.  Now it is arranged such that each slot,
indexed by the MESA_SHADER_* defines, refers to a specific shader
stage.  As a result, some slots will be NULL.  This makes things a
little more complex in the linker, but it simplifies things in other
places.

As a side effect _NumLinkedShaders is removed.

NOTE: This may be a candidate for the 7.9 branch.  If there are other
patches that get backported to 7.9 that use _LinkedShader, this patch
should be cherry picked also.
2010-10-14 17:16:59 -07:00
Ian Romanick
eafebed5bd glcpp: Regenerate files changes by previous commit 2010-10-08 14:21:22 -07:00
Ian Romanick
e0c9f67be5 glcpp: Add the define for ARB_explicit_attrib_location when present 2010-10-08 14:21:22 -07:00
Kenneth Graunke
48e789d71e glcpp: Fix build on non-GCC compilers. 2010-09-07 18:01:33 -07:00
Kenneth Graunke
7dcfc44b72 glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.
Also define it if #version 100 is encountered.
2010-09-07 17:30:37 -07:00
Brian Paul
1be5d1c887 glsl2: remove 'extern' keyword in .c file 2010-08-27 14:30:59 -06:00
Aras Pranckevicius
653ddaab26 glsl/mesa: fixes for MSVC
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-08-25 09:21:10 -06:00
Chia-I Wu
bfd7c9ac22 glsl: Include main/core.h.
Make glsl include only main/core.h from core mesa.
2010-08-24 11:27:29 +08:00
Carl Worth
61f73fec53 glcpp: Make standalone preprocessor work with a tty as stdin
Previously glcpp would silently abort if it couldn't fstat the file being
read, (so it would work with stdin redirected from a file, but would not
work with stdin as a tty). The stat was so that glcpp could allocate
a buffer for the file content in a single call.

We now use talloc_realloc instead, (even if the fstat is
possible). This is theoretically less efficient, but quite irrelevant,
(particularly because the standalone preprocessor is used only for
testing).
2010-08-23 10:48:10 -07:00
Carl Worth
21560c40e8 glcpp: Fix test suite to avoid flagging failed tests as valgrind errors.
We recently added several tests that intentionally trigger
preprocessor errors. During valgrind-based testing, our test script
was noticing the non-zero return value from the preprocessor and
incorrectly flagging the valgrind-based test as failing.

To fix this, we make valgrind return an error code that is otherwise
unused by the preprocessor.
2010-08-23 10:48:10 -07:00
Carl Worth
cf8bb19a11 glcpp: Fix segfault in standalone preprocessor for "file not found", etc.
This error message was missing so that the program would simply
segfault if the provided filename could not be opened for some reason.

While we're at it, we add explicit support for a filename of "-" to
indicate input from stdin.
2010-08-23 10:48:10 -07:00
Carl Worth
eab206510f glcpp: Update generated glcpp-lex.c for the last two changes.
This fixes both "#line 0" and "#line XXX YYY" as described in the two
most recent commits.
2010-08-23 10:48:10 -07:00
Carl Worth
c2280e6381 glcpp: Fix handling of "#line 0"
The existing DECIMAL_INTEGER pattern is the correct thing to use when
looking for a C decimal integer, (that is, a digit-sequence not
starting with 0 which would instead be an octal integer).

But for #line, we really want to accept any digit sequence, (including
"0"), and always interpret it as a decimal constant. So we add a new
DIGITS pattern for this case.

This should fix the compilation failure noted in bug #28138

	https://bugs.freedesktop.org/show_bug.cgi?id=28138

(Though the generated file will not be updated until the next commit.)
2010-08-23 10:48:10 -07:00
Carl Worth
ff10d239af glcpp: Fix source numbers set with "#line LINE_NUMBER SOURCE_NUMBER"
Previously, the YY_USER_ACTION was overwriting the yylloc->source value
in every action, (after that value had been carefully set by the handling
of the #line directive). Instead, we want to initialize it once in
YY_USER_INIT and then not touch it at all in YY_USER_ACTION.
2010-08-23 10:48:10 -07:00
Carl Worth
2a9e791fde glcpp: Add new test for #line directive.
This test exposes two current bugs:

	1. The source number is not being correctly emitted in error
	   messages (instead, it's always 0).

	2. A directive of "#line 0" is resulting in the following
	   parse error:

		preprocessor error: Invalid tokens after #
2010-08-23 10:48:10 -07:00
Carl Worth
c15f04b326 glcpp: Update README file (new specifications and fewer limitations).
The README file had grown a little bit stale. We've been using newer
versions of both the GLSL and C99 specifications, so list those. Also,
several of the documented known limitations have since been fixed, so
remove those.
2010-08-23 10:48:10 -07:00
Carl Worth
0acd68c405 glcpp: Add test for the #error directive.
This directive is already implemented nicely, but wasn't previously tested.
It will be convenient to use this directive in further tests that rely
on error messages, (such as ensuring that #line correctly sets the line
number in the error message).
2010-08-23 10:48:10 -07:00
Kenneth Graunke
bd7853768d glcpp: Refresh autogenerated lexer. 2010-08-18 17:38:47 -07:00
Kenneth Graunke
9cf62bdfeb glcpp: Add basic #line support (adapted from the main compiler). 2010-08-18 17:38:47 -07:00
Carl Worth
9751b4ec60 glcpp: Refresh generated files.
After a recent change to glcpp-parse.y (adding "redefined macro" error).
2010-08-17 23:41:53 -07:00
Carl Worth
3882cf2169 glcpp: Add support for "redefined macro" error.
Carefully avoiding printing any error when the new definition matches
the existing definition.

This fixes the recently-added 088-redefine-macro-legitimate.c and
089-redefine-macro-error.c tests as well as glsparsertest/preprocess1
in piglit.
2010-08-17 23:41:53 -07:00
Carl Worth
105e2137d6 glcpp: Add two new tests for testing redefined macros.
The specification says that redefining a macro is an error, unless the
new definitions is identical to the old one, (identical replacement
lists but ignoring differing amounts of whitespace).
2010-08-17 23:41:53 -07:00
Carl Worth
97638aa77c glcpp: Allow standalone glcpp to accept a filename as first argument.
This is useful for debugging the preprocessor.
2010-08-17 23:41:53 -07:00
Carl Worth
ce5d0a296c glcpp: Fix 064-version.c expected result to track recent change.
In commit 6be3a8b70a, the #version directive
was fixed to stop generating a spurious newline. Here we simply update
the expected result for the single test which includes a #version directive.
2010-08-17 22:23:43 -07:00
Carl Worth
b9892f22d1 glcpp: Regenerated glcpp-lex.c from previous commit.
The previous commit changed glcpp-lex.l so we commit the resulting
generated file here.
2010-08-17 22:22:13 -07:00
Carl Worth
eb26f0d5b6 glcpp: Don't include the newline when discarding single-line comments
Matching the newline here meant having to do some redundant work here,
(incrementing line number, resetting column number, and returning a
NEWLINE token), that could otherwise simply be left to the existing rule
which matches a newline.

Worse, when the comment rule matches the newline as well, the parser
can lookahead and see a token for something that should actually be skipped.

For example, in a case like this:

	#if 0 // comment here
	fail
	#else
	win
	#endif

Both fail and win appear in the output, (not that the condition is being
evaluated incorrectly---merely that one token after the comment's newline
was being lexed/parse regardless of the condition).

This commit fixes the above test case, (which is also remarkably similar
to 087-if-comments which now passes).
2010-08-17 22:17:09 -07:00
Eric Anholt
ede67e3071 glcpp: Add testcase for #if handling bug that breaks Savage2. 2010-08-17 17:51:10 -07:00