platform/upstream/glslang.git
7 years agoHLSL: Have loose uniforms also go through the makeTypeNonIo() path.
John Kessenich [Fri, 3 Feb 2017 21:06:36 +0000 (14:06 -0700)]
HLSL: Have loose uniforms also go through the makeTypeNonIo() path.

7 years agoHLSL: remove pervertex output blocks
steve-lunarg [Fri, 3 Feb 2017 20:37:54 +0000 (13:37 -0700)]
HLSL: remove pervertex output blocks

This removes pervertex output blocks, in favor of using only
loose variables.  The pervertex blocks are not required and were
only partly implemented, and were adding some complication.

This change goes with wrap-entry-point.

7 years agoBuild: Fix Linux for older compiler: Use TMap instead of TUndorderedMap.
John Kessenich [Fri, 3 Feb 2017 18:21:24 +0000 (11:21 -0700)]
Build: Fix Linux for older compiler: Use TMap instead of TUndorderedMap.

7 years agoHLSL: fix copies between arrays of structs of builtins, and arrayed builtins.
steve-lunarg [Thu, 2 Feb 2017 23:32:02 +0000 (16:32 -0700)]
HLSL: fix copies between arrays of structs of builtins, and arrayed builtins.

Structs are split to remove builtin members to create valid SPIR-V.  In this
process, an outer structure array dimension may be propegated onto the
now-removed builtin variables.  For example, a mystruct[3].position ->
position[3].  The copy between the split and unsplit forms would handle
this in some cases, but not if the array dimension was at different levels
of aggregate.

It now does this, but may not handle arbitrary composite types.  Unclear if
that has any semantic meaning for builtins though.

7 years agoHLSL: Make the entry-point shadow function have non-IO params and return.
John Kessenich [Thu, 2 Feb 2017 01:09:17 +0000 (18:09 -0700)]
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.

7 years agoHLSL: Type sanitization: create non-IO types for var decl and fn param/ret
steve-lunarg [Wed, 25 Jan 2017 17:03:17 +0000 (10:03 -0700)]
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.

7 years agoAST: Have type deepCopy() preserve type graphs as graphs.
John Kessenich [Wed, 1 Feb 2017 20:14:03 +0000 (13:14 -0700)]
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.

7 years agoHLSL: Wrap the entry-point; need to write 'in' args, and support 'inout' args.
John Kessenich [Thu, 19 Jan 2017 22:41:47 +0000 (15:41 -0700)]
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

7 years agoResolve issue #700: allow initializers on struct members.
John Kessenich [Thu, 2 Feb 2017 22:16:20 +0000 (15:16 -0700)]
Resolve issue #700: allow initializers on struct members.

7 years agoMemory/constructor/warning clean-up. Addresses issue #705.
John Kessenich [Thu, 2 Feb 2017 21:55:02 +0000 (14:55 -0700)]
Memory/constructor/warning clean-up. Addresses issue #705.

7 years agoMerge pull request #711 from eoma/fix-friendly-specialization-name
John Kessenich [Thu, 2 Feb 2017 21:26:06 +0000 (14:26 -0700)]
Merge pull request #711 from eoma/fix-friendly-specialization-name

SPV: Emit names of specialization constants, fixes #710

7 years agoSPV: Emit names of specialization constants
Endre Oma [Tue, 31 Jan 2017 20:08:19 +0000 (21:08 +0100)]
SPV: Emit names of specialization constants

7 years agoMerge pull request #706 from Ralith/install-headers
John Kessenich [Mon, 30 Jan 2017 03:44:31 +0000 (20:44 -0700)]
Merge pull request #706 from Ralith/install-headers

Install headers

7 years agoInstall headers
Benjamin Saunders [Mon, 30 Jan 2017 01:45:12 +0000 (17:45 -0800)]
Install headers

This enables the vulkan loader to be built against an installed glslang.

