News for hackers. Stuff that matters.
Re:Vulkan Tutorial by legulere on Monday July 18, 2016 @09:51AM (#12115000)
> the advantage of being fully cross-platform

I would scratch the fully, it's not on iOS or macOS

Re:Vulkan Tutorial by vardump on Monday July 18, 2016 @12:00PM (#12115847)
At least it's the most cross platform low level graphics API.

DirectX 12 is Windows only and Metal is iOS/macOs only.

Hopefully we'll get a standard API for graphics one day. Lack of it is holding us back.

Maybe Vulkan can be the TCP of graphics APIs. Something that provides stable foundations for building fancy graphics stacks on top.

Re:Vulkan Tutorial by hellofunk on Monday July 18, 2016 @09:56AM (#12115030)
Re:Vulkan Tutorial by rdsnsca on Tuesday July 19, 2016 @09:24PM (#12126233)
Pretty sure that version of Vulkan will be running on top of Apple's Metal.
Re:Vulkan Tutorial by pjmlp on Monday July 18, 2016 @10:27AM (#12115199)
Neither on any Android < Android N, or any console produced by Sony, Nintendo and Microsoft.
Re:Vulkan Tutorial by zanny on Monday July 18, 2016 @11:04AM (#12115454)
Sony and Nintendo have both announced Vulkan support on their next console iterations.
Re:Vulkan Tutorial by maccard on Monday July 18, 2016 @11:49AM (#12115774)
Sony historically supported OpenGL too, and approximately 0 games ever shipped with it.
Re:Vulkan Tutorial by vardump on Monday July 18, 2016 @11:56AM (#12115821)
Vulkan could very well be a different story, it doesn't have OpenGL's shortcomings.
Re:Vulkan Tutorial by pjmlp on Monday July 18, 2016 @01:00PM (#12116346)
The PS4 API is already much better than Vulkan.
Re:Vulkan Tutorial by SeanDav on Tuesday July 19, 2016 @10:18AM (#12121898)
How well does the PS4 API work on Windows, Linux and Android?

That is kind of the point of Vulcan.

Re:Vulkan Tutorial by pcwalton on Monday July 18, 2016 @02:14PM (#12117000)
Can you describe how, specifically?
Re:Vulkan Tutorial by pjmlp on Monday July 18, 2016 @03:40PM (#12117582)
Here is a NDA free presentation I can point to.

http://develop.scee.net/wp-content/uploads/2014/11/ParisGC20...

Starts on slide 32 for the graphics part.

Re:Vulkan Tutorial by pcwalton on Monday July 18, 2016 @05:47PM (#12118243)
As I suspected, all of the features that I can see described here are in Vulkan. In particular, the first couple of slides pretty much identically resemble Vulkan's "elevator pitch".

The presentation is from 2014, so when they claim "better than DirectX", they're referring to pre-DX12. It certainly doesn't back up your claim that it's "much better" than Vulkan.

Re:Vulkan Tutorial by pjmlp on Tuesday July 19, 2016 @01:39AM (#12119974)
I can only give you what isn't under NDA.

Like another user has commented, the PS4 low level API is like Assembly in terms of hardware control, whereas the higher level, is is similar to Vulkan in API surface, is a bit more like C in terms of control.

Another area where the PS4 APIs are better is infrastructure, meaning graphical debuggers, libraries and OS integration.

Also the amount of production code experience that both Sony and licensed developers have with the whole stack.

So why would Sony throw all this away, just to make some Reddit and HN users happy, that wouldn't anyway make games for the PS4?

Re:Vulkan Tutorial by pcwalton on Tuesday July 19, 2016 @01:01PM (#12122967)
> Like another user has commented, the PS4 low level API is like Assembly in terms of hardware control, whereas the higher level, is is similar to Vulkan in API surface, is a bit more like C in terms of control.

And as I've argued here, that isn't a plus. I don't believe that game developers are producing better GPU assembly than an optimizing backend can.

> Another area where the PS4 APIs are better is infrastructure, meaning graphical debuggers, libraries and OS integration.

That isn't part of the API. That's part of the tooling.

> Also the amount of production code experience that both Sony and licensed developers have with the whole stack.

That isn't part of the API either.

> So why would Sony throw all this away, just to make some Reddit and HN users happy, that wouldn't anyway make games for the PS4?

Er, nobody is talking about "throwing all of this away". I'm simply questioning your claim that Vulkan is worse than what Sony created for the PS4.

Re:Vulkan Tutorial by sangnoir on Tuesday July 19, 2016 @07:11AM (#12121034)
> So why would Sony throw all this away, just to make some Reddit and HN users happy, that wouldn't anyway make games for the PS4?

They won't have to discard their API - they can support Vulkan and their current API and make everyone happy. In this case 'everyone' includes people who would like to port their Vulkan games to PSNext as well as Vulkan-based graphics/game engines.

Re:Vulkan Tutorial by pandaman on Monday July 18, 2016 @09:44PM (#12119030)
What is the SRT equivalent in Vulkan if you don't mind me asking? What about DispatchDraw?
Re:Vulkan Tutorial by Overv on Tuesday July 19, 2016 @07:48AM (#12121152)
Descriptor layouts are the equivalent of SRT in Vulkan. It is unclear to me what exactly DispatchDraw is for, because back-face and offscreen culling are standard features of any graphics pipeline.
Re:Vulkan Tutorial by pandaman on Tuesday July 19, 2016 @10:24AM (#12121942)
>Descriptor layouts are the equivalent of SRT in Vulkan.

I am not sure how. I do not use Vulkan, I use GNM. I asked this because implementing SRT does not seem possible in a platform independent API. So I checked the docs again and the descriptor layout is the same thing I remember - a set of bindings you manage through a bunch of API calls. On the other hand SRT is a plain c-structure. You pass a pointer to structure to a shader as a parameter. Exactly as same as you pass a structure to a function in C/C++. You don't need APIs to create sturctures, you can store them in a file, you can write them from another shader etc. etc.

> It is unclear to me what exactly DispatchDraw is for, because back-face and offscreen culling are standard features of any graphics pipeline.

It's pretty clear what is it for if you actually wrote real-time graphics. JFYI - it's "index shader" essentially. Having control over indices you can implement much faster culling.

Re:Vulkan Tutorial by pcwalton on Tuesday July 19, 2016 @01:26PM (#12123205)
> It's pretty clear what is it for if you actually wrote real-time graphics. JFYI - it's "index shader" essentially. Having control over indices you can implement much faster culling.

This sounds like indirect draw, which has been standard for years and is supported by Vulkan.

Re:Vulkan Tutorial by pandaman on Tuesday July 19, 2016 @01:52PM (#12123438)
Indirect draw is a draw, which instead of direct arguments (number of indices, number of instances, offsets) takes an address of a structure with these parameters. It does not create indices. You could use it for culling but only on the level of a whole draw. DispatchDraw generates indices in a shader and can do a triangle level culling among other things.
Re:Vulkan Tutorial by pcwalton on Tuesday July 19, 2016 @07:47PM (#12125806)
> It does not create indices

You combine it with a Compute Shader to create the indices. Indirect draw is how you make those indices available to the drawing functionality.

Re:Vulkan Tutorial by pandaman on Tuesday July 19, 2016 @08:53PM (#12126113)
Sure, it's possible, but it would be much slower(just for going off chip, not taking synchronization into account) than just letting all triangles through so it has no practical application. Again, even if this had been practical, it does not make DD same as ID. You can draw anything with OpenGl 1.0 but it does not make it the same API as Vulcan, does it?
Re:Vulkan Tutorial by bitbiter on Monday July 18, 2016 @03:53PM (#12117671)
Vulcan, DirectX 12, and Metal are basically like C. They're made to be as low level as possible while maintaining hardware portability.

With the PS4 hardware is locked so their API is more like assembly (or maybe inline assembly in a C program) where you're doing specific hardware operations.

They also provide a second graphics API that wraps that one, working basically at the same level as Direct3D 11 or OpenGL.

This article might be of interest: http://www.eurogamer.net/articles/digitalfoundry-inside-play...

Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @04:27PM (#12117871)
It's not better, it's lower level than even Vulkan, and Vulkan itself is already very low level. Sure you can go as low as hardware specific machine code in theory. The question is whether it's something needed, or it's an overkill for most intents and purposes.

Consoles had a distinct need for assembly like level APIs - their hardware had very long update cycle (7+ years), so it used to quickly become outdated, and developers had to go to insane lengths to squeeze performance out of it. It's not only very costly to do it, it can't be reused (it's all platform specific). Currently consoles are moving away from these long cycles (under competitive pressure), so need for that will be less as well.

Re:Vulkan Tutorial by zanny on Monday July 18, 2016 @10:47PM (#12119229)
There is also the fact that in modern CPU-side development you will find it almost always is a bad idea to try to drop to assembly micro-optimization. Your compiler is going to almost always do a better job optimizing the general case into an optimal set you won't be able to easily implement in raw ASM, especially when you start using vectorization instructions.

The same concept applies to Vulkan / DX12. The hardware manufacturers will know better than any developers about per-device shortcuts to put into their drivers, and if they do not need to maintain millions of LOCs of OpenGL state machine and validation layers they might find time to optimize the shader compiler to be in the same class of "the compiler is smarter than you" reasons not to use a hard ASM language.

In the case of consoles, all of them are using AMD based graphics, and when the next generation comes out they will all be on a similar cadence of GCN. I cannot imagine in what world an optimized AMD SPIR-V compiler that AMD already needs to write for the desktop and mobile won't beat 99% of developers on both the Sony / MS / Nintendo and 3rd party sides trying to microoptimize RadeonSI ASM.

Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @11:19PM (#12119342)
> I cannot imagine in what world an optimized AMD SPIR-V compiler that AMD already needs to write for the desktop and mobile won't beat 99% of developers on both the Sony / MS / Nintendo and 3rd party sides trying to microoptimize RadeonSI ASM.

Good point. Today not to provide Vulkan on consoles is a political diversion (to make cross platform development more costly by taxing developers with doing the same thing multiple times).

Re:Vulkan Tutorial by pcwalton on Monday July 18, 2016 @11:57PM (#12119504)
> There is also the fact that in modern CPU-side development you will find it almost always is a bad idea to try to drop to assembly micro-optimization. Your compiler is going to almost always do a better job optimizing the general case into an optimal set you won't be able to easily implement in raw ASM, especially when you start using vectorization instructions.

I agree. In fact, the fact that it's not even a good idea in most situations to write in assembly on x86 CPUs proves the point even more. GPUs are less willing to spend die space on things like sophisticated branch prediction, complex superscalar architectures, register renaming, and so forth. This effectively means that GPUs punish naive codegen (which is the kind of codegen that humans without in-depth knowledge of the architecture tend to produce with their brains) significantly worse than x86 CPUs do. For an extreme example, look at the vector part of the low-power VideoCore IV architecture [1]: compared to a compiler, I don't trust myself for a second to program this optimally.

[1]: https://github.com/hermanhermitage/videocoreiv/wiki/VideoCor...

Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @04:23PM (#12117842)
> The PS4 API is already much better than Vulkan.

It's like saying that assembly is better than higher level languages. So propose writing everything in assembly as the next step? Everything has its trade-offs.

Re:Vulkan Tutorial by pcwalton on Monday July 18, 2016 @05:55PM (#12118275)
We don't really have enough experience to compare GPU assembly vs. SPIR-V. For pjmlp's claim that the PS4 API is "much better" than Vulkan to hold up, as far as I can tell you'd have to show that the codegen (i.e. passes after IR-level optimizations) of the driver's SPIR-V compiler can't match what game developers regularly do. I'm doubtful (instruction scheduling, for example, is too much to keep in your head to regularly beat a compiler), and especially so without data.
Re:Vulkan Tutorial by pjmlp on Tuesday July 19, 2016 @01:48AM (#12120005)
As I replied on another comment, besides the lower level control of pushing pixels around, there is the whole tooling part and OS integration.

Vulkan like OpenGL is leaving to the developers the effort to bring their own math library, OS integration and graphical debuggers.

For the rest most of it is hidden behind NDA walls, so you need to sign one to see the codegen examples.

Re:Vulkan Tutorial by shmerl on Tuesday July 19, 2016 @02:02AM (#12120055)
Leaving math library and OS integration to developers is a good thing. Mandating them is already too limiting.

Graphical debuggers on the other hand are useful indeed. LunarG stopped working on Glave: https://github.com/LunarG/VulkanTools/commit/87220f80a643860...

Not sure what happened there. Valve were sponsoring Glave development.

Renderdoc is active (not Linux UI yet however): https://github.com/baldurk/renderdoc

Re:Vulkan Tutorial by pcwalton on Tuesday July 19, 2016 @01:06PM (#12123002)
> As I replied on another comment, besides the lower level control of pushing pixels around

I haven't seen any "lower level control" here, except assembly vs. SPIR-V.

> Vulkan like OpenGL is leaving to the developers the effort to bring their own math library, OS integration and graphical debuggers.

A math library is trivial (and it seems odd that you would claim that not having a math library is a significant downside when your entire premise is "low level, minimalist APIs are better"). "OS integration" and "graphical debuggers" are not part of the API.

> For the rest most of it is hidden behind NDA walls, so you need to sign one to see the codegen examples.

Given that none of the presentation you linked was relevant (it was comparing against pre-DX12, not Vulkan), I doubt that signing an NDA would show me anything more.

What I've been repeatedly asking for is the specific technical advantage that the PS4 API has over Vulkan—in other words, what did Sony do right that Khronos did wrong? I'm interested from the perspective of a compiler writer and a graphics programmer. I haven't heard anything, and at this point I'm inclined to believe that no such thing exists.

Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @06:04PM (#12118314)
I'm also doubtful that developers can regularly beat optimizing compiler by a big margin. It's theoretically possible, but I'd expect it to be far from trivial, and as result require substantial effort every time it's needed.

Hacker folklore: http://www.catb.org/jargon/html/story-of-mel.html

Re:Vulkan Tutorial by maccard on Tuesday July 19, 2016 @11:17AM (#12122248)
I disagree. I regularly stomp all over the optimizing compiler, and it's not a massive amount of effort. It doesn't come for free though, and requires some upfront planning. The best way to think of it, IMHO is rather than thinking of "beating the compiler", think about working _with_ the compiler to help it do it's job.

I don't always agree with what he says, but Mike Acton has some good words and examples of this. https://www.youtube.com/watch?v=GPpD4BBtA1Y - a youtube talk where he talks about working with the compiler. The slides are at http://www.slideshare.net/cellperformance/gdc15-code-clinic In particular take a look at slide 69 and the few following it for an example of things the compiler can't figure out (for various reasons) that we can help it along with.

Re:Vulkan Tutorial by pcwalton on Tuesday July 19, 2016 @01:25PM (#12123184)
That presentation is talking about IR-level optimizations, not codegen-level optimizations. Remember that SPIR-V is an IR, so you are free to manually do IR-level optimizations to your heart's content just as you can on the PS4.

Where IR-level optimizations are concerned, I agree that you can often do in areas like aliasing (where you, the programmer, have more knowledge than a compiler can easily prove). I'm much less convinced that you can beat a compiler at codegen-level optimizations: instruction scheduling, isel, register allocation, etc.

Re:Vulkan Tutorial by shmerl on Tuesday July 19, 2016 @12:56PM (#12122913)
As I said, it should be possible in theory. It boils down to details. I.e. how good the compiler is and how hard is to do better than automatic optimization for given hardware. It's not a uniform yes / no situation.
Re:Vulkan Tutorial by vardump on Monday July 18, 2016 @01:02PM (#12116361)
Except in portability.
Re:Vulkan Tutorial by cobalt on Monday July 18, 2016 @01:26PM (#12116564)
given how tailored games are already anyway, as well as wanting to be as low level as possible, that wont really matter
Re:Vulkan Tutorial by vardump on Monday July 18, 2016 @02:51PM (#12117269)
Vulkan is pretty close to "as low level as possible".

If it's available, it'll certainly be a tempting target for those who have lower budget and those who need to port it faster.

Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @12:12PM (#12115949)
Sony doesn't support OpenGL on PS4. Vulkan is a different story. It will depend on their mood. Their desire to deal a blow to MS might outweigh their lock-in habits.
Re:Vulkan Tutorial by pjmlp on Monday July 18, 2016 @11:35AM (#12115663)
Where?
Re:Vulkan Tutorial by TillE on Monday July 18, 2016 @10:49AM (#12115355)
> or any console produced by Sony, Nintendo and Microsoft

I suspect that'll change. Sony and Microsoft are both using more or less standard AMD GPUs, and game (engine) developers will demand it.

Re:Vulkan Tutorial by pjmlp on Monday July 18, 2016 @11:38AM (#12115693)
No, indies will demand it.

AAA studios are doing quite fine with the current API that are even lower than Vulkan.

Indies with FOSS background seem to have a hard time to grasp how the games industry works in terms of IP, technology stacks and outsourcing for platform ports.

Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @11:42AM (#12115724)
That will change when pressure will grow. Same as ActiveX was driven out by standard Web technologies. Lock-in freaks will try to resist, but they can only delay it.

> No, indies will demand it.

> AAA studios are doing quite fine with the current API that are even lower than Vulkan.

Meaning of "AAA" is totally mixed up, so there is no point to use this term without explaining what you mean. Indie might mean independent indeed, but what AAA stands for is completely ambiguous. You might mean projects with big budgets, but they can be independent as well (Star Citizen), so you can't use it as some universal category. For the reference Star Citizen is going to use Vulkan.

Regardless of what "AAA" is supposed to mean, they will use whatever will cut their costs to do the job well enough. And cross platform options surely will, if they'll be available.

Re:Vulkan Tutorial by khedoros on Monday July 18, 2016 @06:20PM (#12118369)
> Meaning of "AAA" is totally mixed up

It makes me think of a big budget game made by a company that makes big budget games and primarily publishes them through mainstream channels. It makes me think "opposite of Indie". I don't think that there's an indisputable, unambiguous definition of either term.

[dead]
Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @01:00PM (#12116347)
I see you still are a fan of lock-in. Calling it "fine" and saying that's how it's supposed to be is not helpful. "Industry" which thinks backwards doesn't need to be shown as an example. It's not the "industry", it's monopolistic participants who use lock-in to control the market. Progress is driven by competition, not by monopolistic lock-in stagnation.
Re:Vulkan Tutorial by cobalt on Monday July 18, 2016 @01:31PM (#12116603)
most companies have and will just port it to different platforms, using the api that gives them the most performance. It's hardly lock-in
Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @01:46PM (#12116743)
> most companies have and will just port it to different platforms, using the api that gives them the most performance

Yes, when they have a choice and resources. It's not even the case here. I.e. it's not like developers simply prefer lock-in when dealing with some of the walled garden platforms. They simply have no choice - the likes of MS, Sony and others don't leave them that choice. It's not a discussion on technical merits. You could use your logic if developers could actually choose.

Re:Vulkan Tutorial by dmytroi on Monday July 18, 2016 @06:42PM (#12118443)
Of course they do, but under NDA, just ask. OpenGL on top of whatever GAPI is on target platform is usually <100 KLOC, so completely possible to write your own if you REALLY need to (really is when your 1kk+$ budget game will fail just because there is an engineering problem).

And if you don't have resources to ask/communicate than just use something like https://github.com/bkaradzic/bgfx/ which is an awesome API agnostic rendering library.

Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @08:45PM (#12118845)
> OpenGL on top of whatever GAPI is on target platform is usually <100 KLOC, so completely possible to write your own

What would be the point for them to use the benefit of cross platform API, if they need to write their own? It won't be any cheaper than using the existing lock-in.

Re:Vulkan Tutorial by dmytroi on Tuesday July 19, 2016 @04:11AM (#12120502)
So first you develop your game for Windows on DirectX, and than you make a port to OSX/iOS/Android using OpenGL, and than if you're lucky you make a port to XBox and PS4, maybe WiiU. Graphics pipeline rendering code is really small and simple part of any game, usually in big games you do have different render code for different GPU series or/and platforms, but it's much smaller in comparison with everything else.

What's big and bulky - shaders themselves, but there are solutions to translate them between different available languages.

Re:Vulkan Tutorial by shmerl on Tuesday July 19, 2016 @11:48AM (#12122415)
> What's big and bulky - shaders themselves, but there are solutions to translate them between different available languages.

Those solutions aren't really ready yet: https://github.com/KhronosGroup/glslang/issues/200

Re:Vulkan Tutorial by dmytroi on Tuesday July 19, 2016 @04:02PM (#12124414)
I might be harsh to say it, but current vulkan/spir-v tooling is more like a toy than production ready. If one need to convert HLSL to GLSL then one probably will use something like https://github.com/James-Jones/HLSLCrossCompiler and IIRC one place just used advanced macros magic to make HLSL and GLSL from the same source code :)
Re:Vulkan Tutorial by shmerl on Tuesday July 19, 2016 @06:16PM (#12125369)
> but current vulkan/spir-v tooling is more like a toy than production ready.

Yes, that's what I meant too. It's not ready (translation to SPIR-V from HLSL). GLSL → SPIR-V should be in better shape.

Re:Vulkan Tutorial by SolarNet on Monday July 18, 2016 @04:52PM (#12117996)
My Android [0] has hardware with Vulkan support.

[0] https://oneplus.net/3

Re:Vulkan Tutorial by pjmlp on Tuesday July 19, 2016 @05:46AM (#12120809)
I doubt developers will care to target an Android fork (OxygenOS).
Re:Vulkan Tutorial by SolarNet on Wednesday July 20, 2016 @08:48PM (#12133754)
I actually chose it to target vulkan on it.
Re:Vulkan Tutorial by 01Michael10 on Monday July 18, 2016 @03:00PM (#12117344)
> I would scratch the fully, it's not on iOS or macOS

Vulkan is mostly certainly cross-platform and it's only Apple stopping it from being available on their closed platform.

Re:Vulkan Tutorial by psydk on Monday July 18, 2016 @04:01PM (#12117713)
My question will probably sound naïve because of my lack of knowledge of the Macintosh, but Macintosh hardware nowadays seems to be the same than PCs. So what prevent Intel, AMD or nVidia to propose a driver for this platform in the same way they do it for Linux and Windows? Is there a legal reason? A technical reason?
Re:Vulkan Tutorial by inDigiNeous on Monday July 18, 2016 @05:34PM (#12118181)
My limited guess as a OpenGL developer on Os X is that it has something to do with Apple prodividing a software OpenGL -implementation also, so maybe they don't want to pour in the work in that to support the more recent advances in OpenGL ?

Or maybe they're just focusing on the Metal -implementation, and iOS more specifically.

Currently the OpenGL stack is years behind on OS X compared to Windows or Linux, Os X supports only version 4.1 (released in 2010) with some 4.2 extensions thrown in.

I've yet to come across a good reason. If somebody knows, would be nice to know also.

Re:Vulkan Tutorial by sangnoir on Tuesday July 19, 2016 @07:23AM (#12121067)
> I've yet to come across a good reason. If somebody knows, would be nice to know also.

It's not a good reason, but a reason nevertheless: it's fair to say Apple likes to lock in developers to its platform[1]. Encouraging the use of Metal and discouraging OpenGL increases the lock-in effect.

1. My Google skills are failing me, but a few years ago there was a blog-post by an app developer who used to get lots of support from Apple while their featured app was iOS-exclusive. The day the app was ported it to Android, Apple stopped responding to their queries.

Re:Vulkan Tutorial by shmerl on Monday July 18, 2016 @11:41AM (#12115715)
It can be fully cross platform, as long as developers can access the system and its GPU. It doesn't include sick systems which are walled gardens and on purpose prevent cross platform technologies.