
Vulkan Tutorial - panic
http://av.dfki.de/~jhenriques/development.html
======
taspeotis
Serious case of NIH...

 _I have also created the helper function assert() that does what you would
expect ..._

    
    
        ...
        int *base = 0;
        *base = 1;
    

Just call abort [1]. Or better yet, just call assert [2].

Then, in favour of using the Vulcan SDK, it continues:

 _just need to copy vulkan.h and vk_platform.h to our application folder ...
[i]f you run this piece of code you will notice that you might have found no
layer... This is because, at leat on my system, the loader could not find any
layer. To get some validation layers we need the SDK ... [w]hat I found out
during the process of trying to figure out if you needed the SDK or not is
that you only need the_.json and the _.dll of the layer you want somewhere on
your project folder and then you can setup the VK_LAYER_PATH environment
variable to the path to the folder with those files._

This is not how you build reliable software. Use the IDE/SDK/standard
libraries already! You'll be done quicker. With less undefined behaviour.

[1]
[http://pubs.opengroup.org/onlinepubs/9699919799/functions/ab...](http://pubs.opengroup.org/onlinepubs/9699919799/functions/abort.html)

[2]
[http://pubs.opengroup.org/onlinepubs/009695399/functions/ass...](http://pubs.opengroup.org/onlinepubs/009695399/functions/assert.html)

~~~
asgeir
In support of this. Dereferencing a NULL pointer is undefined behaviour.

[http://blog.llvm.org/2011/05/what-every-c-programmer-
should-...](http://blog.llvm.org/2011/05/what-every-c-programmer-should-
know.html)

C Standard [http://www.open-
std.org/jtc1/sc22/wg14/www/docs/n1570.pdf](http://www.open-
std.org/jtc1/sc22/wg14/www/docs/n1570.pdf) 6.5.3.2 Address and indirection
operators ... If an invalid value has been assigned to the pointer, the
behavior of the unary * operator is undefined. ... Among the invalid values
for dereferencing a pointer by the unary * operator are a null pointer

------
gulpahum
I've always wondered how Vulkan is bootstrapped and its drawing surface
attached to a window. Now I know.

I would assume that the code for Linux and Android is similar.

------
Keyframe
They weren't kidding when they were saying it's a lot more work.

------
prideout
This looks like a great tutorial; it builds up a "Hello Triangle" using a nice
balance of English and C.

~~~
Narishma
I think you mean C++.

~~~
raverbashing
I don't see any C++ there, besides a file extension (I might be wrong)

~~~
Narishma
He allocates memory with new/delete and passes arguments with references among
other things.

~~~
raverbashing
Ah you're absolutely right

Still there are some C quirks, search for "This extension adds three new
functions" and see the code block above

------
bronz
what is the current status with driver support for vulkan? are they being
rolled out steadily at this point? and does anyone have an opinion on how
quickly we will see vulkan drivers become reliable and ubiquitous?

also, check out this awesome demo of DOOM using vulkan.
[https://www.youtube.com/watch?v=0y3LaLJoo0s](https://www.youtube.com/watch?v=0y3LaLJoo0s)

------
aarongolliver

      *(void **)&vkCreateDebugReportCallbackEXT = vkGetInstanceProcAddr( ... );
    

Is there a cleaner/more idiomatic way to do this?

~~~
ucs
_Is there a cleaner /more idiomatic way to do this?_

I'm afraid this _is_ the C idiom for assigning a void pointer to a function
pointer:

    
    
      *(void **) &fptr = getvoidptr();
    

Without the silly cast you'd get the following warning when compiling with
-Wpedantic:

    
    
      warning: ISO C forbids assignment between function pointer and 'void *'
    

Once you learn the idiom, and the reason behind it, it makes things (slightly)
easier to parse than dealing with a bunch of typedefs, IMHO.

------
shmerl
Interesting, but I'd start with a Linux program for educational purposes. It
wouldn't assume one must have Windows to run it.

 _> First things first, let me just warn you that this is not a beginners
tutorial to rendering APIs. I assume you have some experience with something
like OpenGL or DirectX and you are here just to get to know the
particularities of Vulkan._

Is there some book / tutorial that both introduces rendering APIs to beginners
and is using Vulkan for it at the same time?

~~~
slimsag
There might be more game devs using Windows than Linux, just due to market
share, so I'd say Windows was the right choice here.

~~~
shmerl
I think educational materials should have different considerations than just
market share. But that's my personal opinion.

~~~
sbarre
This is a strange thing to say.

Educational materials are of the most value when they reach their largest
relevant audience.

In this case, the largest relevant audience for this kind of thing _at the
moment_ is probably game developers, and most of them target Windows in their
work.

Are you suggesting this material should have been developed in a way that is
less relevant to that largest audience? I don't see how that would be a good
idea.

Perhaps you are getting tripped up on the phrase "market share", thinking only
of it in a commercial context, when it simply meant targeting the largest
segment of users who will find this useful.

~~~
shmerl
_> This is a strange thing to say._

That's a normal thing to say. One shouldn't assume student has to pay a tax to
learn (i.e. Windows tax). It's inappropriate.

~~~
corysama
One shouldn't assume that they must. But, one can look at the stats to observe
that they have. Linux is still sitting at 0.9% on the Steam hardware survey.
By trying to be inclusive in theory, you would be excluding 99% of the
audience in practice.

~~~
shmerl
_> One shouldn't assume that they must. But, one can look at the stats to
observe that they have._

You have stats about students? Where is it published? You can't use Steam for
measuring education metrics.

Anyway, apparently the author wanted to provide tutorials for different OSes.
My point was that he could focus on Linux first, and that would have been a
proper educational choice as I explained above.

------
andrewclunn
Gonna be honest, was hoping for an into for a Star Trek languange.

~~~
Amanjeev
I think that is spelt "Vulcan".

------
smegel
What is Vulkan and why are we programming in Win32 in 2016?

------
educar
The take away for me is that vulkan is similar to opengl. Mindlessly complex
APIs just to play around with basic stuff. Graphics really doesn't need to be
this complicated :/

~~~
ericflo
With all due respect, you're definitely not the target market for Vulkan. It's
an incredibly low level abstraction layer over GPUs intended to allow
rendering engine developers to control the intricate details of the pipeline.
For something simple, you'll want to use a game engine like Unity or Unreal,
which build on top of this low level stuff to build nice, high level
abstractions.

~~~
zerr
I wander if mass adoption of Vulkan for engine development would initiate
"gentrification" \- I mean, currently, engine devs enjoy working with OpenGL
(or D3D), and there is a big chance many people simply won't enjoy using
Vulkan so they won't use it or just leave the field altogether. I suspect
using Vulkan will be comfortable for GPU hardware people (hence different
demographic).

~~~
geon
> currently, engine devs enjoy working with OpenGL (or D3D)

 _Where_ did you get that idea? I almost only ever hear bad things about them
both. Bloated APIs with even more bloated drivers. Layers upon layers of hacks
and fixes.

Presumably, Vulkan will enable the emergence of slim, nice, rapidly evolving
apis built on top of them, giving developers _much_ better tools to build apps
or engines with.

~~~
zerr
> giving developers much better tools to build apps or engines with.

oh, that's the different [good] thing.

I was talking about abstraction level/layer - I doubt those who enjoy (feel
comfortable) working at the OpenGL or D3D layer will be the same contingent
who will enjoy using Vulkan.

But as you said, if some other API-s emerge on top of Vulkan, better than
OpenGL, that would be great of course.

------
raverbashing
Oh, the niceties of C Windows programming

I wonder how anyone got anything done in that time. Really

And the _wrong_ (but very common) type of Hungarian Notation -
[http://www.joelonsoftware.com/articles/Wrong.html](http://www.joelonsoftware.com/articles/Wrong.html)

Edit: I don't get the downvotes

~~~
akx
I guess you're being downvoted because there's about 60 lines of Win32 code --
the rest is the verbose Vulkan API, which is the same on every platform.

