Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rare deadlock during launch via dlopen(). #2067

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Docs/Whats_New.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ MoltenVK 1.2.7
Released TBD

- Reduce disk space consumed after running `fetchDependencies` script by removing intermediate file caches.
- Fix rare deadlock during launch via `dlopen()`.
- Update to latest SPIRV-Cross:
- MSL: Fix regression error in argument buffer runtime arrays.

Expand Down
63 changes: 34 additions & 29 deletions MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,111 +32,116 @@

#pragma mark Pixel formats

static MVKPixelFormats _platformPixelFormats;
static std::unique_ptr<MVKPixelFormats> _platformPixelFormats;

static MVKPixelFormats* getPlatformPixelFormats() {
if ( !_platformPixelFormats ) { _platformPixelFormats.reset(new MVKPixelFormats()); }
billhollings marked this conversation as resolved.
Show resolved Hide resolved
return _platformPixelFormats.get();
}

MVK_PUBLIC_SYMBOL bool mvkVkFormatIsSupported(VkFormat vkFormat) {
return _platformPixelFormats.isSupported(vkFormat);
return getPlatformPixelFormats()->isSupported(vkFormat);
}

MVK_PUBLIC_SYMBOL bool mvkMTLPixelFormatIsSupported(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.isSupported(mtlFormat);
return getPlatformPixelFormats()->isSupported(mtlFormat);
}

MVK_PUBLIC_SYMBOL MVKFormatType mvkFormatTypeFromVkFormat(VkFormat vkFormat) {
return _platformPixelFormats.getFormatType(vkFormat);
return getPlatformPixelFormats()->getFormatType(vkFormat);
}

MVK_PUBLIC_SYMBOL MVKFormatType mvkFormatTypeFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.getFormatType(mtlFormat);
return getPlatformPixelFormats()->getFormatType(mtlFormat);
}

MVK_PUBLIC_SYMBOL MTLPixelFormat mvkMTLPixelFormatFromVkFormat(VkFormat vkFormat) {
return _platformPixelFormats.getMTLPixelFormat(vkFormat);
return getPlatformPixelFormats()->getMTLPixelFormat(vkFormat);
}

MVK_PUBLIC_SYMBOL VkFormat mvkVkFormatFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.getVkFormat(mtlFormat);
return getPlatformPixelFormats()->getVkFormat(mtlFormat);
}

MVK_PUBLIC_SYMBOL uint32_t mvkVkFormatBytesPerBlock(VkFormat vkFormat) {
return _platformPixelFormats.getBytesPerBlock(vkFormat);
return getPlatformPixelFormats()->getBytesPerBlock(vkFormat);
}

MVK_PUBLIC_SYMBOL uint32_t mvkMTLPixelFormatBytesPerBlock(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.getBytesPerBlock(mtlFormat);
return getPlatformPixelFormats()->getBytesPerBlock(mtlFormat);
}

MVK_PUBLIC_SYMBOL VkExtent2D mvkVkFormatBlockTexelSize(VkFormat vkFormat) {
return _platformPixelFormats.getBlockTexelSize(vkFormat);
return getPlatformPixelFormats()->getBlockTexelSize(vkFormat);
}

MVK_PUBLIC_SYMBOL VkExtent2D mvkMTLPixelFormatBlockTexelSize(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.getBlockTexelSize(mtlFormat);
return getPlatformPixelFormats()->getBlockTexelSize(mtlFormat);
}

MVK_PUBLIC_SYMBOL float mvkVkFormatBytesPerTexel(VkFormat vkFormat) {
return _platformPixelFormats.getBytesPerTexel(vkFormat);
return getPlatformPixelFormats()->getBytesPerTexel(vkFormat);
}

MVK_PUBLIC_SYMBOL float mvkMTLPixelFormatBytesPerTexel(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.getBytesPerTexel(mtlFormat);
return getPlatformPixelFormats()->getBytesPerTexel(mtlFormat);
}

MVK_PUBLIC_SYMBOL size_t mvkVkFormatBytesPerRow(VkFormat vkFormat, uint32_t texelsPerRow) {
return _platformPixelFormats.getBytesPerRow(vkFormat, texelsPerRow);
return getPlatformPixelFormats()->getBytesPerRow(vkFormat, texelsPerRow);
}

MVK_PUBLIC_SYMBOL size_t mvkMTLPixelFormatBytesPerRow(MTLPixelFormat mtlFormat, uint32_t texelsPerRow) {
return _platformPixelFormats.getBytesPerRow(mtlFormat, texelsPerRow);
return getPlatformPixelFormats()->getBytesPerRow(mtlFormat, texelsPerRow);
}

