platform/upstream/glslang.git
7 years agoPP: Add missing i64val code.
John Kessenich [Mon, 19 Dec 2016 22:32:04 +0000 (15:32 -0700)]
PP: Add missing i64val code.

Also, checking both 'atom' and 'name' is redundant, and I'm hoping to
eliminate more atom stuff.

7 years agoBuild: Fix #633, add missing overrides.
John Kessenich [Mon, 19 Dec 2016 21:43:42 +0000 (14:43 -0700)]
Build: Fix #633, add missing overrides.

7 years agoMerge pull request #637 from KhronosGroup/token-paste
John Kessenich [Mon, 19 Dec 2016 21:31:57 +0000 (14:31 -0700)]
Merge pull request #637 from KhronosGroup/token-paste

PP: Implement token pasting for PP identifiers.

7 years agoMerge pull request #624 from steve-lunarg/remapper-strip-removed
John Kessenich [Mon, 19 Dec 2016 21:07:58 +0000 (14:07 -0700)]
Merge pull request #624 from steve-lunarg/remapper-strip-removed

WIP: Remapper: remove debug info for IDs stripped in other passes

7 years agoMerge pull request #635 from steve-lunarg/sample-fix-2
John Kessenich [Mon, 19 Dec 2016 20:30:29 +0000 (13:30 -0700)]
Merge pull request #635 from steve-lunarg/sample-fix-2

HLSL: allow "sample" in expressions.

7 years agoMerge pull request #625 from jbeich/gcc6
John Kessenich [Mon, 19 Dec 2016 20:30:06 +0000 (13:30 -0700)]
Merge pull request #625 from jbeich/gcc6

Unbreak build on FreeBSD with GCC/libstdc++ 6.2.0

7 years agoPP: Implement token pasting for PP identifiers.
John Kessenich [Mon, 19 Dec 2016 16:19:43 +0000 (09:19 -0700)]
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.

7 years agoHLSL: allow "sample" in expressions.
steve-lunarg [Mon, 19 Dec 2016 00:51:14 +0000 (17:51 -0700)]
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.

7 years agoFix comment typo.
John Kessenich [Sat, 17 Dec 2016 00:11:18 +0000 (17:11 -0700)]
Fix comment typo.

7 years agoHLSL: More robust handling of bad shader input, catching a few more things.
John Kessenich [Thu, 15 Dec 2016 00:02:32 +0000 (17:02 -0700)]
HLSL: More robust handling of bad shader input, catching a few more things.

7 years agoMerge pull request #629 from null77/fix-unicode
John Kessenich [Wed, 14 Dec 2016 22:15:41 +0000 (15:15 -0700)]
Merge pull request #629 from null77/fix-unicode

Change unicode dash to ASCII.

7 years agoChange unicode dash to ASCII.
Jamie Madill [Wed, 14 Dec 2016 20:48:56 +0000 (15:48 -0500)]
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.

7 years agoMerge pull request #628 from null77/fix-cast-warn
John Kessenich [Wed, 14 Dec 2016 02:32:01 +0000 (19:32 -0700)]
Merge pull request #628 from null77/fix-cast-warn

Fix size_t to int cast warnings.

7 years agoFix size_t to int cast warnings.
Jamie Madill [Tue, 13 Dec 2016 22:30:58 +0000 (17:30 -0500)]
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

7 years agoFix last commit; EOptionKeepUncalled incorrect enum bug.
John Kessenich [Mon, 12 Dec 2016 18:41:43 +0000 (11:41 -0700)]
Fix last commit; EOptionKeepUncalled incorrect enum bug.

7 years agoRemapper: remove debug info for IDs stripped in other passes
steve-lunarg [Fri, 9 Dec 2016 18:13:23 +0000 (11:13 -0700)]
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.

7 years agoLinker: Eliminate uncalled functions, because they can be ill-defined.
John Kessenich [Sat, 10 Dec 2016 02:22:20 +0000 (19:22 -0700)]
Linker: Eliminate uncalled functions, because they can be ill-defined.

Fixes issue #610. Also provides a testing option to keep uncalled functions.

