Basic Vulkan Tutorial

Hi all,

When learning Vulkan I found that the examples are not clear and there was no good tutorial. So I wrote one.

Here it is: http ://av.dfki.de/~jhenriques/development.html

Hope this is useful for someone… as this is the one I wanted when looking to learn Vulkan.

JH

[QUOTE=jhenriques;40216]Hi all,

When learning Vulkan I found that the examples are not clear and there was no good tutorial. So I wrote one.

Here it is: http ://av.dfki.de/~jhenriques/development.html

Hope this is useful for someone… as this is the one I wanted when looking to learn Vulkan.

JH[/QUOTE]

2 issues I’ll say now,

you are not allowed to transition swapchain images before having acquired it (even right after you created the swapchain). This means that you either need to track which ones have been transitioned already or always transition from UNDEFINED after acquiring (which is good enough if you have clear as the load op for the render).

in your shader loading function you leak the char *code array. It which can be freed as soon as the last vkCreateShaderModule using it returns.

  1. Yeap. You are right. I reread the spec and now I get it a bit better… (even if not really clear)
    I tried and it works. Of course I had to change the srcAccessMash = 0 and remove the other transition after the swap chain creation.
    This was a really helpful comment. Thank you! Do you think I should remove the transition after the swap chain? (I mean the result for me is the same, and the validation layers did not complain either!)

  2. this one I did not get. I know I can delete the ShaderModule after pipeline creation… but the char code* is not even dynamically allocated! …to be honest, that code is not really good, like I point out in the chapter, it’s just “quick & dirty”

Thanks again for the feedback!

[QUOTE=jhenriques;40218]1. Yeap. You are right. I reread the spec and now I get it a bit better… (even if not really clear)
I tried and it works. Of course I had to change the srcAccessMash = 0 and remove the other transition after the swap chain creation.
This was a really helpful comment. Thank you! Do you think I should remove the transition after the swap chain? (I mean the result for me is the same, and the validation layers did not complain either!)
[/QUOTE]

That the validation doesn’t complain is a bug in the validation layers. and yeah the transition after the swap chain creation should be removed as technically you are not allowed to touch the images at that point.

[QUOTE=jhenriques;40218]
2. this one I did not get. I know I can delete the ShaderModule after pipeline creation… but the char code* is not even dynamically allocated! …to be honest, that code is not really good, like I point out in the chapter, it’s just “quick & dirty”

Thanks again for the feedback![/QUOTE]

char *code = new char[1000];

I call that dynamically allocated. It needs a “delete[] code;” after you are done with it.

Yeah. I already did. I will have to change the layout of the tutorial. I have 2 options:

  1. dont do any layout and simply move from VK_IMAGE_LAYOUT_UNDEFINED every frame;
  2. actually do the extra layout change from VK_IMAGE_LAYOUT_UNDEFINED to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR after I get the swap chain with a full vkAcquireNextImageKHR() and vkQueuePresentKHR().

I’m inclined to go with 2 because this is a tutorial after all… but I guess in my code I will go with 1? (is there a performance reason why I might not want to do this every frame?)

[QUOTE=ratchet freak;40219]

char *code = new char[1000];

I call that dynamically allocated. It needs a “delete[] code;” after you are done with it.[/QUOTE]

And you would be right fine sir… I some how had another version of this code… sorry ma bad.