Commit Graph

1722 Commits

Author SHA1 Message Date
John Kessenich
f48faec3ee PP: Non-functional: Make a proper class out of the atom <-> string mapping. 2016-12-21 13:49:16 -07:00
John Kessenich
224b1f733b PP: Support operator creation with token pasting. 2016-12-21 12:32:56 -07:00
John Kessenich
0c4b7c931a PP: Rationalize names of tokens. 2016-12-21 11:55:53 -07:00
John Kessenich
2dcdda921f Merge pull request #641 from chaoc/passthrough
Add support for SPV_NV_geometry_shader_passthrough
2016-12-21 10:59:07 -07:00
John Kessenich
906b0a3e60 Merge pull request #644 from hrydgard/override-warning-fixes
Fix a large number of Clang warnings about inconsistent usage of 'override'
2016-12-21 10:50:33 -07:00
Henrik Rydgård
9a931b39bc Fix a large number of warnings about inconsistent usage of 'override' produced by clang 2016-12-21 12:48:08 +01:00
John Kessenich
907aabb6b0 PP: Non-functional: Only use string <-> atom mapping when needed.
Also, eliminate the 'atom' field of TPpToken.

Parsing a real 300 line shader, through to making the AST, is about 10% faster.

Memory is slightly reduced (< 1%).

The whole google-test suite, inclusive of all testing overhead, SPIR-V generation,
etc., runs 3% faster.

Since this is a code *simplification* that leads to perf. improvement, I'm not
going to invest too much more in measuring the perf. than this. The PP code is
simply now in a better state to see how to further rationalize/improve it.
2016-12-20 23:36:05 -07:00
John Kessenich
54af2de761 PP: Non-functional: rationalize TPpToken.
Always keep 'token' outside.
Always return the string to upper levels inside.
2016-12-20 19:42:53 -07:00
John Kessenich
1fbb9c1430 PP: Non-functional: clean up, simplify, completely identical operation. 2016-12-20 18:36:49 -07:00
chaoc
6e5acae144 Add support for SPV_NV_geometry_shader_passthrough 2016-12-20 13:28:52 -08:00
John Kessenich
3c264ce8f3 Merge pull request #639 from hrydgard/master
CMake: Add option to make it possible to not build the executables
2016-12-20 11:02:11 -07:00
John Kessenich
7a21a11528 Merge pull request #638 from chaoc/master
Add support for SPV_NV_sample_mask_override_coverage
2016-12-20 11:01:21 -07:00
John Kessenich
b8387c87d0 PP: Non-functional: Remove custom allocator and related improvements.
Removed the preprocesser memory pool.

Removed extra copies and unnecessary allocations of objects related to the ones
that were using the pool.

Replaced some allocated pointers with objects instead, generally using more
modern techiques. There end up being fewer memory allocations/deletions to get right.

Overall combined effect of all changes is to use slightly less memory and
run slightly faster (< 1% for both, but noticable).

