Commit Graph

115 Commits

Author SHA1 Message Date
Hans-Kristian Arntzen
9012a39b60 Basic implementation of OpCopyLogical. 2020-01-06 11:47:26 +01:00
Sarah Mashayekhi
eed84684cd Add licensing header to test_shaders.py 2019-11-26 14:46:19 -05:00
Dan Sinclair
d409210ee5 Move all .invalid shaders into no-opt folders. 2019-11-05 13:19:19 -05:00
Dan Sinclair
e5af41255c Only run spirv-opt if the spirv is valid.
This CL updates the test runner to only run spirv-opt if the generated
SPIR-V is valid. If validation is skipped it's possible to hit aborts
and other memory errors in the optimizer as it assumes the SPIR-V is
valid.
2019-11-05 11:00:49 -05:00
Lukas Hermanns
84351d3aed Merge remote-tracking branch 'upstream/master' 2019-10-21 18:55:36 -04:00
Lukas Hermanns
e1b161b54b Removed bounds checks in favor of SPIRV-Tools pass '--graphics-robust-access' 2019-10-21 16:39:53 -04:00
Hans-Kristian Arntzen
4bb673a626 MSL: Add opt-in support for huge IABs.
If there are enough members in an IAB, we cannot use the constant
address space as MSL compiler complains about there being too many
members. Support emitting the device address space instead.
2019-10-14 16:20:34 +02:00
Lukas Hermanns
ffbd801853 Added '--msl-invariant-float-math' option and new test case for it. 2019-10-09 14:03:06 -04:00
Lukas Hermanns
688a39e7f8 Merge remote-tracking branch 'upstream/master' 2019-10-09 10:12:04 -04:00
Hans-Kristian Arntzen
309e994224 Do not value compare JSON files for regression purposes.
0 was comparing equal to False. We expect text equality.
2019-10-04 11:04:52 +02:00
Lukas Hermanns
f3a6d28a1d Further updates for pull request #1162; also added two test cases for spvCubemapTo2DArrayFace function and added '--msl-framebuffer-fetch'/ '--msl-emulate-cube-array' compiler options. 2019-09-27 15:49:54 -04:00
Ryan Harrison
cf1bf1c6ae Update external/ to SPIR-V 1.5
Rolled the hashes used for glslang, SPIRV-Tools, and SPIRV-Headers to
HEAD, which includes the update to 1.5.

Added passing '--amb' to glslang, so I didn't have to explicitly set
bindings in a large number of test shaders that currently don't, and
now glslang considers them invalid.

Marked all shaders that no longer pass spirv-val as .invalid.
2019-09-18 16:04:27 -04:00
Chip Davis
cb35934248 MSL: Support dynamic offsets for buffers in argument buffers.
Vulkan has two types of buffer descriptors,
`VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC` and
`VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC`, which allow the client to
offset the buffers by an amount given when the descriptor set is bound
to a pipeline. Metal provides no direct support for this when the buffer
in question is in an argument buffer, so once again we're on our own.
These offsets cannot be stored or associated in any way with the
argument buffer itself, because they are set at bind time.  Different
pipelines may have different offsets set. Therefore, we must use a
separate buffer, not in any argument buffer, to hold these offsets. Then
the shader must manually offset the buffer pointer.

This change fully supports arrays, including arrays of arrays, even
though Vulkan forbids them. It does not, however, support runtime
arrays. Perhaps later.
2019-09-05 23:29:00 -05:00
Hans-Kristian Arntzen
12ca9d1982 Vulkan GLSL: Support disabling samplerless texture function EXT.
Some platforms support Vulkan GLSL, but not this extension apparently
...
2019-07-25 11:07:14 +02:00
Chip Davis
fb5ee4cb5c MSL: Adjust BuiltInWorkgroupId for vkCmdDispatchBase().
This command allows the caller to set the base value of
`BuiltInWorkgroupId`, and thus of `BuiltInGlobalInvocationId`. Metal
provides no direct support for this... but it does provide a builtin,
`[[grid_origin]]`, normally used to pass the base values for the stage
input region, which we will now abuse to pass the dispatch base and
avoid burning a buffer binding.

`[[grid_origin]]`, as part of Metal's support for compute stage input,
requires MSL 1.2. For 1.0 and 1.1, we're forced to provide a buffer.

(Curiously, this builtin was undocumented until the MSL 2.2 release. Go
figure.)
2019-07-24 08:56:15 -05:00
Hans-Kristian Arntzen
172185016f MSL: Add std140 and scalar matrix layouts. 2019-07-22 11:30:03 +02:00
Hans-Kristian Arntzen
c7eda1bce9 Test glsl.std450 more exhaustively.
Make sure to test everything with scalar as well to catch any weird edge
cases.

