C++ Vulkan Learning 1

Just another WordPress site

C++ Vulkan Learning 1

working on a pipeline layout pipeline my head for the info I think the push constants are like uniform buffers from OpenGL now I’m totally sure about that but that would make the most sense because uniforms were essentially constant after you set them right if they named there’s like it was a pointer that makes no sense the descriptor set layout oh it’s idea so okay pipeline layout do I have one yet all right that’s it for that function let’s see which function of my hand unit descriptor and pipeline layouts next up in it render pass wrong man Vulcan has a lot of pieces God descriptor sets pipelines command buffer joke man cues no pipeline we have a render pass I mean I’m not fully sure yet what the difference is between a pipeline and a render pass of course I don’t know the difference there’s been a pipeline and IQ really either so we’ll get there render pass depth present true yes and one depth of course we won’t depth go go gadget meander pass let’s make sure all this work first success no crashes no drawing but no crashes attachment description I only want two

of them both to zero out wandering one beside brackets would do that I never missed that before yay lack of C knowledge okay okay I said before samples thing as an um samples I want your numbers what okay sample okay this is load up equals Cleve was this clear well clear defaults to true so sure why not sound like clear buffer it’s not really well named it’s just clear the two options are VK attachment load o P clear or V the attachment load OB don’t care I love if they put in a contraction into an enum name constant name so we define our load operation we just start our store operation I’m sure this all makes complete sense once you get the hang of it I’m just trying to imagine all the people who got the Vulcan API and had their engines updated maybe not optimally but they had him up and running and rendering everything the same as I had an OpenGL like the same day it’s like that’s crazy this point of the codeblocks cannot see cannot see the members of anonymous strux I wonder why those are constants the kiss sample count one bit why don’t you just pass it in a number of your own maybe it’s a bit mask or something here we go the same thing I want to clear is this suggesting that it wants to erase it before it writes to it is those like the GL clear kind of step saying on this render pass I want to erase everything it sounds like stencil load wait no they are different the first one is that on pencils door ope initially out ultra her both constant ultra verbose constant no flags

those are attachment descriptions now I am to make a attachment reference type so far this makes sense you’ve gotta have something for the colors and something’s with a depth buffer that’s the same as other api’s now there’s a sub pass not even fully sure what a render passes and I’m already on my way making a sub that’s awesome pipeline buying the point not kidding mmm-hmm color attachment count one my color resolve attachments I don’t set the resolve count as it defaults to zero but it seems worth they would set the rest of them but not that one yeah stencil attachment my death ref preserve nothing cool now this seems strange is there note there’s no depth count that cuz I’m going to do one so you can have a preserve count and an input attach began with nothing else the rest are just assumed null are something cool now we’re actually making render pass under passed radium give it a tight to adjustments color and depth my attachments are I haven’t set that up yet what is attachments oh my array I did set that up duh yeah that’s my ad okay no jaqen files sweet it’s happy it’s totally okay what is my sub pass called SD yes everything is happy dependency count 0

and my pay dependency is nothing now we’re gonna make this render pass ID to figure out what it is let’s call it a render pass closet and it’s called a VK render pass that he makes even more sense cuckoo that device your past create info no allocators into my render pass and make sure that works field and run oh cool no crash no problem window runs check another one off the list even closer I should not have done that see I just finished in an underpass of course in turn pass and now in its shaders whoo or get there’s a pipeline cash to gosh so many layers in it shooters vert shader text are we compiling these maybe I should step aside for a second and compile these suckers because I wanted you to deal with spirit VIII I don’t know deal if the source code it sounds like a very bad plan holla holla holla holla holla holla holla yes let’s take a look at this thing I’ll bring it over here since I’m reading so this is the lunar G sample get in it the shaders it wants the source in it GL slang if you have the text yes there’s a spirit the output blah blah blah blah blah gr Celtic SPV right okay well let’s go find that okay what what is this assign a new Heep instance D reference to a reference does it delete itself or did someone create a leak and not know it well before I go haywire this direction let me go find GLSL beer B compiler it even auto-completed it for me I’m not messing with this is nonsense I’m gonna

