platform/upstream/glslang.git
8 years agoMerge pull request #539 from schwa423/linux_global_lock
John Kessenich [Sun, 16 Oct 2016 04:53:46 +0000 (22:53 -0600)]
Merge pull request #539 from schwa423/linux_global_lock

Use pthread_mutex for global lock on Linux.

8 years agoMerge pull request #550 from amdrexu/bugfix
John Kessenich [Sun, 16 Oct 2016 04:49:53 +0000 (22:49 -0600)]
Merge pull request #550 from amdrexu/bugfix

SPV: Add missing extension declarations for certain AMD extensions.

8 years agoMerge pull request #549 from steve-lunarg/multidim-array
John Kessenich [Sun, 16 Oct 2016 04:43:43 +0000 (22:43 -0600)]
Merge pull request #549 from steve-lunarg/multidim-array

HLSL: allow multi-dimensional arrays

8 years agoUse a recursive mutex.
Josh Gargus [Sat, 15 Oct 2016 22:19:59 +0000 (15:19 -0700)]
Use a recursive mutex.

8 years agoSPV: Add missing extension declarations for certain AMD extensions.
Rex Xu [Fri, 14 Oct 2016 09:41:45 +0000 (17:41 +0800)]
SPV: Add missing extension declarations for certain AMD extensions.

8 years agoMerge pull request #542 from steve-lunarg/rwbuffers
John Kessenich [Thu, 13 Oct 2016 18:49:56 +0000 (12:49 -0600)]
Merge pull request #542 from steve-lunarg/rwbuffers

HLSL: phase 2: add operator[]

8 years agoMerge pull request #538 from steve-lunarg/iomap-binding-range-err
John Kessenich [Thu, 13 Oct 2016 18:44:16 +0000 (12:44 -0600)]
Merge pull request #538 from steve-lunarg/iomap-binding-range-err

Check for out-of-range bindings during IO mapping.

8 years agoHLSL: allow multi-dimensional arrays
steve-lunarg [Thu, 13 Oct 2016 18:26:18 +0000 (12:26 -0600)]
HLSL: allow multi-dimensional arrays

All the underpinnings are there; this just parses multiple array dimensions
and passes them through to the existing mechanisms.

Also, minor comment fixes, and add a new test for multi-dim arrays.

8 years agoHLSL: phase 2e: introduce lower level addBinaryNode/UnaryNode fns
steve-lunarg [Wed, 12 Oct 2016 18:38:12 +0000 (12:38 -0600)]
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

8 years agoHLSL: phase 2d: minor cleanup, & allow operator[] on non-rw textures
steve-lunarg [Mon, 10 Oct 2016 16:00:14 +0000 (10:00 -0600)]
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.

8 years agoHLSL: phase 2c: use lValueErrorCheck in HLSL FE
steve-lunarg [Sat, 8 Oct 2016 16:54:52 +0000 (10:54 -0600)]
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.

8 years agoHLSL: phase 2b: add l-value operator[] for RWTexture/RWBuffer
steve-lunarg [Sat, 8 Oct 2016 01:35:40 +0000 (19:35 -0600)]
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]++++;

8 years agoHLSL: phase 2a: add r-value operator[] for RWTexture/RWBuffer
steve-lunarg [Fri, 7 Oct 2016 02:12:24 +0000 (20:12 -0600)]
HLSL: phase 2a: add r-value operator[] for RWTexture/RWBuffer

This commit adds r-value support for RW textures and buffers.
Supported is:

- Function in parameter conversions
- conversion of rvalue use to imageLoad

8 years agoMerge pull request #546 from yavn/OpImageQueryLod-with-SampledImage
John Kessenich [Wed, 12 Oct 2016 15:05:07 +0000 (09:05 -0600)]
Merge pull request #546 from yavn/OpImageQueryLod-with-SampledImage

SPV: Use SampledImage with OpImageQueryLod

