Happy Halloween(2 days late, whoops)! This week I continued working on my Rust renderer. After my last devlog, I was able to get a triangle fairly quickly. I did struggle with what I thought was getting my Vertex data copied into a vertex buffer, until I looked at RenderDoc more closely and realised the buffer contents were correct, but I had not specified the Vertex stride for the binding, so each vertex of the triangle was reading the first location and nothing more!

wgpu

My main aim this week was to get a .obj mesh displaying on screen. So, once I was happy with my triangle, I worked on a ResourceManager. This is a struct that holds a Slotmap of Buffers. If you don’t know what a Slotmap is, it is essentially a contigous data structure that returns handles to the data you put in. If you want more information, check out this talk, or for my project I used the Slotmap crate, which has great documentation to get you started with it. The reason I am using a Slotmap is that I can then hand out these handles to the other graphics code, but can internally manage the Vulkan buffer. The actual buffer object only needs to be handed to the rest of the code when a Vulkan call needs it. This simplifies a lot of scenarios, for example when the program is closed, the ResourceManager can go through all of the buffers and call the Vulkan deletion method. If I was to use Vulkan buffers directly, I would need to store each buffer and then destroy it manually.

Once I was happy with my simple implementation, I moved on to things needed for a mesh. I setup an upload queue and staging buffers so that meshes can be offloaded completely onto the GPU memory, and then used the obj crate to load in an .obj file. This was easy enough to parse into my Vertex information, which I added two extra attributes to(tex_coords and normals). At this point the mesh could still not be seen on screen, but I knew it was uploading correctly by using RenderDoc to preview what the mesh would look like.

renderdoc_preview

For my work this week and to be able to see the mesh, I needed to create a Uniform buffer for the projection, world and object matrices which the vertex shader could then access. I then also plan to implement mikktspace to generate tangent information, and finally finish off by implement an Index buffer for my meshes. Once this is done, I should have a basic mesh viewer.