799 Commits

Author SHA1 Message Date
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
Bill Hollings
0a536b2747
Merge pull request #508 from cdavis5e/tessellation
Add support for tessellation.
2019-03-15 16:39:45 -04:00
Bill Hollings
caba1186e4
Merge branch 'master' into tessellation 2019-03-15 16:11:11 -04:00
Bill Hollings
1b941bf75b
Merge pull request #522 from billhollings/master
Allow zero offset and stride combo in VkVertexInputBindingDescription.
2019-03-14 18:34:31 -04:00
Bill Hollings
e13444e305 Allow zero offset and stride combo in VkVertexInputBindingDescription.
Also fix memory overrun if no VB found with same binding as a VA.
2019-03-14 17:50:20 -04:00
Bill Hollings
e5ebf069ee
Merge pull request #521 from billhollings/master
Fix potential memory leak on synchronous command buffer submission.
2019-03-12 21:19:03 -04:00
Bill Hollings
05b14366da Use autorelease pool for synchronous command buffer submissions also. 2019-03-12 17:36:01 -04:00
Chip Davis
6061614895 Fix case where all attributes are skipped.
If none of the attributes in a buffer is used but still present, then
the offset will be non-zero, leading us to set a non-zero stride for a
vertex buffer that is not used. This is invalid.

Fixes tessellation in Final Fantasy XIV.
2019-03-11 14:19:49 -05:00
Chip Davis
d50e654acd Fix a possible race condition around MVKMTLBufferAllocation.
I don't think a race is actually possible here, but this makes Thread
Sanitizer happy.
2019-03-11 14:19:49 -05:00
Chip Davis
a1be5a37d3 Fix broken indirect non-tessellated draws. 2019-03-11 14:19:49 -05:00
Chip Davis
d7e0167b43 Fix more brokenness. 2019-03-11 14:19:49 -05:00
Chip Davis
1069786f25 Fix a broken change from the last commit. 2019-03-11 14:19:49 -05:00
Chip Davis
34047f83f9 Only compile in tessellation support kernels on Metal 1.2+.
And set the stage-in indirect params on 2.1+. I missed this when I added
setting the stage-in region.
2019-03-11 14:19:49 -05:00
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
f10150a9fe Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2019-03-08 11:36:28 -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
ae0db194c5 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2019-03-06 16:28:38 -05:00
Bill Hollings
2a2072294b MoltenVKShaderConverterTool support cs & csh for compute shader file extensions. 2019-03-06 16:27:52 -05: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