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

Add support for VK_EXT_debug_marker extension. #608

Merged
merged 1 commit into from
May 25, 2019

Conversation

billhollings
Copy link
Contributor

@billhollings billhollings commented May 25, 2019

  • Move MVKVulkanAPIObject to its own .h/mm files.
  • Add MVKCmdDebug.h/mm files.
  • Change extension on MVKExtensions.cpp and MVKBaseObject.cpp to .mm.
  • Remove unused command use in MVKQueue submit() and waitIdle() functions.
  • MVKCommandPool constructor use default isPooling value in MVKCommandTypePool constructors.
  • MVKSwapchainImage pass image index in constructor.

Fixes issue #11.

Move MVKVulkanAPIObject to its own .h/mm files.
Add MVKCmdDebug.h/mm files.
Change extension on MVKExtensions.cpp and MVKBaseObject.cpp to .mm.
Remove unused command use in MVKQueue submit() and waitIdle() functions.
MVKCommandPool constructor use default isPooling value in MVKCommandTypePool constructors.
MVKSwapchainImage pass image index in constructor.
@oscarbg
Copy link

oscarbg commented May 27, 2019

Hi @billhollings,
for whatever reason this merge request breaks MoltenVK+DXVK "hacky" working.. verified without this patch it works.. i.e. up to d1aba9a):

only patch needed until now is in MVKDevice.mm in MVKPhysicalDevice::initFeatures() function I add:

   if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v3] ) {
        _features.multiViewport = true;
    }
+    _features.shaderCullDistance = true;
+   _features.geometryShader = true;
+   _features.logicOp = true;
#endif

as you see the patch I use exposes "fake" support for this three features..
don't know if crash it's because of some bad interaction of new debug_marker extension with DXVK or because simply this merge request does more checking forbidding overriding supported features..
can take a look?

Full log of crash:

info:  Game: d3d11-triangle.exe
info:  DXVK: v1.1.1
warn:  OpenVR: Failed to locate module
info:  Enabled instance extensions:
info:    VK_KHR_get_physical_device_properties2
info:    VK_KHR_surface
info:    VK_KHR_win32_surface
[mvk-info] MoltenVK version 1.0.35. Vulkan version 1.0.106.
	The following 34 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_get_memory_requirements2 v1
		VK_KHR_get_physical_device_properties2 v1
		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 v1
		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_variable_pointers v1
		VK_EXT_debug_marker v4
		VK_EXT_debug_report v9
		VK_EXT_host_query_reset v1
		VK_EXT_memory_budget v1
		VK_EXT_shader_viewport_index_layer v1
		VK_EXT_vertex_attribute_divisor v3
		VK_EXTX_portability_subset v1
		VK_MVK_macos_surface v2
		VK_MVK_moltenvk v20
		VK_AMD_gpu_shader_half_float v1
		VK_AMD_negative_viewport_height v1
		VK_NV_glsl_shader v1
[mvk-error] VK_ERROR_INCOMPATIBLE_DRIVER: Request for Vulkan version 1.1.0 is not compatible with supported version 1.0.106.
[mvk-info] GPU device:
		model: AMD Radeon RX Vega 64
		type: Discrete
		vendorID: 0x1002
		deviceID: 0x687f
		pipelineCacheUUID: 00002733-0000-2715-C125-BBD2482815F2
	supports Metal Shading Language version 2.1 and the following Metal Feature Sets:
		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 3 Vulkan extensions enabled:
		VK_KHR_get_physical_device_properties2 v1
		VK_KHR_surface v25
		VK_MVK_macos_surface v2
0048:err:vulkan:wine_vkCreateInstance Failed to create instance, res=-9
warn:  Failed to create Vulkan 1.1 instance, falling back to 1.0
[mvk-info] MoltenVK version 1.0.35. Vulkan version 1.0.106.
	The following 34 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_get_memory_requirements2 v1
		VK_KHR_get_physical_device_properties2 v1
		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 v1
		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_variable_pointers v1
		VK_EXT_debug_marker v4
		VK_EXT_debug_report v9
		VK_EXT_host_query_reset v1
		VK_EXT_memory_budget v1
		VK_EXT_shader_viewport_index_layer v1
		VK_EXT_vertex_attribute_divisor v3
		VK_EXTX_portability_subset v1
		VK_MVK_macos_surface v2
		VK_MVK_moltenvk v20
		VK_AMD_gpu_shader_half_float v1
		VK_AMD_negative_viewport_height v1
		VK_NV_glsl_shader v1
