Commit Graph

2204 Commits

Author SHA1 Message Date
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
Hans-Kristian Arntzen
d821a90091
Merge pull request #1159 from KhronosGroup/fix-1157
CMake: Add option to force -fPIC.
2019-09-18 11:41:11 +02:00
Hans-Kristian Arntzen
467d970704 CMake: Add option to force -fPIC.
Used by projects who might embed SPIRV-Cross as part of a shared
library, but not exported.
2019-09-18 10:00:25 +02:00
Hans-Kristian Arntzen
87a3d4cf44
Merge pull request #1156 from KhronosGroup/fix-1155
Disable -Werror by default in CMake, fix -Wshorten-64-to-32 warnings.
2019-09-17 12:39:13 +02:00
Hans-Kristian Arntzen
c3ff67c3f0 Fix -Wshorten-64-to-32 warnings. 2019-09-17 10:18:38 +02:00
Hans-Kristian Arntzen
f20011733a
Merge pull request #1154 from KhronosGroup/fix-1153
CMake: Add option to skip installation targets.
2019-09-16 11:40:17 +02:00
Hans-Kristian Arntzen
9b9ea1fac6 CMake: Add option to skip installation targets. 2019-09-16 10:21:28 +02:00
Hans-Kristian Arntzen
c13e951634
Merge pull request #1152 from KhronosGroup/fix-1151
Consider discard and demote as impure statements.
2019-09-12 15:12:29 +02:00
Hans-Kristian Arntzen
bfa76ee2ab Consider discard and demote as impure statements.
Fixes cases where discard and demote are called in pure functions and
the function result is not consumed.
2019-09-12 14:21:10 +02:00
Hans-Kristian Arntzen
b32a1b4150
Merge pull request #1150 from wadetb/master
MSL: Fix array copies to/from interpolators
2019-09-08 22:31:43 +02:00
Wade Brainerd
f2a1b4320f MSL: Fix array copies to/from interpolators 2019-09-06 18:23:57 -07:00
Hans-Kristian Arntzen
2082e7e801 Run format_all.sh. 2019-09-06 14:23:16 +02:00
Hans-Kristian Arntzen
ee0ac3b313
Merge pull request #1146 from KhronosGroup/strong-types
Introduce stronger types for the SPIR-V ID in C++ API
2019-09-06 14:22:54 +02:00
Hans-Kristian Arntzen
333980ae91 Refactor into stronger types in public API.
Some fallout where internal functions are using stronger types.
Overkill to move everything over to strong types right now, but perhaps
move over to it slowly over time.
2019-09-06 12:29:47 +02:00
Hans-Kristian Arntzen
5af8a04b6c
Merge pull request #1148 from KhronosGroup/dynamic-offsets
Merge dynamic offset support with some bug-fixes.
2019-09-06 12:25:22 +02:00
Hans-Kristian Arntzen
afa5480210 Add dynamic offsets to C API. 2019-09-06 10:17:31 +02:00
Hans-Kristian Arntzen
1935f1a8e3 Fix some issues on certain compilers. 2019-09-06 10:11:18 +02:00
Hans-Kristian Arntzen
f1e0dd9a5c Merge remote-tracking branch 'cdavis5e/msl-argument-buffer-dynamic-offsets' into dynamic-offsets 2019-09-06 09:54:56 +02: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
537bee3cfa
Merge pull request #1144 from cdavis5e/msl-arg-buff-storage-image-ios
MSL: Force storage images on iOS to use discrete descriptors.
2019-09-05 21:33:25 +02:00
Chip Davis
103817009c MSL: Force storage images on iOS to use discrete descriptors.
Writable textures cannot use argument buffers on iOS. They must be
passed as arguments directly to the shader function. Since we won't know
if a given storage image will have the `NonWritable` decoration at the
time we encode the argument buffer, we must therefore pass all storage
images as discrete arguments. Previously, we were throwing an error if
we encountered an argument buffer with a writable texture in it on iOS.
2019-09-05 11:01:05 -05:00
Hans-Kristian Arntzen
a00dbe0db0
Merge pull request #1145 from lifpan/master
Fix ParsedIR::mark_used_as_array_length(uint32_t id)
2019-09-05 10:24:45 +02:00
lifpan
89e7d218c8 Fix ParsedIR::mark_used_as_array_length(uint32_t id) 2019-09-05 06:56:05 +08:00
Hans-Kristian Arntzen
f24654db8c
Merge pull request #1143 from KhronosGroup/interlock
Merge SPV_EXT_fragment_shader_interlock with fixes
2019-09-04 14:43:08 +02:00
Hans-Kristian Arntzen
0286442906 Add test case for interlocks in control flow. 2019-09-04 13:10:32 +02:00
Hans-Kristian Arntzen
1dc7e938d0 Make sure not to propagate loads outside interlock region. 2019-09-04 12:33:20 +02:00
Hans-Kristian Arntzen
65e48ca5ea Add interlock test for split functions doing begin/end. 2019-09-04 12:26:34 +02:00
Hans-Kristian Arntzen
261b46982a Deal with complex interlock cases in GLSL. 2019-09-04 12:18:04 +02:00
Hans-Kristian Arntzen
63a770ed5c Add test shader for simple case of interlocked callstack. 2019-09-04 11:56:19 +02:00
Hans-Kristian Arntzen
36c433bd92 Deal with call stacks when analyzing access. 2019-09-04 11:42:29 +02:00
Hans-Kristian Arntzen
3f2ce375e1 Analyze complex cases for fragment interlocks.
If we are using interlocks in split functions or in control flow, we
have some serious workarounds we need to employ.
2019-09-04 11:20:25 +02:00
Hans-Kristian Arntzen
f577836439 Merge branch 'fragment-shader-interlock' of git://github.com/cdavis5e/SPIRV-Cross into interlock 2019-09-04 10:35:08 +02:00
Chip Davis
2eff420d9a Support the SPV_EXT_fragment_shader_interlock extension.
This was straightforward to implement in GLSL. The
`ShadingRateInterlockOrderedEXT` and `ShadingRateInterlockUnorderedEXT`
modes aren't implemented yet, because we don't support
`SPV_NV_shading_rate` or `SPV_EXT_fragment_invocation_density` yet.