8 years agoSPV: Use SampledImage with OpImageQueryLod
Maciej Jesionowski [Wed, 12 Oct 2016 13:40:37 +0000 (15:40 +0200)]
SPV: Use SampledImage with OpImageQueryLod

Khronos SPIR-V issue #74

8 years agoMerge pull request #543 from slime73/compilerwarnings
John Kessenich [Tue, 11 Oct 2016 21:31:31 +0000 (15:31 -0600)]
Merge pull request #543 from slime73/compilerwarnings

Address some compiler warnings.

8 years agofixup! Address some compiler warnings.
Alex Szpakowski [Tue, 11 Oct 2016 19:16:47 +0000 (16:16 -0300)]
fixup! Address some compiler warnings.

8 years agoMerge pull request #544 from amdrexu/feature
John Kessenich [Tue, 11 Oct 2016 15:29:30 +0000 (09:29 -0600)]
Merge pull request #544 from amdrexu/feature

SPV: Implement extension SPV_KHR_shader_draw_parameters.

8 years agoSPV: Implement extension SPV_KHR_shader_draw_parameters.
Rex Xu [Fri, 22 Jul 2016 10:15:31 +0000 (18:15 +0800)]
SPV: Implement extension SPV_KHR_shader_draw_parameters.

8 years agoMerge pull request #545 from amdrexu/bugfix
John Kessenich [Mon, 10 Oct 2016 15:43:30 +0000 (09:43 -0600)]
Merge pull request #545 from amdrexu/bugfix

Parser: Some function prototypes of interpolateAtXXX are incorrect.

8 years agoParser: Some function prototypes of interpolateAtXXX are incorrect.
Rex Xu [Mon, 10 Oct 2016 07:38:15 +0000 (15:38 +0800)]
Parser: Some function prototypes of interpolateAtXXX are incorrect.

8 years agoAddress some compiler warnings.
Alex Szpakowski [Sun, 9 Oct 2016 01:07:20 +0000 (22:07 -0300)]
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.

8 years agoSPV: Distinguish between SPV and non-SPV rules for member overlap.
John Kessenich [Fri, 7 Oct 2016 17:50:25 +0000 (11:50 -0600)]
SPV: Distinguish between SPV and non-SPV rules for member overlap.

8 years agoHLSL: Add shape conversions for return values.
John Kessenich [Thu, 6 Oct 2016 22:56:54 +0000 (16:56 -0600)]
HLSL: Add shape conversions for return values.

8 years agoHLSL: Do structure conversion for return type struct-punning on non-entry-point funct...
John Kessenich [Thu, 6 Oct 2016 18:59:51 +0000 (12:59 -0600)]
HLSL: Do structure conversion for return type struct-punning on non-entry-point functions.

8 years agoMerge pull request #540 from steve-lunarg/rwbuffers
John Kessenich [Thu, 6 Oct 2016 17:47:37 +0000 (11:47 -0600)]
Merge pull request #540 from steve-lunarg/rwbuffers

HLSL: phase 1: add RWTexture and RWBuffer

8 years agoHLSL: phase 1: add RWTexture and RWBuffer
steve-lunarg [Tue, 4 Oct 2016 22:58:14 +0000 (16:58 -0600)]
HLSL: phase 1: add RWTexture and RWBuffer

There's a lot to do for RWTexture and RWBuffer, so it will be broken up into
several PRs.  This is #1.

This adds RWTexture and RWBuffer support, with the following limitations:
  * Only 4 component formats supported
  * No operator[] yet

Those will be added in other PRs.

This PR supports declarations and the Load & GetDimensions methods.  New tests are
added.

8 years agoUse pthread_mutex for global lock on Linux.
Josh Gargus [Thu, 6 Oct 2016 01:32:51 +0000 (18:32 -0700)]
Use pthread_mutex for global lock on Linux.

