Skip to content

Commit

Permalink
Merge pull request #650 from billhollings/master
Browse files Browse the repository at this point in the history
For shaders created directly from MSL, set function name from VkPipelineShaderStageCreateInfo::pName
  • Loading branch information
billhollings authored Jun 30, 2019
2 parents 17496c3 + fb4dd15 commit a5cefa5
Show file tree
Hide file tree
Showing 16 changed files with 416 additions and 241 deletions.
9 changes: 9 additions & 0 deletions Docs/MoltenVK_Runtime_UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ In addition to the core *Vulkan* API, **MoltenVK** also supports the following
- `VK_KHR_swapchain`
- `VK_KHR_swapchain_mutable_format`
- `VK_KHR_variable_pointers`
- `VK_EXT_debug_marker`
- `VK_EXT_debug_report`
- `VK_EXT_debug_utils`
- `VK_EXT_host_query_reset`
- `VK_EXT_memory_budget`
- `VK_EXT_shader_viewport_index_layer`
Expand Down Expand Up @@ -317,6 +319,13 @@ where `HEADER_FILE` is one of the following:
These functions are exposed in this header for your own purposes such as interacting with *Metal*
directly, or simply logging data values.

>***Note:*** The functions in `vk_mvk_moltenvk.h` are not supported by the *Vulkan SDK Loader and Layers*
framework. The opaque Vulkan objects used by the functions in `vk_mvk_moltenvk.h` (`VkInstance`,
`VkPhysicalDevice`, `VkShaderModule`, `VKImage`, ...), must have been retrieved directly from **MoltenVK**,
and not through the *Vulkan SDK Loader and Layers* framework. The *Vulkan SDK Loader and Layers* framework
often changes these opaque objects, and passing them from a higher layer directly to **MoltenVK** will
result in undefined behaviour.


<a name="moltenvk_config"></a>
### Configuring MoltenVK
Expand Down
23 changes: 21 additions & 2 deletions Docs/Whats_New.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,30 @@ MoltenVK 1.0.36

Released TBD

- For shaders created directly from MSL, set function name from
`VkPipelineShaderStageCreateInfo::pName`.
- On iOS GPU family 2 and earlier, support immutable depth-compare samplers
as constexpr samplers hardcoded in MSL.
- Add MTLCommandBuffer completion timing performance tracking option.
- Add `MTLCommandBuffer` completion timing performance tracking option.
- Expand `MVK_CONFIG_TRACE_VULKAN_CALLS` to optionally log Vulkan call timings.
- Skip `SPIRV-Tools` build in Travis because Travis does not support the required Python 3.
- Separate `SPIRVToMSLConverterContext` into input config and output results.
- Fix pipeline cache lookups.
- Doument that the functions in `vk_mvk_moltenvk.h` cannot be used with objects
retrieved through the *Vulkan SDK Loader and Layers* framework.
- Update `VK_MVK_MOLTENVK_SPEC_VERSION` to 21.
- Update to latest SPIRV-Cross version:
- MSL: Add support for `SubgroupSize` / `SubgroupInvocationID` in fragment.
- MSL: Support `OpImageQueryLod`.
- MSL: Support `MinLod` operand.
- MSL: Support `PrimitiveID` in fragment and barycentrics.
- MSL: Support 64-bit integers.
- MSL: New SDK errors out on cull distance.
- MSL: Conditionally validate MSL 2.2 shaders.
- MSL: Rewrite how resource indices are fallback-assigned.
- MSL: Support custom bindings for argument buffers.
- MSL: Fix sampling with FP16 coordinates.
- MSL: Deal with scalar input values for distance/length/normalize.



Expand Down Expand Up @@ -570,7 +589,7 @@ MoltenVK 1.0.17
Released 2018/07/31

