Commit Graph

262 Commits

Author SHA1 Message Date
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
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
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
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
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
steve-lunarg
c4a1307403 HLSL: add implicit promotions for assignments and function returns. 2016-08-09 13:48:47 -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
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
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
LoopDawg
f245101954 HLSL: Add texture Load method & decomposition 2016-07-21 09:42:35 -06:00
LoopDawg
a78b02941b HLSL: Add SampleCmp and SampleCmpLevelZero texture methods 2016-07-20 09:57:03 -06:00
LoopDawg
5d58faecc0 HLSL: Add tx.GetDimensions method (uint returns only) 2016-07-18 16:40:21 -06:00
LoopDawg
a2b7991497 HLSL: Add SampleBias and SampleGrad, and associated tests 2016-07-15 11:38:49 -06:00
John Kessenich
51e74b17bf Merge pull request #385 from steve-lunarg/inout-qualifiers
HLSL: add in/out/inout qualifiers
2016-07-13 15:42:48 -06:00
LoopDawg
92aff54632 HLSL: add offset Sample() form and arrayed texture support 2016-07-13 11:58:56 -06:00
LoopDawg
9249c709b0 HLSL: add in/out/inout qualifiers. 2016-07-12 20:50:34 -06:00
LoopDawg
4886f69734 HLSL: Sampler/texture declarations, method syntax, partial Sample method 2016-07-12 15:57:46 -06:00
John Kessenich
5e69ec683d HLSL: Add typedef grammar and production. 2016-07-05 00:02:40 -06:00
John Kessenich
532543c1c4 HLSL: Grammar: Make comma-separated declaration lists work. 2016-07-01 19:10:01 -06:00
LoopDawg
6daaa4fadf HLSL: Add template style constructors for vector & matrix types 2016-07-01 13:59:36 -06:00
John Kessenich
d02dc5d05a HLSL: Implement switch/case/default. 2016-07-01 00:04:11 -06:00
LoopDawg
1b7fd0f7b7 Add asdouble, fma, & mad intrinsics and change profile to allow doubles when parsing prototypes 2016-06-28 15:38:38 -06:00
John Kessenich
5bc4d9a26f HLSL: Airplane work: break/continue/discard grammar, and decls for for/if/while. 2016-06-27 21:12:07 -06:00
LoopDawg
6e72fddaa2 Add HLSL memory barrier intrinsics, fix dst, add lit & EvaluateAttributeSnapped 2016-06-20 09:53:59 -06:00
John Kessenich
19b92fff7e HLSL: Basic array grammar. 2016-06-19 11:50:34 -06:00
John Kessenich
93a162a857 HLSL: Handle "." for structure dereference and swizzle. 2016-06-17 17:16:27 -06:00
LoopDawg
589107095c Implement atomic ops, bit conversions, fix fwidth stage mask, fix saturate dest modifier. 2016-06-13 20:50:36 -06:00
John Kessenich
e6e7494e2a HLSL: Implement basic "struct" grammar. 2016-06-12 23:54:31 -06:00
John Kessenich
077e052a8f HLSL: Implement proper nesting of symbol-table scopes and identifier searching. 2016-06-09 02:03:46 -06:00
John Kessenich
71351de879 HLSL: Add all int/float/bool/uint matrix types, void for functions, and a few others. 2016-06-09 01:33:10 -06:00
John Kessenich
119f8f6906 HLSL: Flesh out the loop grammar and productions. 2016-06-05 15:44:07 -06:00
John Kessenich
0d2b6de45b HLSL: Attribute grammar and if-else grammar/productions. 2016-06-05 12:32:18 -06:00
John Kessenich
1cc1a2813e HLSL: 1) Implement lookahead buffers/stacks for token advance/recede, 2) use it for cast operation.
The grammar now accepts type casts, like "(int)x", but that
has to be disambiguated from "(a + b)", needed deeper lookahead
and backing up than what existed so far.
2016-06-03 16:57:53 -06:00
LoopDawg
643fcb5b43 Add negative intrinsics tests 2016-06-03 16:28:57 -06:00
LoopDawg
4b67732c13 Initial implementation of direct-mapped subset of HLSL intrinsics with type subset.
This checkin implements about half of the HLSL intrinsics for a subset of their
entire type support (but a useful subset).  The uncommented lines in
TBuiltInParseablesHlsl::identifyBuiltIns shows which are connected.
2016-06-03 08:28:29 -06:00
John Kessenich
0133c1233e HLSL: Add more matrix types to the grammar. 2016-05-20 12:17:26 -06:00
John Kessenich
8d72f1a2c4 Full stack: distinguish between a scalar and a vector of size 1.
There have been GLSL extensions considering this, and HLSL does it.
This is a fully backward compatible change that allows this distinction.
2016-05-20 12:14:39 -06:00
Lei Zhang
fc697cc938 Fix several comments in GTest fixture. 2016-05-17 16:45:37 -04:00
John Kessenich
e5f29393da Tests: Add a set of gtest-file-based HLSL tests. 2016-05-16 17:39:50 -06:00
Lei Zhang
d6f0ed2c81 Add support for testing file-based HLSL source code in GTest. 2016-05-16 12:51:13 -04:00