Not all opcodes are covered here, just the arithmetic ones. FP64 packing
is also ignored.
2019-07-17 11:53:05 +02: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
Chip Davis
7eecf5a46b MSL: Support SPV_KHR_multiview.
This is needed to support `VK_KHR_multiview`, which is in turn needed
for Vulkan 1.1 support. Unfortunately, Metal provides no native support
for this, and Apple is once again less than forthcoming, so we have to
implement it all ourselves.

Tessellation and geometry shaders are deliberately unsupported for now.
The problem is that the current implementation encodes the `ViewIndex`
as part of the `InstanceIndex`, which in the SPIR-V environment at least
only exists in the vertex shader. So we need to work out a way to pass
the view index along to the later stages.

This implementation runs vertex shaders for all views up to the highest
bit set in the view mask, even those whose bits are clear. The fragments
for the inactive views are then discarded. Avoiding this is difficult:
calculating the view indices becomes far more complicated if we can only
run for those views which are set in the mask.
2019-06-29 09:43:55 -05:00
Hans-Kristian Arntzen
856a8d200e Make sure args.msl22 is set in test_shaders.py.
Works locally, but apparently not on Travis?
2019-06-18 12:22:46 +02:00
Hans-Kristian Arntzen
33fc2ad8cc MSL: Fix path check in test_shaders.py. 2019-06-18 10:36:10 +02:00
Hans-Kristian Arntzen
be1e27a6e5 MSL: Conditionally validate MSL 2.2 shaders.
Travis CI Xcode image does not support MSL 2.2 yet (beta), so just do
local validation for now.
2019-06-17 16:07:07 +02:00
Hans-Kristian Arntzen
fccf1d0462 Add MSL 2.2 path in test_shaders.py. 2019-06-12 09:30:41 +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
647ddaee42 HLSL/MSL: Deal correctly with nonuniformEXT qualifier.
MSL does not seem to have a qualifier for this, but HLSL SM 5.1 does.
glslangValidator for HLSL does not support this, so skip any validation,
but it passes in FXC.
2019-05-13 14:58:27 +02:00
Ryan Harrison
d3c59e76db Set env to vulkan1.1 for spirv-as in test_shaders.py
Fixes #968
2019-05-08 14:03:35 -04:00
Hans-Kristian Arntzen
fc4f39b11f MSL: Support native texture_buffer type, throw error on atomics.
Atomics are not supported on images or texture_buffers in MSL.
Properly throw an error if OpImageTexelPointer is used (since it can
only be used for atomic operations anyways).
2019-04-23 12:21:43 +02:00
Hans-Kristian Arntzen
3a7cb0c2a9 Support running {,update_}test_shader.sh with CMake builds.
Make path to spirv-cross configurable so we can be a bit more flexible
with build systems used to update tests.
2019-04-12 14:56:10 +02:00
Hans-Kristian Arntzen
9ae91c2d1e Deal with mismatched signs in S/U/F conversion opcodes. 2019-04-10 14:03:58 +02:00
Hans-Kristian Arntzen
c60b9a1e96 CLI: Make --iterations more useful.
Add a basic benchmarking mode to test_shaders.py.
We cannot safely just call compile() in a loop. Do the full pipeline for
each iteration.
2019-04-09 15:09:16 +02:00
Hans-Kristian Arntzen
0474848d4a GLSL: Support emitting push constant block as a plain UBO. 2019-03-19 10:58:52 +01:00
Hans-Kristian Arntzen
e2aadf8995 Rename "push descriptor set" to "discrete descriptor set".
Check for case where iOS doesn't support writable argument buffer
textures.
2019-03-15 21:53:21 +01:00
Hans-Kristian Arntzen
b3380ec9dd MSL: Support VK_KHR_push_descriptor.
If we have argument buffers, we also need to support using plain
descriptor sets for certain cases where API wants it.
2019-03-15 14:08:47 +01:00
Hans-Kristian Arntzen
e47a77d596 MSL: Implement Metal 2.0 indirect argument buffers. 2019-03-15 11:01:27 +01:00
Hans-Kristian Arntzen
852e63eebc Clean up some very verbose argument passing. 2019-03-07 12:43:00 +01:00
Hans-Kristian Arntzen
074f765a83 Explicitly pass down paths to glslang/spirv-tools.
Windows and CMake really cannot get along with %PATH%, sigh ...
2019-03-07 12:36:16 +01:00
Hans-Kristian Arntzen
d2cc43e667 Fix edge case where opaque types can be declared on stack.
In the bizarre case where the ID of a loaded opaque type aliased with a
literal which was used as part of another texturing instruction, we
could end up with a case where domination analysis assumed the loaded
opaque type needed to be moved to a different scope.

