Commit Graph

647 Commits

Author SHA1 Message Date
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
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
Lei Zhang
46ea5396ef Fix empty line handling in line directive callback.
The current line number for the #line directive should be passed
in as parameter to the line directive callback. Without it, we
don't know how many empty lines we should output.
2015-07-14 14:38:14 -04:00
Lei Zhang
5cbc990a0a Fix line number handling in line directive callback.
The line argument passed into the lineCallback function is the
literal value of the first argument of the #line directive.
lastLine in DoPreprocessing() should be updated taking into
consideration the different definitions for #line between specs.

Add a test to reveal the bug.
2015-07-14 14:37:59 -04:00
John Kessenich
4d036c455e Merge pull request #14 from google/extensionturnedon
Simplify function calls for extensionsTurnedOn().

Lots of places in the code use extensionsTurnedOn(1, ...). This
patch introduces a new method, extensionTurnedOn(), for testing
if a single extension is turned on.
2015-07-14 12:30:26 -06:00
John Kessenich
eebb20511f Merge pull request #11 from baldurk/size-t-int-warning-fixes
Fix warnings compiling on x64 with size_t to int casts
2015-07-14 12:25:55 -06:00
Lei Zhang
c4d20e0041 Simplify function calls for extensionsTurnedOn().
Lots of places in the code use extensionsTurnedOn(1, ...). This
patch introduces a new method, extensionTurnedOn(), for testing
if a single extension is turned on.
2015-07-14 11:26:52 -04:00
John Kessenich
3a194f7ba4 Update readme to point to Khronos landing page. 2015-07-13 11:41:06 -06:00
John Kessenich
f98ee23415 Fix incorrect used of snprintf() 2015-07-12 19:39:51 -06:00
John Kessenich
68d78fd31e Updated command-line options, adding -o for saving binaries, -G for OpenGL SPIR-V validation, -v etc.
Old uses should still work as they did before.
Also encapsulated use of these flags during parsing, for the parse context.
Added SPIR-V version to -v.
2015-07-12 19:28:10 -06:00
baldurk
d76692dfb8 on x64, size_t is 64-bit and int is 32-bit, so needs an explicit cast 2015-07-12 11:32:58 +02:00
John Kessenich
b329715caf Fix clang static analyzer issues, as reported by floooh. 2015-07-11 18:01:03 -06:00
John Kessenich
1f654e1603 Merge pull request #4 from baldurk/relative-include-paths
include by relative path, so root doesn't need to be in the search path
2015-07-11 16:41:38 -06:00
John Kessenich
549c2932af Merge pull request #5 from floooh/fix-clang-warnings
Fix for most Xcode/clang warnings on OSX
2015-07-11 16:36:08 -06:00
John Kessenich
73fcdefaac Add some missing 'const' and texture-op guards, for future change to enum-based texture calls.
The infrastructure is in place to not do text comparisons for "texture" ... for deducing type of
texture call.  But, it is not yet turned on, as it could break some consumers.  Am soliciting
any feedback on that.

See in Initialize.cpp: const bool PureOperatorBuiltins = false;  // could break backward compatibility; pending feedback
2015-07-11 13:37:02 -06:00
Andre Weissflog
a5ade51363 Fix most clang warnings
- member initializing order in some constructors
- missing default branches in switch-case
- uninitialized variable if switch-case default (uncritical because
  program would exit)
- && and || brace warnings in if()
2015-07-11 14:45:57 +02:00
baldurk
42169c5fee include by relative path, so root doesn't need to be in the search path 2015-07-08 15:27:29 +02:00
John Kessenich
e6f7988ade Linux build: fix case problem with new file. 2015-07-07 00:53:26 -06:00
John Kessenich
ff5abf34a8 Clear up a C++ compile warning 2015-07-06 21:02:26 -06:00
John Kessenich
e0603a441e Front-end: move to rational internal array-of-array interfaces and design. (A-of-A is not yet implemented though.) 2015-07-06 21:00:03 -06:00
John Kessenich
dcab977055 docs: Update missing features list 2015-07-06 14:17:11 -06:00
John Kessenich
ec43d0abec glslang -> SPIR-V: smear scalars for integer (scalar * vector). OpVectorTimesScalar is only for floats. 2015-07-04 17:17:31 -06:00
John Kessenich
9b0d9c8aa4 Use E_ prefix instead of _ for distinguishing extension strings from glext.h 2015-07-03 09:24:46 -06:00
John Kessenich
fd1e048b9c Merge pull request #2 from nwnk/glext-compatibility
Fix incompatibility with <GL/glext.h>
2015-07-03 09:15:03 -06:00
John Kessenich
7867e07631 Merge pull request #3 from fkaa/include-fix
Fix SPV include directives depending on root folder name
2015-07-03 09:12:50 -06:00
Felix Kaaman
61deffd92a Fix include directive depending on root folder name 2015-07-02 15:25:23 +02:00
Adam Jackson
93deac5295 Fix incompatibility with <GL/glext.h>
New extensions in glext.h follow the pattern:

    #ifndef GL_ARB_texture_rectangle
    #define GL_ARB_texture_rectangle 1
    #define GL_TEXTURE_RECTANGLE_ARB          0x84F5
    #define GL_TEXTURE_BINDING_RECTANGLE_ARB  0x84F6
    #define GL_PROXY_TEXTURE_RECTANGLE_ARB    0x84F7
    #define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
    #endif /* GL_ARB_texture_rectangle */

Versions.h tries to declare:

    const char* const GL_ARB_texture_rectangle = "GL_ARB_texture_rectangle";

Which means, if you've included glext.h before Versions.h, that the
compiler will see "const char* const 1 = ...", and rightly refuse to
continue.

The ham-fisted approach taken here is to rename the variables in
Versions.h with a leading underscore.  This does sort of undermine the
comment about "better to have the compiler do spelling checks", but.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2015-06-30 10:11:38 -04:00
John Kessenich
1189a7bc4a Make double underscore "__" an error for ES 300, but a warning for 310.
The 310 spec (and desktop specs) have clarified this is a waring, not an
error, but 300 tests still expect an error.
2015-06-29 17:19:17 -06:00