So you may have seen that I’ve been writing a tutorial series on OpenGL. This is targeting OpenGL 4.5/4.6 and so I need to be able to run the tutorial code and make sure it’s doing what I’m trying to teach.
The issue is that MacOS only supports opengl up to version 4.1. That rules out some stuff that I wan’t to incorporate into the series (multidrawIndirect being one of the features required).
I do have a desktop machine at home and also an intel nuc (which I tend to use more because I don’t really need to have a 24 core dual xeon machine on all the time and fan noise is important to me). The thing is, is that I don’t want to be sitting at a desk to use my desktop. I already spend most of my day at a desk and I like to step away from that if I can. I had back surgery last year, so sitting all day isn’t a great idea.
So I like to grab my M1 macbook and retreat to the lounge/living room where I can hangout with my wife and watch some TV after the kids/monsters have gone to bed (The Crown being the current binge).
So how can I write blog posts and tweak code on a mac? Well for now the workaround is to use Parallels Desktop and run a Ubuntu Virtual Machine. This is great because I can use the mesa project to run a gallium driver called llvmpipe to run my OpenGL code. This runs all the graphics on the CPU and it runs at a decent enough speed that for the simple tutorial cases, it’s just like running on a real GPU. The debug validation I get is great as well and I can run this both in software and on nvidia hardware to make sure that the code is correct across platforms.
Another benefit is that the M1 Macbook stays completely silent during this time, so I’m not disturbing anyone while we watch tv.
The other option I have just started testing is vnc-ing into my intel nuc from a different room over wifi.(I’ve got a powered ethernet connection I’m going to try as well).
So that’s one reason why the tutorials are targeting an OpenGL 4.5 context, because llvmpipe at the moment exposed 4.5 and should hopefully allow anyone with a laptop even without a graphics chip that can do OpenGL 4.5 can follow along and see their code run.
I found out from the very smart and very cool person @DaveAirlie that there is one things stopping llvmpipe from being 4.6 conformant and that is Anisotropic Texture Filtering which will hopefully come soon.
I’m hoping that zink at some point in the near future will come to the rescue and allow modern opengl on macs running on top of MoltenVK. There are a few features that MoltenVK is lacking at the moment so that will be an interesting space to watch. Also there will need to be a custom MacOS windowing system integration for Zink. I’ve been staying up late at night browsing mesa code to see how that all works and it is a deep hole to go down! I’m making notes as I go so maybe in a few months I’ll have a handle on it (a window handle you might say ;p).