4 ms·
> Metal takes Direct3D's object-oriented approach one step further by combining it with the more "verbal" API design common in Objective-C and Swift in an attem
by andrekandre 10mo ago
> Metal takes Direct3D's object-oriented approach one step further by combining it with the more "verbal" API design common in Objective-C and Swift in an attempt to provide a more intuitive and easier API for app developers to use (and not just game developers) and to further motivate those to integrate more 3D and general GPU functionality into their apps.
slightly off-topic perhaps, but i find it amazing that an os-level 3d graphics api can be built in such a dynamic language as objective-c; i think it really goes to show how much optimization put in `objc_msgSend()`... it does a lot of heavy lifting in the whole os.
- Rohansi 10mo agoModern graphics APIs minimize the number of graphics API calls vs. OpenGL and similar. Vulkan/Metal/DirectX 12 will have you pass command buffers with many commands in them instead of separate API calls for everything.
- pmalynin 10mo agoYes and https://reviews.llvm.org/D69991 https://reviews.llvm.org/D69991
- adamnemecek 10mo agoThere is a Metal Obj-C API, Metal implementation is C++.
- almostgotcaught 10mo agoNo it's not - the compiler for MSL is of course C++ because it's LLVM but the runtime is absolutely written in objc (there weren't even C++ bindings until recently).
- adamnemecek 10mo agoNo, I mean what is inside the Objective-C objects. Essentially everything on macOS has an Objective-C API but is implemented using C++. Have you ever noticed the ".cxx_destruct" method on like all objects? What you are talking about are C++ wrappers around Metal Objective-C API. Yes, it is weird as they are going C++ -> Objective-C -> C++. Why not go directly? Because Apple does not ship C++ systems frameworks. The term is Objective-C++.
- jasonwatkinspdx 10mo agoIt's been possible for quite some time. In the early 2000's there was a book on using Direct3D from C# that was pretty influential as far as changing people's assumption that you couldn't do high performance graphics in a GC'd language. In the end a lot of the ideas overlap with what c/c++ gamedevs do, like structuring everything around fixed sized tables allocated at load time and then minimal dynamic memory usage within the frame loop. The same concepts can apply at the graphics API level. Minimize any dynamic language overhead by dispatching work in batches that reference preallocated buffers. That gets the language runtime largely out of the way.
- monster_truck 10mo agoNo, it doesn't. You won't find it used much if at all at these levels of the OS. Once you get past cocoa and friends it's restricted subsets of C++ (IOKit for example)
- pjmlp 10mo agoYes it does, see NeXTSTEP, even the drivers were written in Objective-C.