Commit Graph

601 Commits

Author SHA1 Message Date
Jeff Bolz
02ed310ac3 Rename PCH macro to glslang_pch (to avoid name collision) and update to latest spirv-tools 2018-11-07 09:35:31 -06:00
Jeff Bolz
22d0b7cbad Use precompiled headers for some glslang projects 2018-10-31 15:38:08 -05:00
Alejandro Piñeiro
af8c1bdb16 ParseHelper: assign xfb_offset for struct members too
If the out variable is a struct type, with a xfb_offset explicitly
assigned, the members need to get their xfb_offset assigned. This is
specially relevant, as we cannot use layout qualifiers on struct
members.
2018-10-31 10:34:44 +01:00
John Kessenich
086febc448 PP: Fix #155: Don't give error on HLSL PP-only parsing. 2018-10-25 12:43:02 -06:00
otakuto
d03da06ac1 Remove execute permissions 2018-08-07 03:16:20 +09:00
John Kessenich
62faea79d7
Merge pull request #1451 from KhronosGroup/shadow-forces-depth
GLSL/SPV: If a texture is used with a shadow sampler, force 'shadow'.
2018-07-23 16:41:00 -07:00
John Kessenich
11da9eed5d HLSL: Fix #1445: distance() works on scalars. 2018-07-23 16:55:01 -06:00
John Kessenich
7d4c9a07b5 GLSL: Construct shadow texture from non-shadow sampler.
Tracks https://github.com/KhronosGroup/GLSL/pull/22.
2018-07-23 15:59:09 -06:00
John Kessenich
0ea33a2628 Non-functional: Retrigger bots; the previous failure looks suspicious. 2018-07-11 02:24:36 -06:00
John Kessenich
cf6bd066b9 HLSL: Fix #1432: Globally initialize local static variables. 2018-07-11 01:09:14 -06:00
John Kessenich
dccfeedfc3 HLSL: Fix #1423: implement CalculateLevelOfDetailUnclamped().
(If there is a bias issue, we need to discover what it is.)
2018-07-02 18:53:19 -06:00
LoopDawg
c59916710e HLSL: allow self-type cast (as no-op passthrough)
Previously, casting an object of a struct type to an identical type
would produce an error.  This PR allows this case.

As a side-effect of the change, several self-type casts in existing
tests go away.  For example:

    0:10          Construct float ( temp float)
    0:10            'f' ( in float)

becomes this (without the unneeded constructor op):

    0:10          'f' ( in float)

For vector or array types this can result in somewhat less overall code.

Fixes: #1218
2018-05-17 13:03:12 -06:00
LoopDawg
4e6d3eaf5d HLSL: require coverage mask to be arrayed output.
SPIR-V requires the coverage mask to be an array of integers, but HLSL
allows scalar integers.  This adds the requisite type conversion and
wrapped entry point handling.

Fixes: #1202
2018-05-16 13:58:10 -06:00
John Kessenich
cfb05ec702
Merge pull request #1379 from LoopDawg/groupid-fix
HLSL: various SPIR-V compute shader IDs must be 3-vectors of integers
2018-05-16 10:36:16 -06:00
LoopDawg
91a8178efb HLSL: various SPIR-V compute shader IDs must be a 3-vector of integers.
This PR forces the external definition of SV_GroupID variables to 3-vectors.
The conversion process between the shader-declared type and the external type
happens in wrapped main IO variable conversion.

The same applies to SV_DispatchThreadID and SV_GroupThreadID.

Fixes: #1371
2018-05-16 06:48:02 -06:00
LoopDawg
1326b8c754 HLSL: Allow stream output Append() method after entry point.
Append() method is special: unlike most outputs, it does not copy
some temporary data to a symbol in the entry point epilogue, but
rather uses an emit builtin after each write to the output stream.

This had been handled by remembering the special output symbol for
the stream as it was declared in the shader entry point before
symbol sanitization.  However the prior code was too simple and
only handled cases where the Append() method happened after the
entry point, so that the output symbol had been seen.

