Skip to content

Mac: Update MoltenVk to 1.2.7 #15052

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

Merged
merged 2 commits into from
Jan 16, 2024
Merged

Mac: Update MoltenVk to 1.2.7 #15052

merged 2 commits into from
Jan 16, 2024

Conversation

Megamouse
Copy link
Contributor

  • Remove deprecated extension VK_MVK_moltenvk

fixes #15050

@Megamouse Megamouse added OS: macOS Build and CI Anything related to the build process and continuous integration Driver: MoltenVK Open-source macOS Vulkan driver labels Jan 15, 2024
@shinra-electric
Copy link
Contributor

I gave this a try, but am getting build errors with the following:
Device.cpp
VKHelpers.cpp
VKShaderInterpreter.cpp
VKVertexBuffers.cpp
VKResourceManager.cpp
VKDraw.cpp
VKTexture.cpp
VKPresent.cpp
VKTextureCache.cpp
VKGSRender.cpp

Here is a truncated log (starting from where the errors happen):
mvk terminal output.txt

Also, if we build MVK locally instead of using Homebrew we should change the tag in CMakeLists.txt here to 66f6ff1

@Megamouse Megamouse force-pushed the moltenvk branch 2 times, most recently from 4a98716 to 619ac5f Compare January 15, 2024 23:23
@Megamouse
Copy link
Contributor Author

I gave this a try, but am getting build errors with the following: Device.cpp VKHelpers.cpp VKShaderInterpreter.cpp VKVertexBuffers.cpp VKResourceManager.cpp VKDraw.cpp VKTexture.cpp VKPresent.cpp VKTextureCache.cpp VKGSRender.cpp

Here is a truncated log (starting from where the errors happen): mvk terminal output.txt

Also, if we build MVK locally instead of using Homebrew we should change the tag in CMakeLists.txt here to 66f6ff1

Try again please

@shinra-electric
Copy link
Contributor

Yes, it is building successfully now.

@Megamouse
Copy link
Contributor Author

I wonder if the fastMath and resumeLostDevice settings are stíll working.

@shinra-electric
Copy link
Contributor

shinra-electric commented Jan 15, 2024

I wonder if the fastMath and resumeLostDevice settings are still working.

I presume if fastMath is not working we'd get a performance hit.

Also, for the record, here is the changelog for mvk 1.2.7:

Changelog
  • Add support for extensions:
    • VK_KHR_calibrated_timestamp
    • VK_KHR_format_feature_flags2
    • VK_KHR_vertex_attribute_divisor
    • VK_EXT_extended_dynamic_state3 (Metal does not support VK_POLYGON_MODE_POINT)
    • VK_EXT_headless_surface
    • VK_EXT_layer_settings
  • Add support for format VK_FORMAT_B4G4R4A4_UNORM_PACK16.
  • Add support for vertex formats VK_FORMAT_B10G11R11_UFLOAT_PACK32 & VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.
  • Fix regression that broke VK_POLYGON_MODE_LINE.
  • Fix regression in marking rendering state dirty after vkCmdClearAttachments().
  • Fix regression error in argument buffer runtime arrays.
  • Fix rare deadlock during launch via dlopen().
  • Fix initial value of VkPhysicalDeviceLimits::timestampPeriod on non-Apple Silicon GPUs.
  • Fix swapchain and surface bugs when windowing system is accessed from off the main thread.
  • Fix system memory size of tvOS.
  • Fix heapUsage query for non-unified memory devices.
  • Add a defensive guard to ensure heapUsage[0] calculation is correct.
  • Clamp max per-set descriptor limit to minimum 1024.
  • Enable the cube texture gradient workaround for Apple Silicon.
  • Ensure lineWidthGranularity is zero if the wideLines feature isn't supported.
  • Ensure maxDrawIndexedIndexValue set to UINT32_MAX.
  • Ignore no external handle types specified for buffers and images.
  • Expose VK_EXT_debug_utils device functions as device functions, not instance functions.
  • Emit primitiveRestartEnable disabled warning only for strip topology.
  • Enable mandatory VK_EXT_descriptor_indexing features, and don't advertise extension if they are not supported.
  • Reduce disk space consumed after running fetchDependencies script by removing intermediate file caches.
  • Deprecate vkSetMoltenVKConfigurationMVK().
  • Deprecate mvk_config.h and move content to mvk_private_api.h and mvk_deprecated_api.h.
  • The Cube demo is now based on Volk, with dynamic library linking, and dynamic function pointer calls.
  • Update copyright notices to year 2024.
  • Update dependency libraries to match Vulkan SDK 1.3.275.
  • Update to latest SPIRV-Cross:
    • MSL: Fix regression error in argument buffer runtime arrays.
    • MSL: Work around broken cube texture gradients on Apple Silicon.
    • MSL: Ensure discrete runtime arrays of buffers have known length.
    • MSL: Implement Metal 3.1 image atomics natively.
    • MSL: Fix patch vertex count with raw buffer tese input.
    • MSL: Improve handling of sample masks.
    • MSL: Add divide to reserved function names.
    • MSL: Support std140 half matrices and arrays.
    • MSL: Use more appropriate padded types.
    • MSL: Don't use swizzle if we have wrapper.
    • MSL: Add ray-cull mask
    • MSL: Consider PtrAccessChain on array types.
    • MSL: Use LHS expression to determine whether or not to do array copy.
    • MSL: Only do address-of expression when needed.
    • MSL: Improve PtrAccessChain handling.
    • MSL: Use powr instead of pow.
    • MSL: Remove special case for threadgroup array wrapper.
    • MSL: Added an Op field to SPIRType and refactor.