7 years agoFix bug from PR #678: NV_EXTENSIONS deleted implicit array sizing.
John Kessenich [Fri, 27 Jan 2017 05:03:57 +0000 (22:03 -0700)]
Fix bug from PR #678: NV_EXTENSIONS deleted implicit array sizing.

7 years agoFix issue #693. Ternary operator on void type.
John Kessenich [Thu, 26 Jan 2017 22:48:27 +0000 (15:48 -0700)]
Fix issue #693. Ternary operator on void type.

7 years agoMerge pull request #690 from ligfx/proper_dependencies
John Kessenich [Thu, 26 Jan 2017 22:13:27 +0000 (15:13 -0700)]
Merge pull request #690 from ligfx/proper_dependencies

CMake: add target_link_libraries internally

7 years agoREADME: point to HLSL status issues
John Kessenich [Thu, 26 Jan 2017 19:12:36 +0000 (12:12 -0700)]
README: point to HLSL status issues

7 years agoMerge pull request #702 from resetnow/master
John Kessenich [Thu, 26 Jan 2017 18:51:31 +0000 (11:51 -0700)]
Merge pull request #702 from resetnow/master

SpvBuilder: add const specifier to vector reference arguments

7 years agoSpvBuilder: add const specifier to vector reference arguments
Vlad Ivanov [Thu, 26 Jan 2017 17:46:02 +0000 (20:46 +0300)]
SpvBuilder: add const specifier to vector reference arguments

7 years agoMerge pull request #694 from mtavenrath/fix_origin_link
John Kessenich [Thu, 26 Jan 2017 17:39:54 +0000 (10:39 -0700)]
Merge pull request #694 from mtavenrath/fix_origin_link

Use correct OriginUpperLeft when linking more than one shader.

7 years agoUse correct OriginUpperLeft when linking more than one shader.
Markus Tavenrath [Tue, 24 Jan 2017 00:53:16 +0000 (16:53 -0800)]
Use correct OriginUpperLeft when linking more than one shader.

7 years agoMerge pull request #696 from amdrexu/bugfix2
John Kessenich [Tue, 24 Jan 2017 17:58:21 +0000 (10:58 -0700)]
Merge pull request #696 from amdrexu/bugfix2

Semantics: Texture clamp functions are available for fragment shader only

7 years agoMerge pull request #695 from amdrexu/bugfix
John Kessenich [Tue, 24 Jan 2017 17:57:54 +0000 (10:57 -0700)]
Merge pull request #695 from amdrexu/bugfix

Fix a CMakeLists issue

7 years agoSemantics: Texture clamp functions are available for fragment shader only.
Rex Xu [Tue, 24 Jan 2017 06:36:10 +0000 (14:36 +0800)]
Semantics: Texture clamp functions are available for fragment shader only.

7 years agoFix a CMakeLists issue
Rex Xu [Tue, 24 Jan 2017 06:24:21 +0000 (14:24 +0800)]
Fix a CMakeLists issue

7 years agoMerge pull request #692 from hrydgard/no-nvextensions-build-fix
John Kessenich [Mon, 23 Jan 2017 19:34:15 +0000 (12:34 -0700)]
Merge pull request #692 from hrydgard/no-nvextensions-build-fix

Fix build if NV_EXTENSIONS is not set

7 years agoFix build if NV_EXTENSIONS is not set
Henrik Rydgard [Mon, 23 Jan 2017 15:25:50 +0000 (16:25 +0100)]
Fix build if NV_EXTENSIONS is not set

7 years agoMerge pull request #678 from chaoc/stereo_view_rendering
John Kessenich [Sat, 21 Jan 2017 19:05:47 +0000 (12:05 -0700)]
Merge pull request #678 from chaoc/stereo_view_rendering

support SPV_NV_viewport_array2 and SPV_NV_stereo_view_rendering