[mvk-info] GPU device:
		model: AMD Radeon RX Vega 64
		type: Discrete
		vendorID: 0x1002
		deviceID: 0x687f
		pipelineCacheUUID: 00002733-0000-2715-C125-BBD2482815F2
	supports Metal Shading Language version 2.1 and the following Metal Feature Sets:
		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 3 Vulkan extensions enabled:
		VK_KHR_get_physical_device_properties2 v1
		VK_KHR_surface v25
		VK_MVK_macos_surface v2
info:  AMD Radeon RX Vega 64:
info:    Driver: 0.2.1843
info:    Vulkan: 1.0.106
info:    Memory Heap[0]: 
info:      Size: 8176 MiB
info:      Flags: 0x1
info:      Memory Type[0]: Property Flags = 0x1
info:      Memory Type[1]: Property Flags = 0xb
info:      Memory Type[2]: Property Flags = 0xf
info:  D3D11CoreCreateDevice: Probing D3D_FEATURE_LEVEL_11_0
info:  D3D11CoreCreateDevice: Using feature level D3D_FEATURE_LEVEL_11_0
info:  Enabled device extensions:
info:    VK_EXT_host_query_reset
info:    VK_EXT_shader_viewport_index_layer
info:    VK_EXT_vertex_attribute_divisor
info:    VK_KHR_dedicated_allocation
info:    VK_KHR_descriptor_update_template
info:    VK_KHR_get_memory_requirements2
info:    VK_KHR_image_format_list
info:    VK_KHR_maintenance1
info:    VK_KHR_maintenance2
info:    VK_KHR_sampler_mirror_clamp_to_edge
info:    VK_KHR_shader_draw_parameters
info:    VK_KHR_swapchain
[mvk-info] Created VkDevice to run on GPU AMD Radeon RX Vega 64 with the following 12 Vulkan extensions enabled:
		VK_KHR_dedicated_allocation v3
		VK_KHR_descriptor_update_template v1
		VK_KHR_get_memory_requirements2 v1
		VK_KHR_image_format_list v1
		VK_KHR_maintenance1 v2
		VK_KHR_maintenance2 v1
		VK_KHR_sampler_mirror_clamp_to_edge v1
		VK_KHR_shader_draw_parameters v1
		VK_KHR_swapchain v70
		VK_EXT_host_query_reset v1
		VK_EXT_shader_viewport_index_layer v1
		VK_EXT_vertex_attribute_divisor v3
info:  DXVK: Read 0 valid state cache entries
info:  DXVK: Using 2 compiler threads
2019-05-27 04:03:29.715 wine64-preloader[56272:364533] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString'
*** First throw call stack:
(
)
libc++abi.dylib: terminating with uncaught exception of type NSException
0048:fixme:seh:call_stack_handlers calling personality routine in system library not supported yet
0048:fixme:seh:call_stack_handlers calling personality routine in system library not supported yet
wine: Assertion failed at address 0x7fff65a4c2c6 (thread 0048), starting debugger...
^CCtrl-C: stopping debuggee
Killed: 9

until this patch it works and log of working sample app (wine d3d11-triangle)

wine d3d11-triangle
info:  Game: d3d11-triangle.exe
info:  DXVK: v1.1.1
warn:  OpenVR: Failed to locate module
info:  Enabled instance extensions:
info:    VK_KHR_get_physical_device_properties2
info:    VK_KHR_surface
info:    VK_KHR_win32_surface
[mvk-info] MoltenVK version 1.0.35. Vulkan version 1.0.106.
	The following 33 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_get_memory_requirements2 v1
		VK_KHR_get_physical_device_properties2 v1
		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 v1
		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_variable_pointers v1
		VK_EXT_debug_report v9
		VK_EXT_host_query_reset v1
		VK_EXT_memory_budget v1
		VK_EXT_shader_viewport_index_layer v1
		VK_EXT_vertex_attribute_divisor v3
		VK_EXTX_portability_subset v1
		VK_MVK_macos_surface v2
		VK_MVK_moltenvk v20
		VK_AMD_gpu_shader_half_float v1
		VK_AMD_negative_viewport_height v1
		VK_NV_glsl_shader v1
