Commit Graph

2073 Commits

Author SHA1 Message Date
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
Hans-Kristian Arntzen
3319a3bfd1
Merge pull request #1084 from cdavis5e/msl-intel-integer-funcs
MSL: Support the SPV_INTEL_shader_integer_functions2 extension.
2019-07-17 09:48:55 +02:00
Chip Davis
bc646574a6 MSL: Support the SPV_INTEL_shader_integer_functions2 extension.
This provides a few functions normally available in OpenCL to the SPIR-V
shader environment. These functions happen to be available in Metal as
well.

No GLSL, unfortunately. Intel has yet to publish a
`GL_INTEL_shader_integer_functions2` spec.
2019-07-15 09:42:36 -05:00
Hans-Kristian Arntzen
33d2bbcf69 Merge branch 'msl-amd-trinary-functions' of git://github.com/cdavis5e/SPIRV-Cross 2019-07-15 09:46:31 +02:00
Hans-Kristian Arntzen
4d7aae1050 Merge branch 'device-group' of git://github.com/cdavis5e/SPIRV-Cross 2019-07-15 09:46:16 +02:00
Hans-Kristian Arntzen
041035a7fc Merge branch 'update-externals' of git://github.com/cdavis5e/SPIRV-Cross 2019-07-15 09:46:04 +02:00
Chip Davis
343c6f4ff4 Update external repos.
Fix fallout from changes.

There's a bug in glslang that prevents `float16_t`, `[u]int16_t`, and
`[u]int8_t` constants from adding the corresponding SPIR-V capabilities.
SPIRV-Tools, meanwhile, tightened validation so that these constants are
only valid if the corresponding `Float16`, `Int16`, and `Int8` caps are
on. This affects the `16bit-constants.frag` test for GLSL and MSL.
2019-07-13 16:50:21 -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
Chip Davis
ca91fcfe5f MSL: Support the SPV_AMD_shader_trinary_minmax extension.
This requires MSL 2.1.
2019-07-13 16:43:57 -05:00
Hans-Kristian Arntzen
94710fe608
Merge pull request #1080 from KhronosGroup/fix-1073
Deal correctly with return sign of bitscan operations.
2019-07-12 12:34:12 +02:00
Hans-Kristian Arntzen
a845306b3b
Merge pull request #1071 from KhronosGroup/msvc-warning-fix
MSVC: Fix some warnings in C wrapper.
2019-07-12 11:34:45 +02:00
Hans-Kristian Arntzen
92e5255570 Run format_all.sh. 2019-07-12 10:59:53 +02:00
Hans-Kristian Arntzen
932ee0e328 Deal correctly with return sign of bitscan operations. 2019-07-12 10:57:56 +02:00
Hans-Kristian Arntzen
7ffc24fa20 MSVC 2015: Workaround bogus warning with move_backwards. 2019-07-12 10:19:16 +02:00
Hans-Kristian Arntzen
3548f76a02 MSVC: Fix some warnings in C wrapper.
Implicit casts to bool -> warning.
2019-07-12 10:19:16 +02:00
Hans-Kristian Arntzen
19ebbd48c7
Merge pull request #1077 from cdavis5e/msl-spirv-qualifiers
MSL: Handle coherent, volatile, and restrict.
2019-07-12 10:03:06 +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
Hans-Kristian Arntzen
2820ab0b51
Merge pull request #1076 from KhronosGroup/bitcast-pre-330-glsl
GLSL: Need extension to use bitcast on GLSL < 330.
2019-07-11 18:06:51 +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
Chip Davis
058f1a0933 MSL: Handle coherent, volatile, and restrict.
This maps them to their MSL equivalents. I've mapped `Coherent` to
`volatile` since MSL doesn't have anything weaker than `volatile` but
stronger than nothing.

