Skip to content

Commit

Permalink
Merge pull request #736 from billhollings/master
Browse files Browse the repository at this point in the history
Updates to support Vulkan SDK 1.1.121.
  • Loading branch information
billhollings authored Sep 10, 2019
2 parents f8d8f9b + 5636233 commit 0934e32
Show file tree
Hide file tree
Showing 11 changed files with 2,438 additions and 2,324 deletions.
23 changes: 18 additions & 5 deletions Docs/Whats_New.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For best results, use a Markdown reader.*
MoltenVK 1.0.37
---------------

Released TBD
Released 2019/09/10

- Add support for extensions:
- `VK_KHR_device_group`
Expand All @@ -25,17 +25,22 @@ Released TBD
- `vkInvalidateMappedMemoryRanges()` synchronizes managed device memory to CPU.
- Track supported instance and device extensions correctly.
- Revert to supporting host-coherent memory for linear images on macOS.
- Report limit of 64KB for constant buffer bindings on macOS.
- Disable depth and/or stencil testing if corresponding attachment is missing.
- Ensure Vulkan loader magic number is set every time before returning any dispatchable Vulkan handle.
- Fix crash when `VkDeviceCreateInfo` specifies queue families out of numerical order.
- Fix crash in `vkDestroyPipelineLayout()`.
- Fix crash when signalling swapchain semaphore using `MTLEvent`.
- Fix crash when determining alignment of invalid pixel formats.
- `vkCmdBlitImage():` Support format component swizzling.
- `vkCmdClearImage():` Set error if attempt made to clear 1D image, and fix validation of depth attachment formats.
- `vkCreateRenderPass():` Return `VK_ERROR_FORMAT_NOT_SUPPORTED` if format not supported.
- `vkCmdFillBuffer():` Improve performance 150x by using parallelism more effectively.
- Support optional use of `MTLFence` for Vulkan semaphores via the `MVK_ALLOW_METAL_FENCES` environment variable.
- Remove error logging on `VK_TIMEOUT` of `VkSemaphore` and `VkFence`.
- Remove log message warning of obsolescence of `vkCreateMacOSSurfaceMVK()` and `vkCreateIOSSurfaceMVK()` functions.
- Report error only on the first time a format substitution is made.
- Streamline design and use of `MVKSemaphore`.
- Consolidate the various linkable objects into a `MVKLinkableMixin` template base class.
- Use `MVKVector` whenever possible in MoltenVK, especially within render loop.
- No longer prefer dedicated allocations for buffer memory, including buffer-backed images.
Expand All @@ -44,26 +49,34 @@ Released TBD
- Always submit surface presentations using `MTLCommandBuffer`.
`MVKConfiguration::presentWithCommandBuffer` is now obsolete.
- Don't use `MTLCommandBuffer push/popDebugGroup` if not available.
- `MVKSwapchain::signalWhenAvailable()` add autoreleasepool around `MTLCommandBuffer` use.
- Add ability to automatically cause an *Xcode* GPU capture without developer intervention.
- On macOS, limit uniform buffer bindings to 64k.
- Update `VK_MVK_MOLTENVK_SPEC_VERSION` to version 22.
- Update dependency libraries to match Vulkan SDK 1.1.121.
- Update to renaming of `VK_INTEL_shader_integer_functions2` enums and structs in latest Vulkan headers.
- Update to latest SPIRV-Cross version:
- Support the `SPV_EXT_fragment_shader_interlock` extension.
- MSL: Deal with array copies from and to threadgroup.
- MSL: Deal with `Modf/Frexp` where output is access chain to scalar.
- MSL: Inline all emitted functions.
- MSL: Inline all non-entry-point functions.
- MSL: Add `{Base,}{Vertex,Instance}{,Index}` to `bitcast_from_builtin_load`.
- MSL: Add support for sampler Y'CbCr conversion.
- MSL: Force storage images on iOS to use discrete descriptors.
- MSL: Support dynamic offsets for buffers in argument buffers.
- Support the `SPV_EXT_fragment_shader_interlock` extension.
- MSL: Cleanup temporary use with `emit_uninitialized_temporary`.
- MSL: Unify the `get_*_address_space()` methods.
- Assume image and sampler can be `RelaxedPrecision`.
- Fix post-depth coverage for ESSL.
- Fix variable scope when switch block exits multiple times.
- Fix severe performance issue with invariant expression invalidation.
- Fix `ParsedIR::mark_used_as_array_length(uint32_t id)`
- Deal correctly with sign on bitfield operations.
- Elide branches to continue block when continue block is also a merge.
- Move branchless analysis to CFG.
- Deal with `ldexp` taking `uint` input.
- Do not allow base expressions for non-native row-major matrices.
- GLSL: Assume image and sampler can be `RelaxedPrecision`.
- GLSL: Fix post-depth coverage for ESSL.
- Do not force temporary unless continue-only for loop dominates.
- Fix `ParsedIR::mark_used_as_array_length(uint32_t id)`.
- Refactor into stronger types in public API.

