Commit Graph

2064 Commits

Author SHA1 Message Date
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
Hans-Kristian Arntzen
41399fc899
Merge pull request #1051 from KhronosGroup/fix-1049
MSL/HLSL: Support OpOuterProduct.
2019-07-01 13:40:57 +02:00
Hans-Kristian Arntzen
f8b084de61 MSL/HLSL: Support OpOuterProduct. 2019-07-01 10:57:27 +02:00
Hans-Kristian Arntzen
04e29895a3
Merge pull request #1001 from cdavis5e/msl-multiview
MSL: Support SPV_KHR_multiview.
2019-07-01 10:39:25 +02: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
8ee8e60f70
Merge pull request #1048 from KhronosGroup/fix-1047
Deal with scalar input values for distance/length/normalize.
2019-06-28 14:18:25 +02:00
Hans-Kristian Arntzen
ff87419607 Deal with scalar input values for distance/length/normalize.
HLSL and MSL don't support it, so fall back to simpler intrinsics.
2019-06-28 11:20:14 +02:00
Hans-Kristian Arntzen
d1bdb6d491
Merge pull request #1046 from KhronosGroup/texture-fp16-coord
MSL: Fix sampling with FP16 coordinates.
2019-06-27 15:22:57 +02:00
Hans-Kristian Arntzen
964ec44822
Merge pull request #1045 from KhronosGroup/c-api-get-declared-struct-member-size
Add C API support for get_declared_struct_member_size
2019-06-27 15:12:13 +02:00
Hans-Kristian Arntzen
1543bdaf7b Run format_all.sh. 2019-06-27 15:10:59 +02:00