Граф коммитов

1250 Коммитов

Автор SHA1 Сообщение Дата
John Kessenich 65ee230f1c HLSL: Add tests and refine what decorations are passed through per stage/in/out. 2017-02-06 23:13:16 -07:00
John Kessenich bf47286fe7 HLSL: Move to fine-grained control for defining input/output/uniform IO types. 2017-02-06 23:13:16 -07:00
John Kessenich 727b374fd3 HLSL: Build IO types bottom up, as parsed, and cache the original (IO).
Previously, this was done recursively, per object, and the nonIO version
was cached. This reverses both those approaches.
2017-02-06 23:00:51 -07:00
John Kessenich 88c4464df5 HLSL: Have loose uniforms also go through the makeTypeNonIo() path. 2017-02-06 23:00:51 -07:00
John Kessenich fbb58a4e0b Build: Fix Linux for older compiler: Use TMap instead of TUndorderedMap. 2017-02-06 23:00:51 -07:00
John Kessenich abd8dca86d HLSL: Make the entry-point shadow function have non-IO params and return.
This also removes an no longer needed makeTemporary() and rationalizes
makeTypeNonIo()'s interface.
2017-02-06 22:58:32 -07:00
steve-lunarg 5d3023af03 HLSL: Type sanitization: create non-IO types for var decl and fn param/ret
This introduces parallel types for IO-type containing aggregates used as
non-entry point function parameters or return types, or declared as variables.
Further uses of the same original type will share the same sanitized deep
structure.

This is intended to be used with the wrap-entry-point branch.
2017-02-06 22:58:32 -07:00
John Kessenich 0fe106afd2 AST: Have type deepCopy() preserve type graphs as graphs.
Previously, a type graph would turn into a type tree. That is,
a deep node that is shared would have multiple copies made.

This is important when creating IO and non-IO versions of deep types.
2017-02-06 22:58:32 -07:00
John Kessenich 02467d8d94 HLSL: Wrap the entry-point; need to write 'in' args, and support 'inout' args.
This needs some render testing, but is destined to be part of master.

This also leads to a variety of other simplifications.
 - IO are global symbols, so only need one list of linkage nodes (deferred)
 - no longer need parse-context-wide 'inEntryPoint' state, entry-point is localized
 - several parts of splitting/flattening are now localized
2017-02-06 22:58:32 -07:00
John Kessenich 18adbdbbb8 Resolve issue #700: allow initializers on struct members. 2017-02-02 15:16:20 -07:00
John Kessenich 32fd5d26e3 Memory/constructor/warning clean-up. Addresses issue #705. 2017-02-02 14:55:02 -07:00
Benjamin Saunders 5a074532af Install headers
This enables the vulkan loader to be built against an installed glslang.
2017-01-29 17:46:44 -08:00
John Kessenich 62c3e400cf Fix bug from PR #678: NV_EXTENSIONS deleted implicit array sizing. 2017-01-26 22:03:57 -07:00
John Kessenich 82e0e58993 Fix issue #693. Ternary operator on void type. 2017-01-26 15:50:10 -07:00
John Kessenich c0904c15c2 Merge pull request #690 from ligfx/proper_dependencies
CMake: add target_link_libraries internally
2017-01-26 15:13:27 -07:00
John Kessenich 72754864c1 Merge pull request #694 from mtavenrath/fix_origin_link
Use correct OriginUpperLeft when linking more than one shader.
2017-01-26 10:39:54 -07:00
Markus Tavenrath 7b89e75213 Use correct OriginUpperLeft when linking more than one shader. 2017-01-25 12:11:16 -08:00
Rex Xu 00d54b4440 Semantics: Texture clamp functions are available for fragment shader only. 2017-01-24 14:36:10 +08:00
Henrik Rydgard bec5fc898a Fix build if NV_EXTENSIONS is not set 2017-01-23 16:27:08 +01:00
Michael Maltese 6077a19ba3 CMake: add target_link_libraries internally
Makes it easier to include glslang in a larger CMake project---instead
of having to call `target_link_libraries(glslang OSDependent OGLCompiler
HLSL)`, for example, you only need to call
`target_link_libraries(glslang)` and it will pull in the helpers it
needs.

This is also better in terms of cleaning up the "public interface",
of sorts, for building glslang: end-users probably shouldn't need to
know or be explicitly dependent on internal targets.
2017-01-21 10:59:15 -08:00
chaoc 771d89fc36 support SPV_NV_viewport_array2 and SPV_NV_stereo_view_rendering 2017-01-20 16:48:26 -08:00
John Kessenich 7dccb1519b SPV: Merge pull request #675 from amdrexu/feature
SPV: Implement new revision of extension GL_AMD_shader_ballot
2017-01-19 16:14:28 -07:00
John Kessenich e48b8d74e2 Infrastructure: remove potential memory leaks. 2017-01-19 15:30:56 -07:00
Rex Xu 430ef40ab4 Implement new revision of extension GL_AMD_shader_ballot
- Add support for invocation functions with "InclusiveScan" and
  "ExclusiveScan" modes.
- Add support for invocation functions taking int64/uint64/doube/float16
  as inout data types.
