673 Commits

Author SHA1 Message Date
John Kessenich
aead93aafd Preprocessor: Allow '\' as a token, which gets actual use in #error, but should have no other use.
This is just for '\' that's not before a new line.
Note the specification says it has no use other than as line continuation,
but #error is a grey area. (There are no escape sequences.)
2015-07-25 17:34:32 -06:00
John Kessenich
f330f08129 Consolidate all token length limits (1024), including one bad one (80) hardcoded on the stack (issue #40, issue #41). 2015-07-25 14:02:53 -06:00
John Kessenich
1070e629a9 Merge pull request #44 from fkaa/osx-const-key-fix
Fix missing const qualifier on TUnorderedMap template type
2015-07-25 12:51:02 -06:00
Felix Kaaman
09d16c3ec1 Fix missing const qualifier on TUnorderedMap template type 2015-07-25 16:31:50 +02:00
John Kessenich
2b3442ada1 Portability: Make previous merge work with MSVS 2012. 2015-07-24 15:15:55 -06:00
John Kessenich
b159bd5821 Merge pull request #38 from google/preprocessing-line-number
Preprocessing line number handling
2015-07-24 15:05:17 -06:00
Lei Zhang
79f6451b53 DoPreprocessing() should consider source string change.
Everytime we switch to a new source string, the line are reset.
We need to reset lastLine and also output newlines appropriately.
2015-07-23 12:29:19 -04:00
Lei Zhang
d67e15e9b4 Create a new class to keep track of line number in preprocessor.
SourceLineSynchronizer is added for keeping track of the last
line number and output newlines appropriately if we switch to
a new line in the preprocessor.
2015-07-23 12:29:19 -04:00
John Kessenich
62aa5bdfca AST -> SPV testing: Update test for using new TbdFunctionality() that is non-fatal and uniquifies printed TBDs. 2015-07-23 10:25:20 -06:00
John Kessenich
426394d0c8 AST -> SPV: Add basic atomic_uint and atomic*() built-in function functionality. 2015-07-23 10:22:48 -06:00
John Kessenich
917ec4ac8c Front-end atomics: Finish adding atomic built-in functions (non-image) into the AST. 2015-07-22 19:58:15 -06:00
John Kessenich
d1a6846ba2 Todo.txt: Added key, including notation for who's working on something. 2015-07-22 16:39:12 -06:00
John Kessenich
7ed16efaf6 Update Todo.txt. 2015-07-22 16:36:38 -06:00
John Kessenich
c040e76c58 Portability: Remove unneeded "= default" to work with older compilers. 2015-07-22 15:25:59 -06:00
John Kessenich
96d8042a64 Merge pull request #31 from google/explicit-extension-directive
Only output explicit extension directives in preprocessing.
2015-07-22 15:20:54 -06:00
John Kessenich
12a383379c Issue 32: Guard against constructors consuming unsized arrays. 2015-07-22 11:44:59 -06:00
John Kessenich
f498400945 Merge pull request #33 from google/spv-builder-loop-ctor-inits-all-members
spv::Builder::Loop constructor inits all members.
2015-07-22 11:39:29 -06:00
David Neto
3e6a33cedf spv::Builder::Loop constructor inits all members.
After construction, the Loop is effectively const.

This perturbs the IDs in SPIR-V tests because the body block
is created before generating any of the loop code, rather than
only when the body is first referenced.
2015-07-22 12:24:21 -04:00
John Kessenich
8ba301c7c2 Issue #28: Correctly handle a single input argument conversion when the input argument is an aggregate. 2015-07-21 16:00:34 -06:00
Lei Zhang
1d2996db68 Only output explicit extension directives in preprocessing.
Preprocessing output shouldn't contain extensions enabled as
dependencies.
2015-07-21 17:47:47 -04:00
John Kessenich
efb8461722 Issue #26: Detect empty array constructors, require at least on operand. 2015-07-21 14:35:39 -06:00
John Kessenich
222457054e g++: Fix compilation issue with templates in g++. 2015-07-21 00:07:52 -06:00
John Kessenich
1056110c30 Perf: Put in a portable std::hash that works with the pool. This turns on the 10-15% perf gain. 2015-07-20 23:59:32 -06:00
John Kessenich
96f4911351 SPV: Make previous commit compile with MSVC 2012. 2015-07-20 22:34:49 -06:00
John Kessenich
37e8337958 Merge pull request #22 from google/structured-do-while
Generate correctly structured do-while loops.
2015-07-20 22:14:38 -06:00
John Kessenich
d2762564dc Preprocessor: Prevent (and give an error on) expression division by 0. 2015-07-20 12:29:41 -06:00
John Kessenich
e9022e1ffe Tests: Increase testing around incorrect use of block names and instances. 2015-07-20 12:03:04 -06:00
John Kessenich
78a5a0d7d8 Front end: Prevent use of a block name, which has no other use in a shader. 2015-07-20 11:35:51 -06:00
John Kessenich
68965c0fa9 Fix g++ build break (portibility problems with stl hash). This partly turns off the stl improvements.
It also removes some old code that ancient compilers used to need.
However, the main issue is getting access to hash functions for
unordered_map in portable way.
2015-07-20 02:06:22 -06:00
John Kessenich
6ab3d582d6 Preprocessor: 1) Rationalize the "fixed atom" scheme, 2) remove redundant lookups when the text is already available.
This simplification is a prelude to eliminating what I appear unnecessary
symbol inserts into tables when tokenizing in the preprecessor, which
show up as taking notable time. (Performance issue.)  It also simply makes
the preprocessor easier to understand, which it is badly in need of.
2015-07-19 22:59:24 -06:00
John Kessenich
2f273369e4 Performance: Simple upgrade/cleanup of stl c++11 containers (10% perf. increase). 2015-07-19 12:03:51 -06:00
John Kessenich
f4673162b7 Building: Fix a couple of new warnings. 2015-07-18 11:25:54 -06:00
John Kessenich
2b4b9bd65b Front-end: Add error-recovery code for a switch statement that ends with a case/default that has no statements. 2015-07-18 11:13:14 -06:00
David Neto
c22f37cfb4 Generate correctly structured do-while loops.
The loop test is always emitted before the loop body.

