Commit Graph

368 Commits

Author SHA1 Message Date
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
b92ce60fc7 GLSL/SPV: Fix #1310: don't create unnecessary integer matrices. 2018-04-07 18:49:54 -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
John Kessenich
6a4a427efe GLSL: Implement correct semantic checking for run-time sized arrays. 2018-04-02 14:52:15 -06:00
John Kessenich
5a867acad5 Linker: Fix #1329: correctly merge unsized arrays, and fix link tests. 2018-04-01 21:22:34 -06:00
Jeff Bolz
2abe9a4d34 Implement GL_NV_shader_subgroup_partitioned 2018-03-29 22:52:17 -05:00
GregF
fb03a55e0f Only print legalization warning if optimizer disabled 2018-03-29 13:17:54 -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
7cec64fc42 Non functional: add EshTargetClientVersion alias for EShTargetClientVersion.
Fixes #1304.
2018-03-22 23:54:04 -06:00
John Kessenich
e7e081bda9 PP: don't give errors on some tokens under #if 0 (or similar).
Fixes #1295.

Tokens that are accepted by any version of HLSL or GLSL should be
allowed when #ifdef'd off, such that errors are not reported.
2018-03-19 00:43:18 -06:00
John Kessenich
cd23a47566
Merge pull request #1291 from ben-clayton/add-nv-nopersp
Add support for GL_NV_shader_noperspective_interpolation
2018-03-16 15:50:38 -06:00
Ben Clayton
f648083365 Add tests for GL_NV_shader_noperspective_interpolation 2018-03-16 16:49:29 +00:00
John Kessenich
647fccaf2f AST: Fix shift conversions, which don't require matching types.
The base and shift amount need to be integers, but not of the same type.
This fixes #1296 and replaces #1297.
2018-03-15 21:11:36 -06: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
John Kessenich
663b90d908 Build: Fix build issues with previous commit. 2018-03-06 14:20:16 -07:00
GregF
fd50f6a4c3 Legalization: Omit legalization warning when spirv-opt is linked. 2018-03-06 13:00:08 -07:00
Rex Xu
1e5d7b0b27 Implement the extension GL_AMD_gpu_shader_half_float_fetch
- Support new opaque types: f16sampler*, f16image*, f16subpassInput*.
- Add new built-in GLSL texture/image functions.
2018-03-02 16:48:03 +08:00
John Kessenich
46413d5780 SPV: Fix #1258: cache constant structs by id, not opcode.
Constants were generally cached by type opcode, but all structures share the
same type opcode (OpTypeStruct), so they need to be cached by type id.
2018-02-26 19:35:39 -07:00
John Kessenich
9c9c4e90df GLSL/SPV: Fix #1196: Require resources to have layout(binding=X). 2018-02-22 11:47:41 -07:00
John Kessenich
2d9973de0e Tests: specExamples.vert is used twice, it needs two different output names. 2018-02-21 18:42:10 -07:00
LoopDawg
4425f245a5 HLSL: Add conversions for image ops during SPV construction
HLSL allows image and texture types to be templatized on sub-vec4 types,
or even structures.  This was mostly handled already during creation of
sampling operations.  However, for operator[] which can generate image
loads, this wasn't happening.

It also isn't very easy to do at that point in time, because operator[]
does not know where the results it produces will end up.  They may be
an lvalue or an rvalue, and there's a post-process to convert loads to
stores.  They may end up in atomic ops.

To bypass that difficulty, GlslangToSpv now looks for this case and
adds the appropriate conversion.  LIMITATION: this only works for
cases for which a simple conversion opcode suffices.  That is to say,
it will not work if the type is templatized on a struct.
2018-02-18 13:13:36 -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
eb2c0c72bf GLSL: XFB: more support for built-in block redeclarations with XFB.
- correct inheritence (or not) of the right XFB buffer
- compute implicit stride (fixes #1212)
- semantic check block-member redeclarations
- inherit stride from a member
2018-01-09 18:00:33 -07:00
John Kessenich
8297936dd6 SPV: Change barrier emission to conform to Khronos decisions.
The memory model group agreed to these definitions for how
to map GLSL barrier, memoryBarrier, etc. With HLSL following suit.
2017-12-16 00:30:10 -07:00
John Kessenich
edaf556778 SPV: Plumb through XFB buffer and stride information.
Also, only emit this XFB information where the SPIR-V spec says
it should be emitted: essentially, on objects.

This and the previous commit together fix #1185.
2017-12-15 06:25:14 -07:00
John Kessenich
be3842f6ae GLSL: Implement XFB for redeclared built-in blocks. 2017-12-15 04:43:59 -07:00
Piers Daniell
1c5443c693 Add implementation of SPV_EXT_fragment_fully_covered
This implementation uses the GLSL extension
GL_NV_conservative_raster_underestimation to generate the new SPIR-V
FullyCoveredEXT built in.
2017-12-14 07:42:23 -07:00
LoopDawg
280c75ca51 HLSL: Allow primitive id on hull shader inputs
Fixes #979
2017-12-08 12:01:16 -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
John Kessenich
1ce94b2d68
Merge pull request #1166 from tafuri/#1165-invalid_Store
#1165 invalid store
2017-11-28 19:41:52 -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
Sebastian Tafuri
66b319d30b Added new test to gtests and updated test data 2017-11-27 17:13:22 +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
cbdf871d7f SPV: SampleMask does not depend on SampleRateShading.
Fixes #1158.
Fixes #1159.
2017-11-20 16:32:49 -07:00
John Kessenich
cb421ef991 Test: Add more legalization tests; those effected by flattening. 2017-11-16 15:02:06 -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
88e22a6090 Fix #1079: don't give error when macro() name used without open (. 2017-11-02 06:48:32 -06:00
John Kessenich
e8d21388ed Fix nondeterminism discussed in 258b700f59 2017-11-02 00:05:53 -06:00
John Kessenich
5866e67b8d Tests: Non-determinancy: Add back in the IntMin tests. 2017-10-28 13:03:49 -06:00
John Kessenich
258b700f59 Non-determinant tests: Remove recent tests, to see if things stabelize.
Both debug and release clang builds have segfaulted on recent
changes, non deterministically, while doing the single/multi-thread
test all test files. Removing recent test files, to see if it gives
a clue.
2017-10-27 04:15:57 -06:00
Aaron Muir Hamilton
f83e2f0690 GLSL: Fold constant SHRT_MIN/INT_MIN/LLONG_MIN % -1 to 0. 2017-10-25 01:32:20 +00:00