pre-compiled this crap reference compiler I need you senator befriended obviously she a the perversion statement default this version 100 okay I don’t want open Jill yes per se I want to volcán the Volgin jail tomorrow this isn’t okay okay it’s got to be my SDK then if they include it was part of lunar G stuff no to bring it back I was terrible SDK brain what do you got for me oh there’s the program spear V a s Spivey Dee is remap try let’s run some of them do have ins binary module from trivia assembly text it’s probably not what I want nothing binary module fish head disassemble a spear be binary module that’s cool you know that’s lying validator as soon as is the thing you were talking about just a moment ago cool so back up you compiled things where are you at be passed in you passed in let’s go back to draw a cube you are passed in ah ha ha ha ha ha ok let’s output subscribe to files because anything else is stupid there got my got my content let’s get some file stream action going here hi mercial it’s going well kind of you’ll have to pardon the delay I know from previous streaming experience that there’s like a 10 to 13 second delay so it seems like I’m ignoring chat but I’m not I promise right now I’m just figuring out how to dump I got a dump this GLSL from the sample out to a file and then compile it to a spirit emoji okay I’m not gonna do any runtime compiled and that’s just silly to me I’m gonna have precompiled shader code all the time so yeah let’s do this so I’ve got these I’ll just make a function to do this really easily

binary so if I got a file and write everything cool go to my program where you do anything do you did we get it oh is that the cute program what does it look like yeah that’s what I’m gonna be working on that’s what I’m working toward this is what the finished product looks like which this one disappoints me because you do that and does that so I’m gonna fix that when I get my tutorial done um I should do the stream pick that up I just know occurred to me that I forgot that no it did okay it’s picking up the whole monitor so can I’ve just seen people have problems in the past because it’s Vulcan and they don’t have like Vulcan capturing whatever I like OpenGL and direct3d captures but capturing the whole monitor so I guess it just works okay so project STL volcán there they are there voila okay so what happens if I validate these things GLSL laying validator shader dot Bert what you gonna do for me warning version 400 is not yet complete most version specific features are present but some are missing that’s comforting okay so just cuz all Doozers as validates so what it does just has a good job like let me come in here and break it hey SDF validate that okay cool so it is it’s it’s checking in so it’s just telling me that 400 isn’t done okay that’s cool how do I compile it for Vulcan that’s what I want to know go let’s go to the Vulcan no just go to Vulcan industry forage for Vulcan driver’s demos and samples they linked metal VK here even though it’s like not done – promise – promise of the future do I really have to like write my own program that just takes their code reads in source and compiled the binary module and spits it out I would assume that would have been like done welcome resources aankia what do you got drivers resources Oh Google has a Volcom site now that’s cool huh a light description support for the spear V binary why spear okay I don’t want spear I want

spear V I got that I got that much question is how I do P tools Oh assembler binary parser disassembler sure why not first I’m gonna see if the repos have this um wind sparkle libs but that that is not it okay well just know with a shot spear V tools come to me it’s a sea make not the biggest fans you make I mean it’s not only bad it’s just very natively don’t know any specified generator system is unknown he’ll help me see make I want you unix-like files so sound good not supported okay why not this is what I see make just had a make file because I run it and I’d be done already I know platform generator if only it were that easy I don’t want to build a flex studio or anything else I like ninja I don’t even heard of ninja ninja files well they’re not pre-built versions build passing how did you build it I wish I were set up in Linux to do this but I’m not so let’s just poke fun at it for a minute I’m surprised they have code light support in year two gosh I install scene make generators like more of them yes why can I do em sis make far those are the best those are the best I just do it I’ll just do it cannot create named inner rock don’t like see me see mr. chumps and I want to do like something by default okay I figured out it’s like I don’t know what platform you’re on let’s just go to CMD oh I see making here nope it’s only an incest well almost all my time just doing this Vulcan SDK did you really not come with a compiler you’ve a validator let’s