Expand Down
4,648 changes: 2,372 additions & 2,276 deletions ExternalDependencies.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ExternalRevisions/Vulkan-Headers_repo_revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e3f96a9ccab9397481eb81c4d9bce4ea7590dc33
5671d014bc1792a116d374792f8a6cfba2e6f512
2 changes: 1 addition & 1 deletion ExternalRevisions/Vulkan-Tools_repo_revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fb1fd1d63eb20cc6f922228f04d8b96cec452b46
bcabc204a27a93d6b686920a6d46c17f9aaa3ce0
2 changes: 1 addition & 1 deletion ExternalRevisions/VulkanSamples_repo_revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5a52ebd648b5baf94f2346819b5cf3fdc14b4127
2403b94ed6463062acff8cfff563ad7ec5cf2b58
2 changes: 1 addition & 1 deletion ExternalRevisions/glslang_repo_revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
333d1c95792692205472c457d7bec915a94c8000
34953810a62c5230cc059cfdf42dc44c5aab2246
4 changes: 3 additions & 1 deletion MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,10 @@
NSUInteger dstMTLBuffOffset = _dstBuffer->getMTLBufferOffset() + _dstOffset;

// Determine the number of full threadgroups we can dispatch to cover the buffer content efficiently.
// Some GPU's report different values for max threadgroup width between the pipeline state and device,
// so conservatively use the minimum of these two reported values.
id<MTLComputePipelineState> cps = getCommandEncodingPool()->getCmdFillBufferMTLComputePipelineState();
NSUInteger tgWidth = cps.maxTotalThreadsPerThreadgroup;
NSUInteger tgWidth = std::min(cps.maxTotalThreadsPerThreadgroup, getMTLDevice().maxThreadsPerThreadgroup.width);
NSUInteger tgCount = _wordCount / tgWidth;

