Commit Graph

632 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
47a18b9f1b Simplify row-major matrix/vector multiplies. 2019-07-23 10:56:57 +02:00
Hans-Kristian Arntzen
6224199c76 Add struct size padding tests. 2019-07-23 10:30:37 +02:00
Hans-Kristian Arntzen
2172b19be2 Remove obsolete matrix workaround code. 2019-07-22 16:27:47 +02:00
Hans-Kristian Arntzen
249f8e5180 MSL: Support storing to row-major column.
Defer transposes to actual Load or Store.
2019-07-22 11:13:44 +02:00
Hans-Kristian Arntzen
be2fccd837 Tests run clean. 2019-07-22 10:23:39 +02:00
Hans-Kristian Arntzen
6c1f97b4a9 Fix unpacking of packed but not remapped types on load. 2019-07-19 14:50:35 +02:00
Hans-Kristian Arntzen
12c5020854 Pass down row-major state to unpacking functions. 2019-07-19 13:03:08 +02:00
Hans-Kristian Arntzen
f6251e4699 Can deal with std140 matrices now.
Refactor is coming together.
2019-07-19 11:21:02 +02:00
Hans-Kristian Arntzen
dd7ebaf9f7 Start considering how to emit physical type ID. 2019-07-19 10:06:19 +02:00
Hans-Kristian Arntzen
a86308bce1 MSL: Begin rewrite of buffer packing logic. 2019-07-19 10:06:19 +02:00
Chip Davis
12a8654784 Don't forward uses of an OpIsHelperInvocationEXT op.
If this is computed *before* a `demote`, but used *after*, forwarding it
will produce the wrong value. This does make for uglier shaders, but
it's necessary right now to ensure correctness.

I needed to use an assembly shader to produce the test for this.
`spirv-opt` is not smart enough (or too smart?) to eliminate the
variable that would be used in GLSL to express this.
2019-07-18 17:32:35 -05:00
Chip Davis
50dce10c5d Support the SPV_EXT_demote_to_helper_invocation extension.
This extension provides a new operation which causes a fragment to be
discarded without terminating the fragment shader invocation. The
invocation for the discarded fragment becomes a helper invocation, so
that derivatives will remain defined. The old `HelperInvocation` builtin
becomes undefined when this occurs, so a second new instruction queries
the current helper invocation status.

This is only fully supported for GLSL. HLSL doesn't support the
`IsHelperInvocation` operation and MSL doesn't support the
`DemoteToHelperInvocation` op.

Fixes #1052.
2019-07-17 09:12:22 -05:00
Chip Davis
6a58554568 Support the SPV_KHR_device_group extension.
The only piece added by this extension is the `DeviceIndex` builtin,
which tells the shader which device in a grouped logical device it is
running on.

Metal's pipeline state objects are owned by the `MTLDevice` that created
them. Since Metal doesn't support logical grouping of devices the way
Vulkan does, we'll thus have to create a pipeline state for each device
in a grouped logical device. The upcoming peer group support in Metal 3
will not change this. For this reason, for Metal, the device index is
supplied as a constant at pipeline compile time.

There's an interaction between `VK_KHR_device_group` and
`VK_KHR_multiview` in the
`VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT`, which defines the
view index to be the same as the device index. The new
`view_index_from_device_index` MSL option supports this functionality.
2019-07-13 16:45:54 -05:00
Hans-Kristian Arntzen
932ee0e328 Deal correctly with return sign of bitscan operations. 2019-07-12 10:57:56 +02:00
Hans-Kristian Arntzen
ad5eae46ed
Merge pull request #1078 from cdavis5e/post-depth-coverage
Support the SPV_KHR_post_depth_coverage extension.
2019-07-12 09:56:26 +02:00
Hans-Kristian Arntzen
2e32d4c0db
Merge pull request #1079 from cdavis5e/msl-boolean-mix
MSL: Use the select() function for OpSelect.
2019-07-12 09:52:57 +02:00
Chip Davis
6628ea6e48 MSL: Use the select() function for OpSelect.
This significantly improves codegen for vector `OpSelect` in MSL.
2019-07-11 10:30:37 -05:00
Chip Davis
1df47db6ba Support the SPV_KHR_post_depth_coverage extension.
Using the `PostDepthCoverage` mode specifies that the `gl_SampleMaskIn`
variable is to contain the computed coverage mask following the early
fragment tests, which this mode requires and implicitly enables.

Note that unlike Vulkan and OpenGL, Metal places this on the sample mask
input itself, and furthermore does *not* implicitly enable early
fragment testing. If it isn't enabled explicitly with an
`[[early_fragment_tests]]` attribute, the compiler will error out. So we
have to enable that mode explicitly if `PostDepthCoverage` is enabled
but `EarlyFragmentTests` isn't.