7 years agoLinker: Track the mangled entry-point name along with the non-mangled one.
John Kessenich [Sat, 10 Dec 2016 00:29:07 +0000 (17:29 -0700)]
Linker: Track the mangled entry-point name along with the non-mangled one.

7 years agoGLSL Linker: Track entry point across compilation units.
John Kessenich [Sat, 10 Dec 2016 00:14:27 +0000 (17:14 -0700)]
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.

7 years agoAdd missing header and drop duplicate one
Jan Beich [Fri, 9 Dec 2016 03:32:01 +0000 (03:32 +0000)]
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);
                        ^~~~~~~

7 years agoLinker: Walk the call graph to report an error on missing bodies.
John Kessenich [Fri, 9 Dec 2016 04:01:59 +0000 (21:01 -0700)]
Linker: Walk the call graph to report an error on missing bodies.

7 years agoMerge pull request #621 from steve-lunarg/recursive-flattening
John Kessenich [Thu, 8 Dec 2016 18:18:07 +0000 (11:18 -0700)]
Merge pull request #621 from steve-lunarg/recursive-flattening

HLSL: Recursive composite flattening

7 years agoMerge pull request #619 from steve-lunarg/opcode-specific-promote
John Kessenich [Thu, 8 Dec 2016 18:17:21 +0000 (11:17 -0700)]
Merge pull request #619 from steve-lunarg/opcode-specific-promote

HLSL: opcode specific promotion rules for interlocked ops

7 years agoMerge pull request #620 from fjhenigman/foo
John Kessenich [Thu, 8 Dec 2016 18:15:59 +0000 (11:15 -0700)]
Merge pull request #620 from fjhenigman/foo

GLSL: Always define TShader::~Includer().

7 years agoHLSL: Recursive composite flattening
steve-lunarg [Tue, 29 Nov 2016 00:09:54 +0000 (17:09 -0700)]
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.

7 years agoHLSL: opcode specific promotion rules for interlocked ops
steve-lunarg [Tue, 6 Dec 2016 22:50:11 +0000 (15:50 -0700)]
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.

7 years agoGLSL: Always define TShader::~Includer().
Frank Henigman [Tue, 6 Dec 2016 21:35:12 +0000 (16:35 -0500)]
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().

7 years agoMerge pull request #615 from dneto0/consistent-location-for-test-files
John Kessenich [Tue, 6 Dec 2016 07:48:11 +0000 (00:48 -0700)]
Merge pull request #615 from dneto0/consistent-location-for-test-files

runtests should refer to test files in current directory

7 years agoGLSL: Allow desktop shaders to call functions from outside main().
John Kessenich [Tue, 6 Dec 2016 04:36:48 +0000 (21:36 -0700)]
GLSL: Allow desktop shaders to call functions from outside main().

Fixes issue #239.

7 years agoMerge pull request #613 from Corillian/hlslpreprocess
John Kessenich [Mon, 5 Dec 2016 17:25:02 +0000 (10:25 -0700)]
Merge pull request #613 from Corillian/hlslpreprocess

Fixed processing #include's when preprocessing HLSL

7 years agoruntests should refer to test files in current directory
David Neto [Mon, 5 Dec 2016 16:30:02 +0000 (11:30 -0500)]
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.

7 years agoFixed processing #include's when preprocessing HLSL
Keith Newton [Sun, 4 Dec 2016 22:07:10 +0000 (17:07 -0500)]
Fixed processing #include's when preprocessing HLSL

7 years agoDon't print the "Linked stage" message unless the AST is being dumped.
John Kessenich [Sat, 3 Dec 2016 20:58:46 +0000 (13:58 -0700)]
Don't print the "Linked stage" message unless the AST is being dumped.

7 years agoMerge branch 'steve-lunarg-intrinsic-promotion'
John Kessenich [Sat, 3 Dec 2016 20:29:46 +0000 (13:29 -0700)]
Merge branch 'steve-lunarg-intrinsic-promotion'

