Commit Graph

9 Commits

Author SHA1 Message Date
Bill Hollings
ec054dad7f MSL: Support synthetic functions in function constants.
Emit synthetic functions before function constants.
Support use of spvQuantizeToF16() in function constants for numerical
behavior consistency with the op code.
Ensure subnormal results from OpQuantizeToF16 are flushed to zero per SPIR-V spec.

Adjust SPIRV-Cross unit test reference shaders to accommodate these changes.
Any MSL reference shader that inclues a synthetic function is affected,
since the location it is emitted has changed.
2021-09-28 19:10:16 -04:00
Chip Davis
03ad13bae6 MSL: Simplify spvSubgroupBallot().
A bitcast to `uint2` will do just fine. I honestly don't know why I
didn't do it this way earlier.
2021-07-21 00:25:09 -05:00
Hans-Kristian Arntzen
aea6d29aa8 MSL: Add test for logical subgroup arith ops. 2021-03-08 12:57:37 +01:00
Chip Davis
68908355a9 MSL: Expand subgroup support.
Add support for declaring a fixed subgroup size. Metal, like Vulkan with
`VK_EXT_subgroup_size_control`, allows the thread execution width to
vary depending on factors such as register usage. Unfortunately, this
breaks several tests that depend on the subgroup size being what the
device says it is. So we'll fix the subgroup size at the size the device
declares. The extra invocations in the subgroup will appear to be
inactive. Because of this, the ballot mask builtins are now ANDed with
the active subgroup mask.

Add support for emulating a subgroup of size 1. This is intended to be
used by Vulkan Portability implementations (e.g. MoltenVK) when the
hardware/software combo provides insufficient support for subgroups.
Luckily for us, Vulkan 1.1 only requires that the subgroup size be at
least 1.

Add support for quadgroup and SIMD-group functions which were added to
iOS in Metal 2.2 and 2.3. This will allow clients to take advantage of
expanded quadgroup and SIMD-group support in recent Metal versions and
on recent Apple GPUs (families 6 and 7).

Gut emulation of subgroup builtins in fragment shaders. It turns out
codegen for the SIMD-group functions in fragment wasn't implemented for
AMD on Mojave; it's a safe bet that it wasn't implemented for the other
drivers either. Subgroup support in fragment shaders now requires Metal
2.2.
2020-11-20 15:55:49 -06:00
Chip Davis
1264e2705e MSL: Cast broadcast booleans to ushort.
Metal doesn't support broadcasting or shuffling boolean values, but we
can work around that by casting it to `ushort`, then casting it back to
`bool`. I used `ushort` instead of `uint` because 16-bit values give
better throughput on Apple GPUs.
2020-10-23 21:55:46 -05:00
Chip Davis
065b5bda3c MSL: Mask ballots passed to Ballot bit ops.
Only the least *n* bits are significant, where *n* is the subgroup size.
The Vulkan CTS actually checks this.

The `FindLSB` tests weren't actually failing, but I masked that anyway,
in case there's some corner case the CTS is missing.
2020-10-23 21:55:46 -05:00
Chip Davis
781367d083 MSL: Support vectors with OpGroupNonUniformAllEqual.
This was not tested here in SPIRV-Cross. Predictably, it broke when I
tried it in the CTS.
2020-10-23 21:55:46 -05:00
Chip Davis
6ccb902462 MSL: Correct definitions of subgroup ballot mask variables.
`SubgroupEqMask` had a fencepost error that gave wrong values for
invocation ID 32.

For `SubgroupGeMask` and `SubgroupGtMask`, I forgot to shift the values
from `extract_bits()` up so that the mask is in the correct position.
Using `insert_bits()` instead should fold these two operations into one.

`SubgroupLtMask` and `SubgroupLeMask` were already correct.
2020-10-23 21:54:55 -05:00
Hans-Kristian Arntzen
d4ca91f6c2 Move .invalid. test shaders to the more appropriate subfolders. 2019-11-06 10:40:37 +01:00