7 years agoCMake: add target_link_libraries internally
Michael Maltese [Sat, 21 Jan 2017 18:59:15 +0000 (10:59 -0800)]
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.

7 years agosupport SPV_NV_viewport_array2 and SPV_NV_stereo_view_rendering
chaoc [Fri, 13 Jan 2017 09:10:53 +0000 (01:10 -0800)]
support SPV_NV_viewport_array2 and SPV_NV_stereo_view_rendering

7 years agoMerge pull request #689 from mikew-lunarg/master
John Kessenich [Sat, 21 Jan 2017 00:10:29 +0000 (17:10 -0700)]
Merge pull request #689 from mikew-lunarg/master

Fix for not-handled-in-switch warnings

7 years agoFix for not-handled-in-switch warnings
Mike Weiblen [Fri, 20 Jan 2017 20:34:10 +0000 (13:34 -0700)]
Fix for not-handled-in-switch warnings

Added default to the switch() for AMD_EXTENSIONS to avoid a spew
of warning messages.

7 years agoMerge pull request #683 from rdb/master
John Kessenich [Fri, 20 Jan 2017 20:21:43 +0000 (13:21 -0700)]
Merge pull request #683 from rdb/master

Fix compilation with MSVC 2010

7 years agoFix compilation with MSVC 2010
rdb [Fri, 20 Jan 2017 13:46:39 +0000 (14:46 +0100)]
Fix compilation with MSVC 2010

7 years agoMerge pull request #682 from steve-lunarg/split-copy-fix
John Kessenich [Thu, 19 Jan 2017 23:56:06 +0000 (16:56 -0700)]
Merge pull request #682 from steve-lunarg/split-copy-fix

HLSL: fix dereferencing when copying split structures with arrays

7 years agoMerge pull request #679 from ashwinkolhe/akolhe_spv_khr_subgroup_vote
John Kessenich [Thu, 19 Jan 2017 23:16:49 +0000 (16:16 -0700)]
Merge pull request #679 from ashwinkolhe/akolhe_spv_khr_subgroup_vote

Implement SPV_KHR_subgroup_vote

7 years agoSPV: Merge pull request #675 from amdrexu/feature
John Kessenich [Thu, 19 Jan 2017 23:14:28 +0000 (16:14 -0700)]
SPV: Merge pull request #675 from amdrexu/feature

SPV: Implement new revision of extension GL_AMD_shader_ballot

7 years agoInfrastructure: remove potential memory leaks.
John Kessenich [Thu, 19 Jan 2017 22:29:25 +0000 (15:29 -0700)]
Infrastructure: remove potential memory leaks.

7 years agoHLSL: fix dereferencing when copying split structures with arrays
steve-lunarg [Thu, 19 Jan 2017 22:18:00 +0000 (15:18 -0700)]
HLSL: fix dereferencing when copying split structures with arrays

When copying split types with mixtures of user variables and buitins,
where the builtins are extracted, there is a parallel structures traversal.
The traversal was not obtaining the derefenced types in the array case.

7 years agoImplement new revision of extension GL_AMD_shader_ballot
Rex Xu [Fri, 14 Oct 2016 09:22:23 +0000 (17:22 +0800)]
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.

7 years agoNon-functional: Factor out entry-point logic from handleFunctionDefinition().
John Kessenich [Wed, 18 Jan 2017 23:45:02 +0000 (16:45 -0700)]
Non-functional: Factor out entry-point logic from handleFunctionDefinition().

7 years agoImplement SPV_KHR_subgroup_vote
Ashwin Kolhe [Wed, 18 Jan 2017 22:16:49 +0000 (14:16 -0800)]
Implement SPV_KHR_subgroup_vote

doc.cpp: Add capabilities, scope to the opcodes. Add opcode and
capability strings.
GLSL.ext.KHR.h: Add extension
string.
GlslangToSpv.cpp: Fix handling of opcodes to generate
appropriate SPIR-V.
spirv.hpp: Add capability and opcode
enums.
spv.shaderGroupVote.comp.out: Update SPIR-V output for test
shader.

