Collapsing UI Code Into One Pipe


A while ago I wrote about how I made an entire pipeline to draw the skybox dragon fractal and still had one other pipe that was split into two for "ui elements" and text.

I basically was thinking about how I wanted to a new effect in the game that would require me to use some 2d element of some sort that has a texture and was all like, "it'd be really nice to just have all this flow down one pipe so I don't have to worry about making more one offs that are weird and hard to edit".

So then I thought about it for a while and realized that truly the dragon curve was just a quad with a texture, just like the new effect I wanted to draw. Furthermore, the text texture quads were also just quads (but were created before uploading to GPU in terms of triangles from just a start point and a dimension value), and the old "ui elements" stuff had boiled down into the text quads' vertex format before pushing to the GPU since they were in the same pipe.

It was then I realized that I made a mistake by making the dragon curve its own pipe and that the old "ui elements" and the text quads shouldn't be split, but be in the same pipeline.

So that's what i've been doing all day today. Now, you submit quads or "raw" ui vertex data as the new ui element from the CPU and the platform side of the code, before uploading to the GPU, will transform the quad data into raw ui vertex data and then upload it the GPU. So in the case of the dragon fractal, since it only needs to change UVs, I actually store it as raw ui vertex data and just edit the UI values before submitting to the render pipe that submits to the GPU (to still be platform abstracted). Text quads remain the same, and the odd ui elements I made (like the arrows that appear when you go faster) are also raw ui vertex data as they previously were.

So to sum all this up, I recommend that you read all your code as often as possible to avoid doing  this type of a naive thing where you miss the opportunity to compress the code's functionality down into one simple pipe which gives you a more unified look to the game (one change in the pipe applies to all things that go into it that are related like UI in this case) and it makes it so edits are much easier since you don't need to have tiny duplicate pieces that all need to line up across N pipelines and what not. You still want splits though in my opinion; like you don't want the mesh pipeline and ui pipeline to be the same since ui doesn't need to be lit or anything of that sort so you've gotta start at a basic level of "this thing is totally unique" but when building up your codebase over time, read your old code that does some similar functionality (like ui blitting in this case) and see if you can unify the new thing you want to add to some pre-existing pipeline or what ever.

Thank you for reading and have a nice day! Also, please let me know your thoughts on my game, thank you!

Files

Funmi_Zip.7z 4 MB
Nov 08, 2021

Get Funmi

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.