Newbie questions about Vulkan

Hello,

Im trying to lear Vulkan api from scratch (I assume my knowledge of OpenGL 1.1 - 2.0 are useless).
To achieve that I have read the Intel tutorial on the subjet and come to rewrite the example 2 in C.
Here my attempt https://gist.github.com/TheServer201/26c280d0779423dc714da4a299636ff7 but it seem that the first two image are actually black.
The only thing that is different from the Intel code is that I removed the vkCmdPipelineBarrier that if my thought are corect is useless (I dont need to wait to another pipeline stage to be done).

Since shaders are new for me I can’t understand why they are usefull.
For the next questions I assume that I am in a 2D space.
The vertex shader take care of the projection but since I dislike glOrtho and prefer normalized space it is useless right ?
The geometry shader is here to exploit the power of the GPU to calculate shapes (static equations) ?
The fragment shader give colors to pixels (the only usefull for my point of view) ?

And have you got any good C tutorials or books about Vulkan.

Thank you.

The vertex shader take care of the projection but since I dislike glOrtho and prefer normalized space it is useless right ?

Do you imply setting you all of the vertex data per frame at CPU-side? This approach became obsolete in 90s. You’re super out of touch with modern GPUs and graphics. Basically vertex shaders allow you to store meshes (they can be millions of vertices) completely in GPU RAM, so you only need to do one API call per-frame and only send few skinning matrices over the bus.

I think OpenGL of version at least 3.2 or higher crash course might be in order before you start with Vulkan. You need to adopt the “new” shader-only way of thinking about graphics.

Im trying to lear Vulkan api from scratch (I assume my knowledge of OpenGL 1.1 - 2.0 are useless).

Well, asuming you did not use it mindlessly, the graphics theory behind is timeless. In fact one of the more enjoyable courses in school was when they asked us to actually implement OpenGL 1 (subset of it anyway).

Strictly API-wise it is complete rework (maybe the primitive topology is the only thing that survived). And well, I think in OpenGL 2.0 programmable shaders was already heavily used in profesional spheres(through extensions).

Speaking for myself, I had easier time learning some basic Vulkan. The cons is you have to “do many things yourself” in it. The pro is it is modern, object-oriented, stateless, conceptually clean thing. Another con is Vulkan has learning staircase – you need to know 80 % of Vulkan to make your first app (the hidden pro is you then know 80 % of Vulkan).

To achieve that I have read the Intel tutorial on the subjet and come to rewrite the example 2 in C.

For the love of, why?? Well at least not to Cobol. :stuck_out_tongue:

but it seem that the first two image are actually black.

In case you don’t know, you need to use the Validation Layers. (They should shout that from the rooftops).

Since shaders are new for me I can’t understand why they are usefull.

They are programmable, while OpenGL 1 is fixed (\single-purpose).

For the next questions I assume that I am in a 2D space.
The vertex shader take care of the projection but since I dislike glOrtho and prefer normalized space it is useless right ?

Yup, that makes things easier. If you are already in 2D, you don’t need projection transformation.
You still might want transformation matrix for your 2D stuff for things like translation, rotation, scaling and so.

The geometry shader is here to exploit the power of the GPU to calculate shapes (static equations) ?

It is there to make new primitives (e.g. triangles) from data. I wouldn’t mess with it for your first program (it is optional).

The fragment shader give colors to pixels (the only usefull for my point of view) ?

Indeed. There’s also separate compute pipeline with compute shater, which is sort of like a fragment shader without the (mandatory) vertex shader.
Then again if you have triangles that need to be rasterized, you need graphics pipeline with a (useful) vertex shader.

And have you got any good C tutorials or books about Vulkan.

Do I?? There are now many tutorials, including large company sponsored ones like from LunarG, Intel, ARM, Google. “Good” is in the eye of the beholder. I scanned some of them; they certainly ain’t bad.

There’s official link page for this purpose: Khronosdotorg/api/vulkan/resources.md at main · KhronosGroup/Khronosdotorg · GitHub

I am not sure about them being C. Some of them will probably be very C-like C++ (it can still be pretty time-consuming to write proper wrappers for a C API, and well, bit anti-didactic).

I also shamelessly offer my anti-tutorial Hello Triangle example, if that is more of your learning style.

Some books are out too including the traditional semi-official Red Book. (They probably use C++ too, because why the hell not.)

Salabar - Yes you are right but what I disliked with shaders what the runtime compilation which was fixed by Vulkan.

krOoze - Thank you you triangle exemple is more clean than any tutorial I read (because of the lambda functions and all in main) xD