Fix the issue by never doing dominance analysis for opaque temporaries,
and be more robust when analyzing texturing instructions.

Also make sure reflection output is deterministic.
This patch slightly alterered output for some unknown reason, but it came from an
unordered_map, so it's fine.
2019-02-19 17:28:31 +01:00
Chip Davis
41d9424233 MSL: Add an option to set the tessellation domain origin.
This is intended to be used to support `VK_KHR_maintenance2`'s
tessellation domain origin feature. If `tess_domain_origin_lower_left`
is `true`, the `v` coordinate will be inverted with respect to the
domain. Additionally, in `Triangles` mode, the `v` and `w` coordinates
will be swapped. This is because the winding order is interpreted
differently in lower-left mode.
2019-02-18 14:25:42 -06:00
Chip Davis
c51e5b7911 MSL: Add a setting to capture vertex shader output to a buffer.
This will be necessary to support transform feedback, as well as
tessellation shaders.
2019-02-05 20:00:10 -06:00
Hans-Kristian Arntzen
b8033d7525 MSL: Add option to pad fragment outputs.
If not enough components are provided in the shader,
the shader MSL compiler throws an error rather than make components
undefined. This hurts portability, so we need to add explicit padding
here.
2019-01-14 15:11:52 +01:00
Hans-Kristian Arntzen
973b3155c4 Fix deadlock on Travis with --parallel.
We cannot throw any exception or call exit() in an async task, or Python deadlocks.
Catch any errors and propagate them to top thread.
2019-01-14 11:23:46 +01:00
Hans-Kristian Arntzen
6157bf3cae Add Windows support in Travis CI.
- Add new Windows support
- Use CMake/CTest instead of Make + shell scripts
- Use --parallel in CTest
- Fix CTest on Windows
- Cleanups in test_shaders.py
- Force specific commit for SPIRV-Headers
- Fix Inf/NaN odd-ball case by moving to ASM
2018-10-27 00:22:30 +02:00
Chip Davis
2506046cb4 Merge remote-tracking branch 'origin' into resource-arrays-msl 2018-09-27 10:50:16 -05:00
Hans-Kristian Arntzen
af75ef005f Update glslang and SPIRV-Tools.
A lot of changes in spirv-opt output.
Some new invalid SPIR-V was found but most of them were not significant
for SPIRV-Cross, so just marked them as invalid.
2018-09-27 11:10:22 +02:00
Chip Davis
3a9af9681c MSL: Expand arrays of buffers passed as input.
Even as of Metal 2.1, MSL still doesn't support arrays of buffers
directly. Therefore, we must manually expand them. In the prologue, we
define arrays holding the argument pointers; these arrays are what the
transpiled code ends up referencing. We might be able to do similar
things for textures and samplers prior to MSL 2.0.

Speaking of which, also enable texture arrays on iOS MSL 1.2.
2018-09-26 20:48:09 -05:00
Chip Davis
2583321657 MSL: Add an option to insert texture swizzles into generated shaders.
It's intended to be used with MoltenVK to support arbitrary
`VkComponentMapping` settings. The idea is that MoltenVK will pass a
buffer (which it set to some buffer index that isn't being used)
containing packed versions of the `VkComponentMapping` struct, one for
each sampled image.

Yes, this is horribly ugly. It is unfortunately necessary. Much of the
ugliness is to support swizzling gather operations, where we need to
alter the component that the gather operates on--something complicated
by the `gather()` method requiring the passed-in component to be a
constant expression. It doesn't even support swizzling gathers on depth
textures, though I could add that if it turns out we need it.
2018-09-19 22:32:24 -05:00
Hans-Kristian Arntzen
0312c98825 Validate HLSL with appropriate SM. 2018-09-12 09:44:35 +02:00
crosire
3d39652853 Add tests for previous fix 2018-09-11 20:57:56 +02:00
Hans-Kristian Arntzen
652d8263e5 Use correct spirv-cross version when testing MSL 1.1 shaders. 2018-09-07 09:45:25 +02:00
Hans-Kristian Arntzen
32823b0838 MSL: Do not emit function constants for version < 1.2. 2018-09-07 09:33:34 +02:00