@Megamouse
Copy link
Contributor Author

Megamouse commented Jan 15, 2024

@shinra-electric Please try opening the rpcs3 settings and confirm that opening it doesn't take longer due to the added vulkan instance setting.

@shinra-electric
Copy link
Contributor

@shinra-electric Please try opening the rpcs3 settings and confirm that opening it doesn't take longer due to the added vulkan instance setting.

Do you mean just opening the config settings in the toolbar? I don't notice any difference...

@Megamouse
Copy link
Contributor Author

@shinra-electric Please try opening the rpcs3 settings and confirm that opening it doesn't take longer due to the added vulkan instance setting.

Do you mean just opening the config settings in the toolbar? I don't notice any difference...

yes. thanks.

@nastys
Copy link
Contributor

nastys commented Jan 16, 2024

I presume if fastMath is not working we'd get a performance hit.

fastMath is enabled by default, so if the code for disabling it doesn't work, some games such as Ratchet and Clank won't render correctly even if fast math is explicitly disabled in the graphics settings.

@Megamouse Megamouse force-pushed the moltenvk branch 2 times, most recently from 5a21e9c to 309d423 Compare January 16, 2024 00:29
@shinra-electric
Copy link
Contributor

shinra-electric commented Jan 16, 2024

fastMath is enabled by default, so if the code for disabling it doesn't work, some games such as Ratchet and Clank won't render correctly even if fast math is explicitly disabled in the graphics settings.

It looks like the option to disable fastMath is not working. I tested R&C [NPEA00385]:

Master (Disable MSL Fast Math option selected):
Screenshot 2024-01-16 at 09 31 22

PR (Disable MSL Fast Math option selected):
Screenshot 2024-01-16 at 09 37 44

@Megamouse
Copy link
Contributor Author

Megamouse commented Jan 16, 2024

@shinra-electric can you try replacing VK_LAYER_SETTING_TYPE_INT32_EXT (the type of the setting) with MVKConfigFastMath ?
Also replace the type of the variable itself with MVKConfigFastMath

@Megamouse
Copy link
Contributor Author

We may also need to push the VK_EXT_layer_settings extension
extensions.push_back(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME);

@shinra-electric
Copy link
Contributor

@shinra-electric can you try replacing VK_LAYER_SETTING_TYPE_INT32_EXT (the type of the setting) with MVKConfigFastMath ? Also replace the type of the variable itself with MVKConfigFastMath

