Live data from Hacker News

Clip control on the Apple GPU

rosenzweig.io

41–50 of 127 posts

Re: Clip control on the Apple GPU

#41
post #19

Can someone explain to me why support OpenGL at all? Vulkan is easier to implement. Is there a need for OpenGL on Linux?

Because Vulkan, despite the mystical reputation it has in gaming circles, actually has fairly low adoption vs OpenGL . Very few applications in the grand scheme of things use Vulkan, and a minority of games do. Therefore the ROI on supporting OpenGL is very high.

Doesn’t implementing Vulkan give you DirectX with DXVK and VKD3D and OpenGL with Zink for free?

Re: Clip control on the Apple GPU

#43
post #32
post #30

Earlier quoted context omitted.

Vertex/triangle clipping is quite rare, and mostly used for clipping against the near plane (hopefully rare in practice). Most other implementations use a guard band as a fast path (aka doing it in screen space) -- real clipping is only used where your guard band doesn't cover you, precision issues mostly. I'm not sure what issues you're hitting, but I've never found clipping to be that challenging or difficult. Also…

> clipping against the near plane (hopefully rare in practice) I am not sure I understand why this would be rare. If I am intending to construct a rasterizer for a first-person shooter, clipping is essentially mandatory for all but the most trivial of camera arrangements.

Yes, of course, I was definitely imagining you were struggling to get simpler scenes to work. But also, proportionally few of your triangles in any given scene should be near-plane clipped. It's OK to have a slow path for it, and then speed it up later. I've never felt the math for the adjusted barycentrics is too hard, but it can take a bit to wrap your head around. Good luck :)

Re: Clip control on the Apple GPU

#45
post #28

Despite the progress here, for me it raises a question: Most of the old games she mentions are x86 32bit games. What's the story for how these programs are actually going to run in Asahi? Box86 [1] doesn't sound like it's projected to run on M1. Rosetta 2 on macOS allows 32-bit code to be run by a 64-bit process, which is the workaround CrossOver et. al. use (from what I understand), but that obviously won't be avail…

Someone would need to make an x86 -> ARM recompiler like Rosetta 2. That's not an easy task, but also not the task she's tackling with the GPU driver.

It's not unprecedented in the open-source space though; the PCSX2 PlayStation 2 emulator for example contains a MIPS -> x86 recompiler, and the RPCS3 PlayStation 3 emulator contains a Cell -> x86 recompiler.

Re: Clip control on the Apple GPU

#46
OpenGL on macOS is so frustrating, that I and many other developers have basically abandoned it, and not in favor of using Metal--the easier alternative is to just no longer support Macs.

Yes, OpenGL on macOS is now implemented over Metal, but unfortunately a side effect of this is that implementation-level details that were critical to debugging and profiling OpenGL just no longer exist for tools to work with. Anything is possible? Maybe? I'm sure Apple Graphics engineers could make old tooling work with the new abstraction layer, but it's not happening.

Tooling investment is all on Metal now. But so much existing NON-LEGACY software relied on OpenGL.

So what do you do? You debug and perf test on Windows and Linux and hope that fixing issues there addresses concerns on macOS, and hopefully your problems aren't platform-specific.

This is how some graphics engineers, including myself, continue to ship for macOS while never touching it.

Edit: Also, Vulkan is a waste of time for anyone who isn't a large studio. No one wants to write this stuff. The most common argument is "You only write it once." No, you don't.

You have to support this stuff. If it were that easy, bgfx would have been written in a month and it would have been considered "done" afterwards.

Re: Clip control on the Apple GPU

#48
post #3

> Here’s a little secret: there are two graphics APIs called “Metal”. There’s the Metal you know, a limited API that Apple documents for App Store developers, an API that lacks useful features supported by OpenGL and Vulkan. > And there’s the Metal that Apple uses themselves, an internal API adding back features that Apple doesn’t want you using. Apple does stuff like this so much and gets so little flak for it. I us…

> Apple does stuff like this so much and gets so little flak for it.

Why should they get flak for having internal APIs? The fact that the internal API is a superset of the external API is smart engineering.

Think about it this way: Apple could just as well have made the "Metal that Apple uses themselves" some arcane "foocode" IR language or something, as I'm sure many shader compilers and OpenGL runtime implementations do, and nobody would be nearly as mad about it.

The fact that they use internal APIs for external apps in their weird iOS walled garden is obnoxious, but having private, undocumented APIs in a closed-source driver is not exactly an Apple anomaly.

Re: Clip control on the Apple GPU

#50
post #28

Despite the progress here, for me it raises a question: Most of the old games she mentions are x86 32bit games. What's the story for how these programs are actually going to run in Asahi? Box86 [1] doesn't sound like it's projected to run on M1. Rosetta 2 on macOS allows 32-bit code to be run by a 64-bit process, which is the workaround CrossOver et. al. use (from what I understand), but that obviously won't be avail…

Rosetta 2 runs on Linux. There's also FEX.
Post reply on HN