115 Commits

Author SHA1 Message Date
Chip Davis
cda8a2cf44 MVKPipeline: Pass the pipeline sample mask, if present, to SPIRV-Cross.
SPIRV-Cross can now AND the `gl_SampleMask` output with an additional
fixed mask, presumably from the pipeline. Use this new functionality to
implement pipeline sample mask handling.

Special thanks to Tomek Pontika and Corentin Wallez of Google for
graciously contributing their implementation to SPIRV-Cross.

Update SPIRV-Cross to pull in the change necessary for this.
2020-07-24 15:15:11 -05:00
Bill Hollings
e40153abae Update to latest SPIRV-Cross version,
MSL: Workaround broken scalar access chain behavior in LLVM IR / AIR
2020-07-06 13:05:55 -04:00
Chip Davis
d14d4e918d MVKPipeline: Fix fragment inputs to have as many components as vertex outputs.
Metal is picky about interface matching. If the types of a vertex output
and its corresponding fragment input don't match, down to the number of
vector components, it fails pipeline compilation. To support cases where
the number of components in the fragment input is less than the
corresponding vertex output, we need to fix up the fragment shader to
accept the extra components.
2020-06-19 14:20:29 -05:00
Bill Hollings
e302a6d023 Update to latest version of SPIRV-Cross.
Remove use of obsolete SPIRV-Cross API MSLVertexAttr content.
ExternalDependencies.xcodeproj updated to Xcode 11.5.
Update What's New document.
2020-05-30 16:07:47 -04:00
Chip Davis
06662071a4 Update SPIRV-Cross again to pull in a fix for KhronosGroup/SPIRV-Cross#1322. 2020-04-15 13:40:44 -05:00
Chip Davis
4b479fefd4 Update SPIRV-Cross. 2020-04-14 14:32:00 -05:00
Bill Hollings
a58f6bc441 Update to Vulkan SDK 1.2.135 library dependencies.
Add Scripts/packagePregenSpirvToolsHeaders script to automate packaging Spirv-Tools
headers in support of the fetchDependencies --skip-spirv-tools-build option.
Update Docs/Whats_New.md.
2020-04-02 16:35:48 -04:00
Bill Hollings
bd4e78d5a4 Update to latest SPIRV-Cross and Vulkan-Headers and fixes to pipeline cache loading.
Update Cereal archive structs to match latest MoltenVK and SPIRV-Cross structs.
Fix recent error that caused pipeline cache data to be ignored during loading.
Update to Vulkan-Headers version 1.2.135.
Update to latest SPIRV-Cross version.
Update Whats_New.md document.
2020-03-26 18:57:46 -04:00
Bill Hollings
0c754fb036 Update dependency libraries to match Vulkan SDK 1.2.131.
Update What's New document.
2020-01-21 19:14:14 -05:00
Bill Hollings
9f64cc4bef Fix tessellation break when control stage declares but does not use position builtin.
Add SPIRVShaderOutput::isUsed retrieved from shader reflection.
mvk::sizeOfOutput() returns zero if output var is not used.
Update to latest SPIRV-Cross version.
2019-11-26 16:11:52 -05:00
Bill Hollings
93ae214bc8 Support additional capabilities in 1D images, including rendering, clearing, and mipmaps.
Add `MVK_CONFIG_TEXTURE_1D_AS_2D` environment variable, enabled by default.
Modify 1D warning messages to recommend use of `MVK_CONFIG_TEXTURE_1D_AS_2D`.
Update to latest version of SPIRV-Cross.
Align pipeline cache contents to latest CompilerMSL::Options structure.
Clean up code signing on demo Xcode projects.
2019-10-25 14:40:59 -04:00
Chip Davis
deaaab8eff Support the VK_EXT_fragment_shader_interlock extension.
This extension allows fragment shaders to delineate critical sections
where pairs of invocations may not execute simultaneously. In Metal, the
nearest equivalent functionality is raster order groups. This
implementation is thus implemented on top of them.

Update SPIRV-Cross to pull in SPIR-V support for this new extension.
2019-09-06 12:52:39 -05:00
Chip Davis
100d7aa543 Support the VK_KHR_device_group extension.
Largely minimal for now. Much of it, particularly most of the
interactions with `VK_KHR_swapchain`, was already implemented
previously. The only interesting bits are the `vkCmdDispatchBase()`
command, and the ability to create arbitrary swapchain images and bind
them to swapchain memory, which requires the use of the previously
implemented `VK_KHR_bind_memory2` extension. Most everything else can be
safely ignored for now.