I don't know what I'm doing with C++...

I tried changing this:

layers.push_back(kMVKMoltenVKDriverLayerName);

const VkBool32 setting_true = VK_TRUE;
const int32_t setting_fast_math = g_cfg.video.disable_msl_fast_math.get() ? MVK_CONFIG_FAST_MATH_NEVER : MVK_CONFIG_FAST_MATH_ON_DEMAND;

const std::vector<VkLayerSettingEXT> settings{
	{ kMVKMoltenVKDriverLayerName, "MVK_CONFIG_RESUME_LOST_DEVICE", VK_LAYER_SETTING_TYPE_BOOL32_EXT, 1, &setting_true },
	{ kMVKMoltenVKDriverLayerName, "MVK_CONFIG_FAST_MATH_ENABLED", VK_LAYER_SETTING_TYPE_INT32_EXT, 1, &setting_fast_math }
};

to this:

layers.push_back(kMVKMoltenVKDriverLayerName);
extensions.push_back(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME);

const VkBool32 setting_true = VK_TRUE;
const int32_t setting_fast_math = g_cfg.video.disable_msl_fast_math.get() ? MVK_CONFIG_FAST_MATH_NEVER : MVK_CONFIG_FAST_MATH_ON_DEMAND;

const MVKConfigFastMath settings{
	{ kMVKMoltenVKDriverLayerName, "MVK_CONFIG_RESUME_LOST_DEVICE", VK_LAYER_SETTING_TYPE_BOOL32_EXT, 1, &setting_true },
	{ kMVKMoltenVKDriverLayerName, "MVK_CONFIG_FAST_MATH_ENABLED", MVKConfigFastMath, 1, &setting_fast_math }
};

..but the build fails. Am I doing it correctly? I think I'm not, as I don't see why the resumeLostDevice would be of type MVKConfigFastMath....

@Megamouse
Copy link
Contributor Author

No lol. Replace the type of setting_fast_math with MVKConfigFastMath.
The type of settings should remain std::vector...

@shinra-electric
Copy link
Contributor

No lol. Replace the type of setting_fast_math with MVKConfigFastMath. The type of settings should remain std::vector...

Yeah, I didn't think it looked right 😅

I replaced the type of setting_fast_math from int32_t to MVKConfigFastMath:

layers.push_back(kMVKMoltenVKDriverLayerName);
extensions.push_back(VK_EXT_LAYER_SETTINGS_EXTENSION_NAME);

const VkBool32 setting_true = VK_TRUE;
const MVKConfigFastMath setting_fast_math = g_cfg.video.disable_msl_fast_math.get() ? MVK_CONFIG_FAST_MATH_NEVER : MVK_CONFIG_FAST_MATH_ON_DEMAND;

const std::vector<VkLayerSettingEXT> settings{
	{ kMVKMoltenVKDriverLayerName, "MVK_CONFIG_RESUME_LOST_DEVICE", VK_LAYER_SETTING_TYPE_BOOL32_EXT, 1, &setting_true },
	{ kMVKMoltenVKDriverLayerName, "MVK_CONFIG_FAST_MATH_ENABLED", MVKConfigFastMath, 1, &setting_fast_math }
};

...and it still fails.
Here is the terminal output:
RPCS3 Output.txt

@Megamouse
Copy link
Contributor Author

try with the latest update then.

@shinra-electric
Copy link
Contributor

try with the latest update then.

Yes, it works correctly with the latest update:
Screenshot 2024-01-16 at 17 52 01

@Megamouse Megamouse merged commit e23db7e into RPCS3:master Jan 16, 2024
@Megamouse Megamouse deleted the moltenvk branch January 17, 2024 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build and CI Anything related to the build process and continuous integration Driver: MoltenVK Open-source macOS Vulkan driver OS: macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MoltenVK] [macOS] Can't update to MVK 1.2.7 as vkSetMoltenVKConfigurationMVK is deprecated
4 participants