News for hackers. Stuff that matters.
Re:Vulkan in 30 minutes by panic on Tuesday February 16, 2016 @07:06PM (#11114124)
The sample code shows just how absurdly explicit this API is. 200 lines to get a triangle on the screen!
Re:Vulkan in 30 minutes by yason on Wednesday February 17, 2016 @01:15AM (#11115735)
AFAIK, the point of Vulkan is to get to modelling the hardware as possible. It's not even supposed to be a high-level API but allow efficient access to today's GPUs.

OpenGL is an abstract state machine and it requires a great deal of effort to convert that state into what today's GPUs are actually capable of efficiently handling. Getting that triangle onto the screen in OpenGL is maybe 20 lines of code but you will have 200,000 lines of code in the OpenGL driver translating the commands into the actual configuration of the hardware unit. And if you want to draw 2 million triangles you will have to work hard to work around the overhead introduced by the OpenGL implementation.

Then again, OpenGL can be reimplemented on top of Vulkan for end-developers and more complex game engines will be written against Vulkan directly, and then people will work on those instead of writing direct Vulkan code. Once you get the building blocks right you can build on top of them layers of abstraction that suit what you need.

This is in contrast to the current situation where the abstractions are fixed and don't necessarily suit the end-developer nor the driver developer. Today you need to implement your game or graphics engine abstraction (which you will use yourself) in terms of OpenGL (requiring lots of tricks), then the OpenGL driver has to implement OpenGL in terms of the actual hardware (again, requiring a lot of clever trickery to handle and transform the state efficiently) and as a result the pixels will show up on the screen but at the cost of a potentially huge overhead which could be introduced somewhere along the route.

Re:Vulkan in 30 minutes by mpweiher on Wednesday February 17, 2016 @03:54AM (#11116338)
Yup. The way I understand it is that graphics pipelines today (maybe always) are quite different from the procedural API that OpenGL provides. That mismatch causes all sorts of problems, for example that using the OpenGL APIs "naturally" can be extremely inefficient, whereas trying to access the GPU pipeline naturally is really convoluted and you have to get it just right in non-obvious ways.

The structure of the GPU pipeline appears to be sufficiently settled that we can now expose it more directly. That way, talking to the GPU in a way that's natural for the GPU is at least straightforward, even if it's arduous.

It seems like you should now be able to build APIs that are both at a higher level and not in conflict with how the hardware actually works.

Re:Vulkan in 30 minutes by PopsiclePete on Wednesday February 17, 2016 @09:04AM (#11117874)
Ok so is Vulkan basically assembly code targeting GPU's? If so, my only question is - why the heck did it take so long for it to get here?
Re:Vulkan in 30 minutes by ajuc on Wednesday February 17, 2016 @10:23AM (#11118401)
It's more like C than like assembly.

Different GPUs have different machine codes, Vulkan is abstracting away the differences, but tries (like C) to be simple abstraction close to the real thing.

Re:Vulkan in 30 minutes by skoczymroczny on Wednesday February 17, 2016 @04:02AM (#11116380)
Well, in OpenGL it would take you at least 100 lines of code. Don't forget that glBegin and fixed function pipeline is deprecated nowadays. Sure, with that you can draw a triangle in 10 lines. For modern OpenGL you have to create vertex and fragment shaders, send uniforms, create vertex buffers, upload vertex data, set up vertex attributes, and only then can you render. Vulkan is just the next step of that. Also, a lot of Vulkan code is something you will wrap once, and unless you need the absolute best performance and finetuning you can just stash it in some utility method. Creating an image takes 40 lines of code? Put it into a create_default_image() method and it's only one line of code from now on.
Re:Vulkan in 30 minutes by foodmart on Tuesday February 16, 2016 @07:18PM (#11114167)
With great power, comes great responsibility. For those who don't prefer this level of abstraction, just use a higher level zero cost abstraction.
Re:Vulkan in 30 minutes by Narishma on Tuesday February 16, 2016 @08:44PM (#11114562)
The higher level abstractions aren't zero-cost.
Re:Vulkan in 30 minutes by lmm on Wednesday February 17, 2016 @07:58AM (#11117523)
No reason they can't be.
Re:Vulkan in 30 minutes by samstave on Tuesday February 16, 2016 @07:21PM (#11114180)
This might be a completely ignorant question;

How can there not be an drawing app built on top of this so that you can just model/draw and have it translate??

Re:Vulkan in 30 minutes by whatever_dude on Tuesday February 16, 2016 @08:13PM (#11114431)
There will be.

The point of Vulkan wasn't to change the OpenGL API to something else. It was to expose more of what the inner workings of a modern graphics card is, and to remove ambiguity introduced by higher level abstractions used by OpenGL. It is more of a direct translation of what can be done with a graphics driver.

This means that developers (engine writers) who want to can now get a lower level access to what the graphics card can do, and do so in a more deterministic fashion.

Everyone else will be able to use higher-level abstractions that will undoubtedly appear, and those probably be easier to use than OpenGL itself. Best of all, they'll be open source so anyone can dig in and tweak (or understand) something rather than forever depend on some obscure OpenGL behavior no one really understands.

There will be growing pains. The existing engine codebases are heavily based on OpenGL, as are helper libraries. That will need to change. Things won't just be faster overnight. But judging by what I read, in the long run it will be better for everyone involved.

Re:Vulkan in 30 minutes by 0942v8653 on Tuesday February 16, 2016 @07:34PM (#11114250)
There will be. That's open source's job.

Vulkan isn't a complete replacement for OpenGL; it's a GPU API aimed to be built upon.

Re:Vulkan in 30 minutes by Turbo_hedgehog on Tuesday February 16, 2016 @07:44PM (#11114312)
The goal is to have a cross-platform low level API that can be easily tested for compliance/conformance, right?
Re:Vulkan in 30 minutes by azernik on Tuesday February 16, 2016 @10:51PM (#11115136)
Also one that exposes graphics card mechanics so that higher-level tools can use them more intelligently for optimization purposes.

A good analogy is the RISC transition - implementations were made easier and faster, but as a tradeoff assembly was made much more difficult to program in. The idea being that only a small group of tool-makers with specialized knowledge of the underlying mechanics (in that case compiler developers, in this case engine developers) would ever have to deal with them.

Re:Vulkan in 30 minutes by sdegutis on Tuesday February 16, 2016 @07:34PM (#11114255)
I don't know, I feel like D3 solidly demonstrated that you can have absolute configurability without sacrificing any conciseness.
Re:Vulkan in 30 minutes by ajross on Tuesday February 16, 2016 @11:34PM (#11115326)
D3 is not remotely an abstraction API for a hardware compute engine. Vulkan isn't about "configurability", it's about cleanly expressing the specific operations that the hardware can perform, and the specific requirements for talking to it. Those are complicated, inherently. Data graphing, fundamentally, is "simple" in comparison (and to be fair, D3 exploits that beautifully).
Re:Vulkan in 30 minutes by hodwik on Tuesday February 16, 2016 @08:57PM (#11114632)
D3 is not concise compared with most simple js graphing libs -- e.g. highcharts.
Re:Vulkan in 30 minutes by scardine on Tuesday February 16, 2016 @09:51PM (#11114893)
I agree, but it is not fair to compare D3 and highcharts because they are not in the same league.

There are many higher level libraries leveraging on D3 that could be compared to highcharts. There are also many lower level libraries that have the same scope as D3, and compared to most of them D3 is pretty concise - the parent comment has a point.

Re:Vulkan in 30 minutes by exDM69 on Wednesday February 17, 2016 @04:08AM (#11116408)
200 lines for a triangle is roughly comparable to what it takes on D3D or Metal. This is the level of control that graphics and engine programmers require to make things run efficiently.
Re:Vulkan in 30 minutes by mrec on Wednesday February 17, 2016 @07:27AM (#11117346)
That's D3D12, presumably.
Re:Vulkan in 30 minutes by sgift on Wednesday February 17, 2016 @05:07AM (#11116743)
This only tells me that it is not the right API for putting one triangle on a screen. Sounds okay? APIs (or programming languages or frameworks or ...) which are build for "big things" often have a certain amount of boiler plate required that looks absurd when you use them for something extremely small, but doesn't matter for something bigger.
Re:Vulkan in 30 minutes by sklogic on Wednesday February 17, 2016 @07:12AM (#11117279)
Next thing you'll complain about would be on how absurdly explicit the x86 ISA is. So many instructions just to get "Hello, world" printed.
Re:Vulkan in 30 minutes by gcb0 on Wednesday February 17, 2016 @02:40AM (#11116043)
openGL was a good idea. But drivers were buggy as hell and every vendor was adding their own extensions like crazy.

Vulkan is the F-that solution. They removed most unifying abstractions, made the API turn the video card into a general computer and let the engine developers do the hardware compatibility layer instead of the developers, since they were doing that work indirectly on top of the drivers bugs anyway.

and wow, it is really exactly 200 lines.

Re:Vulkan in 30 minutes by andresmanz on Wednesday February 17, 2016 @05:38AM (#11116881)
Oooh, yes. It couldn't get any better, right? The amount of control you have here is just perfect.

If you don't like that, just wait a few days. I'm sure there will be tons of libraries that let you do that with a few lines of code.