For do-while loops, use a phi node to track whether we're
on the first loop iteration, and only check the loop test
on the second and subsequent iterations.

For do-while loops, the loop test branch no longer occurs
at the top of the loop, so it must get its own selection
merge instruction.

A block can't be the target of more than one merge instruction.
So when the loop test executes after the body (as in do-while in GLSL)
we need to introduce a dummy block to be the target of the selection
merge just before the loop test conditional branch.

The other arm of the branch exits the loop and hence is the
"break block" exception in the structured control flow rules.
2015-07-17 17:51:51 -04:00
John Kessenich
51b31b5785 Merge pull request #21 from google/allow_non_null_strings
Added a setStringsWithLengths() method to TShader.
2015-07-17 11:51:56 -06:00
John Kessenich
72becbe5a2 Merge pull request #20 from google/remove_exception
Removed the single usage of exceptions in all of glslang.
2015-07-17 11:45:31 -06:00
Andrew Woloszyn
6a6aaeffd3 Added a setStringsWithLengths() method to TShader.
This allows us to pass through non null-terminated strings.
2015-07-17 13:37:02 -04:00
Andrew Woloszyn
e837f99afb Removed the single usage of exceptions in all of glslang. 2015-07-17 13:31:25 -04:00
John Kessenich
e3933d684d Front-end: Implement GL_OES_gpu_shader5. 2015-07-15 19:42:59 -06:00
John Kessenich
ace4c45afc Merge pull request #18 from srk-lunarg/v30_static_analysis_fixes
Comment out some dead assignments per suggestion from static analysis…
2015-07-15 15:06:39 -06:00
Steve
465a14666a Comment out some dead assignments per suggestion from static analysis tools.
Code is left in as comments for clarity to humans.
2015-07-15 14:34:35 -06:00
John Kessenich
a417f01041 Merge pull request #17 from google/non-existing-string
Protect location setting methods from writing to non-existing strings.
2015-07-15 14:03:33 -06:00
Lei Zhang
6c9a38161b Protect location setting methods from writing to non-existing strings.
TInputScanner advances its internal indices to the next character at
the end of get(), which means, after reading in the last character
in the user-provided shader string, internal index (currentSource)
will point to the next shader string (currentSource == numSources),
which doesn't exist. Then if a location setting method is called,
we will write to some out-of-bound memory.

A test case for this is "#line 10000\n". The eval() method in CPPline()
will evaluate 10000, but at the same time it reads in the next
token, '\n', and the currentSource will be numSources in TInputScanner.
Then a parseContext.setCurrentLine() is called, we are writing to
out-of-bound memory. Another test case will be "#line 10000 0\n".
2015-07-15 13:03:27 -04:00
John Kessenich
9e55f633bc Include specification revision as part of the version string. 2015-07-15 10:03:39 -06:00
John Kessenich
279012d8c4 Merge pull request #16 from google/pp-directive
Preprocessing directive handling
2015-07-14 19:36:29 -06:00
John Kessenich
fdfa6bbdfe Front-end: enforce qualifiers that cannot appear on block declarations.
Also seems to pick up some white-space (line-ending) test differences with a
prevoius checkin.
2015-07-14 19:30:11 -06:00
John Kessenich
8318878c89 Fix compile errors: about 25 .PpError didn't compile, need to be .ppError. 2015-07-14 15:33:38 -06:00
John Kessenich
4a22f9a4e2 Merge pull request #15 from google/preprocessing-error
Added error output to the preprocessor.

This patch distinguishes preprocessing errors with normal parsing
errors and gives glslangValidator the ability to output preprocessing
errors.
2015-07-14 15:29:13 -06:00
Andrew Woloszyn
aae1ad8296 Added error output to the preprocessor.
This patch distinguishes preprocessing errors with normal parsing
errors and gives glslangValidator the ability to output preprocessing
errors.
2015-07-14 16:02:25 -04:00
Lei Zhang
6aa6d9d3d0 Remove uncessary line break.
We output empty lines before processing non-whitespace tokens,
not after done processing them.
2015-07-14 14:39:19 -04:00