This PR adds a patching step so that the Append()s may appear in
any order WRT the entry point.  They are patched in an epilogue,
whereupon it is guaranteed in a well formed shader that we have
seen the appropriate declaration.

Fixes #1217.
2018-05-15 15:13:09 -06:00
Matthew Albrecht
1199cf92f7 Fixed install for SPIRV, glslang, and hlsl when building shared libs 2018-04-26 14:07:46 -05:00
John Kessenich
c034c5a8a2 HLSL/SPV: Declare DepthReplacing for shaders declaring SV_Depth* outputs. 2018-04-13 18:36:58 -06:00
danginsburg
95c87b657c Fix issue #1350 - set the node type to match the atomic TIntermAggregate node type so that AtomicSMin/Max is not generated with a result type of void. 2018-04-12 16:46:04 -04:00
John Kessenich
b9e9e57f12
Merge pull request #1326 from mattparks/patch1
Allowed for LIB_TYPE to be set to switch between static and shared libs for glslang, SPIRV, and HLSL
2018-04-11 18:14:46 -06:00
John Kessenich
461ea09943 Non-functional: Fix tabs. 2018-04-11 00:03:47 -06:00
John Kessenich
6ae18707f9 HLSL: Fix #1332: consistently use uint for counter buf typing. 2018-04-10 11:59:33 -06:00
John Kessenich
5611c6d27b GLSL/SPV: Implement SPV_EXT_descriptor_indexing and GL_EXT_nonuniform_qualifier 2018-04-05 11:25:02 -06:00
Matthew Albrecht
6c5f649ae8 Allowed for LIB_TYPE to be set to switch between static and shared libs for glslang, SPIRV, and HLSL 2018-03-30 09:32:03 -05:00
GregF
fb03a55e0f Only print legalization warning if optimizer disabled 2018-03-29 13:17:54 -06:00
John Kessenich
ead8622484 Non-functional. Rationalizations enabling future generalizations:
- Use much simpler method to update implicit array sizes.
  The previous overly complicated method was error prone.
- Rationalize all use of unsized arrays.
- Combine decorations when generating SPIR-V, to simplify
  adding extensions.
2018-03-28 18:01:20 -06:00
John Kessenich
859b0342b8 Types: Fix #1290: Rationalize and correct "mixed" style array dimensioning.
There a couple functional problems, which when reduced down also led to
some good simplifications and rationalization.  So, this commit:
 - corrects "mixed" functionality: int[A] f[B] -> f[B][A]
 - correct multi-identifier decls: int[A] f[B], g[C] -> f and g are independently sized.
 - increases symmetry between different places in the code that do this
 - makes fewer ways to do the same thing; several methods are just gone now
 - makes more clear when something is copied or shared
2018-03-26 00:38:53 -06:00
John Kessenich
5d610ee1dc Implement SPV_GOOGLE_hlsl_functionality1.
Enabled via -fhlsl_functionality1
2018-03-16 20:21:44 -06:00
Daniel Koch
bfe0952118 Fix build several build errors
glslang/SPIRV/SpvBuilder.cpp:2533:27: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
        for (int c = 0; c < accessChain.swizzle.size(); ++c)
                        ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

glslang/hlsl/hlslParseHelper.cpp:69:5: error: field 'cullDistanceInput' will be initialized after field 'clipDistanceOutput' [-Werror,-Wreorder]
    cullDistanceInput(nullptr),
    ^
1 error generated.

glslang/glslang/MachineIndependent/attribute.cpp:85:16: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
    if (argNum >= args->getSequence().size())
        ~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
2018-03-13 17:06:51 -04:00
Rex Xu
a00e51b5b2 HLSL: Correct some mistakes for min16 types
- Add missing constructor ops to support float16/int16/uint16 types
- Allow half float literals
- Correct two errors of double literal parse in HLSL: extension check and
  postfix
