197 Commits

Author SHA1 Message Date
Bill Hollings
31a77834f1 Advertise support for extension VK_KHR_spirv_1_4.
- Advertise support for extension VK_KHR_spirv_1_4.
- MoltenVKShaderConverter automatically map bindings when converting GLSL.
- MoltenVKShaderConverter improvements to diagnostic logging.
- Update Whats_New.md document.
2022-09-23 11:43:32 -04:00
Bill Hollings
250e1f988a
Merge pull request #1715 from cdavis5e/tess-unwritten-builtin-read
MVKPipeline: Add builtins that are read but not written to tessellation pipelines.
2022-09-14 10:25:05 -04:00
Chip Davis
fafcc4b844 MVKPipeline: Add builtins that are read but not written to tessellation pipelines.
It is always legal in Vulkan to read a builtin, particularly
`BuiltInPosition`, even if it weren't written by the previous stage. The
CTS tests that this scenario works in the driver.

Update SPIRV-Cross to pull in a change required for this.

Fixes 8 CTS tests under `dEQP-VK.pipeline.*.no_position`. (Eight other
tests worked solely by accident without this change.)
2022-09-13 13:18:41 -07:00
Bill Hollings
4effb9a5fd Support automatically enable Metal argument buffers when
VK_EXT_descriptor_indexing extension is enabled.

- Change MVKConfiguration::useMetalArgumentBuffers to enum instead of boolean
  and default to enabling Metal argument buffers for VK_EXT_descriptor_indexing.
- Leave Metal argument buffers disabled by default until they are improved.
- Enable VkPhysicalDeviceVulkan12Features::descriptorIndexing.
- Add MVKPhysicalDeviceVulkan12FeaturesNoExt to track and enable Vulkan 1.2
  features not part of any prior extensions absorbed by Vulkan 1.2.
- Update VK_MVK_MOLTENVK_SPEC_VERSION to version `36`.
- MVKDeviceTrackingMixin remove unnecessary inline declarations.
- MoltenShaderConveter tool support Metal Argument Buffers and MSL 3.0.
2022-08-26 14:48:13 -04:00
Bill Hollings
8dd1454651 Xcode 14 build fixes from code review and further testing.
- Replace use of deprecated kIOMasterPortDefault with MACH_PORT_NULL.
- Convert an inline VLA with constant length array.
- Add input files to all build phases to trigger dependencies when inputs change.
- Add packaging scripts to per-platform ExternalDependencies targets.
2022-07-08 18:07:18 -04:00
Bill Hollings
5b2e153f26 Fix Xcode projects to support Xcode 11.7.
Add dummy output files to each Xcode Run Script build phase that doesn't
already have dependencies set, to avoid setting alwaysOutOfDate flag
(by disabling "Based on dependency analysis" UI flag), which forces
the Xcode project to a version that can't be read by Xcode 11.7.
2022-07-07 22:28:02 -04:00
Bill Hollings
59554d6139 Update Xcode project build settings to Xcode 14. 2022-07-06 18:23:51 -04:00
Bill Hollings
26d4a13e34 Support Xcode 14, macOS 13, and iOS/tvOS 16.
- Update minimum Xcode deployment targets to macOS 10.13, iOS 11, and tvOS 11,
  to avoid Xcode build warnings.
- Add support for MTLLanguageVersion3_0 enumeration.
- Build efficiencies:
  - Build scripts create_dylib.sh and gen_moltenvk_rev_hdr.sh
    only run if build dependencies require it.
  - Packaging and copy_to_staging.sh scripts are too complex to define dependencies,
    and are fast, so configured to run every time, to avoid build warning.
- Replace use of deprecated sprintf() with  snprintf().
- Replace use of deprecated kIOMasterPortDefault with  kIOMainPortDefault.
- Support old-style GPU debug capture only if building for earlier minimum
  deployment targets, to avoid deprecation warning.