7 years agoMerge branch 'intrinsic-promotion' of https://github.com/steve-lunarg/glslang into...
John Kessenich [Sat, 3 Dec 2016 20:27:22 +0000 (13:27 -0700)]
Merge branch 'intrinsic-promotion' of https://github.com/steve-lunarg/glslang into steve-lunarg-intrinsic-promotion

7 years agoMerge pull request #604 from steve-lunarg/entry-rename-2
John Kessenich [Fri, 2 Dec 2016 06:47:49 +0000 (23:47 -0700)]
Merge pull request #604 from steve-lunarg/entry-rename-2

HLSL: allow renaming of shader entry point when creating SPIR-V

7 years agoallow renaming of shader entry point when creating SPIR-V
steve-lunarg [Mon, 31 Oct 2016 21:13:43 +0000 (15:13 -0600)]
allow renaming of shader entry point when creating SPIR-V

Use "--source-entrypoint name" on the command line, or the
TShader::setSourceEntryPoint(char*) API.

When the name given to the above interfaces is detected in the
shader source, it will be renamed to the entry point name supplied
to the -e option or the TShader::setEntryPoint() method.

7 years agoFix non-Windows build error.
John Kessenich [Mon, 28 Nov 2016 06:00:14 +0000 (23:00 -0700)]
Fix non-Windows build error.

7 years agoHLSL: Support the constructor idiom "(struct type)0".
John Kessenich [Mon, 28 Nov 2016 05:51:36 +0000 (22:51 -0700)]
HLSL: Support the constructor idiom "(struct type)0".

This highly leverages the previous commit to handle partial initializers.

7 years agoHLSL: Support {...} initializer lists that are too short.
John Kessenich [Mon, 28 Nov 2016 00:39:07 +0000 (17:39 -0700)]
HLSL: Support {...} initializer lists that are too short.

7 years agoFix crash by returning early from finalCheck() if there is no tree to process.
John Kessenich [Mon, 28 Nov 2016 00:32:19 +0000 (17:32 -0700)]
Fix crash by returning early from finalCheck() if there is no tree to process.

7 years agoNon-functional: Change a bunch of 0 to nullptr.
John Kessenich [Mon, 28 Nov 2016 00:30:14 +0000 (17:30 -0700)]
Non-functional: Change a bunch of 0 to nullptr.

7 years agoNon-functional: Fix typos.
John Kessenich [Mon, 28 Nov 2016 00:26:21 +0000 (17:26 -0700)]
Non-functional: Fix typos.

7 years agoWarn on HLSL not finding entry point. Issue #588.
John Kessenich [Sat, 26 Nov 2016 20:45:18 +0000 (13:45 -0700)]
Warn on HLSL not finding entry point. Issue #588.

7 years agoNon-functional: Rename some entry-point variables to entryPoint, not main.
John Kessenich [Sat, 26 Nov 2016 20:31:47 +0000 (13:31 -0700)]
Non-functional: Rename some entry-point variables to entryPoint, not main.

7 years agoAlways correctly terminate main. Issue #588, PR #600.
John Kessenich [Sat, 26 Nov 2016 20:23:20 +0000 (13:23 -0700)]
Always correctly terminate main. Issue #588, PR #600.

7 years agoHLSL: add intrinsic function implicit promotions
steve-lunarg [Wed, 2 Nov 2016 18:42:34 +0000 (12:42 -0600)]
HLSL: add intrinsic function implicit promotions

This PR handles implicit promotions for intrinsics when there is no exact match,
such as for example clamp(int, bool, float).  In this case the int and bool will
be promoted to a float, and the clamp(float, float, float) form used.

These promotions can be mixed with shape conversions, e.g, clamp(int, bool2, float2).

Output conversions are handled either via the existing addOutputArgumentConversion
function, which this PR generalizes to handle either aggregates or unaries, or by
intrinsic decomposition.  If there are methods or intrinsics to be decomposed,
then decomposition is responsible for any output conversions, which turns out to
happen automatically in all current cases.  This can be revisited once inout
conversions are in place.

Some cases of actual ambiguity were fixed in several tests, e.g, spv.register.autoassign.*

Some intrinsics with only uint versions were expanded to signed ints natively, where the
underlying AST and SPIR-V supports that.  E.g, countbits.  This avoids extraneous
conversion nodes.