- Disable rasterization and return void from vertex shaders that write to resources.
- Add SPIRVToMSLConverterOptions::isRasterizationDisabled to allow pipeline and
- Add SPIRVToMSLConversionOptions::isRasterizationDisabled to allow pipeline and
vertex shader to communicate rasterization status.
- Track layered rendering capability.
- Add MVKPhysicalDeviceMetalFeatures::layeredRendering.
Expand Down
2 changes: 1 addition & 1 deletion ExternalRevisions/SPIRV-Cross_repo_revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4104e363005a079acc215f0920743a8affb31278
8ee8e60f70f937c72379ab1fc404a1c36d660a31
74 changes: 72 additions & 2 deletions MoltenVK/MoltenVK/API/vk_mvk_moltenvk.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,12 @@ typedef void (VKAPI_PTR *PFN_vkGetIOSurfaceMVK)(VkImage image, IOSurfaceRef* pIO
* that MoltenVK expects the size of MVKConfiguration to be by setting the value of pConfiguration
* to NULL. In that case, this function will set *pConfigurationSize to the size that MoltenVK
* expects MVKConfiguration to be.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkInstance object you provide here must have been retrieved directly from MoltenVK,
* and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan objects
* are often changed by layers, and passing them from one layer to another, or from
* a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkGetMoltenVKConfigurationMVK(
VkInstance instance,
Expand Down Expand Up @@ -700,6 +706,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMoltenVKConfigurationMVK(
* that MoltenVK expects the size of MVKConfiguration to be by setting the value of pConfiguration
* to NULL. In that case, this function will set *pConfigurationSize to the size that MoltenVK
* expects MVKConfiguration to be.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkInstance object you provide here must have been retrieved directly from MoltenVK,
* and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan objects
* are often changed by layers, and passing them from one layer to another, or from
* a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkSetMoltenVKConfigurationMVK(
VkInstance instance,
Expand Down Expand Up @@ -728,6 +740,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkSetMoltenVKConfigurationMVK(
* expects the size of MVKPhysicalDeviceMetalFeatures to be by setting the value of pMetalFeatures to NULL.
* In that case, this function will set *pMetalFeaturesSize to the size that MoltenVK expects
* MVKPhysicalDeviceMetalFeatures to be.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkPhysicalDevice object you provide here must have been retrieved directly from
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceMetalFeaturesMVK(
VkPhysicalDevice physicalDevice,
Expand Down Expand Up @@ -755,6 +773,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceMetalFeaturesMVK(
* that MoltenVK expects the size of MVKSwapchainPerformance to be by setting the value of
* pSwapchainPerf to NULL. In that case, this function will set *pSwapchainPerfSize to the
* size that MoltenVK expects MVKSwapchainPerformance to be.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkDevice and VkSwapchainKHR objects you provide here must have been retrieved directly
* from MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainPerformanceMVK(
VkDevice device,
Expand Down Expand Up @@ -783,6 +807,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainPerformanceMVK(
* that MoltenVK expects the size of MVKPerformanceStatistics to be by setting the value of
* pPerf to NULL. In that case, this function will set *pPerfSize to the size that MoltenVK
* expects MVKPerformanceStatistics to be.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkDevice object you provide here must have been retrieved directly from
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkGetPerformanceStatisticsMVK(
VkDevice device,
Expand All @@ -808,6 +838,12 @@ VKAPI_ATTR void VKAPI_CALL vkGetVersionStringsMVK(
* This needs to be called if you are creating compute shader modules from MSL
* source code or MSL compiled code. Workgroup size is determined automatically
* if you're using SPIR-V.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkShaderModule object you provide here must have been retrieved directly from
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR void VKAPI_CALL vkSetWorkgroupSizeMVK(
VkShaderModule shaderModule,
Expand All @@ -817,7 +853,15 @@ VKAPI_ATTR void VKAPI_CALL vkSetWorkgroupSizeMVK(

#ifdef __OBJC__

/** Returns, in the pMTLDevice pointer, the MTLDevice used by the VkPhysicalDevice. */
/**
* Returns, in the pMTLDevice pointer, the MTLDevice used by the VkPhysicalDevice.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkPhysicalDevice object you provide here must have been retrieved directly from
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR void VKAPI_CALL vkGetMTLDeviceMVK(
VkPhysicalDevice physicalDevice,
id<MTLDevice>* pMTLDevice);
Expand All @@ -831,12 +875,26 @@ VKAPI_ATTR void VKAPI_CALL vkGetMTLDeviceMVK(
* If a MTLTexture has already been created for this image, it will be destroyed.
*
* Returns VK_SUCCESS.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkImage object you provide here must have been retrieved directly from
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkSetMTLTextureMVK(
VkImage image,
id<MTLTexture> mtlTexture);

/** Returns, in the pMTLTexture pointer, the MTLTexture currently underlaying the VkImage. */
/**
* Returns, in the pMTLTexture pointer, the MTLTexture currently underlaying the VkImage.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkImage object you provide here must have been retrieved directly from
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR void VKAPI_CALL vkGetMTLTextureMVK(
VkImage image,
id<MTLTexture>* pMTLTexture);
Expand Down Expand Up @@ -864,6 +922,12 @@ VKAPI_ATTR void VKAPI_CALL vkGetMTLTextureMVK(
* - VK_SUCCESS.
* - VK_ERROR_FEATURE_NOT_PRESENT if IOSurfaces are not supported on the platform.
* - VK_ERROR_INITIALIZATION_FAILED if ioSurface is specified and is not compatible with this VkImage.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkImage object you provide here must have been retrieved directly from
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkUseIOSurfaceMVK(
VkImage image,
Expand All @@ -873,6 +937,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkUseIOSurfaceMVK(
* Returns, in the pIOSurface pointer, the IOSurface currently underlaying the VkImage,
* as set by the useIOSurfaceMVK() function, or returns null if the VkImage is not using
* an IOSurface, or if the platform does not support IOSurfaces.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkImage object you provide here must have been retrieved directly from
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR void VKAPI_CALL vkGetIOSurfaceMVK(
VkImage image,
Expand Down
6 changes: 3 additions & 3 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class MVKDescriptorSetLayoutBinding : public MVKBaseDeviceObject {
MVKShaderResourceBinding& dslMTLRezIdxOffsets);

/** Populates the specified shader converter context, at the specified descriptor set binding. */
void populateShaderConverterContext(mvk::SPIRVToMSLConverterContext& context,
void populateShaderConverterContext(mvk::SPIRVToMSLConversionConfiguration& context,
MVKShaderResourceBinding& dslMTLRezIdxOffsets,
uint32_t dslIndex);

Expand Down Expand Up @@ -160,7 +160,7 @@ class MVKDescriptorSetLayout : public MVKVulkanAPIDeviceObject {


/** Populates the specified shader converter context, at the specified DSL index. */
void populateShaderConverterContext(mvk::SPIRVToMSLConverterContext& context,
void populateShaderConverterContext(mvk::SPIRVToMSLConversionConfiguration& context,
MVKShaderResourceBinding& dslMTLRezIdxOffsets,
uint32_t dslIndex);

Expand Down Expand Up @@ -427,7 +427,7 @@ void mvkUpdateDescriptorSetWithTemplate(VkDescriptorSet descriptorSet,
* If the shader stage binding has a binding defined for the specified stage, populates
* the context at the descriptor set binding from the shader stage resource binding.
*/
void mvkPopulateShaderConverterContext(mvk::SPIRVToMSLConverterContext& context,
void mvkPopulateShaderConverterContext(mvk::SPIRVToMSLConversionConfiguration& context,
MVKShaderStageResourceBinding& ssRB,
spv::ExecutionModel stage,
uint32_t descriptorSetIndex,
Expand Down
6 changes: 3 additions & 3 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
return true;
}

void MVKDescriptorSetLayoutBinding::populateShaderConverterContext(SPIRVToMSLConverterContext& context,
void MVKDescriptorSetLayoutBinding::populateShaderConverterContext(SPIRVToMSLConversionConfiguration& context,
MVKShaderResourceBinding& dslMTLRezIdxOffsets,
uint32_t dslIndex) {

Expand Down Expand Up @@ -632,7 +632,7 @@
}
}

void MVKDescriptorSetLayout::populateShaderConverterContext(SPIRVToMSLConverterContext& context,
void MVKDescriptorSetLayout::populateShaderConverterContext(SPIRVToMSLConversionConfiguration& context,
MVKShaderResourceBinding& dslMTLRezIdxOffsets,
uint32_t dslIndex) {
uint32_t bindCnt = (uint32_t)_bindings.size();
Expand Down Expand Up @@ -1142,7 +1142,7 @@ void mvkUpdateDescriptorSetWithTemplate(VkDescriptorSet descriptorSet,
}
}

void mvkPopulateShaderConverterContext(SPIRVToMSLConverterContext& context,
void mvkPopulateShaderConverterContext(SPIRVToMSLConversionConfiguration& context,
MVKShaderStageResourceBinding& ssRB,
spv::ExecutionModel stage,
uint32_t descriptorSetIndex,
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@

MVKLogInfo(logMsg.c_str(), _properties.deviceName, devTypeStr.c_str(), _properties.vendorID, _properties.deviceID,
[[[NSUUID alloc] initWithUUIDBytes: _properties.pipelineCacheUUID] autorelease].UUIDString.UTF8String,
SPIRVToMSLConverterOptions::printMSLVersion(_metalFeatures.mslVersion).c_str());
SPIRVToMSLConversionOptions::printMSLVersion(_metalFeatures.mslVersion).c_str());
}

MVKPhysicalDevice::~MVKPhysicalDevice() {
Expand Down
Loading

0 comments on commit a5cefa5

Please sign in to comment.