MVK_PUBLIC_SYMBOL size_t mvkVkFormatBytesPerLayer(VkFormat vkFormat, size_t bytesPerRow, uint32_t texelRowsPerLayer) {
return _platformPixelFormats.getBytesPerLayer(vkFormat, bytesPerRow, texelRowsPerLayer);
return getPlatformPixelFormats()->getBytesPerLayer(vkFormat, bytesPerRow, texelRowsPerLayer);
}

MVK_PUBLIC_SYMBOL size_t mvkMTLPixelFormatBytesPerLayer(MTLPixelFormat mtlFormat, size_t bytesPerRow, uint32_t texelRowsPerLayer) {
return _platformPixelFormats.getBytesPerLayer(mtlFormat, bytesPerRow, texelRowsPerLayer);
return getPlatformPixelFormats()->getBytesPerLayer(mtlFormat, bytesPerRow, texelRowsPerLayer);
}

MVK_PUBLIC_SYMBOL VkFormatProperties mvkVkFormatProperties(VkFormat vkFormat) {
return _platformPixelFormats.getVkFormatProperties(vkFormat);
return getPlatformPixelFormats()->getVkFormatProperties(vkFormat);
}

MVK_PUBLIC_SYMBOL const char* mvkVkFormatName(VkFormat vkFormat) {
return _platformPixelFormats.getName(vkFormat);
return getPlatformPixelFormats()->getName(vkFormat);
}

MVK_PUBLIC_SYMBOL const char* mvkMTLPixelFormatName(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.getName(mtlFormat);
return getPlatformPixelFormats()->getName(mtlFormat);
}

MVK_PUBLIC_SYMBOL MTLVertexFormat mvkMTLVertexFormatFromVkFormat(VkFormat vkFormat) {
return _platformPixelFormats.getMTLVertexFormat(vkFormat);
return getPlatformPixelFormats()->getMTLVertexFormat(vkFormat);
}

MVK_PUBLIC_SYMBOL MTLClearColor mvkMTLClearColorFromVkClearValue(VkClearValue vkClearValue,
VkFormat vkFormat) {
return _platformPixelFormats.getMTLClearColor(vkClearValue, vkFormat);
return getPlatformPixelFormats()->getMTLClearColor(vkClearValue, vkFormat);
}

MVK_PUBLIC_SYMBOL double mvkMTLClearDepthFromVkClearValue(VkClearValue vkClearValue) {
return _platformPixelFormats.getMTLClearDepthValue(vkClearValue);
return getPlatformPixelFormats()->getMTLClearDepthValue(vkClearValue);
}

MVK_PUBLIC_SYMBOL uint32_t mvkMTLClearStencilFromVkClearValue(VkClearValue vkClearValue) {
return _platformPixelFormats.getMTLClearStencilValue(vkClearValue);
return getPlatformPixelFormats()->getMTLClearStencilValue(vkClearValue);
}

MVK_PUBLIC_SYMBOL bool mvkMTLPixelFormatIsDepthFormat(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.isDepthFormat(mtlFormat);
return getPlatformPixelFormats()->isDepthFormat(mtlFormat);
}

MVK_PUBLIC_SYMBOL bool mvkMTLPixelFormatIsStencilFormat(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.isStencilFormat(mtlFormat);
return getPlatformPixelFormats()->isStencilFormat(mtlFormat);
}

MVK_PUBLIC_SYMBOL bool mvkMTLPixelFormatIsPVRTCFormat(MTLPixelFormat mtlFormat) {
return _platformPixelFormats.isPVRTCFormat(mtlFormat);
return getPlatformPixelFormats()->isPVRTCFormat(mtlFormat);
}

MVK_PUBLIC_SYMBOL MTLTextureType mvkMTLTextureTypeFromVkImageType(VkImageType vkImageType,
Expand Down Expand Up @@ -192,11 +197,11 @@ MVK_PUBLIC_SYMBOL MTLTextureType mvkMTLTextureTypeFromVkImageViewType(VkImageVie
}

MVK_PUBLIC_SYMBOL MTLTextureUsage mvkMTLTextureUsageFromVkImageUsageFlags(VkImageUsageFlags vkImageUsageFlags, MTLPixelFormat mtlPixFmt) {
return _platformPixelFormats.getMTLTextureUsage(vkImageUsageFlags, mtlPixFmt);
return getPlatformPixelFormats()->getMTLTextureUsage(vkImageUsageFlags, mtlPixFmt);
}

MVK_PUBLIC_SYMBOL VkImageUsageFlags mvkVkImageUsageFlagsFromMTLTextureUsage(MTLTextureUsage mtlUsage, MTLPixelFormat mtlFormat) {
return _platformPixelFormats.getVkImageUsageFlags(mtlUsage, mtlFormat);
return getPlatformPixelFormats()->getVkImageUsageFlags(mtlUsage, mtlFormat);
}

MVK_PUBLIC_SYMBOL uint32_t mvkSampleCountFromVkSampleCountFlagBits(VkSampleCountFlagBits vkSampleCountFlag) {
Expand Down