- Update minimum Xcode deployment targets of Cube demo to macOS 10.14, iOS 12,
  and tvOS 12, to avoid Xcode build warning regarding MTLSharedEvent in .
- Update README.md document regarding minimum Xcode deployment targets.
2022-07-06 18:15:10 -04:00
Bill Hollings
7779f3c098 Update Xcode project build settings.
- Add clang -Wreorder warning.
- Align constructor member inits with member order.
- Update build settings to support Xcode 13.4.
2022-05-30 18:12:14 -04:00
Bill Hollings
6011bfe05d Update Xcode build settings validation, and GitHub CI settings.
Update to Xcode 13.3 build settings validation.
Update GitHub CI settings to latest macOS and Xcode 13.2.1.
2022-03-21 20:31:33 -04:00
Bill Hollings
728182cf75 MoltenVKShaderConverter tool defaults to the
highest MSL version supported on runtime OS.

Update to latest SPIRV-Cross.
Update Docs/Whats_New.md document.
2022-03-08 21:22:25 -05:00
Bill Hollings
afd997ab31 Align flattened shader inputs to previous stage output structs.
When flattening shader inputs for stage_in, which are to be read from a buffer
that was populated as nested structs during an earlier stage, the structs will
be aligned according to C++ rules, which can affect the alignment of the first
member of the flattened input struct.

Add SPIRVShaderOutput::firstStructMemberAlignment to track the alignment
requirements of the first member of a nested structure, and recursively
determine the alignment of the first member of each nested output structure.

Move sizeOfOutput() from MVKPipeline.mm to SPIRVReflection.h,
rename to getShaderOutputSize(), and add getShaderOutputAlignment()
to extract member alignment.
2022-02-22 12:17:15 -05:00
Nikita Fediuchin
be51560ba9 Update license year 2 2022-02-04 17:36:53 +02:00
Nikita Fediuchin
4efb90b3c1 Update license year 2022-02-04 13:33:27 +02:00
Bill Hollings
d4daba6687 MoltenVKShaderConverter updates.
mvk::getShaderOutputs() in SPRIVReflection.h support flattening nested structures.
MoltenVKShaderConverter tool support loading tessellation shader files.
MoltenVKShaderConverter tool update to MSL 2.4 by default.
Remove use of deprecated MTLCreateSystemDefaultDevice().
Update to latest version of SPIRV-Cross.
2022-01-19 15:55:44 -05:00
Malcolm Bechard
f3f02c327c fix for #1501
Maintain the incrementing location throughout the structure traversal.
2022-01-05 15:25:16 -05:00
Bill Hollings
3a8975c21d Support Xcode 13.2 build settings. 2021-12-27 17:50:29 -05:00
Bill Hollings
18642002ce Updates to better support Rosetta2 runtimes, and MSL 2.4 and 2.3 versions.
Do not use MTLEvent for VkSemaphore under Rosetta2.
Remove compile test for MVK_MACOS_APPLE_SILICON and MVK_APPLE_SILICON when testing
for Apple GPU families, to allow x86 builds to test for Apple GPU under Rosetta2.
Simplify identifying M1 GPU. All M1 SoCs currently support the A14 (Apple7) GPU.
Support compiling MSL 2.4 in runtime pipelines and MoltenVKShaderConverterTool.
Fix issue where MSL 2.3 only available on Apple Silicon, even on macOS.
Update to latest SPIRV-Cross (unrelated to Rosetta2).
2021-12-01 18:14:07 -05:00
Bill Hollings
ba9623cad5 Update to latest version of SPIRV-Cross.
Add additional SPIRV-Cross header files to ExternalDependencies.xcodeproj
to allow browsing these files in Xcode.
2021-09-30 13:45:54 -04:00
Bill Hollings
a7a8a88904 Upgrade projects to Xcode 13 build settings. 2021-06-14 11:35:43 -04:00
Bill Hollings
269fca63ba Upgrade project builds to use C++17. 2021-06-14 10:39:42 -04:00
Bill Hollings
ef34fb7f37 Set project build optimizations to -O2 for all Release mode builds. 2021-06-10 18:32:38 -04:00
Bill Hollings
bb7b46be0f MoltenVKShaderConverter build fixes.
Remove #include "SPIRVReflection.h" from SPIRVToMSLConverter.h.
Remove MoltenVKShaderConverter/Common and move contained files to
MoltenVKShaderConverter/MoltenVKShaderConverter.
2021-06-10 15:56:58 -04:00
Bill Hollings
650e8f3a46 To improve cache hits when matching SPIRVToMSLConversionConfiguration structs
to each other to find cached shader, only consider current shader stage resources.