HLSL and MSL were more interesting. They don't support this directly,
but they do support marking resources as "rasterizer ordered," which
does roughly the same thing. So this implementation scans all accesses
inside the critical section and marks all storage resources found
therein as rasterizer ordered. They also don't support the fine-grained
controls on pixel- vs. sample-level interlock and disabling ordering
guarantees that GLSL and SPIR-V do, but that's OK. "Unordered" here
merely means the order is undefined; that it just so happens to be the
same as rasterizer order is immaterial. As for pixel- vs. sample-level
interlock, Vulkan explicitly states:

> With sample shading enabled, [the `PixelInterlockOrderedEXT` and
> `PixelInterlockUnorderedEXT`] execution modes are treated like
> `SampleInterlockOrderedEXT` or `SampleInterlockUnorderedEXT`
> respectively.

and:

> If [the `SampleInterlockOrderedEXT` or `SampleInterlockUnorderedEXT`]
> execution modes are used in single-sample mode they are treated like
> `PixelInterlockOrderedEXT` or `PixelInterlockUnorderedEXT`
> respectively.

So this will DTRT for MoltenVK and gfx-rs, at least.

MSL additionally supports multiple raster order groups; resources that
are not accessed together can be placed in different ROGs to allow them
to be synchronized separately. A more sophisticated analysis might be
able to place resources optimally, but that's outside the scope of this
change. For now, we assign all resources to group 0, which should do for
our purposes.

`glslang` doesn't support the `RasterizerOrdered` UAVs this
implementation produces for HLSL, so the test case needs `fxc.exe`.

It also insists on GLSL 4.50 for `GL_ARB_fragment_shader_interlock`,
even though the spec says it needs either 4.20 or
`GL_ARB_shader_image_load_store`; and it doesn't support the
`GL_NV_fragment_shader_interlock` extension at all. So I haven't been
able to test those code paths.

Fixes #1002.
2019-09-02 12:31:10 -05:00
Hans-Kristian Arntzen
a06997a6a4
Merge pull request #1113 from cdavis5e/msl-sampler-ycbcr-conversion
MSL: Add support for sampler Y'CbCr conversion.
2019-09-02 14:18:20 +02:00
Chip Davis
39dce88d3b MSL: Add support for sampler Y'CbCr conversion.
This change introduces functions and in one case, a class, to support
the `VK_KHR_sampler_ycbcr_conversion` extension. Except in the case of
GBGR8 and BGRG8 formats, for which Metal natively supports implicit
chroma reconstruction, we're on our own here. We have to do everything
ourselves. Much of the complexity comes from the need to support
multiple planes, which must now be passed to functions that use the
corresponding combined image-samplers. The rest is from the actual
Y'CbCr conversion itself, which requires additional post-processing of
the sample retrieved from the image.