[mvk-error] VK_ERROR_INCOMPATIBLE_DRIVER: Request for Vulkan version 1.1.0 is not compatible with supported version 1.0.106.
[mvk-info] GPU device:
		model: AMD Radeon RX Vega 64
		type: Discrete
		vendorID: 0x1002
		deviceID: 0x687f
		pipelineCacheUUID: 00002733-0000-2715-C125-BBD2482815F2
	supports Metal Shading Language version 2.1 and the following Metal Feature Sets:
		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 3 Vulkan extensions enabled:
		VK_KHR_get_physical_device_properties2 v1
		VK_KHR_surface v25
		VK_MVK_macos_surface v2
00c6:err:vulkan:wine_vkCreateInstance Failed to create instance, res=-9
warn:  Failed to create Vulkan 1.1 instance, falling back to 1.0
[mvk-info] MoltenVK version 1.0.35. Vulkan version 1.0.106.
	The following 33 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_get_memory_requirements2 v1
		VK_KHR_get_physical_device_properties2 v1
		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 v1
		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_variable_pointers v1
		VK_EXT_debug_report v9
		VK_EXT_host_query_reset v1
		VK_EXT_memory_budget v1
		VK_EXT_shader_viewport_index_layer v1
		VK_EXT_vertex_attribute_divisor v3
		VK_EXTX_portability_subset v1
		VK_MVK_macos_surface v2
		VK_MVK_moltenvk v20
		VK_AMD_gpu_shader_half_float v1
		VK_AMD_negative_viewport_height v1
		VK_NV_glsl_shader v1
[mvk-info] GPU device:
		model: AMD Radeon RX Vega 64
		type: Discrete
		vendorID: 0x1002
		deviceID: 0x687f
		pipelineCacheUUID: 00002733-0000-2715-C125-BBD2482815F2
	supports Metal Shading Language version 2.1 and the following Metal Feature Sets:
		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 3 Vulkan extensions enabled:
		VK_KHR_get_physical_device_properties2 v1
		VK_KHR_surface v25
		VK_MVK_macos_surface v2
info:  AMD Radeon RX Vega 64:
info:    Driver: 0.2.1843
info:    Vulkan: 1.0.106
info:    Memory Heap[0]: 
info:      Size: 8176 MiB
info:      Flags: 0x1
info:      Memory Type[0]: Property Flags = 0x1
info:      Memory Type[1]: Property Flags = 0xb
info:      Memory Type[2]: Property Flags = 0xf
info:  D3D11CoreCreateDevice: Probing D3D_FEATURE_LEVEL_11_0
info:  D3D11CoreCreateDevice: Using feature level D3D_FEATURE_LEVEL_11_0
info:  Enabled device extensions:
info:    VK_EXT_host_query_reset
info:    VK_EXT_shader_viewport_index_layer
info:    VK_EXT_vertex_attribute_divisor
info:    VK_KHR_dedicated_allocation
info:    VK_KHR_descriptor_update_template
info:    VK_KHR_get_memory_requirements2
info:    VK_KHR_image_format_list
info:    VK_KHR_maintenance1
info:    VK_KHR_maintenance2
info:    VK_KHR_sampler_mirror_clamp_to_edge
info:    VK_KHR_shader_draw_parameters
info:    VK_KHR_swapchain
[mvk-info] Created VkDevice to run on GPU AMD Radeon RX Vega 64 with the following 12 Vulkan extensions enabled:
		VK_KHR_dedicated_allocation v3
		VK_KHR_descriptor_update_template v1
		VK_KHR_get_memory_requirements2 v1
		VK_KHR_image_format_list v1
		VK_KHR_maintenance1 v2
		VK_KHR_maintenance2 v1
		VK_KHR_sampler_mirror_clamp_to_edge v1
		VK_KHR_shader_draw_parameters v1
		VK_KHR_swapchain v70
		VK_EXT_host_query_reset v1
		VK_EXT_shader_viewport_index_layer v1
		VK_EXT_vertex_attribute_divisor v3