8 years agoMerge pull request #537 from dneto0/pass-cwd-to-gtest
John Kessenich [Wed, 5 Oct 2016 19:57:22 +0000 (13:57 -0600)]
Merge pull request #537 from dneto0/pass-cwd-to-gtest

Gtests can be run on another source tree

8 years agoCheck for out-of-range bindings during IO mapping.
steve-lunarg [Wed, 5 Oct 2016 19:40:13 +0000 (13:40 -0600)]
Check for out-of-range bindings during IO mapping.

8 years agoAllow for larger binding numbers. 65K instead of 255.
John Kessenich [Wed, 5 Oct 2016 18:31:24 +0000 (12:31 -0600)]
Allow for larger binding numbers.  65K instead of 255.

8 years agoGtests can be run on another source tree
David Neto [Wed, 5 Oct 2016 14:25:09 +0000 (10:25 -0400)]
Gtests can be run on another source tree

The gtest executable accepts a --test-root option to specify
a root directory for test files.  It defaults to the Test directory
in the source tree from which the executable is built.

For example, this lets us run test exectuables built with MinGW on Linux
on a Windows machine with its own copy of the source tree.

8 years agoMerge pull request #536 from steve-lunarg/flatten-assign-fix
John Kessenich [Wed, 5 Oct 2016 01:45:18 +0000 (19:45 -0600)]
Merge pull request #536 from steve-lunarg/flatten-assign-fix

HLSL: fix for flattening assignments from non-symbol R-values.

8 years agoHLSL: fix for flattening assignments from non-symbol R-values.
steve-lunarg [Mon, 3 Oct 2016 04:13:22 +0000 (22:13 -0600)]
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.

8 years agoMerge pull request #533 from steve-lunarg/reflection
John Kessenich [Mon, 3 Oct 2016 19:57:32 +0000 (13:57 -0600)]
Merge pull request #533 from steve-lunarg/reflection

add reflection queries to return a TType.  Fix minor issue with inter…

8 years agoadd reflection queries to return a TType. Fix minor issue with interface names.
steve-lunarg [Wed, 21 Sep 2016 20:19:40 +0000 (14:19 -0600)]
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.

