vulkano: The triangle example crashes with UnsupportedDimensions on MacOS 10.12 + MoltenVK

I’m using a 2017 MacBook Pro with Intel Iris Graphics 550 1536 MB and a 2560 x 1600 display.

The example builds successfully, and when I run it, it starts fine, printing some messages, including: [mvk-info] You require a license for the MoltenVK Vulkan Core feature set. Reverting to evaluation mode

After that, it panics when creating a new Swapchain. The error is UnsupportedDimensions. Debug-printing the dimensions passed to the new method, the dimensions turn out to be [2048, 1536]. The device capabilities are

Capabilities {
	min_image_count: 2,
	max_image_count: Some(2),
	current_extent: Some([1024, 768]),
	min_image_extent: [1024, 768],
	max_image_extent: [1024, 768],
	max_image_array_layers: 1, 
	supported_transforms: SupportedSurfaceTransforms {
		identity: true, 
		rotate90: false, 
		rotate180: false, 
		rotate270: false, 
		horizontal_mirror: false, 
		horizontal_mirror_rotate90: false, 
		horizontal_mirror_rotate180: false, 
		horizontal_mirror_rotate270: false, 
		inherit: false
	}, 
	current_transform: Identity, 
	supported_composite_alpha: SupportedCompositeAlpha {
		opaque: true, 
		pre_multiplied: true, 
		post_multiplied: true, 
		inherit: false
	}, 
	supported_usage_flags: ImageUsage {
		transfer_source: true, 
		transfer_destination: true, 
		sampled: true, 
		storage: true, 
		color_attachment: true, 
		depth_stencil_attachment: false, 
		transient_attachment: false, 
		input_attachment: false
	}, 
	supported_formats: [
		(B8G8R8A8Unorm, SrgbNonLinear),
		(B8G8R8A8Srgb, SrgbNonLinear),
		(R16G16B16A16Sfloat, SrgbNonLinear)
	], 
	present_modes: SupportedPresentModes {
		immediate: false, 
		mailbox: false, 
		fifo: true, 
		relaxed: false
	}
}

So it seems that it fails because of the max/min image extent checks.

I’m not knowledgeable enough to determine which of these values are wrong, but if I understand the meaning of max/min_image_extent capabilities right, it seems odd to me that the device supports only that. What should I do to fix this or to diagnose the problem further?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 29 (17 by maintainers)

Most upvoted comments

So, I think I solved the HiDPI bug. In Vulkano-win, when setting up the CAMetalLayer, the scaling factor of the layer has to be set, like this: layer.set_contents_scale(view.backingScaleFactor());. However, the wrapper for the setContentsScale API wasn’t implemented in metal-rs, so I sent a pull request: https://github.com/gfx-rs/metal-rs/pull/10 Hopefully it will be pulled in quickly.

Also, according to the docs ( https://developer.apple.com/documentation/appkit/nsview/1483695-wantslayer ) if you set the layer of the view manually, setWantsLayer must be called AFTER the layer has been set:

In addition to creating a layer-backed view, you can create a layer-hosting view by assigning a layer directly to the view’s layer property. In a layer-hosting view, you are responsible for managing the view’s layer. To create a layer-hosting view, you must set the layer property first and then set this property to true. The order in which you set the values of these properties is crucial.

Currently setWantsLayers is set before:

let view = wnd.contentView();
view.setWantsLayer(YES);
view.setLayer(mem::transmute(layer.0)); // Bombs here with out of memory

Fixing these things, it reports the extents of the surface correctly and the resolution is correct.