A new function promoteAggregate is added, and used by findFunction.  This is essentially
a generalization of the "promote 1st or 2nd arg" algorithm in promoteBinary.

The actual selection proceeds in three steps, as described in the comments in
hlslParseContext::findFunction:

1. Attempt an exact match.  If found, use it.
2. If not, obtain the operator from step 1, and promote arguments.
3. Re-select the intrinsic overload from the results of step 2.

7 years agoMerge pull request #601 from BearishSun/master
John Kessenich [Wed, 23 Nov 2016 07:38:32 +0000 (00:38 -0700)]
Merge pull request #601 from BearishSun/master

A way to query "location" qualifier for vertex attributes, using TProgram reflection API

7 years agoMerge pull request #599 from steve-lunarg/gs
John Kessenich [Wed, 23 Nov 2016 07:29:30 +0000 (00:29 -0700)]
Merge pull request #599 from steve-lunarg/gs

HLSL: Add GS support

7 years agoMerge pull request #596 from steve-lunarg/hlsl-intrinsic-parsing
John Kessenich [Wed, 23 Nov 2016 07:19:40 +0000 (00:19 -0700)]
Merge pull request #596 from steve-lunarg/hlsl-intrinsic-parsing

HLSL: use HLSL parser for HLSL intrinsic prototypes, enable int/bool mats

7 years agoMerge pull request #597 from steve-lunarg/sample-keyword-fix
John Kessenich [Wed, 23 Nov 2016 06:33:40 +0000 (23:33 -0700)]
Merge pull request #597 from steve-lunarg/sample-keyword-fix

HLSL: allow "sample" as a valid identifier.

