VirGL for old versions of Mac OS X?

Creating ultra fast virtual machines of old operating systems for fun and profit
Post Reply
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

VirGL for old versions of Mac OS X?

Post by MattKC »

So far I've been treating "retro GPU passthrough" as a kind of preservation project which allows people to get old OSes running to their fullest extent without needing a whole PC from that era. But there is a snag in that it does require some old hardware. Not a whole computer, but a GPU which will almost certainly die one day (in fact, arguably, one of the most likely components in your PC to die).

While I like hardware, I also very much understand the only way to truly preserve something is to emulate it. No physical object lasts forever, but data and software can, simply because they can transcend the medium they're originally stored on.

So while my HD 2400 Pro still doesn't fully work in OS X, and I've been entertaining reverse engineering the old ATI kexts to figure out what's wrong, I've been wondering if there are perhaps better solutions that wouldn't rely on anyone else needing to have this specific card.

I briefly considered emulating a real Mac version of the HD 2400 (or something similar), and while I'm sure that would be an intellectually stimulating project, my guess is it would take years (assuming I didn't give up after a single month).

But there is a Linux technology that's rather interesting. When an OS tries to use OpenGL, it needs to open up a context on a GPU. VirGL allows a guest VM to open up an OpenGL context on the host GPU. I've been testing it out and it actually seems to work pretty well. Since we're talking about older versions of OS X here (pre-Metal) that are entirely OpenGL, this actually theoretically could make for a pretty good solution, without needing extra hardware and without the overhead of emulating an entire GPU.

Only problem is, this technology currently only works on Linux guests. It's not that it can't work on other OSes, it's just that Windows primarily uses DirectX so OpenGL passthrough isn't that useful (a driver was apparently being worked on but seems to have been abandoned now), and Apple has never publicly documented how to write a 3D accelerator (pretty much entirely so people can't get a good experience in a VM).

But none of that means it's impossible, it just means it requires a little reverse engineering. There's also already an open source framebuffer kext for running OS X in VMware/QEMU (IOFramebuffer actually is publicly documented) so that's at least some of the work already done.

I'm not saying I'm going to start work on this any time soon (already got my hands full with other projects), but I wanted to hear if anyone else had any thoughts, and say that it's something I might be interested in working on one day.
User avatar
Wam
Posts: 26
Joined: Thu Dec 08, 2022 12:55 pm

Re: VirGL for old versions of Mac OS X?

Post by Wam »

While I can definitely say this'd be incredibly incredibly hot and cool and also based I do wonder how possible it'd be. I'm far from an expert on how macOS handles GPUs but one thing I do know is it changes quite a lot between versions of the operating system, there's a reason Nvidia's Web Drivers back when they existed (rest in piece) were tied to not only a specific OS version but even a specific *build* of the macOS kernel.

That said I'd love to see this be something that like, exists, and I know that at least some of the things you'd need to build it do already exist like MacKernelSDK but as mentioned documentation on IOGraphicsFamily and friends is loose on the ground. It's also worth noting we've got a pretty hard cutoff around 10.11 when Metal was introduced and OpenGL slowly started becoming deprecated.

Either way, I'm more than willing to do what I can to get the ball rolling on a project like this.
foxlet
Posts: 6
Joined: Wed Jul 19, 2023 7:34 pm

Re: VirGL for old versions of Mac OS X?

Post by foxlet »

This is a bit of an tangent, but with the Windows remark... from what I remember, the softGPU project has a TODO to work on a virGL driver for Windows 9x (as both an OpenGL ICD, and Glide emulated on top). In theory it would be possible to do the same with DirectX by passing it through wined3d (using OpenGL as a backend).
Post Reply