Commit Graph

381 Commits

Author SHA1 Message Date
John Kessenich
66011cb2c2 SPV: Implement Vulkan 1.1 features and extensions. 2018-03-06 16:12:04 -07:00
John Kessenich
b2ae1d0521 Revert "Merge pull request #1274 from greg-lunarg/legal2"
This reverts commit 2c65069ecd, reversing
changes made to fa9b465b92.
2018-03-06 14:50:41 -07:00
GregF
fd50f6a4c3 Legalization: Omit legalization warning when spirv-opt is linked. 2018-03-06 13:00:08 -07:00
John Kessenich
c5215791f5 IO mapper: Fix #1261: Supply location mapper with size computer.
This factored computeTypeLocationSize() out of needing the TIntermediate contents,
and uses it to show how to know how many locations an object needs.
However, it still does not do cross stage, or mixed location/no-location
analysis.
2018-02-27 13:31:48 -07:00
John Kessenich
d55fe86512 HLSL: Fix #1257: layout float1, int1, etc., as scalars. 2018-02-27 00:48:17 -07:00
John Kessenich
23ea3db3e5 Warning for #pragma once. GLSL and HLSL. Addresses #824. 2018-02-11 23:23:22 -07:00
John Kessenich
a2858d9bdd GLSL: Implement GL_EXT_control_flow_attributes.
See https://github.com/KhronosGroup/GLSL/pull/11.
2018-02-01 00:55:08 -07:00
John Kessenich
e18fd20d5c HLSL: Refactor attribute implementation.
- make it sharable with GLSL
- correct the case insensitivity
- remove the map; queries are not needed, all entries need processing
- make it easier to build bottom up (will help GLSL parsing)
- support semantic checking and reporting
- allow front-end dependent semantics and attribute name mapping
2018-02-01 00:30:34 -07:00
John Kessenich
046bae0bab HLSL: Attributes: Add [[vk::constant_id()]] and [[vk::push_constant]] 2017-12-23 17:29:45 -07:00
Jean-François Marquis
3f0aff8ee5 HLSL: Fix possibly incorrect type conversion in StoreN and LoadN
Set type to r-value resulting from indexing vector, to prevent
float->uint conversion when source is already uint. Resulting
OpConvertFToU would otherwise fail validation because source is
already uint.
For LoadN, incorrect uint->float->uint can be avoided; fixing
potential truncation of big integer values.
2017-12-21 12:11:40 -05:00
John Kessenich
788fbeb36f HLSL: Make attributes for built-in override semantics.
Fixes #1188.
2017-12-15 08:15:26 -07:00
John Kessenich
396de16cfb
Merge pull request #1183 from LoopDawg/builtin-output-array-indirect
HLSL: for split output structs, propagate indirection to builtins.
2017-12-14 01:39:25 -07:00
Arseny Kapoulkine
c92860e288 HLSL: Implement support for RT/Viewport output from VS
In DX10/DX11 you can only output RT/Viewport indices from GS; however,
DX11.4/DX12 add support for outputting these from VS as well.

This is supported by Vulkan if the relevant extension is available, and
by MSL and by MSL (which you can cross-compile to via SPIRV-Cross).
2017-12-13 16:08:20 -08:00
LoopDawg
0cff51004d HLSL: for split output structs, propagate indirection to builtin.
Some stage (e.g, hull shaders) have arrayed builtin outputs (e.g, position).
When copying from the internal structure to the split form, it is necessary
to propagate that indirection to the actual arrayed outputs.  This was not
happening.

Addresses #1181
2017-12-12 16:22:48 -07:00
John Kessenich
e078059d06
Merge pull request #1174 from LoopDawg/y-flip
HLSL: add optional position.Y inversion
2017-12-12 09:16:01 -07:00
John Kessenich
87982be1a0 HLSL: Remove unintended/untested functionality PrimitiveID.
This was listed as outputs for tessellation stages, but they
are input only.
2017-12-08 19:41:05 -07:00
John Kessenich
67fca7c4ce
Merge pull request #1178 from LoopDawg/primitiveid-hs-input
HLSL: Allow primitive id on hull shader input
2017-12-08 19:35:17 -07:00
LoopDawg
280c75ca51 HLSL: Allow primitive id on hull shader inputs
Fixes #979
2017-12-08 12:01:16 -07:00
John Kessenich
dc005fb083 HLSL: Stop flattening non-IO structs containing opaques.
This makes struct returns from functions work, but breaks
structs containing arrays, due to limitations in subsequent
transforms in spirv-opt. This is expected to be fixed soon.
2017-12-08 04:30:29 -07:00
LoopDawg
b22c069f7a HLSL: add optional position.Y inversion
Adds command line options:

   --invert-y
   --iy