7 years agoFix build break for non-VS.
John Kessenich [Sat, 14 Jan 2017 03:22:00 +0000 (20:22 -0700)]
Fix build break for non-VS.

7 years agoNon-functional: Fix round of compiler warnings.
John Kessenich [Sat, 14 Jan 2017 03:08:54 +0000 (20:08 -0700)]
Non-functional: Fix round of compiler warnings.

7 years agoFront-ends: Non-functional: Rationalize vector and matrix swizzles.
John Kessenich [Sat, 14 Jan 2017 02:34:22 +0000 (19:34 -0700)]
Front-ends: Non-functional: Rationalize vector and matrix swizzles.

This reduces code duplication in a few ways, and better encapsulates
vector swizzle representation.

7 years agoMerge pull request #656 from TiemoJung/overload_fix
John Kessenich [Fri, 13 Jan 2017 22:10:20 +0000 (15:10 -0700)]
Merge pull request #656 from TiemoJung/overload_fix

HLSL: Improved overload handling

7 years agoHLSL: Add EOpMatrixSwizzle, selectively decomposed to other ops, for issue #670.
John Kessenich [Fri, 13 Jan 2017 19:27:52 +0000 (12:27 -0700)]
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.

7 years agoHLSL: matrix swizzle (_12, _m23) syntax, partial semantics.
John Kessenich [Thu, 12 Jan 2017 23:51:18 +0000 (16:51 -0700)]
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.

7 years agoPP: Clean up and rationalize floating-point-number scanner.
John Kessenich [Thu, 12 Jan 2017 19:00:59 +0000 (12:00 -0700)]
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).

7 years agoMerge pull request #664 from steve-lunarg/stage-io-fix
John Kessenich [Thu, 12 Jan 2017 17:18:23 +0000 (10:18 -0700)]
Merge pull request #664 from steve-lunarg/stage-io-fix

add other builtins to interstage IO

7 years agoInfrastructure: Support standard build with ENABLE_HLSL set to off.
John Kessenich [Wed, 11 Jan 2017 21:50:16 +0000 (14:50 -0700)]
Infrastructure: Support standard build with ENABLE_HLSL set to off.

7 years agoInfrastructure: Protect against missing built-in symbol table generators.
John Kessenich [Wed, 11 Jan 2017 21:24:56 +0000 (14:24 -0700)]
Infrastructure: Protect against missing built-in symbol table generators.

7 years agoMerge pull request #663 from KhronosGroup/full-include-semantics
John Kessenich [Wed, 11 Jan 2017 01:49:07 +0000 (18:49 -0700)]
Merge pull request #663 from KhronosGroup/full-include-semantics

Includer interface change to support full include semantics (requires downstream changes)

7 years agoMerge pull request #668 from slime73/DisableHLSL
John Kessenich [Tue, 10 Jan 2017 01:52:55 +0000 (18:52 -0700)]
Merge pull request #668 from slime73/DisableHLSL

Add a CMake option to disable compilation of HLSL input support.

7 years agoChange disabled-by-default DISABLE_HLSL option to enabled-by-default ENABLE_HLSL.
Alex Szpakowski [Mon, 9 Jan 2017 22:10:14 +0000 (18:10 -0400)]
Change disabled-by-default DISABLE_HLSL option to enabled-by-default ENABLE_HLSL.

Matches existing options.

7 years agoWIP: add other builtins to interstage IO
steve-lunarg [Sat, 7 Jan 2017 16:07:14 +0000 (09:07 -0700)]
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)

7 years agoAdd a CMake option to disable compilation of HLSL input support.
Alex Szpakowski [Mon, 9 Jan 2017 01:20:25 +0000 (21:20 -0400)]
Add a CMake option to disable compilation of HLSL input support.