7 years agoAdding a way to retrieve vertex attribute TType using TProgram reflection API (requir...
BearishSun [Tue, 22 Nov 2016 08:53:04 +0000 (09:53 +0100)]
Adding a way to retrieve vertex attribute TType using TProgram reflection API (required in order to query location attributes).

7 years agoWIP: HLSL: Add GS support
steve-lunarg [Thu, 17 Nov 2016 22:04:20 +0000 (15:04 -0700)]
WIP: HLSL: Add GS support

This PR adds:

[maxvertexcount(n)] attributes

point/line/triangle/lineadj/triangleadj qualifiers

PointStream/LineStream/TriangleStream templatized types

Append method on above template types

RestartStrip method on above template types.

7 years agoHLSL: allow "sample" as a valid identifier.
steve-lunarg [Wed, 16 Nov 2016 20:22:11 +0000 (13:22 -0700)]
HLSL: allow "sample" as a valid identifier.

HLSL has keywords for various interpolation modifiers such as "linear",
"centroid", "sample", etc.  Of these, "sample" appears to be special,
as it is also accepted as an identifier string, where the others are not.

This PR adds this ability, so the construct "int sample = 42;" no longer
produces a compilation error.

New test = hlsl.identifier.sample.frag

7 years agoHLSL: use HLSL parser to parse HLSL intrinsic prototypes, enable int/bool mats
steve-lunarg [Tue, 15 Nov 2016 17:11:04 +0000 (10:11 -0700)]
HLSL: use HLSL parser to parse HLSL intrinsic prototypes, enable int/bool mats

This PR adds a CreateParseContext() fn analogous to CreateBuiltInParseables(),
to create a language specific built in parser.  (This code was present before
but not encapsualted in a fn).  This can now be used to create a source language
specific parser for builtins.

Along with this, the code creating HLSL intrinsic prototypes can now produce
them in HLSL syntax, rather than GLSL syntax.  This relaxes certain prior
restrictions at the parser level.  Lower layers (e.g, SPIR-V) may still have
such restrictions, such as around Nx1 matrices: this code does not impact
that.

This PR also fleshes out matrix types for bools and ints, both of which were
partially in place before.  This was easier than maintaining the restrictions
in the HLSL prototype generator to avoid creating protoypes with those types.

Many tests change because the result type from intrinsics moves from "global"
to "temp".

Several new tests are added for the new types.

7 years agoTest results: Fix incorrect test result caused by parallel development. Issue #594.
John Kessenich [Tue, 15 Nov 2016 04:22:05 +0000 (21:22 -0700)]
Test results: Fix incorrect test result caused by parallel development. Issue #594.

7 years agoMerge pull request #576 from steve-lunarg/uav-registers
John Kessenich [Mon, 14 Nov 2016 16:39:46 +0000 (09:39 -0700)]
Merge pull request #576 from steve-lunarg/uav-registers

Add UAV (image) binding offset and HLSL register class support

7 years agoMerge pull request #592 from ChrisGautier/barrier-wg
John Kessenich [Mon, 14 Nov 2016 16:37:34 +0000 (09:37 -0700)]
Merge pull request #592 from ChrisGautier/barrier-wg

SPV: The execution scope for barriers should be Workgroup.

7 years agoGLSL: The execution scope for barriers should be Workgroup.
chrgau01@arm.com [Mon, 14 Nov 2016 09:10:05 +0000 (10:10 +0100)]
GLSL: The execution scope for barriers should be Workgroup.

7 years agoMerge pull request #583 from null77/fix-unref-warning
John Kessenich [Mon, 14 Nov 2016 05:04:04 +0000 (22:04 -0700)]
Merge pull request #583 from null77/fix-unref-warning

SPV: Fix unreferenced variable warning with AMD_EXTENSIONS disabled.

7 years agoMerge pull request #589 from steve-lunarg/vec1-promotion-fix
John Kessenich [Mon, 14 Nov 2016 05:01:54 +0000 (22:01 -0700)]
Merge pull request #589 from steve-lunarg/vec1-promotion-fix

HLSL: allow promotion from 1-vector types to scalars, e.g, float<-float1

7 years agoHLSL: allow promotion from 1-vector types to scalars, e.g, float<-float1
steve-lunarg [Fri, 11 Nov 2016 22:37:10 +0000 (15:37 -0700)]
HLSL: allow promotion from 1-vector types to scalars, e.g, float<-float1

Previously, an error was thrown when assigning a float1 to a scalar float,
or similar for other basic types.  This allows that.

Also, this allows calling functions accepting scalars with float1 params,
so for example sin(float1) will work.  This is a minor change in
HlslParseContext::findFunction().

7 years agoMerge pull request #584 from steve-lunarg/attribute-expressions
John Kessenich [Fri, 11 Nov 2016 18:27:12 +0000 (11:27 -0700)]
Merge pull request #584 from steve-lunarg/attribute-expressions

HLSL: Allow expressions in attributes

7 years agoHLSL: Allow expressions in attributes
steve-lunarg [Fri, 11 Nov 2016 15:17:44 +0000 (08:17 -0700)]
HLSL: Allow expressions in attributes

For example:

[numthreads(2+2, 2*3, (1+FOO)*BAR)]

This will result in a thread count (4, 6, 8).

7 years agoFix unrefenced variable warning with AMD_EXTENSIONS disabled.
Jamie Madill [Wed, 9 Nov 2016 18:49:24 +0000 (13:49 -0500)]
Fix unrefenced variable warning with AMD_EXTENSIONS disabled.

7 years agoWhole stack: Fix stale types in the AST linker object nodes, fixing #557.
John Kessenich [Sat, 5 Nov 2016 16:15:53 +0000 (10:15 -0600)]
Whole stack: Fix stale types in the AST linker object nodes, fixing #557.

Rationalizes the entire tracking of the linker object nodes, effecting
GLSL, HLSL, and SPIR-V, to allow tracked objects to be fully edited before
their type snapshot for linker objects.

Should only effect things when the rest of the AST contained no reference to
the symbol, because normal AST nodes were not stale. Also will only effect such
objects when their types were edited.

7 years agoAdd UAV (image) binding offset and HLSL register support
steve-lunarg [Tue, 1 Nov 2016 16:31:42 +0000 (10:31 -0600)]
Add UAV (image) binding offset and HLSL register support

This PR adds:

1. The "u" register class for RW* objects.

2. --shift-image-bindings (== --sib), analogous to --shift-texture-bindings etc.

3. Case insensitive reg classes.

4. Tests for above.

7 years agoMerge pull request #575 from steve-lunarg/iomap-warning-fix
John Kessenich [Tue, 1 Nov 2016 15:49:49 +0000 (09:49 -0600)]
Merge pull request #575 from steve-lunarg/iomap-warning-fix

Fix build warnings in iomapper.cpp, re-indent to glslang standard

7 years agoFix build warnings in remapper, re-indent for glslang standard
steve-lunarg [Tue, 1 Nov 2016 14:51:46 +0000 (08:51 -0600)]
Fix build warnings in remapper, re-indent for glslang standard

This has no functional changes.

7 years agoMerge pull request #572 from steve-lunarg/numthreads
John Kessenich [Tue, 1 Nov 2016 06:25:06 +0000 (00:25 -0600)]
Merge pull request #572 from steve-lunarg/numthreads

HLSL: implement numthreads for compute shaders

7 years agoMerge pull request #562 from TiemoJung/io_map_control_publish
John Kessenich [Tue, 1 Nov 2016 06:24:01 +0000 (00:24 -0600)]
Merge pull request #562 from TiemoJung/io_map_control_publish

HLSL -> Spir-V: Resource mapping handler

7 years agoMerge pull request #570 from steve-lunarg/mintypes
John Kessenich [Tue, 1 Nov 2016 06:23:29 +0000 (00:23 -0600)]
Merge pull request #570 from steve-lunarg/mintypes

HLSL: Add min*{float,int,uint} types

7 years agoMerge pull request #574 from dneto0/android-has-no-std-stoi
John Kessenich [Tue, 1 Nov 2016 06:08:40 +0000 (00:08 -0600)]
Merge pull request #574 from dneto0/android-has-no-std-stoi

Use std::atoi instead of std::stoi

7 years agoUse std::atoi instead of std::stoi
David Neto [Mon, 31 Oct 2016 21:02:45 +0000 (17:02 -0400)]
Use std::atoi instead of std::stoi

Some Android cross cross-compilers don't have std::stoi.

E.g. i686-linux-android-g++ from Android NDK r10e don't have std::stoi.

7 years agoHLSL: Add min*{float,int,uint} types
steve-lunarg [Thu, 27 Oct 2016 01:18:55 +0000 (19:18 -0600)]
HLSL: Add min*{float,int,uint} types

These HLSL types are guaranteed to have at least the given number of bits, but may have more.

min{16,10}float is mapped to EbtFloat at medium precision -> SPIRV RelaxedPrecision
min{16,12}int and min16uint are mapped to mediump -> SPIR-V RelaxedPrecision

7 years agoHLSL: implement numthreads for compute shaders
steve-lunarg [Thu, 20 Oct 2016 19:07:10 +0000 (13:07 -0600)]
HLSL: implement numthreads for compute shaders

This PR adds handling of the numthreads attribute for compute shaders, as well as a general
infrastructure for returning attribute values from acceptAttributes, which may be needed in other
cases, e.g, unroll(x), or merely to know if some attribute without params was given.

A map of enum values from TAttributeType to TIntermAggregate nodes is built and returned.  It
can be queried with operator[] on the map.  In the future there may be a need to also handle
strings (e.g, for patchconstantfunc), and those can be easily added into the class if needed.

New test is in hlsl.numthreads.comp.

7 years agoMerge pull request #571 from baldurk/explicit-lambda-returns
John Kessenich [Sat, 29 Oct 2016 01:16:13 +0000 (19:16 -0600)]
Merge pull request #571 from baldurk/explicit-lambda-returns

Add explicit lambda return types, for compilers without C++14 support

7 years agoAdd explicit lambda return types, for compilers without C++14 support
baldurk [Fri, 28 Oct 2016 15:57:25 +0000 (17:57 +0200)]
Add explicit lambda return types, for compilers without C++14 support

7 years agoNew uniform mapping handling
t.jung [Thu, 27 Oct 2016 13:45:02 +0000 (15:45 +0200)]
New uniform mapping handling

- add optional callback to handle mapping of uniform variables in linking phase
- if no resolver is provided, it uses the internal default resolver with all shifts and auto bind settings

Change-Id: Icfe38a9eabe8bfc8f8bb6d8150c06f7ed38bb762

7 years agoMerge pull request #560 from jeremy-lunarg/pragmas
John Kessenich [Thu, 27 Oct 2016 05:02:47 +0000 (23:02 -0600)]
Merge pull request #560 from jeremy-lunarg/pragmas

silence -Wunknown-pragmas warnings on gcc

7 years agoMerge pull request #568 from steve-lunarg/logicalop-fix
John Kessenich [Thu, 27 Oct 2016 05:01:16 +0000 (23:01 -0600)]
Merge pull request #568 from steve-lunarg/logicalop-fix

HLSL: allow component-wise operations for logical || and &&.

7 years agoMerge pull request #567 from steve-lunarg/compare-fix
John Kessenich [Thu, 27 Oct 2016 04:54:35 +0000 (22:54 -0600)]
Merge pull request #567 from steve-lunarg/compare-fix

HLSL: Enable component-wise vector comparisons from operators

7 years agoMerge pull request #561 from jeremy-lunarg/unused
John Kessenich [Thu, 27 Oct 2016 04:51:43 +0000 (22:51 -0600)]
Merge pull request #561 from jeremy-lunarg/unused

GLSL: apply unused variable

7 years agoHLSL: allow component-wise operations for logical || and &&.
steve-lunarg [Wed, 26 Oct 2016 18:42:49 +0000 (12:42 -0600)]
HLSL: allow component-wise operations for logical || and &&.

HLSL || and && can operate component-wise.

7 years agoHLSL: Enable component-wise vector comparisons from operators
steve-lunarg [Fri, 21 Oct 2016 22:43:38 +0000 (16:43 -0600)]
HLSL: Enable component-wise vector comparisons from operators

This PR only changes a few lines of code, but is subtle.

In HLSL, comparison operators (<,>,<=,>=,==,!=) operate component-wise
when given a vector operand.  If a whole vector equality or inequality is
desired, then all() or any() can be used on the resulting bool vector.

This PR enables this change.  Existing shape conversion is used when
one of the two arguments is a vector and one is a scalar.

Some existing HLSL tests had assumed == and != meant vector-wise
instead of component-wise comparisons.  These tests have been changed
to add an explicit any() or all() to the test source.  This verifably
does not change the final SPIR-V binary relative to the old behavior
for == and !=.  The AST does change for the (now explicit, formerly
implicit) any() and all().  Also, a few tests changes where they
previously had the return type wrong, e.g, from a vec < vec comparison
in hlsl.shapeConv.frag.

Promotion of comparison opcodes to vector forms
(EOpEqual->EOpVectorEqual) is handled in promoteBinary(), as is setting
the proper vector type of the result.

EOpVectorEqual and EOpVectorNotEqual are now accepted as either
aggregate or binary nodes, similar to how the other operators are
handled.  Partial support already existed for this: it has been
fleshed out in the printing functions in intermOut.cpp.

There is an existing defect around shape conversion with 1-vectors, but
that is orthogonal to this PR and not addressed by it.

7 years agoMerge pull request #565 from mre4ce/master
John Kessenich [Tue, 25 Oct 2016 06:16:12 +0000 (00:16 -0600)]
Merge pull request #565 from mre4ce/master

Disabled MSVC 2015 compile warnings.

7 years agoWIP: avoid strtok
steve-lunarg [Fri, 21 Oct 2016 05:56:45 +0000 (23:56 -0600)]
WIP: avoid strtok

7 years agoWIP: apply unused variable
Jeremy Hayes [Thu, 20 Oct 2016 22:12:36 +0000 (16:12 -0600)]
WIP: apply unused variable

I happened upon numArgs while hunting for unused variables. I suspect
the intent was to apply it as shown in this patch. However, I am not a
compiler dude. Someone more appropriate should grok this change.

7 years agoupdate
Johannes van Waveren [Fri, 21 Oct 2016 08:30:50 +0000 (17:30 +0900)]
update

7 years agoMerge remote-tracking branch 'upstream/master'
Johannes van Waveren [Fri, 21 Oct 2016 08:21:46 +0000 (17:21 +0900)]
Merge remote-tracking branch 'upstream/master'

7 years agofixed MSVC 2015 compile warnings
Johannes van Waveren [Fri, 21 Oct 2016 08:21:12 +0000 (17:21 +0900)]
fixed MSVC 2015 compile warnings

7 years agoMerge pull request #559 from steve-lunarg/samplecmp-fix
John Kessenich [Fri, 21 Oct 2016 01:22:57 +0000 (19:22 -0600)]
Merge pull request #559 from steve-lunarg/samplecmp-fix

HLSL: fix defect in EOpMethodSampleCmp* texture decomposition

7 years agoMerge pull request #558 from steve-lunarg/image-atomics
John Kessenich [Fri, 21 Oct 2016 01:09:55 +0000 (19:09 -0600)]
Merge pull request #558 from steve-lunarg/image-atomics

HLSL: phase 4 of RWTexture support: add image atomics

7 years agoMerge pull request #555 from steve-lunarg/promotion-fixes
John Kessenich [Fri, 21 Oct 2016 01:07:27 +0000 (19:07 -0600)]
Merge pull request #555 from steve-lunarg/promotion-fixes

HLSL: Fix unary and binary operator type conversion issues

7 years agoMerge pull request #556 from dneto0/guard-amd-enums
John Kessenich [Fri, 21 Oct 2016 01:04:30 +0000 (19:04 -0600)]
Merge pull request #556 from dneto0/guard-amd-enums

SPV: Add missing guard to code that uses AMD extensions

7 years agoHLSL: fix defect in EOpMethodSampleCmp* texture decomposition
steve-lunarg [Thu, 20 Oct 2016 20:50:12 +0000 (14:50 -0600)]
HLSL: fix defect in EOpMethodSampleCmp* texture decomposition

HLSL holds the compare value in a separate intrinsic arg, but the AST wants
a vector including the cmp val, except in the 4-dim coord case, where it
doesn't fit and is in fact a separate AST parameter.  This is awkward but
necessary, given AST semantics.  In the process, a new vector is constructed
for the combined result, but this vector was not being given the correct
TType, so was causing some downstream troubles.

Now it is.  A similar defect existed in OpTextureBias, and has also been
fixed.

7 years agoMove promote methods to TIntermediate class
steve-lunarg [Wed, 19 Oct 2016 18:57:22 +0000 (12:57 -0600)]
Move promote methods to TIntermediate class

A need arose to use capabilities from TIntermediate during
node promotion.  These methods have been moved from virtual
methods on the TIntermUnary and TIntermBinary nodes to methods
on TIntermediate, so it is easy for them construct new nodes
and so on.

This is done as a separate commit to verify that no test results
are changed as a result.

7 years agoHLSL: phase 4 of rwtexture support: add image atomics
steve-lunarg [Wed, 19 Oct 2016 16:15:25 +0000 (10:15 -0600)]
HLSL: phase 4 of rwtexture support: add image atomics

This PR will turn Interlocked* intrinsics using rwtexture or rwbuffer
object as the first parameter into the proper OpImageAtomic* operations.

7 years agoAdd missing guard to code that uses AMD extensions
David Neto [Wed, 19 Oct 2016 14:16:29 +0000 (10:16 -0400)]
Add missing guard to code that uses AMD extensions

Otherwise compilation fails when ENABLED_AMD_EXTENSIONS is off.

7 years agoHLSL: Fix unary and binary operator type conversion issues
steve-lunarg [Sat, 15 Oct 2016 16:29:58 +0000 (10:29 -0600)]
HLSL: Fix unary and binary operator type conversion issues

This fixes defects as follows:

1. handleLvalue could be called on a non-L-value, and it shouldn't be.

2. HLSL allows unary negation on non-bool values.  TUnaryOperator::promote
   can now promote other types (e.g, int, float) to bool for this op.

3. HLSL allows binary logical operations (&&, ||) on arbitrary types, similar
   (2).

4. HLSL allows mod operation on arbitrary types, which will be promoted.
   E.g, int % float -> float % float.