ScintillatorSynth / Scintillator

A Video Synthesis Engine for SuperCollider
https://scintillatorsynth.org
56 stars 8 forks source link

Swiftshader MacOS crash on swapchain creation #70

Open lnihlen opened 4 years ago

lnihlen commented 4 years ago

Offscreen render contexts seem to work fine, but there's a crash in swiftshader when trying to create the swapchain. Callstack looks like:

Process 52511 launched: '/Users/luken/src/Scintillator/bin/scinsynth.app/Contents/MacOS/scinsynth' (x86_64)
[mvk-info] MoltenVK version 1.0.40. Vulkan version 1.0.131.
    The following 48 Vulkan extensions are supported:
        VK_KHR_16bit_storage v1
        VK_KHR_8bit_storage v1
        VK_KHR_bind_memory2 v1
        VK_KHR_dedicated_allocation v3
        VK_KHR_descriptor_update_template v1
        VK_KHR_device_group v4
        VK_KHR_device_group_creation v1
        VK_KHR_get_memory_requirements2 v1
        VK_KHR_get_physical_device_properties2 v2
        VK_KHR_get_surface_capabilities2 v1
        VK_KHR_image_format_list v1
        VK_KHR_maintenance1 v2
        VK_KHR_maintenance2 v1
        VK_KHR_maintenance3 v1
        VK_KHR_push_descriptor v2
        VK_KHR_relaxed_block_layout v1
        VK_KHR_sampler_mirror_clamp_to_edge v3
        VK_KHR_shader_draw_parameters v1
        VK_KHR_shader_float16_int8 v1
        VK_KHR_storage_buffer_storage_class v1
        VK_KHR_surface v25
        VK_KHR_swapchain v70
        VK_KHR_swapchain_mutable_format v1
        VK_KHR_uniform_buffer_standard_layout v1
        VK_KHR_variable_pointers v1
        VK_EXT_debug_marker v4
        VK_EXT_debug_report v9
        VK_EXT_debug_utils v1
        VK_EXT_fragment_shader_interlock v1
        VK_EXT_hdr_metadata v2
        VK_EXT_host_query_reset v1
        VK_EXT_inline_uniform_block v1
        VK_EXT_memory_budget v1
        VK_EXT_metal_surface v1
        VK_EXT_scalar_block_layout v1
        VK_EXT_shader_stencil_export v1
        VK_EXT_shader_viewport_index_layer v1
        VK_EXT_swapchain_colorspace v4
        VK_EXT_texel_buffer_alignment v1
        VK_EXT_vertex_attribute_divisor v3
        VK_EXTX_portability_subset v1
        VK_MVK_macos_surface v2
        VK_MVK_moltenvk v24
        VK_AMD_gpu_shader_half_float v2
        VK_AMD_negative_viewport_height v1
        VK_AMD_shader_trinary_minmax v1
        VK_INTEL_shader_integer_functions2 v1
        VK_NV_glsl_shader v1
[mvk-info] GPU device:
        model: AMD Radeon Pro 5500M
        type: Discrete
        vendorID: 0x1002
        deviceID: 0x7340
        pipelineCacheUUID: 00002738-0300-07D2-F981-8F0804E6E73E
    supports the following Metal Versions, GPU's and Feature Sets:
        Metal Shading Language 2.2
        GPU Family Mac 2
        GPU Family Mac 1
        GPU Family Common 3
        GPU Family Common 2
        GPU Family Common 1
        macOS GPU Family 2 v1
        macOS GPU Family 1 v4
        macOS GPU Family 1 v3
        macOS GPU Family 1 v2
        macOS GPU Family 1 v1
        macOS Read-Write Texture Tier 2
[mvk-info] GPU device:
        model: Intel(R) UHD Graphics 630
        type: Integrated
        vendorID: 0x8086
        deviceID: 0x3e9b
        pipelineCacheUUID: 00002738-0300-07D2-F981-8F0804E6E73E
    supports the following Metal Versions, GPU's and Feature Sets:
        Metal Shading Language 2.2
        GPU Family Mac 2
        GPU Family Mac 1
        GPU Family Common 3
        GPU Family Common 2
        GPU Family Common 1
        macOS GPU Family 2 v1
        macOS GPU Family 1 v4
        macOS GPU Family 1 v3
        macOS GPU Family 1 v2
        macOS GPU Family 1 v1
[mvk-info] Created VkInstance with the following 4 Vulkan extensions enabled:
        VK_KHR_get_physical_device_properties2 v2
        VK_KHR_surface v25
        VK_EXT_debug_utils v1
        VK_EXT_metal_surface v1
Process 52511 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x22)
    frame #0: 0x000000013023cb85 libvk_swiftshader.dylib`::vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice=0x000000010349ced8, surface=(handle = 4350436288), pSurfaceCapabilities=0x00007ffeefbfdaa0) at libVulkan.cpp:3333:21
   3330     TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities = %p)",
   3331           physicalDevice, static_cast<void *>(surface), pSurfaceCapabilities);
   3332 
-> 3333     vk::Cast(surface)->getSurfaceCapabilities(pSurfaceCapabilities);
   3334     return VK_SUCCESS;
   3335 }
   3336 
Target 0: (scinsynth) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x22)
  * frame #0: 0x000000013023cb85 libvk_swiftshader.dylib`::vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice=0x000000010349ced8, surface=(handle = 4350436288), pSurfaceCapabilities=0x00007ffeefbfdaa0) at libVulkan.cpp:3333:21
    frame #1: 0x00000001018b039b libvulkan.1.dylib`terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice=0x00000001034bcc20, surface=0x00000001034e63c0, pSurfaceCapabilities=0x00007ffeefbfdaa0) at wsi.c:293:12
    frame #2: 0x00000001157bf02f libVkLayer_khronos_validation.dylib`DispatchGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice_T*, VkSurfaceKHR_T*, VkSurfaceCapabilitiesKHR*) + 95
    frame #3: 0x000000011569c8d5 libVkLayer_khronos_validation.dylib`vulkan_layer_chassis::GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice_T*, VkSurfaceKHR_T*, VkSurfaceCapabilitiesKHR*) + 277
    frame #4: 0x00000001018b01ea libvulkan.1.dylib`vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice=0x00000001034bed50, surface=0x0000020000000002, pSurfaceCapabilities=0x00007ffeefbfdaa0) at wsi.c:256:20
    frame #5: 0x00000001000e22a3 scinsynth`scin::comp::Swapchain::create(this=0x00000001034c0460, window=0x00000001034c7b50, directRendering=true) at Swapchain.cpp:62:5
    frame #6: 0x00000001000ea009 scinsynth`scin::comp::Window::create(this=0x00000001034c7b50) at Window.cpp:53:23
    frame #7: 0x000000010013d6de scinsynth`main(argc=2, argv=0x00007ffeefbff948) at scinsynth.cpp:179:22
    frame #8: 0x00007fff6b2a07fd libdyld.dylib`start + 1
    frame #9: 0x00007fff6b2a07fd libdyld.dylib`start + 1
(lldb)

It looks like there's potentially some odd interaction with glfw, see all the moltenvk log chatter in the above debug log.

lnihlen commented 4 years ago

It looks like glfw is assuming MoltenVK is the vulkan device of record when running on MacOS. Swiftshader breaks that assumption, and it's causing a crash somewhere within its internals.