(synonyms) which invert position.Y on vertex shader output.  Handles these cases:

* Direct single variable return
* Member of direct returned struct
* Single variable output parameter
* Member of struct output parameter

API:

    // Enables position.Y output negation in vertex shader
    void TShader::setInvertY(bool invert);

Fixes #1173
2017-12-07 10:48:14 -07:00
John Kessenich
471bfed062 HLSL: Fix #606: make layout() override register. 2017-12-06 08:17:21 -07:00
John Kessenich
cc951f8183 HLSL: Fix #1154: Support PointSize, as an attribute. 2017-12-06 07:33:36 -07:00
LoopDawg
8c49f9b4e6 HLSL: minor: add warning for mat() matrix size truncation
Minor change to add a compilation warning on implicit matrix size
truncations.
2017-11-30 10:26:21 -07:00
John Kessenich
1ce94b2d68
Merge pull request #1166 from tafuri/#1165-invalid_Store
#1165 invalid store
2017-11-28 19:41:52 -07:00
LoopDawg
cee29b04d6 HLSL: add implicit mat*mat truncations
Goes with PR #1161, and completes the space for mul() implicit truncations.

Note that the v*v and scalar cases are already handled by existing code.
2017-11-27 09:42:53 -07:00
Sebastian Tafuri
59677daef7 Respect the array type in Store operation 2017-11-27 17:13:21 +01:00
LoopDawg
2e62910633 HLSL: matrix and vector truncations for m*v, v*m, m*m
HLSL truncates the vector, or one of the two matrix dimensions if there is a
dimensional mismatch in m*v, v*m, or m*m.

This PR adds that ability.  Conversion constructors are added as required.
2017-11-22 12:01:45 -07:00
LoopDawg
7573a2ab7f HLSL: ignore geometry attributes on non-GS stages.
If a shader includes a mixture of several stages, such as HS and GS,
the non-stage output geometry should be ignored, lest it conflict
with the stage output.
2017-11-15 11:33:25 -07:00
John Kessenich
715c353a15 Non-functional: copyright update, to help with non-determinism test. 2017-10-28 14:42:44 -06:00
LoopDawg
2915da303f Nonfunctional: minor: use std::array for per-set shifts, fix warning.
Two unrelated, minor tweaks:

(1) Use std::array for shiftBindingForSet.  Now matches shiftBinding.
(2) Add parens in shouldFlatten() to make compiler warning happy.
2017-10-20 12:02:38 -06:00
John Kessenich
1b46f137f7 HLSL: Fix #1106. Support shader setting of binding/set for $Global. 2017-10-19 16:54:25 -06:00
John Kessenich
0b55e0f203 Merge pull request #1102 from KhronosGroup/partially-flatten
HLSL: Partially flatten hierarchies, instead of all or nothing.
2017-10-18 14:53:53 -06:00
John Kessenich
1a4bbc4a95 HLSL: More clip fix: It is more involved than previous commit. Complete. 2017-10-16 13:11:53 -06:00
John Kessenich
41aa19953f HLSL: Partially flatten hierarchies, instead of all or nothing.
Fixes #1092.  Allows arrays of opaques to keep arrayness, unless
needed by uniform array flattening.
Can handle assignments of mixed amounts of flattening.
2017-10-12 16:52:32 -06:00
John Kessenich
60e9161100 Merge pull request #1098 from LoopDawg/attribute-gets
HLSL: nonfunctional: add helper access methods to TAttributeMap
2017-10-11 06:05:06 +03:00
LoopDawg
52c087ff53 HLSL: add helper access methods to TAttributeMap
There was some code replication around getting string and integer
values out of an attribute map.  This adds new methods to the
TAttributeMap class to encapsulate some accessor details.
2017-10-10 14:59:40 -06:00
LoopDawg
028c5a8dc4 HLSL: nonfunctional: rename setId -> switchId, add comment
Method rename, add comment about its intended use.  No
test diffs.
2017-10-07 16:43:18 -06:00
John Kessenich
bb79abccb3 HLSL: Validate implicit initializer assignment to opaque members.
Fixes #1091.
2017-10-07 13:25:21 -06:00
John Kessenich
b27de0289c Merge pull request #1090 from tafuri/#1084-fix-segfault
Only track variables in the global scope
2017-10-07 07:19:21 +03:00
Sebastian Tafuri
5133b108da Fixed formatting 2017-10-07 00:12:50 +02:00
Sebastian Tafuri
0a82611174 Only track variables in the global scope 2017-10-06 22:45:00 +02:00
LoopDawg
73c57bbe50 HLSL: split textures used for both shadow and non-shadow modes
A single texture can statically appear in code mixed with a shadow sampler
and a non-shadow sampler.  This would be create invalid SPIR-V, unless
one of them is provably dead.

