783 Commits

Author SHA1 Message Date
Chip Davis
4fa4941551 Update SPIRV-Cross yet again. 2019-03-11 14:19:49 -05:00
Chip Davis
cb8a678c28 Fix stride of stage input arrays to tessellation shaders.
These should be set to the alignment of the first member of the output
struct. This fixes the `dEQP-VK.tessellation.common_edge.*` tests.
2019-03-11 14:19:49 -05:00
Chip Davis
069ee53ac5 Exclude the PointSize builtin when we're not rendering points.
And fix a silly mistake I made setting up the tess. control stage
pipeline.
2019-03-11 14:19:49 -05:00
Chip Davis
403d52d9fa Correct passing the tessellation level builtins around. 2019-03-11 14:19:49 -05:00
Chip Davis
075792e436 Reverse tessellation windings from SPIR-V.
Because we flip the direction of `y`, we need to reverse the windings.
2019-03-11 14:19:49 -05:00
Chip Davis
bfdf0c4233 Set the stage in region for tess. control invocations.
Otherwise, Metal won't fetch any stage input.
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
b78235045c Fix a reversed condition.
I have to stop doing that...
2019-03-11 14:19:49 -05:00
Chip Davis
58dbdcdab4 Make sure there's enough space in the tess ctl output buffer. 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
309efa7068
Merge pull request #519 from alexey-lysiuk/deps_error_stop
Stop on the first error in fetch dependencies script
2019-03-08 11:18:54 -05:00
alexey.lysiuk
d015381fa3 Stop on the first error in fetch dependencies script 2019-03-08 10:58:06 +02:00
Bill Hollings
40097d79b5
Merge pull request #518 from billhollings/master
Increase shader float constant accuracy beyond 6 digits of precision.
2019-03-06 09:53:01 -05:00
Bill Hollings
3b1e53002e Increase shader float constant accuracy beyond 6 digits of precision. 2019-03-06 08:58:27 -05:00
Bill Hollings
e4f79af39c
Merge pull request #515 from billhollings/master
Update What's New document.
2019-02-27 19:39:20 -05:00
Bill Hollings
d8ee4873b6 Update What's New document. 2019-02-27 18:04:42 -05:00
Bill Hollings
1fbc1333f8 Update What's New document.
Fix issue loading from Vulkan-Portability_repo_revision in fetchDependencies.
2019-02-27 17:47:15 -05:00
Bill Hollings
7bdd12ea4f
Merge pull request #513 from billhollings/master
Update to latest dependency libraries to support SDK 1.1.101.
2019-02-27 14:34:24 -05:00
Bill Hollings
fd8aa3c412 Update to latest dependency libraries to support SDK 1.1.101.
Remove SPRIV-Cross source files erroneously compiling into libglslang.a.
2019-02-27 11:56:31 -05:00
Bill Hollings
e54e21dbca
Merge pull request #512 from billhollings/master
Set MSL version for shader compiling from Metal feature set.
2019-02-25 22:14:05 -05:00
Bill Hollings
0984b11bc0 Set MSL version for shader compiling from Metal feature set.
Add MVKPhysicalDeviceMetalFeatures::mslVersionEnum and set from Metal feature sets.
Derive MVKPhysicalDeviceMetalFeatures:: mslVersion from mslVersionEnum.
MVKDevice::getMTLCompileOptions() sets MTLCompileOptions::languageVersion
from MVKPhysicalDeviceMetalFeatures::mslVersionEnum.
MVKAssert logs error even when assertions disabled.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 18.
2019-02-25 18:11:47 -05:00
Bill Hollings
fbb906f163
Merge pull request #511 from billhollings/master
Building external dependency libraries cleans MoltenVK.
2019-02-24 16:55:32 -05:00
Bill Hollings
64648d19c3 Move MoltenVK clean on dependency build from fetchDependencies.sh to package_ext_libs.sh. 2019-02-24 16:21:20 -05:00
Bill Hollings
ed702e0b29 fetchDependencies cleans MoltenVK build to ensure using latest dependency libs.
Makefile abstract names of Xcode schemes for maintainability.
MoltenVKShaderConverter Frameworks group relative to External/build.
2019-02-24 15:21:30 -05:00
Bill Hollings
5e0f624b34
Merge pull request #505 from cdavis5e/no-storage-image-ms
Disable the shaderStageImageMultisample feature.
2019-02-19 02:12:33 -05:00
Bill Hollings
04ce4ad3a9
Merge pull request #504 from billhollings/master
Add static and dynamic libraries to MoltenVKShaderConverter project.
2019-02-19 02:11:34 -05:00
Chip Davis
b98b47501d Disable the shaderStageImageMultisample feature.
While Metal *does* allow read access to multisampled textures, it does
*not* allow write access. In Vulkan, storage images are always writable.
Therefore, we can't fully support this feature.
2019-02-18 21:44:34 -06:00
Bill Hollings
6f2dc4bdcb Add static and dynamic libraries to MoltenVKShaderConverter project.
Refactor build scripts.
Update paths to MoltenVKGLSLToSPIRVConverter framework in demos.
Fix rare build race condition on MoltenVKShaderConverter link to MoltenVK.
2019-02-18 22:19:37 +00:00
Bill Hollings
136c7ea855
Merge pull request #498 from billhollings/master
Clarify Xcode version requirements in documentation.
2019-02-15 08:47:05 -05:00
Bill Hollings
c57e29bc5c Clarify Xcode version requirements in documentation. 2019-02-13 14:34:55 -05:00
Bill Hollings
b2319e5fd4
Merge pull request #495 from cdavis5e/shader-int8
Turn on shaderInt8.
2019-02-11 14:28:06 -05:00
Chip Davis
e81bd4b25d Turn on shaderInt8.
Now that SPIRV-Cross is updated to support it, we can safely advertise
this.