As part of simplifying the code base, this change makes it easier to see
PP symbol tracking, which I suspect has an even bigger run-time simplification
to make.
2016-12-19 21:57:06 -07:00
Henrik Rydgård
868746ad55 Add option to make it possible not to build the executables 2016-12-20 01:56:00 +01:00
John Kessenich
bfff871dad PP: Add missing i64val code.
Also, checking both 'atom' and 'name' is redundant, and I'm hoping to
eliminate more atom stuff.
2016-12-19 17:46:20 -07:00
chaoc
0ad6a4e60d Add support for SPV_NV_sample_mask_override_coverage 2016-12-19 16:29:34 -08:00
chaoc
7583ed73ef Merge remote-tracking branch 'refs/remotes/KhronosGroup/master' 2016-12-19 16:21:14 -08:00
John Kessenich
432576fdce Build: Fix #633, add missing overrides. 2016-12-19 14:43:42 -07:00
John Kessenich
0955b1cb35 Merge pull request #637 from KhronosGroup/token-paste
PP: Implement token pasting for PP identifiers.
2016-12-19 14:31:57 -07:00
John Kessenich
e6cbc5b19d Merge pull request #624 from steve-lunarg/remapper-strip-removed
WIP: Remapper: remove debug info for IDs stripped in other passes
2016-12-19 14:07:58 -07:00
John Kessenich
4ba444b61c Merge pull request #635 from steve-lunarg/sample-fix-2
HLSL: allow "sample" in expressions.
2016-12-19 13:30:29 -07:00
John Kessenich
059d46ee45 Merge pull request #625 from jbeich/gcc6
Unbreak build on FreeBSD with GCC/libstdc++ 6.2.0
2016-12-19 13:30:06 -07:00
John Kessenich
d485e0b710 PP: Implement token pasting for PP identifiers.
Implement token pasting as per the C++ specification, within the current
style of the PP code.
Non-identifiers (turning 12 ## 10 into the numeral 1210) is not yet covered;
they should be a simple incremental change built on this one.
Addresses issue #255.
2016-12-19 09:19:43 -07:00
steve-lunarg
a64ed3eba0 HLSL: allow "sample" in expressions.
Unlike other qualifiers, HLSL allows "sample" to be either a qualifier keyword or an
identifier (e.g, a variable or function name).

A fix to allow this was made a while ago, but that fix was insufficient when 'sample'
was used in an expression.  The problem was around the initial ambiguity between:

   sample float a; // "sample" is part of a fully specified type
and
   sample.xyz;     // sample is a keyword in a dot expression

Both start the same.  The "sample" was being accepted as a qualifier before enough
further parsing was done to determine we were not a declaration after all.  This
consumed the token, causing it to fail for its real purpose.

Now, when accepting a fully specified type, the token is pushed back onto the stack if
the thing is not a fully specified type.  This leaves it available for subsequent
purposes.

Changed the "hlsl.identifier.sample.frag" test to exercise this situation, distilled
down from a production shaders.
2016-12-18 18:01:34 -07:00
John Kessenich
abf5057948 Fix comment typo. 2016-12-16 17:11:18 -07:00
John Kessenich
1e275c8486 HLSL: More robust handling of bad shader input, catching a few more things. 2016-12-14 17:02:32 -07:00
John Kessenich
dca93d6baa Merge pull request #629 from null77/fix-unicode
Change unicode dash to ASCII.
2016-12-14 15:15:41 -07:00
Jamie Madill
cebd97eb24 Change unicode dash to ASCII.
This change is helpful for integration with Chromium, which recently
added a compiler option to warn when compiling any source files which
use extended characters. In this case the offending character was a
single unicode dash in a comment.
2016-12-14 15:48:56 -05:00
John Kessenich
95abd284dd Merge pull request #628 from null77/fix-cast-warn
Fix size_t to int cast warnings.
2016-12-13 19:32:01 -07:00
Jamie Madill
3ec327c5a5 Fix size_t to int cast warnings.
Several instances in Visual Studio 2015:

warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
2016-12-13 17:33:07 -05:00
John Kessenich
20f01e7fd0 Fix last commit; EOptionKeepUncalled incorrect enum bug. 2016-12-12 11:41:43 -07:00
steve-lunarg
297754cfe8 Remapper: remove debug info for IDs stripped in other passes
If some DCE is performed such as removing dead functions, then even
if we are NOT stripping debug info, we still must remove the debug
opcodes that refer to the now-dead IDs.

Also, this adds a small change to perform no ID remapping if none
is requested, making spirv-remap properly be a no-op if no options
are given.
2016-12-12 09:01:11 -07:00
John Kessenich
906cc21816 Linker: Eliminate uncalled functions, because they can be ill-defined.
Fixes issue #610. Also provides a testing option to keep uncalled functions.
2016-12-09 19:22:20 -07:00
John Kessenich
bf6d7f43fd Linker: Track the mangled entry-point name along with the non-mangled one. 2016-12-09 17:29:07 -07:00
John Kessenich
4b6ce415ef GLSL Linker: Track entry point across compilation units.
This wasn't needed until the recent generalization of "main" to "entry point",
so makes some HLSL-specific code be generic now, for GLSL functional correctness.
2016-12-09 17:14:27 -07:00
Jan Beich
1bcb254a30 Add missing header and drop duplicate one
In file included from C:/Projects/glslang/glslang/MachineIndependent/glslang.y:59:0:
glslang/MachineIndependent/ParseHelper.h:276:24: error: 'va_list' has not been declared
                        va_list args);
                        ^~~~~~~