remap math help usage doot doot doot doot doot doot doot doot doot if I don’t have help same thing what is the remap tool ASD is a similar disassembler try let’s try sig fault awesome oh it’s a program okay right at its segfault doesn’t like didn’t know where its files work didn’t like what’s bins or everything hey they have SPV that’s not fair but you know what I’m to steal these they’ve been pre-compile they’re mine holla mine well that’s all that we win I’m just gonna move right into just importing those files because yeah oh hey Mitchie 2:32 you can use you know slang validator – V that’s very good to know that’s what I was trying to figure out so I should probably do that as a learning thing um give us pervy tools I’m peachy yes slang could I’ve run the validator but I didn’t know what I was doing so – V what does – vimi nice probably check the manual if I were to take shader dot frag linked fragment stage animate if it made the frag dot s pv ah that’s what I wanted mucho gracias you know I was gonna muscle pass it past at one way or another if I didn’t couldn’t figure out how to run the command I was just gonna copy their precompiled modules so either way it works I guess so back to what I was doing so come back to the sample code coming here blah blah blah okay i’m should make a method to load a file into that i have that in source code probably in a hundred places i should be able to find one let’s see my other projects just out of curiosity miki 232 how did you know that you’ve been working with vulcan spear v already and that kind of stuff I’ve been trying to learn it all week and I’m just been behind but it’s I’m just picking up bits and pieces as I go I knew about the existence of spirit II but I hadn’t planned the tools or anything let’s see source tools get file content so I’m gonna fix this unsigned char and don’t return it by move that was a mistake I made before I don’t need I don’t need standard in here I’m doing one file failed vector does not name and type oh yes it does didn’t spend the past week writing a big Vulcan C++ wrappers I’ve been muscling to the spec it’s a beast for sure yes indeed oh I don’t have it on my desk off you’ll get it but I printed out the spec I actually printed went to a local shop well I sent my wife to look at the local shop and she printed out the spec for me and brought it home so I have like two volumes of these books each like this thick and I’m just reading through the spec beginning to end but you know I can only do that so long and then you me like sit down actually code so I haven’t finished reading it

but I’ve been pretty close unsigned there you go char star yeah okay I don’t need to write these files anymore hard to written them here goes a fun part actually before I move too much further let me just see laying validator help – V creates pervy binary under Vulcan semantics turns on – okay so if I were to read a little more closely it would have stared I’m you’re in the face that’s very good to know so thank you for that help I have a Vulcan compiler Thank You lunar G SDK that helps a lot okay don’t need you anymore okay in it CPP here we go so I’ve got my render pass now we’re doing some shader initialization VK shader module create info she dramatic read info SMC I Oh before you to that yeah it’s running the freaking compiler I don’t want to do this but I do need the shader stages those are important so shader stages holy buckets pipeline shaders stage create info and I need two of them whoo okay again here we go visualize make sure there’s all I’m Dean what not COO yes I know these aren’t needed anymore I’ve dumped them two files I’m gonna pull these out I can reference them later if I want okay so for step one PSS ya ci0 copy that well so much for copying it I have to copy this big monstrosity boom aim next nothing specialization info nothing flags nothing stage a shader stage vertex bit named mein daag the entry point that’s cool so I mean you could pick like any entry point you can ever gonna shoot it with like a hundred entry points but like I want for this particular setup to run that entry point if so that’s really cool really really cool in fact I want to look at the vertex sheet yeah so there’s Maine and I guess I’m picking Maine out from the source cool that could that could be very powerful to be able to say on the phone right at runtime pick what you know which function run run check which features are available that kind of stuff so alrighty then so let’s keep moving moving right along no come back okay so now that I’ve picked mean and then the sample code does the on-the-fly compilation which is a whole lot of nope