7 years agoMerge pull request #667 from slime73/Compiler-Warnings
John Kessenich [Sun, 8 Jan 2017 23:11:24 +0000 (16:11 -0700)]
Merge pull request #667 from slime73/Compiler-Warnings

Address several compiler warnings

7 years agoReorder initializer fields to match variable declaration order (or vice versa) for...
Alex Szpakowski [Sun, 8 Jan 2017 22:21:17 +0000 (18:21 -0400)]
Reorder initializer fields to match variable declaration order (or vice versa) for several class constructors.

7 years agoAdd a virtual destructor to a class which has virtual methods.
Alex Szpakowski [Sun, 8 Jan 2017 21:57:21 +0000 (17:57 -0400)]
Add a virtual destructor to a class which has virtual methods.

7 years agoMark an overriden method in a subclass with ‘override’.
Alex Szpakowski [Sun, 8 Jan 2017 21:54:48 +0000 (17:54 -0400)]
Mark an overriden method in a subclass with ‘override’.

7 years agoPP #include: address PR feedback.
John Kessenich [Fri, 6 Jan 2017 23:48:18 +0000 (16:48 -0700)]
PP #include: address PR feedback.

7 years agoExternal interface change: PP: Full <> and "" semantics for the Includer.
John Kessenich [Fri, 6 Jan 2017 22:01:48 +0000 (15:01 -0700)]
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

7 years agoPP #include non-functional: consistent notation for "header" and "header name".
John Kessenich [Fri, 6 Jan 2017 21:54:18 +0000 (14:54 -0700)]
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.

7 years agoNon-functional: White space after "//", mostly for copyrights.
John Kessenich [Fri, 6 Jan 2017 19:34:14 +0000 (12:34 -0700)]
Non-functional: White space after "//", mostly for copyrights.

7 years agoNon-Functional: Whitespace, comments, replace accidentally deleted comment.
John Kessenich [Fri, 6 Jan 2017 07:34:48 +0000 (00:34 -0700)]
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

7 years agoMerge pull request #661 from KhronosGroup/fix-include-error-paths
John Kessenich [Fri, 6 Jan 2017 07:32:39 +0000 (00:32 -0700)]
Merge pull request #661 from KhronosGroup/fix-include-error-paths

PP: #include: simplify the different paths out of #include.

7 years agoPP: #include: simplify the different paths out of #include.
John Kessenich [Thu, 5 Jan 2017 20:32:52 +0000 (13:32 -0700)]
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.

7 years agoPP: #include: add names to error messages, so that lexical analysis can be tested.
John Kessenich [Thu, 5 Jan 2017 19:18:34 +0000 (12:18 -0700)]
PP: #include: add names to error messages, so that lexical analysis can be tested.

7 years agoNon-functional: Very minor clean up.
John Kessenich [Thu, 5 Jan 2017 17:45:32 +0000 (10:45 -0700)]
Non-functional: Very minor clean up.

7 years agoMerge pull request #650 from steve-lunarg/lvalue-swizzle-fix
John Kessenich [Thu, 5 Jan 2017 17:40:14 +0000 (10:40 -0700)]
Merge pull request #650 from steve-lunarg/lvalue-swizzle-fix

HLSL: allow destination swizzles when writing RWTexture/RWBuffer

7 years agoHLSL: Fix issue #658: Don't adopt initializer constness from declaration.
John Kessenich [Thu, 5 Jan 2017 17:28:26 +0000 (10:28 -0700)]
HLSL: Fix issue #658: Don't adopt initializer constness from declaration.

This also makes it match how GLSL handles the same thing.

7 years agoMerge pull request #648 from steve-lunarg/type-identifiers
John Kessenich [Wed, 4 Jan 2017 21:07:34 +0000 (14:07 -0700)]
Merge pull request #648 from steve-lunarg/type-identifiers

HLSL: allow type keywords as identifiers, and add half type