2017-01-19 12:09:51 +08:00
John Kessenich 94dfb7a523 Non-functional: Factor out entry-point logic from handleFunctionDefinition(). 2017-01-18 16:50:47 -07:00
John Kessenich 33dadd1287 Fix build break for non-VS. 2017-01-13 20:22:00 -07:00
John Kessenich 442515393e Non-functional: Fix round of compiler warnings. 2017-01-13 20:08:54 -07:00
John Kessenich c142c88967 Front-ends: Non-functional: Rationalize vector and matrix swizzles.
This reduces code duplication in a few ways, and better encapsulates
vector swizzle representation.
2017-01-13 19:35:29 -07:00
John Kessenich fdf6347f0a HLSL: Add EOpMatrixSwizzle, selectively decomposed to other ops, for issue #670.
Since EOpMatrixSwizzle is a new op, existing back-ends only work when the
front end first decomposes it to other operations. So far, this is only
being done for simple assignment into matrix swizzles.
2017-01-13 12:35:01 -07:00
John Kessenich 001dfa1c5c HLSL: matrix swizzle (_12, _m23) syntax, partial semantics.
This partially addressess issue #670, for when the matrix swizzle
degenerates to a component or column: m[c], m[c][r] (where HLSL
swaps rows and columns for user's view).

An error message is given for the arbitrary cases not covered.

These cases will work for arbitrary use of l-values.

Future work will handle more arbitrary swizzles, which might
not work as arbitrary l-values.
2017-01-12 16:51:18 -07:00
John Kessenich 913e3b686a PP: Clean up and rationalize floating-point-number scanner.
This encapsulates where the string could overflow, removing 40 lines
of fragile code.  It also improves handling of numbers that are too long.

There are a couple of open issues that could related to this function
being more rational (locale dependence, 1.#INF).
2017-01-12 12:06:18 -07:00
John Kessenich e86fc0946f Merge pull request #664 from steve-lunarg/stage-io-fix
add other builtins to interstage IO
2017-01-12 10:18:23 -07:00
John Kessenich dc1a8196cf Infrastructure: Support standard build with ENABLE_HLSL set to off. 2017-01-11 14:50:16 -07:00
John Kessenich 65d538c832 Infrastructure: Protect against missing built-in symbol table generators. 2017-01-11 14:24:56 -07:00
John Kessenich ce80197c22 Merge pull request #663 from KhronosGroup/full-include-semantics
Includer interface change to support full include semantics (requires downstream changes)
2017-01-10 18:49:07 -07:00
Alex Szpakowski ff21a25bc8 Change disabled-by-default DISABLE_HLSL option to enabled-by-default ENABLE_HLSL.
Matches existing options.
2017-01-09 18:10:14 -04:00
steve-lunarg 46d5428422 WIP: add other builtins to interstage IO
(Still adding tests: do not commit)

This fixes PR #632 so that:

(a) The 4 PerVertex builtins are added to an interface block for all stages except fragment.

(b) Other builtin qualified variables are added as "loose" linkage members.

(c) Arrayness from the PerVertex builtins is moved to the PerVertex block.

(d) Sometimes, two PerVertex blocks are created, one for in, one for out (e.g, for some GS that
    both reads and writes a Position)
2017-01-09 13:58:05 -07:00
Alex Szpakowski 84eabf7ea7 Add a CMake option to disable compilation of HLSL input support. 2017-01-08 21:20:25 -04:00
Alex Szpakowski 5f316d9b17 Reorder initializer fields to match variable declaration order (or vice versa) for several class constructors. 2017-01-08 18:21:17 -04:00
John Kessenich facde2c804 PP #include: address PR feedback. 2017-01-06 16:48:18 -07:00
John Kessenich 63204c2501 External interface change: PP: Full <> and "" semantics for the Includer.
Any previous use would only be for "", which would probably mean changing

    include(...)  -> includeLocal(...)

See comments about includeLocal() being an additional search over
includeSystem(), not a superset search.

This also removed ForbidIncluder, as
 - the message in ForbidIncluder was redundant: error results were
   already returned to the caller, which then gives the error it
   wants to
 - there is a trivial default implementation that a subclass can
   override any subset of (I still like abstract base classes though)
 - trying to get less implementation out of the interface file anyway
2017-01-06 15:08:54 -07:00
John Kessenich 2508602541 PP #include non-functional: consistent notation for "header" and "header name".
This is versus a variety of file-related language, designated, requested, etc.
Will simplify diffs for next commit.
2017-01-06 14:54:18 -07:00
John Kessenich 927608b393 Non-functional: White space after "//", mostly for copyrights. 2017-01-06 12:34:14 -07:00
John Kessenich ecba76fe73 Non-Functional: Whitespace, comments, replace accidentally deleted comment.
- fixed ParseHelper.cpp newlines (crlf -> lf)
- removed trailing white space in most source files
- fix some spelling issues
- extra blank lines
- tabs to spaces
- replace #include comment about no location
2017-01-06 11:24:14 -07:00
John Kessenich 1b1defd605 PP: #include: simplify the different paths out of #include.
- some paths didn't release 'res'
- token is always '\n' after proper acceptance of the directive itself,
  so no need to test it, change it to '\n', etc.
- assuming setCurrentColumn(0) is not needed unless there are header tokens,
  but not clear why it is ever needed

Note: much of the simplified code read as if the included header tokens had
actually been processed, versus queued up for processing; maybe that explains
some things.
2017-01-05 13:32:52 -07:00
John Kessenich 28d3133581 PP: #include: add names to error messages, so that lexical analysis can be tested. 2017-01-05 12:24:19 -07:00
John Kessenich 64285c9e69 Non-functional: Very minor clean up. 2017-01-05 10:45:32 -07:00
John Kessenich 085b833490 HLSL: Fix issue #658: Don't adopt initializer constness from declaration.
This also makes it match how GLSL handles the same thing.
2017-01-05 10:28:26 -07:00
John Kessenich ddfbbe26f2 Merge pull request #632 from steve-lunarg/structure-splitting
HLSL: inter-stage structure splitting.
2017-01-04 11:41:36 -07:00
John Kessenich 5abd308e71 Merge pull request #659 from steve-lunarg/d3dcolortoubyte4
Add D3DCOLORtoUBYTE4 decomposition
2017-01-03 15:34:33 -07:00
John Kessenich c4ed950057 Merge pull request #647 from steve-lunarg/default-fn-params
HLSL: default function parameters
2017-01-03 15:30:05 -07:00
steve-lunarg 7ea7ff4cd4 Add EOpD3DCOLORtoUBYTE4 decomposition 2017-01-03 14:42:18 -07:00
John Kessenich affc26674d PP: Recognize <> style #include header names. I.e., #include <header-name>.
Also correctly test and handle missing newline.
2017-01-03 11:05:16 -07:00
John Kessenich faa720f14c PP: Fix issue #426, recover from bad-source macro expansion. 2017-01-02 17:56:08 -07:00
John Kessenich bc5196c003 SPV: Fix issue #369, don't support gl_NumSamples -> SPIR-V. 2017-01-02 17:01:21 -07:00
John Kessenich f37f4d23fc HLSL: Fix issue #646: map SV_DispatchThreadID -> GlobalInvocationID. 2017-01-02 14:59:19 -07:00
John Kessenich aa6d56298d HLSL: Handle const with no initializer. Fixes issue #651. 2016-12-30 16:42:57 -07:00
John Kessenich 53864846a9 HLSL: Support empty {} initializers for arrays and scalars. 2016-12-30 16:39:18 -07:00
steve-lunarg 26d3145334 HLSL default function parameters
This PR adds support for default function parameters in the following cases:

1. Simple constants, such as void fn(int x, float myparam = 3)
2. Expressions that can be const folded, such a ... myparam = sin(some_const)
3. Initializer lists that can be const folded, such as ... float2 myparam = {1,2}

New tests are added: hlsl.params.default.frag and hlsl.params.default.err.frag
(for testing error situations, such as ambiguity or non-const-foldable).

In order to avoid sampler method ambiguity, the hlsl better() lambda now
considers sampler matches.  Previously, all sampler types looked identical
since only the basic type of EbtSampler was considered.
2016-12-29 12:15:48 -07:00
steve-lunarg 132d331870 HLSL: struct splitting: assignments of hierarchical split types
This commit adds support for copying nested hierarchical types of split
types.  E.g, a struct of a struct containing both user and builtin interstage
IO variables.

When copying split types, if any subtree does NOT contain builtin interstage
IO, we can copy the whole subtree with one assignment, which saves a bunch
of AST verbosity for memberwise copies of that subtree.
2016-12-26 20:17:13 -07:00
steve-lunarg a2e7531057 HLSL: inter-stage structure splitting.
This adds structure splitting, which among other things will enable GS support where input structs
are passed, and thus become input arrays of structs in the GS inputs.  That is a common GS case.

The salient points of this PR are:

* Structure splitting has been changed from "always between stages" to "only into the VS and out of
  the PS".  It had previously happened between stages because it's not legal to pass a struct
  containing a builtin IO variable.

* Structs passed between stages are now split into a struct containing ONLY user types, and a
  collection of loose builtin IO variables, if any.  The user-part is passed as a normal struct
  between stages, which is valid SPIR-V now that the builtin IO is removed.

* Internal to the shader, a sanitized struct (with IO qualifiers removed) is used, so that e.g,
  functions can work unmodified.

* If a builtin IO such as Position occurs in an arrayed struct, for example as an input to a GS,
  the array reference is moved to the split-off loose variable, which is given the array dimension
  itself.

When passing things around inside the shader, such as over a function call, the the original type
is used in a sanitized form that removes the builtIn qualifications and makes them temporaries.
This means internal function calls do not have to change.  However, the type when returned from
the shader will be member-wise copied from the internal sanitized one to the external type.
The sanitized type is used in variable declarations.

When copying split types and unsplit, if a sub-struct contains only user variables, it is copied
as a single entity to avoid more AST verbosity.

Above strategy arrived at with talks with @johnkslang.

This is a big complex change.  I'm inclined to leave it as a WIP until it can get some exposure to
real world cases.
2016-12-26 10:11:15 -07:00
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
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 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
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
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 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
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
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
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 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
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 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
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 21b11f4cc1 Merge branch 'intrinsic-promotion' of https://github.com/steve-lunarg/glslang into steve-lunarg-intrinsic-promotion 2016-12-03 13:27:22 -07:00
steve-lunarg f1e0c87127 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.
2016-12-01 08:51:43 -07:00
John Kessenich 8ce6e2ba49 Fix non-Windows build error. 2016-11-27 23:00:14 -07:00
John Kessenich f97f2ce603 HLSL: Support the constructor idiom "(struct type)0".
This highly leverages the previous commit to handle partial initializers.
2016-11-27 22:51:36 -07:00
John Kessenich 98ad485321 HLSL: Support {...} initializer lists that are too short. 2016-11-27 17:39:07 -07:00
John Kessenich 1c98904014 Fix crash by returning early from finalCheck() if there is no tree to process. 2016-11-27 17:32:19 -07:00
John Kessenich 5307eb2d1b Non-functional: Change a bunch of 0 to nullptr. 2016-11-27 17:30:14 -07:00
John Kessenich 509c4216e6 Non-functional: Fix typos. 2016-11-27 17:26:21 -07:00
John Kessenich e50dc536ff Warn on HLSL not finding entry point. Issue #588. 2016-11-26 13:45:18 -07:00
John Kessenich 517fe7a6ad Non-functional: Rename some entry-point variables to entryPoint, not main. 2016-11-26 13:31:47 -07:00
John Kessenich fca826212c Always correctly terminate main. Issue #588, PR #600. 2016-11-26 13:23:20 -07:00
steve-lunarg ef33ec0925 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.
2016-11-23 10:36:34 -07:00
John Kessenich 1c573fbcfb Merge pull request #601 from BearishSun/master
A way to query "location" qualifier for vertex attributes, using TProgram reflection API
2016-11-23 00:38:32 -07:00
John Kessenich e122f053bb Merge pull request #599 from steve-lunarg/gs
HLSL: Add GS support
2016-11-23 00:29:30 -07:00
BearishSun 32c294ed76 Adding a way to retrieve vertex attribute TType using TProgram reflection API (required in order to query location attributes). 2016-11-22 09:53:04 +01:00
steve-lunarg f49cdf4183 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.
2016-11-21 18:25:08 -07:00
steve-lunarg 0842dbb39a 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.
2016-11-16 11:19:22 -07:00
John Kessenich fabe7d6a61 Test results: Fix incorrect test result caused by parallel development. Issue #594. 2016-11-14 21:22:05 -07:00
John Kessenich 0bf06d3cf5 Merge pull request #576 from steve-lunarg/uav-registers
Add UAV (image) binding offset and HLSL register class support
2016-11-14 09:39:46 -07:00
steve-lunarg d9cb832f9c 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().
2016-11-13 14:44:46 -07:00
John Kessenich d3f1122a44 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.
2016-11-05 10:22:33 -06:00
steve-lunarg 9088be4c07 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.
2016-11-01 14:44:54 -06:00
steve-lunarg 5b2d667fea Fix build warnings in remapper, re-indent for glslang standard
This has no functional changes.
2016-11-01 08:51:46 -06:00
t.jung c2016a52d2 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
2016-10-28 15:43:14 +02:00
John Kessenich 51634468da Merge pull request #568 from steve-lunarg/logicalop-fix
HLSL: allow component-wise operations for logical || and &&.
2016-10-26 23:01:16 -06:00
John Kessenich aba444005f Merge pull request #567 from steve-lunarg/compare-fix
HLSL: Enable component-wise vector comparisons from operators
2016-10-26 22:54:35 -06:00
John Kessenich 850ac0628d Merge pull request #561 from jeremy-lunarg/unused
GLSL: apply unused variable
2016-10-26 22:51:43 -06:00
steve-lunarg 27939caa86 HLSL: allow component-wise operations for logical || and &&.
HLSL || and && can operate component-wise.
2016-10-26 12:54:56 -06:00
steve-lunarg 85244d7486 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.
2016-10-26 08:50:10 -06:00
Jeremy Hayes c8e60e28b7 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.
2016-10-21 14:48:46 -06:00
Johannes van Waveren d1300753f7 update 2016-10-21 17:30:50 +09:00
Johannes van Waveren 2f4c832d47 Merge remote-tracking branch 'upstream/master' 2016-10-21 17:21:46 +09:00
Johannes van Waveren 8e1e717cae fixed MSVC 2015 compile warnings 2016-10-21 17:21:12 +09:00
steve-lunarg 6cb1637f37 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.
2016-10-19 12:57:22 -06:00
steve-lunarg e5921f1309 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.
2016-10-18 16:56:37 -06:00
John Kessenich 5d45eadedc HLSL: Turn on tests for groupshared. 2016-10-16 12:22:20 -06:00
John Kessenich b50fd17acb HLSL: Support SV_Coverage and SV_DispatchThreadId; catch SV_GroupIndex. 2016-10-16 12:12:11 -06:00
John Kessenich 4a3467933e Build: Fix unsigned/signed warning. 2016-10-16 11:50:46 -06:00
John Kessenich 1fabc0f697 Merge pull request #548 from baldurk/vs2010-compile-fixes
VS2010 compile fixes
2016-10-15 23:09:31 -06:00
John Kessenich bf8a6ef750 Merge pull request #551 from steve-lunarg/rwbuffers-fmt
HLSL: phase 3 of rwtexture support: add sub-vec4 capabilities
2016-10-15 23:03:38 -06:00
John Kessenich c658497846 Merge pull request #539 from schwa423/linux_global_lock
Use pthread_mutex for global lock on Linux.
2016-10-15 22:53:46 -06:00
Josh Gargus 425af5f6b0 Use a recursive mutex. 2016-10-15 15:19:59 -07:00
steve-lunarg cce8d48bcc HLSL: phase 3c: add option to use Unknown storage format
This uses the Unknown storage format, instead of deducing the
format from the texture declaration type.
2016-10-14 18:50:37 -06:00
steve-lunarg 8b0227ced9 HLSL: phase 3b: Texture methods remember and return vector size.
Also makes a (correct) test change for global -> temp vars.
2016-10-14 18:44:32 -06:00
steve-lunarg 4f2da27aec HLSL: phase 3a: Add sub-vec4 rwtexture formats (qualifier.layoutFormat)
This PR sets the TQualifier layoutFormat according to the HLSL image type.
For instance:

  RWTexture1D <float2> g_tTex1df2;

becomes ElfRg32f.  Similar on Buffers, e.g, Buffer<float4> mybuffer;

The return type for image and buffer loads is now taken from the storage format.
Also, the qualifier for the return type is now (properly) a temp, not a global.
2016-10-14 18:44:32 -06:00
John Kessenich f042e407a9 Merge pull request #542 from steve-lunarg/rwbuffers
HLSL: phase 2: add operator[]
2016-10-13 12:49:56 -06:00
John Kessenich e4ad1bb68a Merge pull request #538 from steve-lunarg/iomap-binding-range-err
Check for out-of-range bindings during IO mapping.
2016-10-13 12:44:16 -06:00
baldurk 75c3bf68e9 Add strtoull wrapper for VS2010, pointing to MS implementation 2016-10-13 19:24:23 +02:00
baldurk 54a28de4a9 Give all complex lambdas an explicit return type 2016-10-13 19:23:39 +02:00
steve-lunarg b3da8a9cb3 HLSL: phase 2e: introduce lower level addBinaryNode/UnaryNode fns
- hlsl.struct.frag variable changed to static, assignment replacd.

- Created new low level functions addBinaryNode and addUnaryNode.  These are
  used by higher level functions such as addAssignment, and do not do any
  argument promotion or conversion of any sort.

- Two functions above are now used in RWTexture lvalue conversions.  Also,
  other direction creations of unary or binary nodes now use them, e.g, addIndex.
  This cleans up some existing code.

- removed handling of EOpVectorTimesScalar from promote()

- removed comment from ParseHelper.cpp
2016-10-12 12:39:44 -06:00
steve-lunarg 07830e805b HLSL: phase 2d: minor cleanup, & allow operator[] on non-rw textures
Improve comments.
A few tweaked lines allow [] on non-rw tx.  Add test case for this.
Improve VectorTimesScalar handling.
2016-10-12 12:39:44 -06:00
steve-lunarg 0de16da2c0 HLSL: phase 2c: use lValueErrorCheck in HLSL FE
This commit splits lValueErrorCheck into machine dependent and independent
parts.  The GLSL form in TParseContext inherits from and invokes the
machine dependent part in TParseContextBase.  The base form checks language
independent things.  This split does not change the set of errors tested
for: the test results are identical.

The new base class interface is now used from the HLSL FE to test lvalues.
There was one test diff due to this, where the test was writing to a uniform.
It still does the same indirections, but does not attempt a uniform write.
2016-10-12 12:39:44 -06:00
steve-lunarg 90707966ea HLSL: phase 2b: add l-value operator[] for RWTexture/RWBuffer
This commit adds l-value support for RW texture and buffer objects.
Supported are:

- pre and post inc/decrement
- function out parameters
- op-assignments, such as *=, +-, etc.
- result values from op-assignments.  e.g, val=(MyRwTex[loc] *= 2);

Not supported are:
- Function inout parameters
- multiple post-inc/decrement operators.  E.g, MyRWTex[loc]++++;
2016-10-12 12:39:44 -06:00
John Kessenich 631f223b1b Merge pull request #543 from slime73/compilerwarnings
Address some compiler warnings.
2016-10-11 15:31:31 -06:00
Alex Szpakowski f887785990 fixup! Address some compiler warnings. 2016-10-11 16:16:47 -03:00
Rex Xu 4c25709f45 Parser: Some function prototypes of interpolateAtXXX are incorrect. 2016-10-10 16:55:04 +08:00
Alex Szpakowski 49ad2b72a1 Address some compiler warnings.
- Add explicit casts from long to int.
- Comment out method argument names that are unused.
- Always initialize a boolean variable before it's read.
2016-10-08 22:07:20 -03:00
John Kessenich 19bdf90eba SPV: Distinguish between SPV and non-SPV rules for member overlap. 2016-10-07 11:50:25 -06:00
John Kessenich 087a454af2 HLSL: Add shape conversions for return values. 2016-10-06 16:56:54 -06:00
John Kessenich ed33e05762 HLSL: Do structure conversion for return type struct-punning on non-entry-point functions. 2016-10-06 13:06:13 -06:00
Josh Gargus 87a83d6841 Use pthread_mutex for global lock on Linux. 2016-10-05 18:32:51 -07:00
steve-lunarg 9ae34742cf Check for out-of-range bindings during IO mapping. 2016-10-05 13:42:42 -06:00
John Kessenich c056adcddd Allow for larger binding numbers. 65K instead of 255. 2016-10-05 12:31:24 -06:00
steve-lunarg 2199c2404b HLSL: fix for flattening assignments from non-symbol R-values.
If a member-wise assignment from a non-flattened struct to a flattened struct sees a complex R-value
(not a symbol), it now creates a temporary to hold that value, to avoid repeating the R-value.
This avoids, e.g, duplicating a whole function call.  Also, it avoids re-using the AST node, making a
new one for each member inside the member loop.

The latter (re-use of AST node) was also an issue in the GetDimensions intrinsic decomposition,
so this PR fixes that one too.
2016-10-04 17:07:45 -06:00
steve-lunarg 8ffc36aecc add reflection queries to return a TType. Fix minor issue with interface names.
- Add new queries: TProgram::getUniformTType and getUniformBlockTType,
  which return a const TType*, or nullptr on a bad index.  These are valid for
  any source language.

- Interface name for HLSL cbuffers is taken from the (only) available declaration name,
  whereas before it was always an empty string, which caused some troubles with reflection
  mapping them all to the same index slot.  This also makes it appear in the SPIR-V binary
  instead of an empty string.

- Print the binding as part of the reflection textual dump.

- TType::clone becomes const.  Needed to call it from a const method, and anyway it doesn't
  change the object it's called on.

- Because the TObjectReflection constructor is called with a TType *reference* (not pointer)
  so that it's guaranteed to pass in a type, and the "badReflection" value should use a nullptr
  there, that now has a dedicated static method to obtain the bad value.  It uses a private
  constructor, so external users can't create one with a nullptr type.
2016-10-02 16:57:58 -06:00
John Kessenich de97fe0ad4 Non-functional: Rationalizing parse helper hierarchy, step 3 (effected editable symbols and IO resize). 2016-10-01 18:44:38 -06:00
John Kessenich a2a5dd474e Non-functional: Rationalizing parse helper hierarchy, step 2 (effected error messaging and cascading errors). 2016-10-01 18:07:57 -06:00
John Kessenich 273060c2d3 Non-functional: Rationalizing parse helper hierarchy, step 1 (effected memory of HLSL keyword map). 2016-10-01 17:47:40 -06:00
John Kessenich a08c929d8e HLSL: Line numbers only: Set locations (line numbers) on synthesized flattening code. 2016-10-01 17:17:55 -06:00
John Kessenich d8fe2ca8e5 HLSL: Handle flattened I/O structs passed to function *out* parameters. 2016-10-01 17:11:21 -06:00
John Kessenich c86d38bb2b Non-functional: Better use of .isParamOutput() and some other methods. 2016-10-01 13:30:37 -06:00
John Kessenich ba56e23e8a Fix typo in error message. 2016-10-01 12:36:19 -06:00
John Kessenich f571d0c037 Non-functional: Use isOpaque() instead of compare against EbtSampler. 2016-10-01 12:35:01 -06:00
steve-lunarg 088c59d7ea Change binding auto-map to use provided offsets.
Previously, the binding auto-mapping facility was free to use any unused
binding.  This change makes auto-bindings use the same offset value as
explicit bindings.
2016-10-01 11:40:43 -06:00
John Kessenich 3e47f5f7c8 Merge pull request #523 from amdrexu/feature2
Parser: Implement extension GL_AMD_gpu_shader_half_float.
2016-09-30 09:54:17 -06:00
Rex Xu c9e3c3c941 Parser: Implement extension GL_AMD_gpu_shader_half_float.
- Add built-in types: float16_t, f16vec, f16mat.
- Add support of half float constant: hf, HF.
- Extend built-in floating-point operators: +, -, *, /, ++, --, +=, -=,
  *=, /=, ==, !=, >=, <=, >, <.
- Add support of type conversions: float16_t -> XXX, XXX -> float16_t.
- Add new built-in functions.
2016-09-30 16:13:06 +08:00
John Kessenich df98cc26d5 Add amend ability for anonymous blocks, so they can grow between function bodies. 2016-09-29 23:59:26 -06:00
John Kessenich 21e7e32126 HLSL: Fix merge conflict. 2016-09-29 10:27:57 -06:00
John Kessenich 4e55988a47 HLSL Tests: Tests for previous commit, to make it easier to see what's changing. 2016-09-29 10:25:15 -06:00
John Kessenich 6dbc0a7a33 Support a uniform block to hold global uniform variables.
Used initially just by HLSL, for $Global.  Could be an option
for GLSL -> Vulkan.
2016-09-29 10:25:15 -06:00
John Kessenich e82061de08 HLSL: Rationalize combination of type arrayness and name arrayness. 2016-09-29 10:25:15 -06:00
John Kessenich 10f7fc739c HLSL: Reverse what the driver is told about row/column majorness, matching the row-column reversal. 2016-09-25 20:26:03 -06:00
steve-lunarg cf43e66125 Fix defects in uniform array flattening
Fix for two defects as follows:

- The IO mapping traverser was not setting inVisit, and would skip some AST nodes.
  Depending on the order of nodes, this could have prevented the binding from
  showing up in the generated SPIR-V.

- If a uniform array was flattened, each of the flattened scalars from the array
  is still a (now-scalar) uniform.  It was being converted to a temporary.
2016-09-22 15:58:06 -06:00
John Kessenich 02df206c9e Merge pull request #516 from amdrexu/feature3
SPV: Implement the extension SPV_KHR_shader_ballot
2016-09-22 10:54:18 -06:00
steve-lunarg e0b9debda2 Flatten uniform arrays
This checkin adds a --flatten-uniform-arrays option which can break
uniform arrays of samplers, textures, or UBOs up into individual
scalars named (e.g) myarray[0], myarray[1], etc.  These appear as
individual linkage objects.

Code notes:

- shouldFlatten internally calls shouldFlattenIO, and shouldFlattenUniform,
  but is the only flattening query directly called.

- flattenVariable will handle structs or arrays (but not yet arrayed structs;
  this is tested an an error is generated).

- There's some error checking around unhandled situations.  E.g, flattening
  uniform arrays with initializer lists is not implemented.

- This piggybacks on as much of the existing mechanism for struct flattening
  as it can.  E.g, it uses the same flattenMap, and the same
  flattenAccess() method.

- handleAssign() has been generalized to cope with either structs or arrays.

- Extended test infrastructure to test flattening ability.
2016-09-22 08:47:48 -06:00
Rex Xu 5159664475 SPV: Implement the extension SPV_KHR_shader_ballot 2016-09-22 16:05:07 +08:00
John Kessenich 6714bcc2ca HLSL: Fix result type of passing a flattened-aggregate to a function. 2016-09-21 17:50:12 -06:00
steve-lunarg 7f7c2ed780 HLSL: Add location offsets per resource type
This PR adds the ability to offset sampler, texture, and UBO bindings
from provided base bindings, and to auto-number bindings that are not
provided with explicit register numbers. The mechanism works as
follows:

- Offsets may be given on the command line for all stages, or
  individually for one or more single stages, in which case the
  offset will be auto-selected according to the stage being
  compiled. There is also an API to set them. The new command line
  options are --shift-sampler-binding, --shift-texture-binding, and
  --shift-UBO-binding.

- Uniforms which are not given explicit bindings in the source code
  are auto-numbered if and only if they are in live code as
  determined by the algorithm used to build the reflection
  database, and the --auto-map-bindings option is given. This auto-numbering
  avoids using any binding slots which were explicitly provided in
  the code, whether or not that explicit use was live. E.g, "uniform
  Texture1D foo : register(t3);" with --shift-texture-binding 10 will
  reserve binding 13, whether or not foo is used in live code.

- Shorter synonyms for the command line options are available.  See
  the --help output.

The testing infrastructure is slightly extended to allow use of the
binding offset API, and two new tests spv.register.(no)autoassign.frag are
added for comparing the resulting SPIR-V.
2016-09-20 20:31:27 -06:00
John Kessenich a1e2d4952e HLSL: Move to correct parsing of annotations, improving all annotations and recent string grammar. 2016-09-20 13:22:58 -06:00
John Kessenich 2572b19e94 HLSL: Turn on reflection, with basic test file, to catch regressions.
This is not a claim that reflection is working right, only a way to
see it is occurring and catch any regression.
2016-09-19 23:12:48 -06:00
John Kessenich 86f7138706 HLSL: Add string basic type and recognize string declaration grammar.
This includes the "< decl ; decl ; >" syntax which has its own namespace.
This functionality is not implemented, just silently accepted.
2016-09-19 20:29:45 -06:00
John Kessenich eee9d536bc Track separate entry-point names and mangled names...
... and use each in the correct way at consumption sites.
This completes issue #513.
2016-09-19 18:09:30 -06:00
steve-lunarg 55717302ef Refactor TLiveTraverser from the former reflection traverser, for future use in binding mapping.
This PR factors out the code that knows how to walk just the live parts of the AST.
The traverser in reflect.cpp is renamed to TReflectionTraverser, and inherits from
TLiveTraverser, which will also be used by a future binding offset PR.

The code is now smart about the entry point name (no longer hardcoded to "main").

There is an option to traverse all code (live+dead), because a consumer of the
class may wish to use it for both purposes without wanting a whole separate
class hierarchy.
2016-09-19 16:33:02 -06:00
John Kessenich 6fccb3cd75 Non-functional: Sweep through the stack for consistent with "main" and entry point.
Partially addresses issue #513.
2016-09-19 16:01:41 -06:00
John Kessenich 142785f324 HLSL: Change the final syntax-error printf to go to the infoLog.
Fixes issue #510.
2016-09-19 14:56:55 -06:00
John Kessenich 28b28140bb HLSL: Fix assert: ensure flattened shadow is EvqTemporary. 2016-09-19 00:19:49 -06:00
John Kessenich 5159d4f1af HLSL: Intercept flatten aggregates passed to a function input, and copy member-by-member. 2016-09-19 00:06:19 -06:00
John Kessenich f911500db8 HLSL: Non-functional; make flatten semantics be about aggregates, not just structures. 2016-09-18 23:36:39 -06:00
John Kessenich d2ce838a58 HLSL: Handle flatten for reads from flatten structs and parameter passing. 2016-09-16 20:24:14 -06:00
John Kessenich 34e7ee79bb HLSL: Improve setting and testing of interpolation qualifiers.
Notably, use of 'linear' on a non-input could mark it as an input.
2016-09-16 18:05:44 -06:00
John Kessenich d21baed6bc HLSL: Flatten whole-struct assigns and returns when targeting flattened I/O structs. 2016-09-16 03:20:03 -06:00
John Kessenich f8e494c18c HLSL: Flatten all input/output structs, regardless of stage.
This is needed because an output structure can contain embedded built-ins
(like SV_Position) which should not get locations assigned.
2016-09-16 01:52:14 -06:00
John Kessenich 7dc630f3da HLSL: Flatten a return struct from an entry point and assign locations after flattening.
Locations now get assigned in order, but skipping built-ins, which can be
done post flattening.
2016-09-16 01:44:43 -06:00
John Kessenich 7f702124ec HLSL: return correct error when HLSL parsing fails.
At least partially addresses issue #510.
2016-09-15 22:49:31 -06:00
John Kessenich deb4940c17 HLSL: Register all entry-point in/out as part of the interface.
This makes the interface be invariant, whether or not individual
variables are used.
2016-09-12 11:55:47 -06:00
John Kessenich b3e24e4359 SPV: Fix issue #506: generalize struct deep copy to include arrays. 2016-09-11 12:33:43 -06:00
John Kessenich cd0a78a0d9 HLSL: Flatten vertex input and fragment output structures.
Vulkan can't handle structures into the vertex stage or out
of the fragment stage.
2016-09-10 11:09:24 -06:00
John Kessenich d4032293ce HLSL: Report an error if SPIR-V for Vulkan wasn't selected. 2016-09-09 11:43:11 -06:00
John Kessenich 4bfb32e17b Merge branch 'bugfix2' of https://github.com/amdrexu/glslang into amdrexu-bugfix2 2016-09-09 10:46:10 -06:00
Rex Xu 99c4dd16db Preprocessor: UINT_MAX is translated to constant incorrectly. 2016-09-09 17:06:15 +08:00
John Kessenich cfd7ce87cd HLSL: Support register(..., spaceN) for setting the descriptor set.
This was suggested in issue #454.
2016-09-05 16:03:45 -06:00
John Kessenich e3218e270e HLSL: Accept layout(...) also as a post-decl. Issue #454. 2016-09-05 14:37:03 -06:00
John Kessenich 7735b94403 HLSL Non-Functional: Move to more robust capturing of postDecls into a qualifier.
This will prevent a possible future defect of thinking the type can be changed,
where there is a code path today that would drop that change.
2016-09-05 12:40:06 -06:00
John Kessenich b804de605c HLSL: Track binding numbers to struct instances; fixes issue #496. 2016-09-05 12:19:18 -06:00
Rex Xu 64bcfdb632 Parser: Add 64-bit type conversion for specialization constant. 2016-09-05 22:20:28 +08:00
John Kessenich 7d01bd6f0b HLSL: Handle swizzles on vectors of size 1. Addresses issue #453. 2016-09-02 22:21:25 -06:00
John Kessenich 841db35bb3 HLSL: Fix issue #442, smear and truncate shape conversions for == and !=. 2016-09-02 21:12:23 -06:00
John Kessenich 07350f3382 HLSL: Handle "fake" entry points, by undoing their built-in variable declarations. 2016-09-02 20:24:07 -06:00
John Kessenich 9e079535a0 HLSL: Handle greater/less depth modes. Fixes issue #489. 2016-09-02 20:05:52 -06:00
John Kessenich a305166ea4 HLSL: Error if funcion with return type doesn't return a value. 2016-09-02 19:13:36 -06:00
John Kessenich 4bf7155051 SPV: Flatten structs for copy when they are GLSL type aliases.
Addresses issue #304 and issue #307 by replacing unmatched type OpStores with
per-member copies. Covers assignment statements and most argument passing, but
does not yet cover r-value-based argument passing.
2016-09-02 16:35:01 -06:00
John Kessenich f2b7f3353b SPV: Tighten up number of struct-types declared based on decoration.
Takes some pressure off of issue #304.
Structures don't inherit locations and then explicitly decorate
members with them, so removed this reason to have another instance
of a structure type.
2016-09-01 17:05:23 -06:00
John Kessenich 5e56423046 Front-ends: Remove now defunct afterEOF and related, use scanner's instead.
Code using atEndOfFile was dead, instead do something useful with
the scanners atEndOfInput().  This allows a better error message
for early termination of cascading errors.
2016-08-31 13:46:50 -06:00
John Kessenich 830b0cc98b HLSL: Start location numbering with the entry-point return value.
Also, increment location numbers by the size of the objects.
2016-08-29 18:10:47 -06:00
John Kessenich a05d8b5604 HLSL: Remove recent change to put locations on SV_TARGET*.
This put locations on members of structures, which is not allowed
in either AST or SPIR-V.

This was caught by asserts in the debug build.
2016-08-29 16:49:39 -06:00
John Kessenich 510d83b384 HLSL: Create test results for the previous commits. 2016-08-29 16:34:12 -06:00
John Kessenich 81d4714908 Merge branch 'HLSL_Semantic_Mapping' of https://github.com/dankbaker/glslang into dankbaker-HLSL_Semantic_Mapping 2016-08-29 16:07:29 -06:00
John Kessenich 6a70eb7161 HLSL: Emulate write-to-output on return-from-entry-point, for return value.
This fixes issue #487 and #480.
It also correctly handles output parameters from the entry point.
2016-08-28 20:13:07 -06:00
John Kessenich 81cd764b5f Non-functional: Add some missing const, related to signature selection. 2016-08-26 14:01:43 -06:00
John Kessenich e3f2c8f98a HLSL: Include shape-changing conversions in overloaded signature selection.
This also enables vecN -> vec1 shape conversions for all places doing shape
conversions.

For signature selection, makes shape changes worse than any other comparison
when deciding what conversions are better than others.
2016-08-25 23:57:39 -06:00
John Kessenich 90dd70f752 HLSL: Allow arbitrary baseType -> baseType conversion of calling arguments.
This also puts a stake in the ground as to which is better when selection
from multiple signatures.
2016-08-25 10:51:29 -06:00
John Kessenich fcc0aa3b64 HLSL: Switch to generic selector, but using GLSL #version 400 rules.
Next step is to modify for HLSL rules.
2016-08-24 18:34:43 -06:00
John Kessenich ab89bbe702 Merge branch 'overloaded-400' of github.com:KhronosGroup/glslang 2016-08-23 18:30:20 -06:00
John Kessenich 32c169dbdf Front-end: Warn for likely missed change in default precisions.
This is part of the change to have desktop shaders respect precision
qualifiers on Vulkan, but since the defaults are all highp, and that's
different from ES fragment shaders, detect likely cases and warn about
them (but being careful to not be too noisy if it's unlikely to be a
problem).
2016-08-23 18:13:08 -06:00
John Kessenich 54571c2519 Vulkan: Have desktop shaders respect precision qualifiers.
Sets highp defaults for the appropriate types, for all stages,
and turns on precision qualifiers for non-ES shaders.  Required
fixing some qualifier orders for desktop built-in declarations
for pre-420 shaders.
2016-08-23 18:12:25 -06:00
John Kessenich 4d535640e4 Front-End: Non-ES trigger for processing precision qualifiers.
Initially non-functional: Have an independent test for whether to obey
precision qualifiers other than whether the profile is es.
2016-08-23 18:12:25 -06:00
John Kessenich 219b025d7e Non-functional: Fix commit 98f164ec48.
Fix previous commit to not use tabs and otherwise match local coding
conventions better.
2016-08-23 17:51:13 -06:00
steve-lunarg efe9724795 HLSL: Add EHTokStringConstant, so that string attributes may be parsed 2016-08-22 17:13:17 -06:00
John Kessenich 370234888d Front-end: Add a function selector under implicit type conversion.
Use the new function selector for #version 400 and above,
parameterized for the GLSL #version 400 selection rules.

This can be used for both GLSL and HLSL, and other languages
as well.
2016-08-21 14:26:27 -06:00
John Kessenich 0a04b4df02 Front-end/Non-functional: Add some const/auto, useful for upcoming changes. 2016-08-19 07:27:28 -06:00
John Kessenich 2c6038ecf1 Merge branch 'cpp-headers' 2016-08-11 10:01:13 -06:00
John Kessenich 0a6fb85494 Infrastructure: Make shared symbol-table cache complete, delete work around.
Fixes issue #370 and replaces PR #371.
2016-08-09 19:15:17 -06:00
steve-lunarg c4a1307403 HLSL: add implicit promotions for assignments and function returns. 2016-08-09 13:48:47 -06:00
John Kessenich 426542ba57 Front-end: Fix issue #443: dvec3 uses only 2 components of second location. 2016-08-08 15:34:00 -06:00
John Kessenich 34177cd778 Tests: Test base case for fixing issue #443. 2016-08-08 15:29:25 -06:00
John Kessenich 4583b61e20 HLSL: Smear scalars to match vectors for relational operations.
Yield a vector relational compare and a vector result.
2016-08-07 19:14:22 -06:00
John Kessenich 267590d452 Whitespace: Nonfunctional: fix inconsistent white space, esp. no tabs. 2016-08-05 17:34:34 -06:00
John Kessenich bbd1b0ef76 Tests: Add some location-decoration tests, to aid PR #422. 2016-08-05 15:19:46 -06:00
John Kessenich 66ec80e01b Build: C++ headers: Replace PR #366 with a more directed version. 2016-08-05 14:04:23 -06:00
John Kessenich 9f9bad09b4 PP: Add missing atoms that effect -E mode.
When preprocessing only, some tokens were emitted as <bad token>.
This fixes them to preserve their original content.

This supplants PR #182, with a correction and test results.
2016-08-04 22:46:19 -06:00
steve-lunarg 7dfcf4d1ad HLSL: Add GatherRed/Green/Blue/Alpha methods, inc 4-offset forms 2016-08-03 13:34:39 -06:00
John Kessenich f6640761c4 Front-end: Implement 2nd task of issue #400; precision of result and operation.
From the ES spec + Bugzilla 15931 and GL_KHR_vulkan_glsl:
- Update precision qualifiers for all built-in function prototypes.
- Implement the new algorithm used to distinguish built-in function
  operation precisions from result precisions.
Also add tracking of separate result and operation precisions, and
use that in generating SPIR-V.
(SPIR-V cares about precision of operation, while the front-end
cares about precision of result, for propagation.)
2016-08-02 21:48:02 -06:00
John Kessenich 1176530bf5 SPV: Prevent issue #415 with better semantic checking. 2016-07-31 12:39:46 -06:00
John Kessenich 11e1a073f3 PP: Fix issue #407; handle empty identifier.
The sequence

  #define m()
  int m"

creates a token of no length (a string of 0 size).  Protect
against a string of 0 size as well as the existing protect
against a null string.
2016-07-30 13:39:52 -06:00