For Metal, only iOS supports this; for some reason, Apple has yet to
implement it on macOS, even though many desktop cards support it.
2019-07-11 10:28:43 -05:00
Hans-Kristian Arntzen
63bcbd511e GLSL: Need extension to use bitcast on GLSL < 330. 2019-07-11 15:32:57 +02:00
Hans-Kristian Arntzen
25c74b324e Forget loop variable enables after emitting block chain. 2019-07-10 12:57:12 +02:00
Hans-Kristian Arntzen
f6f849397e MSL: Re-roll array expressions in initializers.
We cannot rely on copy path when using an array as part of a struct
initializer, so reroll such expressions to an initializer list again.
2019-07-10 11:19:33 +02:00
Hans-Kristian Arntzen
53ab2144b9
Merge pull request #1064 from KhronosGroup/fix-1062
Fall back to complex loop if non-trivial continue block is found.
2019-07-08 13:58:35 +02:00
Hans-Kristian Arntzen
50342966c0 Fall back to complex loop if non-trivial continue block is found.
There is a case where we can deduce a for/while loop, but the continue
block is actually very painful to deal with, so handle that case as
well. Removes an exceptional case.
2019-07-08 11:54:29 +02:00
Hans-Kristian Arntzen
d12b54bbb4 Propagate NonUniformEXT to dependent expressions.
This decoration might only be present for the very last ID which is
consumed by a sampling or Load/Store instruction. To make sure our
access chains are emitted correctly, we have to back-propagate this
decoration.
2019-07-08 11:19:38 +02:00
Lifeng Pan
5ca8779044 Parse SPIR-V debug information extended instructions, as well as OpNoLine.
No impact on result shader string.
2019-07-04 16:21:44 +08:00
Hans-Kristian Arntzen
581ed0fd59 HLSL: Does not support case-fallthrough.
Disable any fallthrough on HLSL. Risky business if fallthrough blocks
had a barrier(), but can't do anything about that ...
2019-06-27 15:10:17 +02:00
Hans-Kristian Arntzen
c76b99b711 Handle more cases with FP16 and texture sampling. 2019-06-27 15:04:22 +02:00
Hans-Kristian Arntzen
bcef66fbf3 Fix declaration of loop variables with a Phi helper copy.
Certain Phi variables need to maintain a temporary copy, but we forgot
to declare them when the master variable is a loop variable itself.
2019-06-25 10:45:15 +02:00
Hans-Kristian Arntzen
7557ff5567 Workaround GCC 9 bug. 2019-06-24 10:17:25 +02:00
Hans-Kristian Arntzen
b4e0163749 Run format_all.sh. 2019-06-21 16:02:22 +02:00
Hans-Kristian Arntzen
bcec5cb370 Old MSVC does not like +[] constructs. 2019-06-21 14:59:51 +02:00
Hans-Kristian Arntzen
c365cc1b43 Deal with OpPhi and case fallthrough.
This is quite complex since we cannot flush Phi inside the case labels,
we have to do it outside by emitting a lot of manual branches ourselves.

This should be extremely rare, but we need to handle this case.
2019-06-21 13:38:23 +02:00
Hans-Kristian Arntzen
22e3beaab9 Deal with switch block fallthrough more correctly ... 2019-06-20 12:14:19 +02:00
Hans-Kristian Arntzen
bc3bf47446 Rewrite how switch block case labels are emitted. 2019-06-20 11:57:05 +02:00
Hans-Kristian Arntzen
7fdb418f18
Merge pull request #1028 from KhronosGroup/fix-1010
MSL: Support barycentrics and PrimitiveID in fragment shaders
2019-06-19 15:29:14 +02:00
Hans-Kristian Arntzen
707312b83a GLSL: Support NV barycentrics. 2019-06-19 09:52:35 +02:00
Hans-Kristian Arntzen
f171d82590 MSL: Support MinLod operand. 2019-06-19 09:43:03 +02:00
Hans-Kristian Arntzen
d81bfc5b58 MSL: Fix regression with Private parameter declaration.
If we compile multiple times due to forced_recompile, we had
deferred_declaration = true while emitting function prototypes which
broke an assumption. Fix this by clearing out stale state before leaving
a function.
2019-06-13 10:36:21 +02:00
Hans-Kristian Arntzen
a9da59b0b8 GLSL: Support GL_ARB_shader_stencil_export. 2019-06-12 10:06:54 +02:00
Hans-Kristian Arntzen
bf56dc88b9 Rewrite how loop dominators are propagated.
Do this analysis in the CFG stage rather than last minute with the
ad-hoc algorithm we had in place before CFG was introduced.
2019-06-06 12:17:46 +02:00
Hans-Kristian Arntzen
720681da39
Merge pull request #1006 from KhronosGroup/fix-1003
Deal with case where a block is somehow emitted in a duplicated fashion.
2019-06-05 16:11:06 +02:00
Patrick Mours
8d64d5e776 Fix storage packing qualifiers missing on "shaderRecordNV" buffers 2019-06-05 13:31:24 +02:00
Patrick Mours
be3035db26 Fix callable data variables 2019-06-05 13:31:24 +02:00
Patrick Mours
789178666f Add support for "shaderRecordNV" qualifier 2019-06-05 13:31:24 +02:00
Hans-Kristian Arntzen
c09ca74c61 Deal with case where a block is somehow emitted in a duplicated fashion.
We seen to have to deal with a case where a block is used multiple times
without any "proper" structured control flow, so we risk losing deferred
declaration state.
2019-06-05 12:39:40 +02:00
Hans-Kristian Arntzen
65af09d2d1 Support emitting OpLine directive.
Facilitates easier mapping from source language to cross-compiled output
in tooling.
2019-05-28 13:44:24 +02:00
Hans-Kristian Arntzen
23889f7b87 GLSL: Support std430 in UBOs with scalar layout. 2019-05-28 12:22:44 +02:00
Hans-Kristian Arntzen
b3094cd02a Run format_all.sh. 2019-05-27 16:54:13 +02:00
Hans-Kristian Arntzen
7b9e0fb428 MSL: Implement OpArrayLength.
This gets rather complicated because MSL does not support OpArrayLength
natively. We need to pass down a buffer which contains buffer sizes, and
we compute the array length on-demand.

Support both discrete descriptors as well as argument buffers.
2019-05-27 16:13:09 +02:00
Hans-Kristian Arntzen
96492648d4 MSL: Fix struct declaration order with complex type aliases.
MSL generally emits the aliases, which means we cannot always place the
master type first, unlike GLSL and HLSL. The logic fix is just to
reorder after we have tagged types with packing information, rather than
doing it in the parser fixup.
2019-05-23 14:54:04 +02:00