Rename more references to ShaderConverterContext to ShaderConversionConfig.
2021-05-04 20:06:34 -04:00
Bill Hollings
1b937aeac4 MSLShaderInput and MSLResourceBinding compare SPIRV-Cross components via memcmp()
to save having to track individual evolutionary changes to those components.
2021-05-04 15:50:56 -04:00
Bill Hollings
1655f3b455 Add tag names to anonymous structs. 2021-04-30 20:49:01 -04:00
Bill Hollings
c0e5f88bf5 Support Xcode 12.5 build settings. 2021-04-30 19:41:54 -04:00
Bill Hollings
1b54d50ae1 Rename SPIRVToMSLConverter.mm back to SPIRVToMSLConverter.cpp
as it no longer needs to access the Metal framework directly.
2021-04-20 19:56:11 -04:00
Bill Hollings
f35922507a With Metal argument buffers, track descriptor bindings used by
pipelines and only encode bindings that are in use for each stage.

Add SPIRVToMSLConversionConfiguration::isResourceUsed() and
remove SPIRVToMSLConversionResults::isDescriptorSetUsed().
MVKBitArray add copy constructor and allow queries beyond range.
2021-04-19 22:05:06 -04:00
Bill Hollings
ca89d258c9 No longer extract MTLTextureType from SPIR-V Cross to create MTLArgumentEncoders.
MVKDescriptorSetLayoutBinding no longer uses MTLTextureType to create
MTLArgumentEncoder, which is not needed for descriptor set argument encoding.
Remove obsolete MSLResourceBinding::outMTLTextureType and
SPIRVToMSLConversionConfiguration::getMTLTextureType().
2021-04-19 13:31:19 -04:00
Bill Hollings
4f0367130d Metal argument buffers support options for one MTLArgumentEncoder per descriptor set,
or one MTLArgumentEncoder per combination of pipeline-stage/descriptor set.