As part of this, I had to remove the implicit `volatile` added for
atomic operation casts. If the buffer is already `coherent` or
`volatile`, then we would add a second `volatile`, which would be
redundant. I think this is OK even when the buffer *doesn't* have
`coherent`: `T *` is implicitly convertible to `volatile T *`, but not
vice-versa. It seems to compile OK at any rate. (Note that the
non-`volatile` overloads of the atomic functions documented in the spec
aren't present in the MSL 2.2 stdlib headers.)

`restrict` is tricky, because in MSL, as in C++, it needs to go *after*
the asterisk or ampersand for the pointer type it's modifying.

Another issue is that, in the `Simple`, `GLSL450`, and `Vulkan` memory
models, `Restrict` is the default (i.e. does not need to be specified);
but MSL likely follows the `OpenCL` model where `Aliased` is the
default. We probably need to implicitly set either `Restrict` or
`Aliased` depending on the module's declared memory model.
2019-07-11 10:22:30 -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
9f3bebe3d0
Merge pull request #1075 from lifpan/master
Remove unreasonable assertion for OpTypeImage Sampled parameter.
2019-07-11 15:09:45 +02:00
lifpan
b11c20fc1d Remove unreasonable assertion for OpTypeImage Sampled parameter. 2019-07-11 19:39:44 +08:00
Hans-Kristian Arntzen
1a592b7c0f
Merge pull request #1067 from cdavis5e/msl-scalar-block-layout
MSL: Support scalar block layout.
2019-07-11 13:03:03 +02:00
Chip Davis
28454facbb MSL: Handle packed matrices.
The old method of using a different unpacked matrix type doesn't work
for scalar alignment. It certainly wouldn't have any effect for a square
matrix, since the number of columns and rows are the same. So now we'll
store them as arrays of packed vectors.
2019-07-10 18:37:31 -05:00
Chip Davis
ea5c0ed82f MSL: Fix alignment of packed types.
Packed types have scalar alignment.
2019-07-10 11:57:04 -05:00
Hans-Kristian Arntzen
44f688bf0b
Merge pull request #1070 from KhronosGroup/fix-1066
Forget loop variable enables after emitting block chain.
2019-07-10 14:04:50 +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
6b010e0cbc
Merge pull request #1069 from KhronosGroup/fix-1053
MSL: Re-roll array expressions in initializers.
2019-07-10 12:15: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
Chip Davis
e5fa7edfd6 MSL: Support scalar block layout.
Relaxed block layout relaxed the restrictions on vector alignment,
allowing them to be aligned on scalar boundaries. Scalar block layout
relaxes this further, allowing *any* member to be aligned on a scalar
boundary. The requirement that a vector not improperly straddle a
16-byte boundary is also relaxed.

I've also added a test showing that `std430` layout works with UBOs.

I'm troubled by the dual meaning of the `Packed` extended decoration. In
some instances (struct, `float[]`, and `vec2[]` members), it actually
means the exact opposite, that the member needs extra padding. This is
especially problematic for `vec2[]`, because now we need to distinguish
the two cases by checking the array stride. I wonder if this should
actually be split into two decorations.
2019-07-09 20:59:32 -05:00
Hans-Kristian Arntzen
8aa6731925
Merge pull request #1065 from KhronosGroup/msvc-2013-workaround
MSVC 2013: Work around another compiler bug with array init.
2019-07-09 17:25:30 +02:00
Hans-Kristian Arntzen
909040e2eb MSVC 2013: Work around another compiler bug with array init. 2019-07-09 15:31:01 +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
e0cd8595a4
Merge pull request #1063 from KhronosGroup/fix-1061
Propagate NonUniformEXT to dependent expressions
2019-07-08 13:57:57 +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
fa9af7223a Add test shaders for NonUniformEXT propagation. 2019-07-08 11:32:09 +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
Hans-Kristian Arntzen
13378ad1ac Add simple test for extended debug operations. 2019-07-05 10:44:30 +02:00
Hans-Kristian Arntzen
6d9c502a3a Merge branch 'master' of git://github.com/lifpan/SPIRV-Cross 2019-07-05 10:18: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
c5904dd245
Merge pull request #1059 from KhronosGroup/fix-1056
MSL/HLSL: Support scalar reflect and refract.
2019-07-03 16:43:53 +02:00
Hans-Kristian Arntzen
4056d0b74e Don't use scalar dot(). 2019-07-03 14:32:06 +02:00
Hans-Kristian Arntzen
041f103d44 MSL/HLSL: Support scalar reflect and refract. 2019-07-03 12:31:52 +02:00
Hans-Kristian Arntzen
9a6e2534e9
Merge pull request #1058 from KhronosGroup/fix-1054
Fix variable scope when an if or else block dominates a variable.
2019-07-03 12:28:47 +02:00
Hans-Kristian Arntzen
fc9fe4e480 Fix variable scope when an if or else block dominates a variable.
Just like loops, we need complicated hoisting again to make this work.
2019-07-03 11:18:50 +02:00
Hans-Kristian Arntzen
3af18e741f
Merge pull request #1055 from cdavis5e/msl21-frag-subgroup-builtins
MSL: Support SubgroupLocalInvocationId and SubgroupSize in all stages.
2019-07-03 10:13:19 +02:00
Chip Davis
31b6c93516 MSL: Support SubgroupLocalInvocationId and SubgroupSize in all stages.
MSL prior to 2.2 doesn't support these natively in any stage but
compute. But, we can (assuming no threads were terminated prematurely)
get their values with some creative uses of the
`simd_prefix_exclusive_sum()` and `simd_sum()` functions.

Also, fix a missing `to_expression()` with `BuiltInSubgroupEqMask`.

For KhronosGroup/MoltenVK#629.
2019-07-02 11:48:59 -05:00