Non-zero dispatch bases use the compute stage-input region to pass the
dispatch base group to the shader, which must manually adjust the
`WorkgroupId` and `GlobalInvocationId` builtins, since Metal does not do
this for us. I have tested that this approach works well--at least, well
enough to pass the CTS.

Because of the ability to bind arbitrary images to swapchain memory,
I've sucked the guts out of `MVKSwapchainImage` and into `MVKSwapchain`
itself. Availability and drawable management is now performed by the
swapchain object. `MVKSwapchainImage` is now just a specialized kind of
image, created when requested with a `VkImageCreateSwapchainInfoKHR`
structure.

Update SPIRV-Cross so we can support the `vkCmdDispatchBase()` command.

One more step towards Vulkan 1.1.
2019-08-09 11:41:10 -05:00
Bill Hollings
095dd3339b Update to latest version of SPIRV-Cross.
Update demos to latest dependency library versions.
Update to Xcode 10.3.
Update What's New document.
2019-07-24 14:39:38 -04:00
Chip Davis
0263808763 Update SPIRV-Cross. 2019-07-17 11:36:58 -05:00
Bill Hollings
84ea825ea3 Separate SPIRVToMSLConverterContext into input config and output results.
Refactor SPIRVToMSLConverterContext into distinct SPIRVToMSLConversionConfiguration
and SPIRVToMSLConversionResults for conversion input and output, respectively.
Update to latest SPIRV-Cross version.
Update What's New document.
2019-06-29 18:01:07 -04:00
Bill Hollings
bf8c7f8bb8 Updates for SDK 1.1.108 release.
Update to latest external dependency libraries.
MVKDescriptorSetLayoutBinding allow binding of null MVKBuffer.
Update What's New document.
2019-06-13 17:11:44 -04:00
Chip Davis
f075adc93f Update SPIRV-Cross.
This adds support for the `OpArrayLength` instruction.
2019-05-29 10:49:28 -05:00
Bill Hollings
04cf30a0b5 Update to latest version of SPIRV-Cross. 2019-05-08 17:19:24 -04:00
Michael Barriault
08d3d91016 Update to latest SPIRV-Cross. 2019-04-17 22:37:52 +01:00
Bill Hollings
189a41e8d2 Update dependency libraries for SDK 1.1.106. 2019-04-11 17:52:50 -04:00
Bill Hollings
ef86d58552 Update to latest version of SPIRV-Cross.
Clean up demo build warnings.
Update What's New document.
2019-04-05 12:08:32 -04:00
Bill Hollings
4183a6489b
Merge branch 'master' into master 2019-03-29 13:06:00 -04:00
Hans-Kristian Arntzen
38edfdb3de Override namespace for SPIRV-Cross.
Some projects also link against SPIRV-Cross statically, and in order to
avoid ABI conflicts, we should use a private namespace for the
SPIRV-Cross dependency to avoid bugs. See SPIRV-Cross issue #902 for
more information. The new namespace is MVK_spirv_cross, and the code
now makes use of the SPIRV_CROSS_NAMESPACE macro rather than spirv_cross.
2019-03-29 11:34:55 +01:00
Bill Hollings
0f22e2a70e MSL: Fix crash where variable storage buffer pointers are passed down.
Explicitly build dSYM files in BUILT_PRODUCTS_DIR
to avoid conflict between macOS and iOS build locations.
Update to latest SPIRV-Cross version.
2019-03-28 11:58:05 -04:00
Bill Hollings
19576e031b Update to latest SPIRV-Cross version. 2019-03-16 09:29:17 -04:00
Bill Hollings
a2b1e04e8d Update to latest SPIRV-Cross version.
Adapt to API changes resulting from the introduction of the SPIRV-Cross C API.
Update What's New document.
2019-03-15 20:25:55 -04:00
Chip Davis
4fa4941551 Update SPIRV-Cross yet again. 2019-03-11 14:19:49 -05:00
Chip Davis
ccc1a32426 Update SPIRV-Cross again to pull in some fixes. 2019-03-11 14:19:49 -05:00
Chip Davis
79d434553c Add support for tessellation.
At long last, tessellation comes to MoltenVK! With this change, clients
will now be able to specify tessellation shaders when creating
pipelines, and then draw tessellated patches with them.

