Is Vulkan Hard?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Well, graphic APIs like Vulkan are not designed to make simple things easy. They are designed to make complicated things possible. They do not care about providing an accessible beginner experience. They care about providing professionals with all the tools they need to do exactly what they want in the most efficient way.

👍︎︎ 3 👤︎︎ u/PhilippTheProgrammer 📅︎︎ Jan 08 2022 🗫︎ replies
Captions
is vulcan hard vulcan is a graphics api it's similar to opengl and directx 12 in that you can render whatever on screen using a whatever graphics card you have in your machine is it hard to code in well here's here's what what i what i did you see i i had this goal i want to make a game engine right so it's got to be fast right gotta go fast so it's written in c plus plus right because that's a pretty fast language and then the graphics api i just picked uh one of the faster ones that's cross platform which is vulcan right right anyway so i thought i've done opengl this shouldn't be this hard right so i go i jump into it and i'm reading tutorials right i'm brand new to this right so i'm like reading a bunch of tutorials and i'm like for learning in order to just draw the hello triangle which is the basic thing you do in a graphics api is you know draw a triangle it's the simplest shape i took like a thousand lines of code my current little triangle is quite a bit more than a thousand lines of code that's because i've got it all you know abstract and stuff so it's anyway so okay i've been looking at different uh tutorial websites this is i'm because i'm new to vulcan uh so there's the tutorial website there's a youtube series which is where i ended up uh learning the most from i'll link to that and yeah i'm gonna say from my experience it's pretty hard it took me a long time like a really long time before i got any like anything on screen at all but now that i've got something on screen let me show you my little program here so this see it renders a triangle what it does is i i'm having a push constants which i can update so i'm drawing the same triangle multiple times but changing the push constant let me how about listen i maybe you don't know how bad vulcan is so i'll just i'll just go over like step by step what you need to do in order to get a triangle on screen okay so first what you need to do is you need to i'm going to list a bunch of vk objects vulcan objects that you need to create each one of them need to be configured because there is no default settings so to configure one of these it means creating some kind of object and then setting every single parameter the way you want it to be and then giving the object the then giving that object to the thing that you're configuring i'll show an example but um in order to render a triangle or anything on screen uh for you first need to create a vk instance right which is the vk sort of environment then you choose a vk physical device which is whatever graphics card your machine currently has it'll list them all out and you need to figure out which one you want with that physical device you need to create a vk device which is you know vulcan abstraction the logical device then you need to make a vkq what a vkq does is you give vk the vkq the commands and it'll it'll on the cpu and then the gpu will look at the queue and run the commands basically once you have the the vkq you need to create your vk surface which is the uh you know the thing that you're actually going to render to on screen you also need to create a vk swap chain so by default well there is no default so like in opengl you could just be like all right you can buffer the image when you render it so you don't get screen tearing but in in vulcan it's like now you got to code this manually how many uh how many like buffers do you want your swap chain like you can have like triple buffer that's what i currently have it's triple buffered but you could i could just add more for some reason i can make it quintuple buffered i can just add five buffers and then it just picks one to go on i don't why are we doing it like this um i i don't know why i would want this level of control on the swap chain to be honest maybe i'm just you know i'm a beginner maybe that's why and i just can't conceive of a reason to do that but yeah so then once you have that you need to create a vka imageview and vk frame buffer once you have those like this can actually like that's how you actually render the swap chain onto the surface okay you use those and then you need what's called a vk pipeline so vk pipeline this is the like object that is just your your render pipeline it could that's what that object is it'll take your data turn it into a rendered image and you need to configure that you also need to give it the shaders now if you're familiar with opengl you'd have like a vertex shader and a fragment shader which you can code and that'd be the standard the standard way to go about things which is how vulcan does it but in a vulcan you need to provide compiled code because there's now a compiler for the shaders you can't just upload the shader code normally which you know makes it faster combined codes faster but you know now when you build every time i build this triangle i have to like have cmake like compile the shaders this project using cmake by the way and then you need to allocate memory from the vk command pool so that you can create a vk command buffer now in opengl you can just tell opengl like oh here's the command like draw this or do whatever right you just give it commands and and opengl just accepts commands and doesn't tells your graphic card what to do in vulcan uh you record a command buffer which is a list of commands and then you just give the list of commands which is this is supposed to make things faster and in theory i could just record one command buffer and that whole process is done and now i'm all i'm doing is reusing command buffers most from what i've read most vulcan applications though write their own command buffer every single frame because it's potentially different that's all set up okay that's just set up before i can start actually running the program and getting a triangle on screen so what i have to do to like in the game loop right i've already run the program all this shit's initial as what i do uh so here's what you do you have you have a main loop that uh gets the next image from the swap chain uh and then you submit a vk command buffer to the vkq and then that'll that'll do that on the image and then you just return the image back to the swap chain so like once it's up and running once all this stuff set up it's like really simple you know i guess that's why it's faster but oh my god dude that took forever like setting this all up like this is like over a thousand line of code just to get this there's like a lot of trial and error along the way okay so that's how it works was it worth it am i am i glad that i like took the extra time to learn vulcan over opengl or at least get to the part where i can render a triangle this is like to involve in like opengl isn't this like tutorial one like i'm gonna i'm gonna look up a tutorial right now and just see okay so was it worth it i'd say like i definitely i know it's faster you know uh that that might be worth in the end maybe maybe i'm just being whiny in this early stage but maybe maybe it's actually good uh maybe i should do this instead of opengl i never want to do this again so i made this into a library you know what i i think it was worth it in the end uh because now that i've got all this whole system set up it's very easy to expand on it to add same rendering models or doing whatever like from this point forward it's easy it's like opengl easy i'm pretty sure i've got it all set up ready to go and if anything needs to be tweaked well i know exactly where to tweak it so no i think this was overall a good skill to learn i'm i'm still learning i'm you know i'm still beginner all i've done is rendered a triangle but i think i think i've got a pretty good platform to expand from here like i get a good foundation for a potential future project so i'm going to upload this on github i'm also going to make a branch that's just hello triangle that's just this so i can always come back and grab this and run with it again if i ever need to that's it for this video um if uh if you had any experiences with vulkan i'd love to hear your thoughts on like this sort of beginner learning phase but yes uh this current this code as it is again it's going to be on github so you can check that out in case you wanted to see what goes into making this triangle but that's it for this video thank you for watching i'll see you next time bye
Info
Channel: Coffee++
Views: 13,551
Rating: undefined out of 5
Keywords: Vulkan, OpenGL, Hello Tirangle, devlog, graphics, graphics programing, graphics engine
Id: LOQLg-JHRZc
Channel Id: undefined
Length: 9min 42sec (582 seconds)
Published: Fri Jan 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.