Fixes #372.
2019-02-11 12:41:10 -06:00
Bill Hollings
5d60ba9043
Merge pull request #494 from billhollings/master
README.md enhancements. Update to latest SPIRV-Cross. Fix registryID crash.
2019-02-11 12:45:23 -05:00
Bill Hollings
e0b75dbc2c Fix crash from use of MTLDevice registryID on early OS versions.
Add mvkGetRegistryID() function to check OS support for registry ID.
Rename build setting MVK_FORCE_LOW_POWER_GPU to MVK_CONFIG_FORCE_LOW_POWER_GPU
and make it an env var / build setting combo.
Rename env var MVK_LOG_LEVEL to MVK_CONFIG_LOG_LEVEL.
Rename MVKLogging.mm to MVKLogging.cpp.
2019-02-11 10:49:58 -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
677f2cb9be Modify README.md to direct developers to Vulkan SDK. 2019-02-08 19:36:52 -05:00
Bill Hollings
94404ae0da
Merge pull request #489 from cdavis5e/quiesce-swizzle-log
Only warn on non-default swizzles when fullImageViewSwizzle is off.
2019-02-07 16:35:34 -05:00
Chip Davis
1652f6d719 Don't warn at all on pipelines with full swizzling support.
This could happen, for example, if image views with a non-default
swizzle are used with shaders that don't sample those images. In this
case, MoltenVK will warn, because the pipeline said not to set up the
aux buffer.
2019-02-06 13:17:50 -06:00
Chip Davis
f1c5c79365 Only warn on non-default swizzles when fullImageViewSwizzle is off.
Otherwise, the log will be spammed with hundreds of useless messages
that the `IDENTITY` swizzle is not supported.
2019-02-05 13:56:45 -06:00
Bill Hollings
24c7be84dc
Merge pull request #488 from billhollings/master
Add GPU device ID for iOS A12 SoC.
2019-02-04 11:42:52 -05:00
Bill Hollings
8e02a5d2f3 Add GPU device ID for iOS A12 SoC. 2019-02-04 10:15:03 -05:00
Bill Hollings
31069218db
Merge pull request #485 from cdavis5e/registry-id
Use the device's registryID property to locate it in IOKit.
2019-02-04 10:04:04 -05:00
Chip Davis
8307a66f80 Use the device's registryID property to locate it in IOKit.
This should be better behaved with systems that have more than one GPU
and aren't e.g. MacBooks with graphics switching.
2019-01-31 19:34:01 -06:00
Bill Hollings
e4c196c3b6
Merge pull request #484 from cdavis5e/memory-budget
Support the VK_EXT_memory_budget extension.
2019-01-31 16:12:07 -06:00
Chip Davis
3df6d2d00f Support the VK_EXT_memory_budget extension.
This requires macOS 10.13 or iOS 11, for the `currentAllocatedSize`
property of `MTLDevice`. Ideally, we'd check for that method instead of
keying on the version.
2019-01-31 12:10:57 -06:00
Bill Hollings
97ab7dfa92
Merge pull request #482 from billhollings/master
Allow logging level to be controlled via runtime environment variable.
2019-01-30 10:20:18 -06:00
Bill Hollings
216e86de19 Allow logging level to be controlled via runtime environment variable. 2019-01-29 21:10:31 -05:00
Bill Hollings
66e383f4b2
Merge pull request #481 from billhollings/master
Update to latest SPIRV-Cross version.
2019-01-28 19:34:09 -06:00
Bill Hollings
f591fed43e Update to latest SPIRV-Cross version. 2019-01-28 19:58:32 -05:00
Bill Hollings
eba0908ef3
Merge pull request #480 from billhollings/master
vkSetMTLTextureMVK() function retains texture object.
2019-01-28 18:56:59 -06:00