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

Metal rendering driver fails to run on Apple's software Metal implementation (paravirtual device) #101773

Open
Calinou opened this issue Jan 18, 2025 · 6 comments

Comments

@Calinou
Copy link
Member

Calinou commented Jan 18, 2025

Tested versions

  • Reproducible in: 4.4.beta 7b1ed52

System information

GitHub Actions

Issue description

The Metal rendering driver fails to run on Apple's software Metal implementation (paravirtual device):

 Metal 3.1 - Forward+ - Using Device #0: Apple - Apple Paravirtual device (Apple5)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppleParavirtDevice newArgumentEncoderWithLayout:]: unrecognized selector sent to instance 0x15186e800'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000019c1722cc __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000019bc56158 objc_exception_throw + 60
	2   CoreFoundation                      0x000000019c224568 -[NSObject(NSObject) __retain_OA] + 0
	3   AppleParavirtGPUMetalIOGPUFamily    0x0000000114fb0f5c doUncompressedBlit + 11180
	4   Metal                               0x00000001a643cec4 -[_MTLDevice newArgumentEncoderWithArguments:structType:] + 136
	5   godot.macos.editor.universal        0x00000001048b74b0 _ZN9DirAccess15_create_builtinI13DirAccessUnixEE3RefIS_Ev + 3011780
	6   godot.macos.editor.universal        0x0000000107161a68 _ZN17RendererSceneCull8Instance18dependency_deletedERK3RIDP17DependencyTracker + 165848
	7   godot.macos.editor.universal        0x000000010730b378 _ZN22RendererCanvasRenderRD22_create_material_funcsEPN10RendererRD15MaterialStorage10ShaderDataE + 98132
	8   godot.macos.editor.universal        0x0000000107db8fd8 _ZNK6Object22can_translate_messagesEv + 265940
	9   godot.macos.editor.universal        0x0000000107db9bb4 _ZNK6Object22can_translate_messagesEv + 268976
	10  godot.macos.editor.universal        0x000000010777b3ec _ZN7ClassDB7creatorIN9core_bind14EngineDebuggerEEEP6Objectb + 35228
	11  godot.macos.editor.universal        0x000000010777b7d0 _ZN7ClassDB7creatorIN9core_bind14EngineDebuggerEEEP6Objectb + 36224
	12  libsystem_pthread.dylib             0x000000019c01df94 _pthread_start + 136
	13  libsystem_pthread.dylib             0x000000019c018d34 thread_start + 8
)
libc++abi: terminating due to uncaught exception of type NSException

This is most likely because the GPU exposed via paravirtualization is only Apple5, but we need a newer GPU. See also JuliaGPU/Metal.jl#309. While it's unlikely we can cater to the Apple5 GPU, we should exit with a proper error message (one that refers to the paravirtualized device not being supported) instead of crashing.

For context, I'm looking to run the Metal renderer on CI so we can check for visual regressions. I have this working on Vulkan/OpenGL on Linux already using llvmpipe, and on D3D12 on Windows using WARP (the official software implementation of Direct3D).

This is the command line I'm using on CI as part of https://github.com/Calinou/godot/tree/ci-check-visual-regressions:

godot --audio-driver Dummy --path tests/visual_regressions --rendering-driver metal --rendering-method forward_plus -- --save-results

cc @stuartcarnie

Steps to reproduce

  • Try running a Godot project with --rendering-driver metal on a headless platform with no GPU (e.g. GitHub Actions). Do not use the --headless flag at the same time.

Minimal reproduction project (MRP)

N/A

@stuartcarnie
Copy link
Contributor

Interesting – as that suggests that the features check for using argument encoders is not working as expected in the virtualised environment. I would not expect the argument encoder API to be called at all on an Apple5 GPU.

You can force-disable them by running with the following environment variable to see if that works:

GODOT_DISABLE_ARGUMENT_BUFFERS=1

I have also found VirtualBuddy, which allows us to run virtual macOS machines, so I can try it through that too.

@stuartcarnie
Copy link
Contributor

From reading that Julia link, it looks like it probably won't work anyhow. I'll still try and see how it goes.

@stuartcarnie
Copy link
Contributor

stuartcarnie commented Jan 19, 2025

@Calinou interestingly, it works locally in a paravirtual device via VirtualBuddy:

Image

I suspect it might be because my host hardware

@bruvzg
Copy link
Member

bruvzg commented Jan 21, 2025

interestingly, it works locally in a paravirtual device via VirtualBuddy:

It might be fixed in Sequoia VMs, but GitHub CI macos-latest runner seems to be Sonoma.

MoltenVK seems to have the same issue - KhronosGroup/MoltenVK#2373 (comment)

@onurtnrkl onurtnrkl marked this as a duplicate of #101873 Jan 21, 2025
@fire
Copy link
Member

fire commented Jan 24, 2025

#101994 is affected by the bug.

@bruvzg
Copy link
Member

bruvzg commented Jan 29, 2025

For the reference: I have tested it in multiple UTM macOS VMs, it works on Sequoia and crashes on Sonoma and older. All have a GPU identified as Apple5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants