134 points · by panic · 10y ago · 66 comments
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...
[2] http://pubs.opengroup.org/onlinepubs/009695399/functions/ass...
http://blog.llvm.org/2011/05/what-every-c-programmer-should-...
C Standard 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
I would assume that the code for Linux and Android is similar.
also, check out this awesome demo of DOOM using vulkan. https://www.youtube.com/watch?v=0y3LaLJoo0s
*(void **)&vkCreateDebugReportCallbackEXT = vkGetInstanceProcAddr( ... );
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.> 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?
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.
OpenGL is like the C std/runtime library. Vulkan is like calling the kernel functions directly without wrapping code.
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.
If you want a simple way to draw graphics without all the complexity, you don't want a graphics API, you want a game engine.
Also, it is still unclear whether D3D12 or Vulkan (or Metal on OSX for that matter) actually provide a real-world advantage in complex games. Most big games that have been released with a D3D12 renderer so far, don't run better than with the D3D11 renderer. Metal mostly shines on iOS, where it is dramatically faster then OpenGLES, but it isn't dramatically better on OSX (at least on the Intel GPU configs I'm testing on).
I wonder if anyone has written a wrapper, which would be at the same level as Metal, but run on top of Metal and Vulkan. That would be something I'd like to use!
I still think Vulkan is great. Now, we need to start building libraries on top of it. The nice thing about very low-level APIs is that it is possible to write higher-level APIs on top of them. The opposite isn't really possible.
[1] https://www.raywenderlich.com/77488/ios-8-metal-tutorial-swi...
https://twitter.com/renderpipeline/status/699501481632886786
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
Edit: I don't get the downvotes