7 years agoMerge pull request #632 from steve-lunarg/structure-splitting
John Kessenich [Wed, 4 Jan 2017 18:41:36 +0000 (11:41 -0700)]
Merge pull request #632 from steve-lunarg/structure-splitting

HLSL: inter-stage structure splitting.

7 years agoMerge pull request #659 from steve-lunarg/d3dcolortoubyte4
John Kessenich [Tue, 3 Jan 2017 22:34:33 +0000 (15:34 -0700)]
Merge pull request #659 from steve-lunarg/d3dcolortoubyte4

Add D3DCOLORtoUBYTE4 decomposition

7 years agoMerge pull request #647 from steve-lunarg/default-fn-params
John Kessenich [Tue, 3 Jan 2017 22:30:05 +0000 (15:30 -0700)]
Merge pull request #647 from steve-lunarg/default-fn-params

HLSL: default function parameters

7 years agoAdd EOpD3DCOLORtoUBYTE4 decomposition
steve-lunarg [Tue, 3 Jan 2017 21:42:18 +0000 (14:42 -0700)]
Add EOpD3DCOLORtoUBYTE4 decomposition

7 years agoPP: Recognize <> style #include header names. I.e., #include <header-name>.
John Kessenich [Tue, 3 Jan 2017 03:12:08 +0000 (20:12 -0700)]
PP: Recognize <> style #include header names. I.e., #include <header-name>.

Also correctly test and handle missing newline.

7 years agoHLSL: allow destination swizzles when writing RWTexture/RWBuffer objects.
steve-lunarg [Wed, 28 Dec 2016 17:03:58 +0000 (10:03 -0700)]
HLSL: allow destination swizzles when writing RWTexture/RWBuffer objects.

Reads and write syntax to UAV objects is turned into EOpImageLoad/Store
operations.  This translation did not support destination swizzles,
for example, "mybuffer[tc].zyx = 3;", so such statements would fail to
compile.  Now they work.

Parial updates are explicitly prohibited.

New test: hlsl.rw.swizzle.frag

7 years agoPP: Fix issue #426, recover from bad-source macro expansion.
John Kessenich [Tue, 3 Jan 2017 00:56:08 +0000 (17:56 -0700)]
PP: Fix issue #426, recover from bad-source macro expansion.

7 years agoSPV: Fix issue #369, don't support gl_NumSamples -> SPIR-V.
John Kessenich [Tue, 3 Jan 2017 00:01:21 +0000 (17:01 -0700)]
SPV: Fix issue #369, don't support gl_NumSamples -> SPIR-V.

7 years agoHLSL: Fix issue #646: map SV_DispatchThreadID -> GlobalInvocationID.
John Kessenich [Mon, 2 Jan 2017 21:59:19 +0000 (14:59 -0700)]
HLSL: Fix issue #646: map SV_DispatchThreadID -> GlobalInvocationID.

7 years agoupdates overload handling to be more careful when allowing overloads over texture...
t.jung [Mon, 2 Jan 2017 16:10:27 +0000 (17:10 +0100)]
updates overload handling to be more careful when allowing overloads over texture types

Change-Id: I60cf0b0e03da89b0e415125f1a9ffb1de7db71d4

7 years agoHLSL: Handle const with no initializer. Fixes issue #651.
John Kessenich [Fri, 30 Dec 2016 23:42:57 +0000 (16:42 -0700)]
HLSL: Handle const with no initializer. Fixes issue #651.

7 years agoHLSL: Support empty {} initializers for arrays and scalars.
John Kessenich [Fri, 30 Dec 2016 22:59:28 +0000 (15:59 -0700)]
HLSL: Support empty {} initializers for arrays and scalars.

7 years agoHLSL default function parameters
steve-lunarg [Sat, 24 Dec 2016 01:56:57 +0000 (18:56 -0700)]
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.

