21 ms·
So if I'm reading this right, there is still no such thing as a standard graphics API. There's OpenGL, there's Direct3D, there's other hardware-specific APIs (M
by pdonis 6y ago
So if I'm reading this right, there is still no such thing as a standard graphics API. There's OpenGL, there's Direct3D, there's other hardware-specific APIs (Metal and Vulkan are mentioned), and now Qt is inventing their own API to abstract over all these APIs.
How is having a standard API to draw 3D graphics not a solved problem at this point?
- Impossible 6y agoGPU hardware is varied and changes frequently. Many API features are partially or entirely implemented in software (drivers or API runtime) complicating things. Console, mobile and desktop parts are different in terms of functionality. OpenGL is probably the closest to runs on everything. BGFX, sokol, WebGPU and other abstraction layers might be good fits as well. I think options are pretty good if you just want rasterized triangles, vertex and fragment shaders (and maybe compute). As you start to need better performance or other parts of the pipeline options are less clear cut.
- Jasper_ 6y agoThe game revs ruined it for everyone else ;) The revisionist history: AAA game developers are used to console APIs. Which do exactly what you tell them to at the hardware, no sugar coating or drivers in the way. Having shipped a few games, drivers are indeed a terrible curse. One vendor's D3D11 drivers are pretty notorious for being incredibly invasive to your game in the goal of speed, making it difficult to ship content that was consistent across devices. Another vendor, sick of having to turn their driver into a rocket engine, found common ground with some game developers, and made a prototype, Mantle, which showed real-world performance gains on game content. But it was pretty specific to how their hardware and GPUs worked. But given that Xbox wanted performance, Microsoft was I intrigued and worked closely with that vendor to design the next-generation Direct3D API. Meanwhile, the vendor with the super fancy drivers had a pretty major chokehold on OpenGL, which is just an absolute terrible mess of a bad API. It's an API that is so backwards and difficult that nobody likes it from the driver or the application perspective, but given that this vendor had the best drivers for it, they didn't want to lose it. But Mantle vendor wanted to shake things up and submitted Mantle to Khronos, the organization that standardizes OpenGL, to form the basis for the "gl-next" initiative. Mobile GPU vendors get invo.ved and turn the design into a mess. The original engineers who designed Mantle left their parent company over design disagreements to go join Apple, who also had a vested interest in getting rid of OpenGL but had little desire to use gl-next. This is Metal. Ultimately, D3D12 is Microsoft's turf. Nobody likes Vulkan but it's there on Android and Stadia and Linux and is pretty mediocre there. And Metal is pretty well-rounded but is the domain of Apple. 3D rendering has always been a mess, but now it's even worse because tiles exist, data bandwidth is crazy expensive, and game revs need more fidelity and FPS than ever before. Synchronizing between coprocessors is now the job of the application.
- ekianjo 6y ago> Nobody likes Vulkan but it's there on Android and Stadia and Linux and is pretty mediocre there. Mediocre on Linux? Since when?
- dcow 6y agoDidn't Vulkan omit a way to query for active displays so you just have to pick a random display index when your application starts up? Other than that I thought Vulkan was pretty decently comparable to Metal. I don't have any first hand experience with it though.
- josefx 6y agoThat sounds more as if it would be a window system specific issue? As far as I know OpenGL didn't have that kind of API either and you had to use X11 and the glX bindings for that kind of information.
- phire 6y ago> Microsoft was I intrigued and worked closely with that vendor to design the next-generation Direct3D API. I've heard "accusations" that it was actually the inverse. Microsoft and that vendor were working together on next gen consoles, including the new D3D12 API. But Microsoft weren't planning to release it on windows until long after the xbox one released. The vendor wanted something to show off now, so they pulled together Mantel in a reasonably short time-frame and announced/launched it before D3D12 was even in an announceable state. I have idea if these "accusations" are true, it's just what I've heard.
- smallstepforman 6y agoI didn't know that Johan Andersson, from DICE (Battlefield) fame who created Frostbite (the EA engine), the creator of Mantle spec, joined Microsoft. Is your data correct?
- boltzmann_brain 6y ago
- esperent 6y agoThis sentence from the article offers a clue. Of course Apple are not the only bad actors here. But basically, it's company politics. > So at some point, the engine stopped working on macOS. Mostly because Apple doesn’t want people to use OpenGL, so they’re starving their drivers from development
- adamnemecek 6y agoWebGPU is going to be dope. It goes beyond the web. https://github.com/gfx-rs/wgpu-rs https://github.com/gfx-rs/wgpu-rs
- deleted 6y ago[deleted]
- badsectoracula 6y agoPolitics mainly. We could have OpenGL but Microsoft wanted their own so they made Direct3D and ATI and Intel were unable to make both Direct3D and OpenGL work properly (because most people targeted Direct3D anyway so why bother?) so after SGI bankrupted themselves, Khronos was formed and they decided to define a new OpenGL from scratch to help ATI and Intel claim they have OpenGL (they pay money after all) so they built the core profile but ATI-now-AMD and Intel failed to make that work too (since people still targeted Direct3D so why bother?) so to help them again they decided to ignore OpenGL and make Vulkan which kinda seems to work for now but AMD and Intel took their time to produce certified drivers and Vulkan doesn't look that popular (though Direct3D 12 which is essentially the same thing also isn't that popular either, but the alternative tends to be Direct3D 11 so still no reason to bother fixing OpenGL) so who knows for how long this will work? Apple was in the OpenGL train initially but like their Java and X11 support that was so they have some easy ports of important stuff and once they got a sniff of popularity they ditched anything non-Apple because why bother maintaining something others control? That is my interpretation of the story so far anyway. And i didn't mention OpenGL ES which is OpenGL in name only but not in anything that really matters - but thanks to iOS and Android it became popular even though both of these devices had more than enough power to handle the proper thing instead of the crippled down version that was originally designed for J2ME feature phones that couldn't even do floating point math. On the positive side, OpenGL is still the API that has the most wide availability and of all APIs the one that has the most reimplementations on top of other APIs - though in both cases you'll want to stick to older versions, but TBH versions were always a fluid thing with OpenGL anyway, you're not supposed to think in versions but in extensions.
- cmroanirgo 6y agoI also recall the early days of D3D (Immediate mode), which although it came after OpenGL, immediate mode allowed better integration with the cards at the time (notably 3dfx) and OpenGL did not have hardware drivers, which meant it was limited to software rendering. So, if you were into game dev, then D3D was your only option early on. My recollection was that it wasn't until NVidia started up (and broke 3dfx by poaching engineers) that OpenGL started to become 'better'. Intel was left in the dust until mobo support for DMA (?around DX5?), which allowed cards to gain quick access to RAM, which was vital for texturing (you always had to 'upload' textures to the card itself prior to that). It was the final nail in the coffin for 3fdx at that point, who still hadn't released a new card for ages, and OpenGL was finally on par with D3D. D3D had a retained mode which began to be really useful by about that time too. At the time, many people wanted to use OpenGL because it was loads easier than Immediate Mode and a lot more intuitive to grok. I recall a certain prominant Doom developer berating D3D loudly in a private email list (John Cormack) about this very fact. Ironically, a few months later some guys released a demo for a game called "Unreal" using D3D and everyone was blown away. (circa 1995-6). More ironically, it wasn't for another year that GL Quake came to fruition.
- vbezhenar 6y agoYou need an abstraction over different hardware implementations to have a standard API. Abstraction comes with a cost. And 3D graphics applications want to utilize hardware at its fullest capability. So basically it's not a simple problem. Especially considering that hardware is constantly evolving, inventing new approaches. For example I learned OpenGL about 15 years ago and I never used any shaders. Now, AFAIK, shaders are everywhere. Probably the best thing you could do at this point is to use game engine like Unity or UE as an abstraction.
- slx26 6y agoThe problem here is that abstraction comes at a cost, and that cost is so great that we need even crazier abstractions to be able to work around it... and now the suggestion is, as you say, work with a whole engine. Ah, now I can draw a pixel on screen! I see it as a lot of wasted potential (even if maybe not that much wasted commercial potential).
- zanny 6y agoMeanwhile we have been compiling the same C and above code for mips, arm, power, x86, and riscv for decades in portable ways while still getting performant code. Now to be fair GPUs have a legacy of slowly becoming generic processors whereas 10+ years ago they were largely fixed function hardware. Writing generic code for a GPU today is totally sensible because it supports most arithmetic, primitive types, branching, etc. But there is nothing stopping you from optimizing your compiler for glsl any more than optimizing your platform specific custom vendor compiler for C.
- vbezhenar 6y agoYou still write performance-critical code using assembly language. C compiler is not ideal.
- Reelin 6y ago> How is having a standard API to draw 3D graphics not a solved problem at this point? It seems like it mostly is? The problems described in the article appear to be due to a mismatch between how QT and Krita do things under the hood. OpenGL has broad support (except Apple). The OpenGL ES subset adds web browsers and lots of embedded devices. ANGLE provides translation of ES to D3D, Vulkan, and soon even Metal. Vulkan seems to work pretty much everywhere (except Apple of course). MoltenVK provides translation of v1.0 to Metal. If departing native hardware APIs is acceptable, gfx-rs appears to work today. WebGPU is well on it's way to being fully implemented. Plus (as the article mentions) apparently QT6 is intending to introduce their own custom abstraction layer?
- coldtea 6y ago>Vulkan seems to work pretty much everywhere (except Apple of course). There's Molten.
- zapzupnz 6y agoIndeed, which is now managed by Khronos itself.
- boudewijnrempt 6y agoOpenGL works badly on MacOS and even worse on Windows unless translated through Angle. On Windows, using OpenGL directly will give performance problems and crashes _all the time_. And weird bugs, like red and blue swap on some combinations of AMD GPU's and driver versions.
- Reelin 6y ago> On Windows, using OpenGL directly will give performance problems and crashes _all the time_. Didn't the original (Java) version of Minecraft use OpenGL? It seems to have done well enough...
- pjmlp 6y agoExcept PlayStation, Android until version 10, Win32 and UWP sandboxing.
- erikbye 6y agoThere are abstraction layers utilizing either, but many implement their own.
- jfkebwjsbx 6y agoA couple of corrections, if you don't mind... Vulkan is not hardware-specific, it is an open, cross platform standard like OpenGL. Direct3D is not standard, but it is so well supported and used (even in Linux!) that you can consider it one.
- jcelerier 6y agoAs a data point I've been developing the visual side of Https://ossia.io with the new Qt RHI and it's been a breeze.
- boudewijnrempt 6y agoI'll check it out... Does it use QML and the scenegraph, or does it have a custom C++ canvas widget implementation?
- jcelerier 6y agothe software's "main editor" uses a very traditional QGraphicsScene with a QGLWidget - no QML / QtQuick (QtQuick is a very good tool for a lot of usecases, but not the right tool for this one particular "traditional big desktop app" job imho). The RHI-using part is for creating custom visuals (think applying various shaders to video & camera inputs for VJ), so I wrote my own scene / render graph leveraging it which renders in separate windows through QRhi.
- boudewijnrempt 6y agoThat sounds interesting. I've cloned score and libossia, but I haven't found that code yet. Could you point me at it?
- jcelerier 6y ago95% of the RHI code is in there: https://github.com/OSSIA/score/tree/master/src/plugins/score-addon-gfx/Gfx/Graph https://github.com/OSSIA/score/tree/master/src/plugins/score... - Window: https://github.com/OSSIA/score/blob/master/src/plugins/score-addon-gfx/Gfx/Graph/window.hpp https://github.com/OSSIA/score/blob/master/src/plugins/score... - Renderer: https://github.com/OSSIA/score/blob/master/src/plugins/score-addon-gfx/Gfx/Graph/renderer.cpp https://github.com/OSSIA/score/blob/master/src/plugins/score... - Example of a very simple node which renders a texture generated by a std::function: https://github.com/OSSIA/score/blob/master/src/plugins/score-addon-gfx/Gfx/Graph/texgennode.hpp https://github.com/OSSIA/score/blob/master/src/plugins/score... It was mostly written at my Ballmer peak during last year's christmas / new year's eve though :-) so lacks code quality a fair bit. There's a graph of nodes. The graph is walked from every output node (screen surfaces) to create a matching "rendered node" (pretty much a render pass). For every node "model", a node "renderer" will be created, which contains uniforms, GPU buffer (QRhiBuffer) & texture (QRhiTexture) handles, etc. and a QRhiGraphicsPipeline (the state in which the GPU must be to render a node, the VAOs, shader programs, layout, culling, blending, etc etc) Then every time the output node renders due to vsync or whatever, the associated chain of node (render passes) is executed in order. I recommend looking at the RHI manual tests in the qt source, they show the usage in a very straightforward manner: https://code.qt.io/cgit/qt/qtbase.git/tree/tests/manual/rhi?h=v5.15.0 https://code.qt.io/cgit/qt/qtbase.git/tree/tests/manual/rhi?... In particular, I started with this one : https://code.qt.io/cgit/qt/qtbase.git/tree/tests/manual/rhi/triquadcube/trianglerenderer.cpp?h=v5.15.0 https://code.qt.io/cgit/qt/qtbase.git/tree/tests/manual/rhi/...
- akvadrako 6y agoIt is mostly a solved problem. OpenGL is the old high-level standard, Vulkan is the new standard, though it's closer to the hardware. WebGPU is the main contender for a new high-level standard, which will probably mostly run on Vulkan. Only Apple doesn't support Vulkan, but nobody can force them to.
- jfkebwjsbx 6y agoWebGPU is not high-level, no? It is closer to Vulkan than to OpenGL. And I am not sure Vulkan runs everywhere... what about consoles?
- q3k 6y ago> And I am not sure Vulkan runs everywhere... what about consoles? The Nintendo Switch supports it. Playstations had their own custom proprietary API since forever, and Microsoft peddles their own API on Xbox.
- pjmlp 6y agoSwitch supports it alongside NVN and OpenGL 4.5, and most engines end up using NVN. Unity alone accounts for 50% of the games.
- akvadrako 6y ago> WebGPU is not high-level, no? Right - what I read is performant WebGPU is more consistent than Vulkan between GPU vendors and I understood that to mean higher-level. But perhaps it's just a promise of a better design.
- skocznymroczny 6y agoWebGPU is very similar to Metal. While it is closer to Vulkan than to OpenGL, it's still higher level than Vulkan and easier to use.
- pjmlp 6y agoOnly on the Switch, and even then they have their own API, NVN, which is what most AAA and middleware like Unity actually use.
- pjmlp 6y agoAnd LibGNM, LibGNMX, GX, NVN, the APIs that game consoles actually use.
- fulafel 6y ago> How is having a standard API to draw 3D graphics not a solved problem at this point? The problems come from having proprietary GPU hardware ISAs. And baseless optimism about working around that by the magic of software.
- PaulDavisThe1st 6y agoCould we just get 2D figured out before adding another dimension?