2018-03-12 23:15:11 +08:00
Rex Xu
7798aaf149 Allow --hlsl-enable-16bit-types to be used without AMD_EXTENSIONS 2018-03-08 22:17:04 +08:00
John Kessenich
a51525059f
Merge pull request #1269 from bkaradzic/master
Fixed GCC+Clang errors and warnings on Linux and OSX.
2018-03-07 14:31:57 -07:00
John Kessenich
fb97d25c98 Merge branch 'feature' of https://github.com/amdrexu/glslang into amdrexu-feature 2018-03-07 14:29:45 -07:00
Neil Henning
fd920b3b6a WaveReadLaneFirst is the correct wording (was using WaveReadFirstLane previously...). 2018-03-07 17:04:20 +00:00
Rex Xu
cb61eec948 HLSL: Map min types to GLSL 16-bit types 2018-03-07 13:10:01 +08:00
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
Branimir Karadžić
1de8e54d66 Fixed GCC+Clang errors and warnings on Linux and OSX. 2018-03-03 13:04:12 -08: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
e22e347395 HLSL: Fix #1208: accept both int and uint in asuint() and asint(). 2018-01-11 13:26:09 -07:00
John Kessenich
63400477f6 HLSL: Protect against 'continue' outside of loops. 2018-01-10 03:50:42 -07:00
John Kessenich
9b5668c8ef HLSL: Fix #1214: check for nesting in loop/switch of break statements. 2018-01-09 22:32:42 -07:00
John Kessenich
7420a761a3 HLSL: Fix #1215: propagate error on seeing a type name instead of a variable. 2018-01-09 21:35:44 -07:00
John Kessenich
adc33b23cc Non-functional: Fix HLSL error message, and code formatting. 2018-01-08 11:47:08 -07:00
John Kessenich
798d005ccd Build: Tickle bots to try again... seems like a process hang; all tests passed. 2018-01-02 13:07:14 -07:00
John Kessenich
132cf53737 HLSL: Fix #1203: Declare anonymous members for cbuffer with no ';'
The grammar for no semicolon and no object name for cbuffer/tbuffer
was correct, but the production still skipped the anonymous declarations
if an identifier followed.
2018-01-02 11:27:54 -07:00
John Kessenich
fd1e8a78a8 HLSL: Fix 1201: Accept 'layout' as an identifier. 2017-12-29 20:59:13 -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
838d7afc61 SPV: HLSL: Move to correct HLSL barrier semantics, per Khronos recommendation. 2017-12-16 00:34:08 -07: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
8116cfc9bf HLSL: Give error on unsupported buffer initializer. 2017-12-09 04:42:42 -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
7199a6d1a9 Add initialization in case it is causing the Apple Clang release failure. 2017-11-29 16:42:42 -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
John Kessenich
b2abe2f0a5
Merge pull request #1169 from LoopDawg/cbuffer-identifier
HLSL: allow keyword-identifiers as cbuffer/struct names.
2017-11-28 16:51:42 -07:00
LoopDawg
7ee29ba730 HLSL: allow keyword-identifiers as cbuffer/struct names.
Issue #791 was partially fixed by PR #1161 (the mat mul implicit
truncations were its main point), but it still wouldn't compile due to
the use of ConstantBuffer as an identifier.  Apparently those fall into
the same class as "float float", where float is both a type and an
identifier.

This allows struct definitions with such keyword-identifiers,
and adds ConstantBuffer to the set.  'cbuffer int' is legal in HLSL,
and 'struct int' appears to only be rejected due to the redefinition
of the 'int' type.

Fixes #791
2017-11-28 10:17:19 -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
John Kessenich
ca4ef9f43b
Merge pull request #1156 from LoopDawg/snorm-uav
HLSL: Accept unorm and snorm on types
2017-11-15 15:30:59 -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
LoopDawg
fa39cffd6a HLSL: Accept unorm and snorm on types
This is currently parsed and ignored, save for some minor validation.
2017-11-14 14:55:40 -07:00
LoopDawg
e5530b92ce HLSL: implement TextureBuffer<type>
Almost equivalent to tbuffer, except members not at global scope.
So, reference is "TextureBuffer_var.member", not simply "member".
2017-11-08 19:48:11 -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
4ce5b562bb Fix #1103: clip() works on int/uint. 2017-10-16 11:42:35 -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