Commit Graph

112 Commits

Author SHA1 Message Date
steve-lunarg
9ae34742cf Check for out-of-range bindings during IO mapping. 2016-10-05 13:42:42 -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
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
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
steve-lunarg
e4fe8b5c44 Add a test for buffer auto-binding assignment. 2016-09-30 14:26:34 -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
steve-lunarg
265c0618b1 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.
2016-09-27 14:28:26 -06:00
steve-lunarg
ad0752e8fa 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.
2016-09-26 17:02:44 -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
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
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
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
d2ce838a58 HLSL: Handle flatten for reads from flatten structs and parameter passing. 2016-09-16 20:24:14 -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
steve-lunarg
297ae211f1 WIP: HLSL: Treat HLSL rows as GLSL columns.
WIP: HLSL: EOpGenMul arg reversal
2016-09-09 12:02:42 -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
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
steve-lunarg
65564a4ad6 Remapper: move remapper tests into the glslangtests executable. 2016-09-02 09:21:12 -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
steve-lunarg
a8456415b8 WIP: SPV Remapper: add remapper test framework 2016-08-25 10:46:51 -06:00
steve-lunarg
36e87d0871 HLSL: add precise keyword 2016-08-25 08:48:54 -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
steve-lunarg
efe9724795 HLSL: Add EHTokStringConstant, so that string attributes may be parsed 2016-08-22 17:13:17 -06:00
John Kessenich
b9e39120b4 HLSL: Partially address issue #463: accept GLSL layout(...).
This includes all "per variable" layout qualifiers, but the
key ones mattering and tested for now are:
  set=
  binding=
  constant_id=
  push_constant
2016-08-17 17:38:45 -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
66ec80e01b Build: C++ headers: Replace PR #366 with a more directed version. 2016-08-05 14:04:23 -06:00
steve-lunarg
7dfcf4d1ad HLSL: Add GatherRed/Green/Blue/Alpha methods, inc 4-offset forms 2016-08-03 13:34:39 -06:00
steve-lunarg
cb88de5e5e HLSL: allow semicolons between global scope declarations. 2016-08-03 07:08:06 -06:00
John Kessenich
73d4fb5bc5 PP: Fix issue #408: # as last character in macro.
This would look ahead for a second #, for token pasting, and if not
found, backup one token.  This is fine, unless at the end of line,
which would backup the #, rather than the look ahead.
2016-07-30 12:41:35 -06:00
steve-lunarg
fe5a3ff2f3 HLSL: allow trailing commas in initializer lists & scalar initialization 2016-07-30 10:47:33 -06:00
steve-lunarg
5964c64b2a HLSL: Fix a grammar error related to constructors in parenthetical expressions 2016-07-30 08:09:09 -06:00
John Kessenich
fea226ba43 HLSL: Add shape conversions for scalar -> vector assigments.
Also, this allows turning on the error check for a failed assigment
when parsing.

This makes 39 HLSL tests have a working assignment that was previously
silently dropped, due to lack of this functionality.
2016-07-28 18:41:20 -06:00
John Kessenich
c552aece83 Merge pull request #417 from steve-lunarg/buffers
HLSL: add Buffer support for Load method
2016-07-28 16:56:39 -06:00
steve-lunarg
2de329112b HLSL: allow uint literals, and add test for numeric suffixes 2016-07-28 14:49:48 -06:00
steve-lunarg
d53f717fd3 HLSL: add Buffer support for Load method 2016-07-27 15:57:31 -06:00
steve-lunarg
68f2c144e3 HLSL: Add CalculateLevelOfDetail, and unimplemented errors for *Unclamped and GetSamplePosition 2016-07-27 10:46:33 -06:00
John Kessenich
00957f8110 HLSL: Implement ?: grammar productions.
Missing are implicit conversions between int/bool/etc.
2016-07-27 10:39:57 -06:00
steve-lunarg
1e19d90043 HLSL: add 2DMS texture formats, and matching Load / GetDimensions support 2016-07-27 07:37:21 -06:00
John Kessenich
8c8505c604 SPV: For AST interpolateAt* ops consuming a swizzle, invert the order.
Apply the interpolation first, then apply the swizzle to the result,
the inverse of the order requested by the AST.  This fixes issue #411.
2016-07-26 12:53:54 -06:00
John Kessenich
731cd83ef6 Merge pull request #405 from steve-lunarg/samplers
HLSL: Add gather, improve proto generator machine for upcoming 2DMS/S…
2016-07-26 09:40:46 -06:00
John Kessenich
64723c20b5 Merge pull request #406 from steve-lunarg/pp_line
HLSL: enable #line extension by default for HLSL source.
2016-07-26 09:39:48 -06:00
John Kessenich
3d157c510f HLSL: cbuffer and tbuffer grammar and production. 2016-07-25 16:05:33 -06:00
LoopDawg
6256146ef3 HLSL: enable #line extension by default for HLSL source. 2016-07-23 10:45:00 -06:00
LoopDawg
a2f3d285a8 HLSL: Add gather, improve proto generator machine for upcoming 2DMS/Shadow 2016-07-22 12:46:11 -06:00
LoopDawg
3ef7852ef6 HLSL: Add SampleLevel method 2016-07-21 15:02:30 -06:00