7 years agoHLSL: allow scalar type keywords as identifiers, and add half type support.
steve-lunarg [Tue, 27 Dec 2016 01:45:52 +0000 (18:45 -0700)]
HLSL: allow scalar type keywords as identifiers, and add half type support.

HLSL allows type keywords to also be identifiers, so a sequence such as "float half = 3" is
valid, or more bizzarely, something like "float.float = int.uint + bool;"

There are places this is not supported.  E.g, it's permitted for struct members, but not struct
names or functions.  Also, vector or matrix types such as "float3" are not permitted as
identifiers.

This PR adds that support, as well as support for the "half" type.  In production shaders,
this was seen with variables named "half".  The PR attempts to support this without breaking
useful grammar errors such as "; expected" at the end of unterminated statements, so it errs
on that side at the possible expense of failing to accept valid constructs containing a type
keyword identifier.  If others are discovered, they can be added.

Also, half is now accepted as a valid type, alongside the min*float types.

7 years agoHLSL: struct splitting: assignments of hierarchical split types
steve-lunarg [Mon, 19 Dec 2016 22:48:01 +0000 (15:48 -0700)]
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.

7 years agoHLSL: inter-stage structure splitting.
steve-lunarg [Wed, 14 Dec 2016 22:22:25 +0000 (15:22 -0700)]
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.

7 years agoMerge pull request #640 from chaoc/modify-shader-ballot
John Kessenich [Thu, 22 Dec 2016 00:40:29 +0000 (17:40 -0700)]
Merge pull request #640 from chaoc/modify-shader-ballot

Modify shader ballot extension by adding OpSubgroupReadInvocationKHR

7 years agoPP: Non-functional: Make a proper class out of the atom <-> string mapping.
John Kessenich [Wed, 21 Dec 2016 20:49:16 +0000 (13:49 -0700)]
PP: Non-functional: Make a proper class out of the atom <-> string mapping.

7 years agoModify shader ballot extension by adding OpSubgroupReadInvocationKHR
chaoc [Tue, 20 Dec 2016 20:44:35 +0000 (12:44 -0800)]
Modify shader ballot extension by adding OpSubgroupReadInvocationKHR

7 years agoPP: Support operator creation with token pasting.
John Kessenich [Wed, 21 Dec 2016 19:32:56 +0000 (12:32 -0700)]
PP: Support operator creation with token pasting.

7 years agoPP: Rationalize names of tokens.
John Kessenich [Wed, 21 Dec 2016 18:55:53 +0000 (11:55 -0700)]
PP: Rationalize names of tokens.

7 years agoMerge pull request #641 from chaoc/passthrough
John Kessenich [Wed, 21 Dec 2016 17:59:07 +0000 (10:59 -0700)]
Merge pull request #641 from chaoc/passthrough

Add support for SPV_NV_geometry_shader_passthrough

7 years agoMerge pull request #644 from hrydgard/override-warning-fixes
John Kessenich [Wed, 21 Dec 2016 17:50:33 +0000 (10:50 -0700)]
Merge pull request #644 from hrydgard/override-warning-fixes

Fix a large number of Clang warnings about inconsistent usage of 'override'

7 years agoFix a large number of warnings about inconsistent usage of 'override' produced by...
Henrik Rydgård [Wed, 21 Dec 2016 11:48:08 +0000 (12:48 +0100)]
Fix a large number of warnings about inconsistent usage of 'override' produced by clang

7 years agoPP: Non-functional: Only use string <-> atom mapping when needed.
John Kessenich [Wed, 21 Dec 2016 04:47:30 +0000 (21:47 -0700)]
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.

7 years agoPP: Non-functional: rationalize TPpToken.
John Kessenich [Wed, 21 Dec 2016 02:42:53 +0000 (19:42 -0700)]
PP: Non-functional: rationalize TPpToken.

Always keep 'token' outside.
Always return the string to upper levels inside.