Unfortunately, there seem to be a few gotchas with tessellation in
Metal. For one thing, tessellation pipelines in Metal are structured
very differently from Vulkan. There is no tessellation control or even
vertex stage. Instead, the tessellation evaluation shader takes the
place of the vertex function as a "post-tessellation vertex function."
The tessellation levels are supplied in a buffer to the tessellator,
which you are expected to populate. The most common way to do this is by
running a compute shader. MoltenVK thus runs the vertex shader and
tessellation control shader by themselves; a single `VkPipeline` object
then requires at least *three* `MTLPipelineState` objects.

But wait, there's more! The tessellation-control-as-compute stage uses
Metal's support for vertex-style stage input to a compute shader. But,
this support requires one to declare indexing *ahead of time*, when the
pipeline state is created. So a single `VkPipeline` object could have as
many as *five* `MTLPipelineState` objects.

Further, if there are more output than input control points for the
tessellation control stage, then later invocations may end up fetching
the wrong attributes! To get around this, this change uses index buffers
to ensure that all tessellation control shaders see the correct input.
Unfortunately, in the indexed draw case, this means that the incoming
index buffer needs to be munged.

Instancing is another pain point here. In Vulkan, as in OpenGL and
Direct3D, instancing is done in the vertex shader; but in Metal, it is
done at the tessellation evaluation stage. For this reason, only the
vertex stage of a tessellated draw supports instancing. Additional
memory is required to hold data for the extra vertices generated by
instancing. This also requires still more munging of index buffers for
indexed draws.

Indirect draws are even more painful. Because the number of vertices and
instances is unknown, storage for the maximum possible number of
vertices must be allocated. This change imposes a totally arbitrary
limit of 131072 vertices from a single draw, including all vertices
generated by instancing. On a Mac, this requires about 194-256 MB of
VRAM for all the temporary buffers.

There are some possible optimizations here. If we could prove that the
vertex shader's output doesn't depend on the instance ID, either
directly or through a per-instance attribute, then we could avoid
running the vertex and tess. control stages per instance, and take
advantage of Metal's support for tess. eval instancing. If we could
also prove that the vertex shader simply passes instance attributes
through (similarly with the tess. control shader), we could do this for
many more instanced draws as well. It should also be possible to cache
the output from the tess. control stage; if the draw comes up again, we
can then skip the vertex and tess. control stages entirely!

Fixes #56 and #501.
2019-03-11 14:19:49 -05:00
Bill Hollings
d83d934150 Update to latest version of SPIRV-Cross.
Track version of spvAux buffer struct in SPRIV-Cross and
fail build if different than version expected by MoltenVK.
Update MoltenVK version to 1.0.33.
Update What's New document.
2019-02-08 21:31:14 -05:00
Bill Hollings
f591fed43e Update to latest SPIRV-Cross version. 2019-01-28 19:58:32 -05:00
Bill Hollings
cb0c91cbd0 Update to latest SPIRV-Cross and update What's new document. 2019-01-27 21:18:47 -05:00
Bill Hollings
991a1944fe Update to latest dependency libraries for Vulkan SDK 1.1.97.
Update to latest SPIRV-Cross version:
2019-01-17 15:27:20 -05:00
Bill Hollings
7f03e1fb3b Pad fragment output to 4 components when needed.
Update to latest SPIRV-Cross.
2019-01-15 13:52:01 -05:00
Bill Hollings
02aeb0797a Add full texture swizzling to config, and disable it by default.
Add MVKConfiguration::fullTextureSwizzle and corresponding MVK_CONFIG_FULL_TEXTURE_SWIZZLE
env var & build setting, and set to false, to disable texture swizzling by default.
Add SPIRVToMSLConverterOptions::shouldSwizzleTextureSamples.
Lazily init queue families to allow time for specializedQueueFamilies config change.
Fix consistency of pipeline encoding state auxiliary buffer binding.
Improve documentation of MVKConfiguration environment variables and build settings.
2019-01-12 12:19:01 -05:00
Bill Hollings
d13e5d487c Support 4 queue families.
Add config setting to determine if queue families are general or specialized.
Update to latest SPIRV-Cross version.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 16.
Update MoltenVK version to 1.0.31.
2019-01-07 19:25:20 -05:00
Bill Hollings
e6dfdca6c0 MSL don't emit memory_scope after MSL 2.0.
For each GPU, log MSL version and updated list of feature sets.
Add SPIRVToMSLConverterOptions::printMSLVersion() function.
Update to latest SPIRV-Cross version.
Update MoltenVK version to 1.0.29.
2018-12-11 18:27:01 -05:00
Chip Davis
18fa43994f Force signedness of shader vertex attributes to match the host.
Based on a patch by Stefan Dösinger.