yeah this is the part where we say vector unsigned char Paul spear VI yes and what I call the function get file content now are the names of files oh I’m missing more you can pick different entry point during run times and that just has been missing that accomplish variable yes that confirms what I suspected that is very very neat I’m excited about that granted I didn’t even get far enough and OpenGL where I made sophisticated enough programs for that to matter but I still understand the benefit and I’m hoping to make a a game big enough to where that does matter so good to know so here we go get file content spear V I want Q with vert SPV and let’s go ahead and spit that out that’s not the content just proof that I opened it loaded vertex shader spear V side might run loaded vertex shader 1584 bytes good I’ll leave that in there as part of the program I mean it’s a learning program so I like output so I’ve got my stuff um module create info cool beans cool story bro wait I didn’t see what type of us come back to me now shader module create info okay shader module create info change mother p.m. vote SMC a I’ve already made one of these oh I made it up above okay we’re good no flower is no next no flags code sighs spear V what I better be careful here spear the it’s already a bite so I think that’s all I need they have size of unsigned int oh because they’re capturing it as an array of unsigned int yeah so I think it is as fine as it is I’m just reading it wrong it’s really sad I wish the standard Victor had eight like dot size and bytes or whatever so you never ever had to do that math yourself I mean it’s not hard math but it’s just a common enough call that it’d be nice field just to have that as a convenience method but whatever so we know our code size and the actual code comms to you and oh it takes a pointer to that type well that’s rude we’ll just cast it in that case yeah I thought I needed an unsigned eight but whatever I’m just gonna put this back to a charge the way it was before because then it ought to do this dumb cast okay so pointer to the data

yeah according to their example its size times size of one side in so they want the bite size of the program so yeah guess I’m just gonna cast it oh here’s the fun part okay I’m asserting my victory create shading module vice straighten wonder create info no allocator and okay run no air sweet I want to see an error though instead of a 1584 let’s just be a jerk and resize it to like 1400 so we’re just gonna just truncate the crap out of it it is still okay with that that’s not cool does a shader module not actually icon compiler that ever yeah it’s definitely truncating it but it’s not complaining now mm-hmm well let’s keep going maybe we’ll get to the plant where it complains because maybe the shader module I mean it doesn’t happen until you try to use it maybe all right okay I’ll come back to that now we’re to load the fragment shader this fragment shader fragment shader is 656 bytes okay well let’s keep rolling same thing as before I’m assuming I can reuse great in folks I mean just create info she used to create it and then it’s done so let’s just take this copy that nothing changes except oh I need this stuff too these are all ones there’s no main here obviously or is there I lied there’s totally a main there yeah I was made in both programs it’s this one that has to change it’s the type it is a fragment bit everything else is zeroed out doesn’t matter okay gets it already and then passing the first module and that’s it well why won’t I complain well I’m not complained I run it I

wanted to break it that’s all wait I all have plenty of chances to break it I just wanted to see if it would assert that the create the shooter module would not be successful or something but what do I know okay we’ve initialized Cedars now initialize frame buffers it’s not too long let’s just dive right in image view attachments attachments 1 equals depth view framebuffer create info now it’s gonna make the frame buffer should be FB or just F a lowercase the B but that’s two words frame buffers nothing word naming stuff another name 1/8 FB info and they’re gonna happens with Adrian I do it I’ll do two words FBC I type bat monstrosity next nothing there you have a render pass oh yes two attachments one for color one for depth my two attachments are my attachments although I just made these locally okay blind fate at this point as soon as the height that my display hope so because those are not powers of twelve ten twenty fourth power to seven six years I don’t have to it can be made from other powers of two it’s not itself a power to okay this is where things get weird wart okay so they mm allocate space for the swap chain image count times the size of the buffer so we make an array I know I held an info so I guess it’s freed later don’t like it well it’s fine soft change image count up changes it’s like – yeah this is where I just avoid Malik and all doesn’t make localized thingamabob me kid rainbow flower rainbow hers Shh no not to eight for over cap purposes but stuff I’ve been using my de facto number is eight soft chain image Kent

or each one sign it offers ones buffers I don’t have buffers let’s go a little buffer is’s they are swapped chain buffers have this somewhere yes it’s just called swap chain buffers so bhakti the tutorial suction buffers want the view create frame Bihar device no allocator and I assume it’s a success oh right hey let’s run it didn’t complain woo next one let’s see actually I’m probably gonna call it at night cuz I’m tired it’s late so thanks for watching give me subscribe if you want to see more in the future hopefully I can get it up and running all the way next time so I’m getting close to the end where I actually can begin rendering so um anyway until next time I can find my stream program