Add MVKPhysicalDeviceMetalFeatures::descriptorSetArgumentBuffers,
and MVKDeviceTrackingMixin::isUsingDescriptorSetMetalArgumentBuffers()
and isUsingPipelineStageMetalArgumentBuffers() to track this.
Create a separate MTLArgumentEncoder for each shader stage from
MTLFunction instead of MTLDevice, and track per-stage in MVKPipeline.
Add MVKMTLArgumentEncoder to track MTLArgumentEncoders in pipelines and desc set layouts.
Add SPIRVToMSLConversionResults::activeDescriptorSets to get desc sets used by a shader.
In SPIRV-Cross make padded Metal argument buffer descriptors
for buffers a pointer to float instead of pointer to void.
Update to latest version of SPIRV-Cross to use arg buffer padding feature.
Enable argument buffer support only when one MTLArgumentEncoder per
descriptor set can be used (macOS 10.16 and later or Intel GPU's).
2021-04-19 12:36:29 -04:00
Bill Hollings
52854bb76f Metal argument buffers support dynamic buffer offsets.
Move dynamic offsets from the Metal argument buffer to an implicit shader buffer.
Add SPIRVToMSLConversionConfiguration::dynamicBufferDescriptors to track dynamic
buffer descriptors, and add SPIRVToMSLConversionResults::needsDynamicOffsetBuffer
to indicate shader needs an implicit buffer to track these dynamic offsets.
Add MVKShaderStageResourceBinding::dynamicOffsetBufferIndex to track a
descriptor's index into the implicit dynamic offsets buffer.
MVKPipelineLayout change how per-descriptor set offsets are calculated and tracked
when using Metal argument buffers, so that resource indexes do not accumulate
across descriptor sets, but dynamic offset buffer indexes do accumulate.
MVKPipelineLayout rearrange order of implicit buffer indexes to give more commonly used
implicit buffers lower indexes to help reduce risk of exhausting discrete buffer bindings.
2021-04-09 12:06:57 -04:00
Bill Hollings
3d010dba67 Fix issue where Metal argument buffer resource
usage not tracked accurately across shader stages.

Remove tracking of descriptor usage in MVKPipeline.
Don't bind argument buffer to command encoder if descriptor set unused by shader stage.
MVKDescriptor::encodeToMetalArgumentBuffer() remove unused shader stage argument.
Remove SPIRVToMSLConversionConfiguration::isResourceUsed().
2021-04-07 14:52:33 -04:00
Bill Hollings
8145aa2707 Align shader descriptor set definitions with Metal argument buffer definitions.
Support SPIRV-Cross CompilerMSL::Options::pad_argument_buffer_resources and
MSLResourceBinding::base_type.
Consolidate mvkPopulateShaderConverterContext() and set
MSLResourceBinding::base_type from VkDescriptorType.
Add MVKDescriptorSetLayout::initForMetalArgumentBufferUse() to measure size of Metal
argument buffer needed for descriptor set by creating a ephemeral MTLArgumentEncoder
from the descriptor bindings and measuring its length.
MVKDescriptorPool::initMetalArgumentBuffer() measure size of a single MTLBuffer
to use for all descriptor sets in the pool.
MVKDescriptorPool use VkDescriptorPoolInlineUniformBlockCreateInfoEXT to determine
descriptor count for VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.
Set max size of temporary inline block buffer allocations from
MVKDevice::_pMetalFeatures->dynamicMTLBufferSize.
Set MTLSamplerDescriptor::supportArgumentBuffers property when appropriate.
2021-04-05 13:23:53 -04:00
Bill Hollings
4920362f43 Fixes to argument buffers during initial testing.
Use specific resource indices of MVKShaderStageResourceBinding
when assigning indices to argument buffer elements.
MVKShaderStageResourceBinding expand elements to uint32_t
to support larger numbers of resource arguments.
Fix calculation of descriptor set Metal argument buffer size requirements.
Streamline MVKResourcesCommandEncoderState::encodeToMetalArgumentBuffer(),
and add fix for GPU capturing of Metal arg buffers for Xcode 12.
Update MSLResourceBinding::outMTLTextureType and outIsUsedByShader from shader
only if resource binding is for the correct shader stage, to allow outIsUsedByShader
to be carried across multiple-stage shader compilations.
Remove MVKDescriptorSet::populateMetalArgumentBufferBinding().
Remove MVKSamplerDescriptorMixin::getMetalArgumentBufferSamplerIndexOffset().
Add MVKCommandEncoderState::getDevice().
2021-03-31 14:56:38 -04:00
Bill Hollings
36a5a6e654 Fix time and space inefficiencies caused by missed
shader cache lookup hits in MVKShaderLibraryCache.

Rename MSLResourceBinding::mtlTextureType, MSLResourceBinding::isUsedByShader, and
MSLShaderInput::isUsedByShader to add a prefix out*, to clarify that those variables
are output from the conversion process, instead of input to the conversion process.
Don't use MSLResourceBinding::outMTLTextureType when looking up cached shaders.
2021-03-30 09:53:07 -04:00
Bill Hollings
aa89f845a9 Update Metal argument buffer resource usage in Metal command encoder.
MVKPipeline track descriptors used by shaders.
Update resources as dirty at start of Metal render pass or compute encoder.
Add MVKCommandEncoder::beginMetalComputeEncoding() to mark a new Metal compute encoder.
MVKResourcesCommandEncoderState track resource usage that needs to be encoded.
Add MVKResourcesCommandEncoderState::encodeArgumentBufferResourceUsage().
Add MVKCommandEncoderState::beginMetalComputeEncoding() to mark compute
state dirty when a MTLComputeEncoder is created.
Add SPIRVToMSLConversionConfiguration::isResourceUsed().
MVKBitArray add ability to retain contents when resizing, and clear bit during getBit().
Add MVKBitArray getBit() option to clear bit.
2021-03-26 13:16:16 -04:00
Bill Hollings
0a8f9995c9 Device and shader framework framework changes to support Metal argument buffers.
Add MVKPhysicalDeviceMetalFeatures::argumentBuffers.
Add MVKConfiguration::useMetalArgumentBuffers and
MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS env var.
MVKPhysicalDevice and MVKDeviceTrackingMixin add isUsingMetalArgumentBuffers().
Populate VkPhysicalDeviceDescriptorIndexingPropertiesEXT with larger Tier2
limits when supported.
Populate pipelineCacheUUID with feature flag if Metal arg buffers are used.
SPIRVToMSLConversionConfiguration add content to extract shader texture types
and mark discrete descriptor sets.
2021-03-18 13:29:10 -04:00
Bill Hollings
ff7269f26e Add NDEBUG macro to all Release builds to remove assert() calls.
External libraries in particular make liberal use of assert() calls, which bypass
error catching, sometimes causing crashes rather than catch errors and moving on.
2021-03-04 13:47:25 -05:00
Bill Hollings
5dd56ccfd3 Restore project qualifiers to references to glslang header files. 2021-03-01 17:44:13 -05:00
Bill Hollings
64681832c1 Remove project qualifiers from references to SPIRV-Cross and glslang header files.
Remove SPIRV-Cross/ qualifier from include references to SPIRV-Cross header files.
Remove glslang/ qualifier from include references to glslang header files.
This change allows easier integration with app build scripts.
2021-02-28 18:22:52 -05:00
Bill Hollings
4d60058efb Remove ONLY_ACTIVE_ARCH from Debug builds.
Debug builds now build for all platform architectures.
2021-02-12 09:50:17 -05:00
Bill Hollings
e5e1f65dfc Update Xcode build settings to cover Xcode 12.4. 2021-02-01 13:50:42 -05:00
Bill Hollings
4083dd1229 Merge branch 'master' of https://github.com/billhollings/MoltenVK into fastmath 2021-01-29 17:30:23 -05:00
Chip Davis
2bfb5ed77b Fix build on Xcode 11.
I missed this.
2021-01-29 14:53:03 -06:00
Bill Hollings
3e20e1a137 Support compiling MSL with position invariance if indicated in SPIRV shader.
Add SPIRVToMSLConversionResults::isPositionInvariant to query
position invariance from SPIR-V.
MVKDevice::getMTLCompileOptions() takes into consideration need to preserve invariance.
MVKShaderModule compile MSL to preserve invariance if required by shader.
2021-01-28 16:46:49 -05:00
Bill Hollings
2343c0267b Enable MSL ffast-math compilation option by default.
Support querying SignedZeroInfNanPreserve execution mode
from SPIR-V to disable fast-math for individual shaders.
Clean up namespace references in SPIRVToMSLConverter.cpp.
2021-01-28 08:05:33 -05:00
Bill Hollings
2fc9fcb079 Support shaderInt64 feature only on minimum MSL 2.3 and higher GPUs. 2021-01-25 21:40:29 -05:00
Bill Hollings
57763529b1 Advertise support for shaderInt64 feature.
Add MVKDevice::mslVersionIsAtLeast() to support tests for MSL version.
Also bump MSL support level of standalone MoltenVKShaderConverter tool.
2021-01-25 13:08:41 -05:00
Bill Hollings
015031c955 Update copyright notices to year 2021 and Xcode build settings check to Xcode 12.3. 2021-01-21 13:37:07 -05:00