The previous detection of this happened before DCE, so some shaders would
trigger the error even though they wouldn't after DCE.  To handle that
case, this PR splits the texture into two: one with each mode.  It sets
"needsLegalization" (if that happens for any texture) to warn that this shader
will need post-compilation legalization.

If the texture is only used with one of the two modes, behavior is as it
was before.
2017-10-06 11:23:16 -06:00
John Kessenich
700bdeb742 HLSL: Fix #954: Track/access subsets of flattened multi-level aggregates.
Works in conjuction with d1be754 to represent and modify a partially
dereferenced multi-level flattened aggregate.
2017-10-04 13:40:13 -06:00
Unknown
a6085875ef HLSL: Fix crash when flattening both side of assignement simultaneously. 2017-10-03 09:10:26 +02:00
LoopDawg
7f93d56ef2 HLSL: add subpass input types and methods
Add support for Subpass Input proposal of issue #1069.

Subpass input types are given as:

    layout(input_attachment_index = 1) SubpassInput<float4> subpass_f;
    layout(input_attachment_index = 2) SubpassInput<int4>   subpass_i;
    layout(input_attachment_index = 3) SubpassInput<uint4>  subpass_u;

    layout(input_attachment_index = 1) SubpassInputMS<float4> subpass_ms_f;
    layout(input_attachment_index = 2) SubpassInputMS<int4>   subpass_ms_i;
    layout(input_attachment_index = 3) SubpassInputMS<uint4>  subpass_ms_u;

The input attachment may also be specified using attribute syntax:

    [[vk::input_attachment_index(7)]] SubpassInput subpass_2;

The template type may be a shorter-than-vec4 vector, but currently user
structs are not supported.  (An unimplemented error will be issued).

The load operations are methods on objects of the above type:

    float4 result = subpass_f.SubpassLoad();
    int4   result = subpass_i.SubpassLoad();
    uint4  result = subpass_u.SubpassLoad();

    float4 result = subpass_ms_f.SubpassLoad(samp);
    int4   result = subpass_ms_i.SubpassLoad(samp);
    uint4  result = subpass_ms_u.SubpassLoad(samp);

Additionally, the AST printer could not print EOpSubpass* nodes.  Now it can.

Fixes #1069
2017-10-02 12:46:55 -06:00
John Kessenich
092b7d2e20 Build: Fix a couple build issues. 2017-09-30 14:54:18 -06:00
John Kessenich
77ea30bdc9 HLSL: Additional attribute support: [[]], namespace, parameters:
- support C++11 style brackets [[...]]
- support namespaces [[vk::...]]
- support these on parameter declarations in functions
- support location, binding/set, input attachments
2017-09-30 14:34:50 -06:00
John Kessenich
15fa7ef5f5 HLSL: Remove workarounds for assigning to opaques.
This assumes it will be combined with optimizing transforms
that eliminate assignments to opaques.
2017-09-29 09:53:24 -06:00
LoopDawg
195f584e09 HLSL: force textures to shadow modes from combined samplers
Texture shadow mode must match the state of the sampler they are
combined with.  This change does that, both for the AST and the
symbol table.  Note that the texture cannot easily be *created*
the right way, because this may not be known at that time.  Instead,
the texture is subsequently patched.

This cannot work if a single texture is used with both a shadow and
non-shadow sampler, so that case is detected and generates an error.
This is permitted by the HLSL language, however.  See #1073 discussion.

Fixed one test source that was using a texture with both shadow and
non-shadow samplers.
2017-09-28 14:17:25 -06:00
xavier
ae8af5d33e HLSL: fix array[1] of vec4 constant declaration. 2017-09-15 15:28:38 -06:00