Passing sampled images to a function was a particular problem. To
support this, I've added a new class which is emitted to MSL shaders
that pass sampled images with Y'CbCr conversions attached around. It
can handle sampled images with or without Y'CbCr conversion. This is an
awful abomination that should not exist, but I'm worried that there's
some shader out there which does this. This support requires Metal 2.0
to work properly, because it uses default-constructed texture objects,
which were only added in MSL 2. I'm not even going to get into arrays of
combined image-samplers--that's a whole other can of worms.  They are
deliberately unsupported in this change.

I've taken the liberty of refactoring the support for texture swizzling
while I'm at it. It's now treated as a post-processing step similar to
Y'CbCr conversion. I'd like to think this is cleaner than having
everything in `to_function_name()`/`to_function_args()`. It still looks
really hairy, though. I did, however, get rid of the explicit type
arguments to `spvGatherSwizzle()`/`spvGatherCompareSwizzle()`.

Update the C API. In addition to supporting this new functionality, add
some compiler options that I added in previous changes, but for which I
neglected to update the C API.
2019-09-01 18:35:53 -05:00
Hans-Kristian Arntzen
9b845a4788
Merge pull request #1141 from troughton/inline-everything
MSL: Inline all non-entry-point functions
2019-08-30 11:05:04 +02:00
Thomas Roughton
6b5403206e Clang-format changes 2019-08-30 20:25:40 +12:00
Thomas Roughton
91b2f34a3d Update tests to account for all non-entry-point functions being inlined 2019-08-30 09:39:06 +12:00
Hans-Kristian Arntzen
ee7357f2a6
Merge pull request #1140 from KhronosGroup/fix-1139
MSL: Add {Base,}{Vertex,Instance}Index to bitcast_from_builtin_load.
2019-08-29 16:06:32 +02:00
Hans-Kristian Arntzen
07c76f66b5 MSL: Add {Base,}{Vertex,Instance}Index to bitcast_from_builtin_load.
Totally missed these, so float(index) would not work correctly for
negative numbers.
2019-08-29 13:56:37 +02:00
Hans-Kristian Arntzen
761d3da677
Merge pull request #1137 from cdavis5e/post-depth-coverage-essl
GLSL: Fix post-depth coverage for ESSL.
2019-08-29 13:11:59 +02:00
Thomas Roughton
e5f9e2c203 Inline all non-entry-point functions 2019-08-29 17:07:57 +12:00
Thomas Roughton
6338f0aa0f MSL: inline all emitted functions
# Conflicts:
#	spirv_msl.cpp
2019-08-29 17:07:27 +12:00
Chip Davis
5fe1ecc324 GLSL: Fix post-depth coverage for ESSL.
ESSL does not support `GL_ARB_post_depth_coverage`. There, we must use
`GL_EXT_post_depth_coverage`. I've added this as a fallback for desktop
as well.

Note that `GL_EXT_post_depth_coverage` also requires the fragment shader
to set `early_fragment_tests` explicitly, while
`GL_ARB_post_depth_coverage` does not. It doesn't really matter either
way, since `SPV_KHR_post_depth_coverage` *also* requires both execution
modes to be explicitly set.
2019-08-28 13:40:13 -05:00
Hans-Kristian Arntzen
3ccfbce264 Run format_all.sh. 2019-08-28 14:25:26 +02:00
Hans-Kristian Arntzen
de26e08195
Merge pull request #1136 from KhronosGroup/fix-1132
GLSL: Assume image and sampler can be RelaxedPrecision.
2019-08-28 14:24:28 +02:00
Hans-Kristian Arntzen
d5a65b4190 GLSL: Assume image and sampler can be RelaxedPrecision.
When merging combined image samplers, we only looked at sampler, but DXC
emits RelaxedPrecision only for texture. Does not hurt to check for more
things.
2019-08-27 17:15:19 +02:00
Hans-Kristian Arntzen
563e994486
Merge pull request #1135 from KhronosGroup/fix-1119
MSL: Deal with array copies from and to threadgroup.
2019-08-27 15:48:08 +02:00
Hans-Kristian Arntzen
aec826222d
Merge pull request #1134 from KhronosGroup/fix-1117
Do not allow base expressions for non-native row-major matrices.
2019-08-27 15:47:33 +02:00
Hans-Kristian Arntzen
9436cd3036 MSL: Deal with array copies from and to threadgroup. 2019-08-27 13:18:01 +02:00