Metal cannot do signedness conversion on vertex attributes, and for good
reason. Putting a `uint4` into an `int4`, or a `char4` into a `uint4`,
would lose those values that are outside the range of the target type.
But putting a `uchar4` into a `short4` or an `int4`, or a `ushort4` into
an `int4`, should work. In that case, force the signedness in the shader
to match the declared type of the host.

Update SPIRV-Cross to pull in the corresponding change. Bump MoltenVK
version.
2018-12-04 15:04:10 -06:00
Bill Hollings
d99984e064 Align MoltenVK with Vulkan SDK 1.1.92.
Update to latest dependency libraries for Vulkan SDK 1.1.92.
Generate Hologram demo dispatch files in fetchDependencies and remove them from git.
Update MoltenVK version to 1.0.27.
Update What's New document.
2018-11-15 17:40:15 +01:00
Bill Hollings
38160b3eb3 MoltenVK 1.0.26.
Fixes to create_dylib.sh to cleanup bitcode and architecture support.
Update to latest SPIRV-Cross version.
Update MoltenVK version to 1.0.26.
Update Xcode projects to Xcode 10.1.
Update What's New document.
2018-11-06 16:01:36 -05:00
Chip Davis
082d282b28 Support arbitrary swizzles of image data.
The swizzles are passed to shaders that need them using an "auxiliary
buffer", for which there must be room in the function argument table.
Code is inserted into the shaders to swizzle reads from sampled
textures--per the Vulkan spec, component mappings must only be applied
to sampled images.

Update SPIRV-Cross to pull in some fixes for handling swizzled image
data. Bump MoltenVK version.
2018-10-16 11:33:13 -05:00
Chip Davis
fcbbdc1948 Support the shader{Sampled,Storage}ImageArrayDynamicIndexing feature.
Update SPIRV-Cross to support dynamic indexing on iOS 10... and to
actually support arrays of input buffers (which should've been present
before I flipped the `shader{Uniform,Storage}BufferArrayDynamicIndexing`
switch).

Bump patch version.

Fixes #96.
2018-09-27 13:11:55 -05:00
Bill Hollings
dfa27ecc61 Update SPRIV-Cross version. 2018-09-25 13:47:43 -04:00
Chip Davis
f0db0c746a Fix SPIRV-Cross update that I bungled.
(Do I have to bump the patch version again...?)
2018-09-20 18:19:25 -05:00
Chip Davis
801ce71108 Support the VK_EXT_shader_viewport_index_layer extension.
Update SPIRV-Cross to support the `ViewportIndex` builtin, and pull in a
fix for the `Layer` builtin. Bump `MVK_VERSION_PATCH`.
2018-09-20 10:00:21 -05:00
Chip Davis
eeca918c92 Support the sampleRateShading feature.
This is for fragment shaders that run per-sample instead of
per-fragment. It implies that the `SampleId`, `SampleMask`, and
`SamplePosition` builtins, as well as per-sample interpolation, are all
available--using any of these causes the frag shader to run once per
sample. (In Metal, reading the color buffers may also cause a frag
shader to run per-sample.)

Update SPIRV-Cross to pull in a change that properly translates the
`SamplePosition` builtin to a form that Metal can understand.
2018-09-18 09:58:56 -05:00
Bill Hollings
e7cb8b35da Update MoltenVK to v1.0.21.
Update to latest version of SPRIV-Cross.
Update What's New document.
2018-09-08 18:38:32 -04:00
Bill Hollings
c369da1cdd Update to What's New document.
Update to latest version of SPIRV-Cross.
2018-09-01 18:27:07 -04:00
Chip Davis
ccb1afe42b Support the VK_KHR_shader_draw_parameters extension.
Update SPIRV-Cross to support shaders which use the builtins provided by
this extension.
2018-08-30 09:10:47 -05:00