info:  DXVK: Read 0 valid state cache entries
info:  DXVK: Using 2 compiler threads
[mvk-info] vkCreate_PLATFORM_SurfaceMVK(): You are not calling this function from the main thread. PLATFORM_VIEW_CLASS should only be accessed from the main thread. When using this function outside the main thread, consider passing the CAMetalLayer itself in Vk_PLATFORM_SurfaceCreateInfoMVK::pView, instead of the PLATFORM_VIEW_CLASS.
info:  Presenter: Actual swap chain properties:
  Format:       VK_FORMAT_B8G8R8A8_SRGB
  Present mode: VK_PRESENT_MODE_IMMEDIATE_KHR
  Buffer size:  632x453
  Image count:  2
[mvk-info] Created 2 swapchain images with initial size (632, 453).
info:  Presenter: Actual swap chain properties:
  Format:       VK_FORMAT_B8G8R8A8_SRGB
  Present mode: VK_PRESENT_MODE_IMMEDIATE_KHR
  Buffer size:  1024x600
  Image count:  3
[mvk-info] Created 3 swapchain images with initial size (1024, 600).
[mvk-info] Shader library compilation succeeded with warnings (Error code 4):
Compilation succeeded with: 

program_source:9:15: warning: unused variable 'omap0_r'
constant uint omap0_r = is_function_constant_defined(omap0_r_tmp) ? omap0_r_tmp : 0u;
              ^
program_source:11:15: warning: unused variable 'omap0_g'
constant uint omap0_g = is_function_constant_defined(omap0_g_tmp) ? omap0_g_tmp : 1u;
              ^
program_source:13:15: warning: unused variable 'omap0_b'
constant uint omap0_b = is_function_constant_defined(omap0_b_tmp) ? omap0_b_tmp : 2u;
              ^
program_source:15:15: warning: unused variable 'omap0_a'
constant uint omap0_a = is_function_constant_defined(omap0_a_tmp) ? omap0_a_tmp : 3u;

@jozefkucia
Copy link
Contributor

#611 should probably fix the crash.

_deviceMemory->_debugName.length == 0) {

_deviceMemory->setDebugName(_debugName.UTF8String);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setDebugName() is called with NULL pointer for dedicated allocation in MVKBuffer::propogateDebugName().

@billhollings billhollings added Bug Completed Issue has been fixed, or enhancement implemented. labels May 27, 2019
@billhollings
Copy link
Contributor Author

@oscarbg

As @jozefkucia mentioned, there was a null pointer error introduced in this PR. PR #616 fixes it. Can you retest with latest MoltenVK and close this if it fixes the issue?

@oscarbg
Copy link

oscarbg commented May 29, 2019

@billhollings just tested and issue is fixed.. thanks.. I didn't open any issue, just commented here, so nothing to close, right?.. finally don't want to open separate issue, but can SPIRV-Cross dependency be updated to latest? just interested on "MSL: Add support for subgroup operations." and also in "Support emitting OpLine directive." can this OpLine support help in your last efforts to support debug extensions in some way, or mapping original source code in "Xcode Metal debugger"? thanks as always..

@billhollings
Copy link
Contributor Author

@oscarbg D'oh! Sorry...nothing to close here of course. I'm used to copying that out on issues.

@billhollings
Copy link
Contributor Author

interested on "MSL: Add support for subgroup operations." and also in "Support emitting OpLine directive

@cdavis5e Is it useful to bring the latest SPIRV-Cross in? Are these SPIRV-Cross features stand-alone...or are we waiting on compatible changes to MoltenVK?

@cdavis5e
Copy link
Collaborator

@cdavis5e Is it useful to bring the latest SPIRV-Cross in? Are these SPIRV-Cross features stand-alone...or are we waiting on compatible changes to MoltenVK?

Subgroup operations need Vulkan 1.1. We can't support that yet, because we don't support multiview. According to the 1.1 spec, multiview is a required feature. This needs further work on SPIRV-Cross, to support the ViewId builtin.

On the other hand, the latest SPIRV-Cross also supports emulating OpArrayLength. But, we need to make some changes to MoltenVK to accommodate this, as well as some name changes in the SPIRV-Cross API. I have a patch to do all that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Completed Issue has been fixed, or enhancement implemented.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants