Commit Graph

402 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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