2016-12-09 22:40:55 +00:00
John Kessenich
6a60c2f9ea Linker: Walk the call graph to report an error on missing bodies. 2016-12-08 23:22:21 -07:00
John Kessenich
e795cc915c Merge pull request #621 from steve-lunarg/recursive-flattening
HLSL: Recursive composite flattening
2016-12-08 11:18:07 -07:00
John Kessenich
302e619e4e Merge pull request #619 from steve-lunarg/opcode-specific-promote
HLSL: opcode specific promotion rules for interlocked ops
2016-12-08 11:17:21 -07:00
John Kessenich
56b4547624 Merge pull request #620 from fjhenigman/foo
GLSL: Always define TShader::~Includer().
2016-12-08 11:15:59 -07:00
steve-lunarg
a2b01a0da8 HLSL: Recursive composite flattening
This PR implements recursive type flattening.  For example, an array of structs of other structs
can be flattened to individual member variables at the shader interface.

This is sufficient for many purposes, e.g, uniforms containing opaque types, but is not sufficient
for geometry shader arrayed inputs.  That will be handled separately with structure splitting,
 which is not implemented by this PR.  In the meantime, that case is detected and triggers an error.

The recursive flattening extends the following three aspects of single-level flattening:

- Flattening of structures to individual members with names such as "foo[0].samp[1]";

- Turning constant references to the nested composite type into a reference to a particular
  flattened member.

- Shadow copies between arrays of flattened members and the nested composite type.

Previous single-level flattening only flattened at the shader interface, and that is unchanged by this PR.
Internally, shadow copies are, such as if the type is passed to a function.

Also, the reasons for flattening are unchanged.  Uniforms containing opaque types, and interface struct
types are flattened.  (The latter will change with structure splitting).

One existing test changes: hlsl.structin.vert, which did in fact contain a nested composite type to be
flattened.

Two new tests are added: hlsl.structarray.flatten.frag, and hlsl.structarray.flatten.geom (currently
issues an error until type splitting is online).

The process of arriving at the individual member from chained postfix expressions is more complex than
it was with one level.  See large-ish comment above HlslParseContext::flatten() for details.
2016-12-07 14:40:01 -07:00
steve-lunarg
05f75142d6 HLSL: opcode specific promotion rules for interlocked ops
PR #577 addresses most but not all of the intrinsic promotion problems.
This PR resolves all known cases in the remainder.

Interlocked ops need special promotion rules because at the time
of function selection, the first argument has not been converted
to a buffer object.  It's just an int or uint, but you don't want
to convert THAT argument, because that implies converting the
buffer object itself.  Rather, you can convert other arguments,
but want to stay in the same "family" of functions.  E.g, if
the first interlocked arg is a uint, use only the uint family,
never the int family, you can convert the other args as you please.

This PR allows making such opcode and arg specific choices by
passing the op and arg to the convertible lambda.  The code in
the new test "hlsl.promote.atomic.frag" would not compile without
this change, but it must compile.

Also, it provides better handling of downconversions (to "worse"
types), which are permitted in HLSL.  The existing method of
selecting upconversions is unchanged, but if that doesn't find
any valid ones, then it will allow downconversions.  In effect
this always uses an upconversion if there is one.
2016-12-07 12:00:32 -07:00
Frank Henigman
8dcf20298f GLSL: Always define TShader::~Includer().
Rather than update the existing ifdef to cover all necessary cases,
get rid of it and always define TShader::~Includer().
2016-12-06 16:37:07 -05:00
John Kessenich
b56f4ac72c Merge pull request #615 from dneto0/consistent-location-for-test-files
runtests should refer to test files in current directory
2016-12-06 00:48:11 -07:00
John Kessenich
9df6aa5361 GLSL: Allow desktop shaders to call functions from outside main().
Fixes issue #239.
2016-12-05 21:36:48 -07:00
John Kessenich
ec2e27adf8 Merge pull request #613 from Corillian/hlslpreprocess
Fixed processing #include's when preprocessing HLSL
2016-12-05 10:25:02 -07:00
David Neto
5cc92c5623 runtests should refer to test files in current directory
Recently added entry point renaming file referred to
test source file hlsl.entry.rename.frag via relative directory.

Change it to be consistent with other tests: assume test
sources are in the current directory.
2016-12-05 11:31:18 -05:00
Keith Newton
205dc4e4ec Fixed processing #include's when preprocessing HLSL 2016-12-04 17:07:10 -05:00
John Kessenich
fb06e9552e Don't print the "Linked stage" message unless the AST is being dumped. 2016-12-03 13:59:51 -07:00
John Kessenich
09512cbd5c Merge branch 'steve-lunarg-intrinsic-promotion' 2016-12-03 13:29:46 -07:00