id<MTLComputeCommandEncoder> mtlComputeEnc = cmdEncoder->getMTLComputeEncoder(kMVKCommandUseFillBuffer);
Expand Down
22 changes: 10 additions & 12 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@
portabilityFeatures->samplerMipLodBias = false;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS2_FEATURES_INTEL: {
auto* shaderIntFuncsFeatures = (VkPhysicalDeviceShaderIntegerFunctions2INTEL*)next;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL: {
auto* shaderIntFuncsFeatures = (VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL*)next;
shaderIntFuncsFeatures->shaderIntegerFunctions2 = true;
break;
}
Expand Down Expand Up @@ -1164,22 +1164,20 @@
_properties.limits.nonCoherentAtomSize = _metalFeatures.mtlBufferAlignment;

if ([_mtlDevice respondsToSelector: @selector(minimumLinearTextureAlignmentForPixelFormat:)]) {
// Figure out the greatest alignment required by all supported formats, and
// whether or not they only require alignment to a single texel. We'll use this
// information to fill out the VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT
// struct.
// Figure out the greatest alignment required by all supported formats, and whether
// or not they only require alignment to a single texel. We'll use this information
// to fill out the VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT struct.
uint32_t maxStorage = 0, maxUniform = 0;
bool singleTexelStorage = true, singleTexelUniform = true;
mvkEnumerateSupportedFormats({0, 0, VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT | VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT}, true, [&](VkFormat vk) {
// MTLDevice minimumLinearTextureAlignmentForPixelFormat with MTLPixelFormatInvalid will cause as a failed assertion on iOS 13.x and iPad OS 13.x
if ( vk == VK_FORMAT_UNDEFINED )
return false;

MTLPixelFormat mtlFmt = mvkMTLPixelFormatFromVkFormat(vk);
if ( !mtlFmt ) { return false; } // If format is invalid, avoid validation errors on MTLDevice format alignment calls

NSUInteger alignment;
if ([_mtlDevice respondsToSelector: @selector(minimumTextureBufferAlignmentForPixelFormat:)]) {
alignment = [_mtlDevice minimumTextureBufferAlignmentForPixelFormat: mvkMTLPixelFormatFromVkFormat(vk)];
alignment = [_mtlDevice minimumTextureBufferAlignmentForPixelFormat: mtlFmt];
} else {
alignment = [_mtlDevice minimumLinearTextureAlignmentForPixelFormat: mvkMTLPixelFormatFromVkFormat(vk)];
alignment = [_mtlDevice minimumLinearTextureAlignmentForPixelFormat: mtlFmt];
}
VkFormatProperties props = mvkVkFormatProperties(vk, getFormatIsSupported(vk));
// For uncompressed formats, this is the size of a single texel.
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKSurface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
const Vk_PLATFORM_SurfaceCreateInfoMVK* pCreateInfo,
const VkAllocationCallbacks* pAllocator) : _mvkInstance(mvkInstance) {

MVKLogInfo("%s(): This function is obsolete. Consider using the vkCreateMetalSurfaceEXT() function from the VK_EXT_metal_surface extension instead.", STR(vkCreate_PLATFORM_SurfaceMVK));
// MVKLogInfo("%s(): This function is obsolete. Consider using the vkCreateMetalSurfaceEXT() function from the VK_EXT_metal_surface extension instead.", STR(vkCreate_PLATFORM_SurfaceMVK));

// Get the platform object contained in pView
id<NSObject> obj = (id<NSObject>)pCreateInfo->pView;
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/Layers/MVKExtensions.def
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ MVK_EXTENSION(AMD_negative_viewport_height, AMD_NEGATIVE_VIEWPORT_HEIGHT, MVK_EX
MVK_EXTENSION(AMD_shader_image_load_store_lod, AMD_SHADER_IMAGE_LOAD_STORE_LOD, MVK_EXTENSION_DEVICE)
MVK_EXTENSION(AMD_shader_trinary_minmax, AMD_SHADER_TRINARY_MINMAX, MVK_EXTENSION_DEVICE)
MVK_EXTENSION(IMG_format_pvrtc, IMG_FORMAT_PVRTC, MVK_EXTENSION_DEVICE)
MVK_EXTENSION(INTEL_shader_integer_functions2, INTEL_SHADER_INTEGER_FUNCTIONS2, MVK_EXTENSION_DEVICE)
MVK_EXTENSION(INTEL_shader_integer_functions2, INTEL_SHADER_INTEGER_FUNCTIONS_2, MVK_EXTENSION_DEVICE)
MVK_EXTENSION_LAST(NV_glsl_shader, NV_GLSL_SHADER, MVK_EXTENSION_DEVICE)

#undef MVK_EXTENSION
Expand Down
53 changes: 29 additions & 24 deletions MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#define MVK_FMT_NO_FEATS 0

#define MVK_MAKE_FMT_STRUCT(VK_FMT, MTL_FMT, MTL_FMT_ALT, IOS_SINCE, MACOS_SINCE, BLK_W, BLK_H, BLK_BYTE_CNT, MTL_VTX_FMT, MTL_VTX_FMT_ALT, VTX_IOS_SINCE, VTX_MACOS_SINCE, CLR_TYPE, PIXEL_FEATS, BUFFER_FEATS) \
{ VK_FMT, MTL_FMT, MTL_FMT_ALT, IOS_SINCE, MACOS_SINCE, { BLK_W, BLK_H }, BLK_BYTE_CNT, MTL_VTX_FMT, MTL_VTX_FMT_ALT, VTX_IOS_SINCE, VTX_MACOS_SINCE, CLR_TYPE, { (PIXEL_FEATS & MVK_FMT_LINEAR_TILING_FEATS), PIXEL_FEATS, BUFFER_FEATS }, #VK_FMT, #MTL_FMT }
{ VK_FMT, MTL_FMT, MTL_FMT_ALT, IOS_SINCE, MACOS_SINCE, { BLK_W, BLK_H }, BLK_BYTE_CNT, MTL_VTX_FMT, MTL_VTX_FMT_ALT, VTX_IOS_SINCE, VTX_MACOS_SINCE, CLR_TYPE, { (PIXEL_FEATS & MVK_FMT_LINEAR_TILING_FEATS), PIXEL_FEATS, BUFFER_FEATS }, #VK_FMT, #MTL_FMT, false }

#pragma mark Texture formats

Expand All @@ -117,6 +117,7 @@
VkFormatProperties properties;
const char* vkName;
const char* mtlName;
bool hasReportedSubstitution;

inline double bytesPerTexel() const { return (double)bytesPerBlock / (double)(blockTexelSize.width * blockTexelSize.height); };

Expand Down Expand Up @@ -569,31 +570,35 @@ MVK_PUBLIC_SYMBOL MTLPixelFormat mvkMTLPixelFormatFromVkFormat(VkFormat vkFormat
}

MTLPixelFormat mvkMTLPixelFormatFromVkFormatInObj(VkFormat vkFormat, MVKBaseObject* mvkObj) {
MTLPixelFormat mtlPixFmt = MTLPixelFormatInvalid;
MTLPixelFormat mtlPixFmt = MTLPixelFormatInvalid;

const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
if (fmtDesc.isSupported()) {
mtlPixFmt = fmtDesc.mtl;
} else if (vkFormat != VK_FORMAT_UNDEFINED) {
// If the MTLPixelFormat is not supported but VkFormat is valid,
// report an error, and possibly substitute a different MTLPixelFormat.
string errMsg;
errMsg += "VkFormat ";
errMsg += (fmtDesc.vkName) ? fmtDesc.vkName : to_string(fmtDesc.vk);
errMsg += " is not supported on this device.";

if (fmtDesc.isSupportedOrSubstitutable()) {
mtlPixFmt = fmtDesc.mtlSubstitute;

const MVKFormatDesc& fmtDescSubs = formatDescForMTLPixelFormat(mtlPixFmt);
errMsg += " Using VkFormat ";
errMsg += (fmtDescSubs.vkName) ? fmtDescSubs.vkName : to_string(fmtDescSubs.vk);
errMsg += " instead.";
}
MVKBaseObject::reportError(mvkObj, VK_ERROR_FORMAT_NOT_SUPPORTED, "%s", errMsg.c_str());
}
const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
if (fmtDesc.isSupported()) {
mtlPixFmt = fmtDesc.mtl;
} else if (vkFormat != VK_FORMAT_UNDEFINED) {
// If the MTLPixelFormat is not supported but VkFormat is valid, attempt to substitute a different format.
mtlPixFmt = fmtDesc.mtlSubstitute;

// Report an error if there is no substitute, or the first time a substitution is made.
if ( !mtlPixFmt || !fmtDesc.hasReportedSubstitution ) {
string errMsg;
errMsg += "VkFormat ";
errMsg += (fmtDesc.vkName) ? fmtDesc.vkName : to_string(fmtDesc.vk);
errMsg += " is not supported on this device.";

if (mtlPixFmt) {
((MVKFormatDesc*)&fmtDesc)->hasReportedSubstitution = true;

const MVKFormatDesc& fmtDescSubs = formatDescForMTLPixelFormat(mtlPixFmt);
errMsg += " Using VkFormat ";
errMsg += (fmtDescSubs.vkName) ? fmtDescSubs.vkName : to_string(fmtDescSubs.vk);
errMsg += " instead.";
}
MVKBaseObject::reportError(mvkObj, VK_ERROR_FORMAT_NOT_SUPPORTED, "%s", errMsg.c_str());
}
}

return mtlPixFmt;
return mtlPixFmt;
}

MVK_PUBLIC_SYMBOL VkFormat mvkVkFormatFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
Expand Down

0 comments on commit 0934e32

Please sign in to comment.