8 years agoNon-functional: Rationalizing parse helper hierarchy, step 3 (effected editable symbo...
John Kessenich [Sun, 2 Oct 2016 00:44:38 +0000 (18:44 -0600)]
Non-functional: Rationalizing parse helper hierarchy, step 3 (effected editable symbols and IO resize).

8 years agoNon-functional: Rationalizing parse helper hierarchy, step 2 (effected error messagin...
John Kessenich [Sun, 2 Oct 2016 00:07:57 +0000 (18:07 -0600)]
Non-functional: Rationalizing parse helper hierarchy, step 2 (effected error messaging and cascading errors).

8 years agoNon-functional: Rationalizing parse helper hierarchy, step 1 (effected memory of...
John Kessenich [Sat, 1 Oct 2016 23:47:40 +0000 (17:47 -0600)]
Non-functional: Rationalizing parse helper hierarchy, step 1 (effected memory of HLSL keyword map).

8 years agoHLSL: Line numbers only: Set locations (line numbers) on synthesized flattening code.
John Kessenich [Sat, 1 Oct 2016 23:17:55 +0000 (17:17 -0600)]
HLSL: Line numbers only: Set locations (line numbers) on synthesized flattening code.

8 years agoHLSL: Handle flattened I/O structs passed to function *out* parameters.
John Kessenich [Sat, 1 Oct 2016 23:11:21 +0000 (17:11 -0600)]
HLSL: Handle flattened I/O structs passed to function *out* parameters.

8 years agoNon-functional: Better use of .isParamOutput() and some other methods.
John Kessenich [Sat, 1 Oct 2016 19:30:37 +0000 (13:30 -0600)]
Non-functional: Better use of .isParamOutput() and some other methods.

8 years agoFix typo in error message.
John Kessenich [Sat, 1 Oct 2016 18:36:19 +0000 (12:36 -0600)]
Fix typo in error message.

8 years agoNon-functional: Use isOpaque() instead of compare against EbtSampler.
John Kessenich [Sat, 1 Oct 2016 18:35:01 +0000 (12:35 -0600)]
Non-functional: Use isOpaque() instead of compare against EbtSampler.

8 years agoMerge pull request #532 from steve-lunarg/automap-offsets
John Kessenich [Sat, 1 Oct 2016 18:00:51 +0000 (12:00 -0600)]
Merge pull request #532 from steve-lunarg/automap-offsets

Change binding auto-map to use provided offsets.

8 years agoChange binding auto-map to use provided offsets.
steve-lunarg [Sat, 1 Oct 2016 17:27:43 +0000 (11:27 -0600)]
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.

8 years agoMerge pull request #527 from steve-lunarg/array-flattening-fix
John Kessenich [Sat, 1 Oct 2016 17:40:27 +0000 (11:40 -0600)]
Merge pull request #527 from steve-lunarg/array-flattening-fix

HLSL: Restrict uniform array flattening to sampler and texture arrays

8 years agoMerge pull request #521 from yavn/frag-shader-primitive-id-capability
John Kessenich [Sat, 1 Oct 2016 17:38:18 +0000 (11:38 -0600)]
Merge pull request #521 from yavn/frag-shader-primitive-id-capability

SPV: PrimitiveId in frag shader will emit OpCapability

8 years agoMerge pull request #531 from steve-lunarg/add-autobinding-test
John Kessenich [Sat, 1 Oct 2016 17:37:09 +0000 (11:37 -0600)]
Merge pull request #531 from steve-lunarg/add-autobinding-test

HLSL: Add a test for buffer auto-binding assignment.

8 years agoAdd a test for buffer auto-binding assignment.
steve-lunarg [Fri, 30 Sep 2016 20:26:34 +0000 (14:26 -0600)]
Add a test for buffer auto-binding assignment.

8 years agoMerge pull request #523 from amdrexu/feature2
John Kessenich [Fri, 30 Sep 2016 15:54:17 +0000 (09:54 -0600)]
Merge pull request #523 from amdrexu/feature2

Parser: Implement extension GL_AMD_gpu_shader_half_float.

8 years agoParser: Implement extension GL_AMD_gpu_shader_half_float.
Rex Xu [Fri, 29 Jul 2016 08:00:05 +0000 (16:00 +0800)]
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.

8 years agoAdd amend ability for anonymous blocks, so they can grow between function bodies.
John Kessenich [Fri, 30 Sep 2016 05:58:30 +0000 (23:58 -0600)]
Add amend ability for anonymous blocks, so they can grow between function bodies.

8 years agoMerge pull request #530 from annygakh/master
John Kessenich [Thu, 29 Sep 2016 23:39:01 +0000 (17:39 -0600)]
Merge pull request #530 from annygakh/master

Updated README.md

8 years agoUpdated README.md
Anny [Thu, 29 Sep 2016 23:29:58 +0000 (16:29 -0700)]
Updated README.md

Added an alternative link for cloning the repo in the build instructions

8 years agoRestrict uniform array flattening to sampler and texture arrays.
steve-lunarg [Thu, 29 Sep 2016 14:43:22 +0000 (08:43 -0600)]
Restrict uniform array flattening to sampler and texture arrays.

Previously the uniform array flattening feature would trigger on loose
uniform arrays of any basic type (e.g, floats).  This PR restricts it
to sampler and texture arrays.  Other arrays would end up in their own
uniform block (anonymous or otherwise).  (Atomic counter arrays might be an
exception, but those are not currently flattened).

8 years agoHLSL: Fix merge conflict.
John Kessenich [Thu, 29 Sep 2016 16:27:57 +0000 (10:27 -0600)]
HLSL: Fix merge conflict.

8 years agoHLSL Tests: Tests for previous commit, to make it easier to see what's changing.
John Kessenich [Wed, 28 Sep 2016 05:09:32 +0000 (23:09 -0600)]
HLSL Tests: Tests for previous commit, to make it easier to see what's changing.

8 years agoSupport a uniform block to hold global uniform variables.
John Kessenich [Wed, 28 Sep 2016 01:13:05 +0000 (19:13 -0600)]
Support a uniform block to hold global uniform variables.

Used initially just by HLSL, for $Global.  Could be an option
for GLSL -> Vulkan.

8 years agoHLSL: Rationalize combination of type arrayness and name arrayness.
John Kessenich [Tue, 27 Sep 2016 20:38:57 +0000 (14:38 -0600)]
HLSL: Rationalize combination of type arrayness and name arrayness.

8 years agoMerge pull request #525 from steve-lunarg/implicit-size
John Kessenich [Wed, 28 Sep 2016 05:15:22 +0000 (23:15 -0600)]
Merge pull request #525 from steve-lunarg/implicit-size

HLSL: allow implicit size in array declarations

8 years agoHLSL: allow implicit array sizing.
steve-lunarg [Tue, 27 Sep 2016 16:57:35 +0000 (10:57 -0600)]
HLSL: allow implicit array sizing.

In HLSL array sizes need not be provided explicitly in all circumstances.
For example, this is valid (note no number between the [ ]):

  // no explicit array size
  uniform float g_array[] = { 1, 2, 3, 4, 5 };

This PR does not attempt to validate most invalid cases.

A new test is added to verify the resulting linker objects.

8 years agoMerge pull request #524 from DominikWitczakAMD/517_include_amd_extensions_by_default
John Kessenich [Tue, 27 Sep 2016 15:48:38 +0000 (09:48 -0600)]
Merge pull request #524 from DominikWitczakAMD/517_include_amd_extensions_by_default

#517: Enable AMD extensions by default

8 years agoSPV: PrimitiveId in frag shader will emit Geometry capability
Maciej Jesionowski [Mon, 26 Sep 2016 14:49:09 +0000 (16:49 +0200)]
SPV: PrimitiveId in frag shader will emit Geometry capability

Using PrimitiveId in a fragment shader requires declaring
an OpCapability with either Geometry or Tessellation.

8 years ago#517: Enable AMD extensions by default
Dominik Witczak [Tue, 27 Sep 2016 07:51:34 +0000 (09:51 +0200)]
#517: Enable AMD extensions by default

8 years agoMerge pull request #520 from amdrexu/bugfix
John Kessenich [Mon, 26 Sep 2016 23:45:25 +0000 (17:45 -0600)]
Merge pull request #520 from amdrexu/bugfix

SPV: OpGroupBroadcast is unable to handle vector operand.

8 years agoMerge pull request #522 from steve-lunarg/glsl-binding-test
John Kessenich [Mon, 26 Sep 2016 23:40:17 +0000 (17:40 -0600)]
Merge pull request #522 from steve-lunarg/glsl-binding-test

GLSL: Add IO map tests

8 years agoGLSL: Add binding map tests
steve-lunarg [Mon, 26 Sep 2016 23:02:44 +0000 (17:02 -0600)]
GLSL: Add binding map tests

This PR adds a GLSL equivalent to the HLSL binding mapping tests for offsets and auto-numbering.
The shaders are as equivalent as possible.  The bindings of the base results match exactly
between the two.

8 years agoSPV: OpGroupBroadcast is unable to handle vector operand.
Rex Xu [Mon, 26 Sep 2016 07:53:40 +0000 (15:53 +0800)]
SPV: OpGroupBroadcast is unable to handle vector operand.

8 years agoHLSL: Reverse what the driver is told about row/column majorness, matching the row...
John Kessenich [Mon, 26 Sep 2016 02:25:06 +0000 (20:25 -0600)]
HLSL: Reverse what the driver is told about row/column majorness, matching the row-column reversal.

8 years agoMerge pull request #519 from amdrexu/bugfix
John Kessenich [Fri, 23 Sep 2016 23:31:31 +0000 (17:31 -0600)]
Merge pull request #519 from amdrexu/bugfix

SPV: Still have to specify SPIR-V extension for gl_SubGroupSizeARB and gl_SubGroupInvocationARB.

8 years agoSPV: Still have to specify SPIR-V extension for gl_SubGroupSizeARB and gl_SubGroupInv...
Rex Xu [Fri, 23 Sep 2016 14:13:43 +0000 (22:13 +0800)]
SPV: Still have to specify SPIR-V extension for gl_SubGroupSizeARB and gl_SubGroupInvocationARB.

8 years agoMerge pull request #518 from steve-lunarg/flatten-fix
John Kessenich [Fri, 23 Sep 2016 03:52:44 +0000 (21:52 -0600)]
Merge pull request #518 from steve-lunarg/flatten-fix

Fix defects in uniform array flattening

8 years agoFix defects in uniform array flattening
steve-lunarg [Thu, 22 Sep 2016 20:35:23 +0000 (14:35 -0600)]
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.

8 years agoMerge pull request #516 from amdrexu/feature3
John Kessenich [Thu, 22 Sep 2016 16:54:18 +0000 (10:54 -0600)]
Merge pull request #516 from amdrexu/feature3

SPV: Implement the extension SPV_KHR_shader_ballot

8 years agoHLSL: Merge pull request #515 from steve-lunarg/flatten-uniform-array
John Kessenich [Thu, 22 Sep 2016 16:01:37 +0000 (10:01 -0600)]
HLSL: Merge pull request #515 from steve-lunarg/flatten-uniform-array

HLSL: Flatten uniform arrays

8 years agoFlatten uniform arrays
steve-lunarg [Fri, 16 Sep 2016 19:26:37 +0000 (13:26 -0600)]
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.

8 years agoSPV: Implement the extension SPV_KHR_shader_ballot
Rex Xu [Wed, 21 Sep 2016 10:56:12 +0000 (18:56 +0800)]
SPV: Implement the extension SPV_KHR_shader_ballot

8 years agoHLSL: Fix result type of passing a flattened-aggregate to a function.
John Kessenich [Wed, 21 Sep 2016 23:50:12 +0000 (17:50 -0600)]
HLSL: Fix result type of passing a flattened-aggregate to a function.

8 years agoMerge pull request #514 from steve-lunarg/binding-map-3
John Kessenich [Wed, 21 Sep 2016 14:57:31 +0000 (08:57 -0600)]
Merge pull request #514 from steve-lunarg/binding-map-3

HLSL: Add location offsets per resource type

8 years agoHLSL: Add location offsets per resource type
steve-lunarg [Wed, 7 Sep 2016 21:20:19 +0000 (15:20 -0600)]
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.

8 years agoHLSL: Move to correct parsing of annotations, improving all annotations and recent...
John Kessenich [Tue, 20 Sep 2016 19:22:58 +0000 (13:22 -0600)]
HLSL: Move to correct parsing of annotations, improving all annotations and recent string grammar.

8 years agoHLSL: Turn on reflection, with basic test file, to catch regressions.
John Kessenich [Tue, 20 Sep 2016 05:12:48 +0000 (23:12 -0600)]
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.

8 years agoHLSL: Remove extraneous built-in member decorations for IO structs used in non-IO...
John Kessenich [Tue, 20 Sep 2016 04:16:09 +0000 (22:16 -0600)]
HLSL: Remove extraneous built-in member decorations for IO structs used in non-IO situations.

8 years agoHLSL: Add string basic type and recognize string declaration grammar.
John Kessenich [Tue, 20 Sep 2016 02:23:18 +0000 (20:23 -0600)]
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.

8 years agoTrack separate entry-point names and mangled names...
John Kessenich [Tue, 20 Sep 2016 00:09:30 +0000 (18:09 -0600)]
Track separate entry-point names and mangled names...

... and use each in the correct way at consumption sites.
This completes issue #513.

8 years agoMerge pull request #512 from steve-lunarg/liveness-traverser
John Kessenich [Mon, 19 Sep 2016 23:19:25 +0000 (17:19 -0600)]
Merge pull request #512 from steve-lunarg/liveness-traverser

Refactor TLiveTraverser from the former reflection traverser, for fut…

8 years agoRefactor TLiveTraverser from the former reflection traverser, for future use in bindi...
steve-lunarg [Mon, 19 Sep 2016 21:35:12 +0000 (15:35 -0600)]
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.

8 years agoNon-functional: Sweep through the stack for consistent with "main" and entry point.
John Kessenich [Mon, 19 Sep 2016 22:01:41 +0000 (16:01 -0600)]
Non-functional: Sweep through the stack for consistent with "main" and entry point.

Partially addresses issue #513.

8 years agoHLSL: Change the final syntax-error printf to go to the infoLog.
John Kessenich [Mon, 19 Sep 2016 20:56:55 +0000 (14:56 -0600)]
HLSL: Change the final syntax-error printf to go to the infoLog.

Fixes issue #510.

8 years agoHLSL: Fix assert: ensure flattened shadow is EvqTemporary.
John Kessenich [Mon, 19 Sep 2016 06:19:49 +0000 (00:19 -0600)]
HLSL: Fix assert: ensure flattened shadow is EvqTemporary.

8 years agoHLSL: Intercept flatten aggregates passed to a function input, and copy member-by...
John Kessenich [Mon, 19 Sep 2016 06:06:19 +0000 (00:06 -0600)]
HLSL: Intercept flatten aggregates passed to a function input, and copy member-by-member.

8 years agoHLSL: Non-functional; make flatten semantics be about aggregates, not just structures.
John Kessenich [Mon, 19 Sep 2016 05:10:22 +0000 (23:10 -0600)]
HLSL: Non-functional; make flatten semantics be about aggregates, not just structures.

8 years agoHLSL: Fix bug in previous checkin when non-flattened objects are not simple l-values.
John Kessenich [Sat, 17 Sep 2016 03:16:04 +0000 (21:16 -0600)]
HLSL: Fix bug in previous checkin when non-flattened objects are not simple l-values.

8 years agoHLSL: Handle flatten for reads from flatten structs and parameter passing.
John Kessenich [Sat, 17 Sep 2016 01:44:00 +0000 (19:44 -0600)]
HLSL: Handle flatten for reads from flatten structs and parameter passing.

8 years agoHLSL: Improve setting and testing of interpolation qualifiers.
John Kessenich [Fri, 16 Sep 2016 23:10:39 +0000 (17:10 -0600)]
HLSL: Improve setting and testing of interpolation qualifiers.

Notably, use of 'linear' on a non-input could mark it as an input.

8 years agoHLSL: Flatten whole-struct assigns and returns when targeting flattened I/O structs.
John Kessenich [Fri, 16 Sep 2016 09:05:12 +0000 (03:05 -0600)]
HLSL: Flatten whole-struct assigns and returns when targeting flattened I/O structs.

8 years agoHLSL: Flatten all input/output structs, regardless of stage.
John Kessenich [Fri, 16 Sep 2016 07:52:14 +0000 (01:52 -0600)]
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.

8 years agoHLSL: Flatten a return struct from an entry point and assign locations after flattening.
John Kessenich [Fri, 16 Sep 2016 07:44:43 +0000 (01:44 -0600)]
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.

8 years agoHLSL: return correct error when HLSL parsing fails.
John Kessenich [Fri, 16 Sep 2016 04:49:31 +0000 (22:49 -0600)]
HLSL: return correct error when HLSL parsing fails.

At least partially addresses issue #510.