Index: sdl-game.cpp
===================================================================
--- sdl-game.cpp	(revision 996dd3efcf576a5eaf4f04878167c007d853dbac)
+++ sdl-game.cpp	(revision a3cefaa6294c97206ade08805f4ff1b8c13d2d4e)
@@ -70,4 +70,5 @@
                      , gui(nullptr)
                      , window(nullptr)
+                     , objects_modelPipeline()
                      , score(0)
                      , fps(0.0f) {
@@ -87,4 +88,9 @@
 
    initVulkan();
+
+   VkPhysicalDeviceProperties deviceProperties;
+   vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
+
+   objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.minUniformBufferOffsetAlignment);
 
    initImGuiOverlay();
@@ -131,7 +137,7 @@
       }, {
          mat4(1.0f)
-      }, storageBuffers_modelPipeline, false);
-
-   updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare->ssbo);
+      }, storageBuffers_modelPipeline);
+
+   objects_modelPipeline.numObjects++;
 
    texturedSquare->model_base =
@@ -152,7 +158,7 @@
       }, {
          mat4(1.0f)
-      }, storageBuffers_modelPipeline, false);
-
-   updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare->ssbo);
+      }, storageBuffers_modelPipeline);
+
+   objects_modelPipeline.numObjects++;
 
    texturedSquare->model_base =
@@ -263,7 +269,7 @@
    modelPipeline = GraphicsPipeline_Vulkan<ModelVertex>(
       VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, physicalDevice, device, renderPass,
-      { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 16, 24, 10);
-
-   createBufferSet(modelPipeline.objectCapacity * sizeof(SSBO_ModelObject),
+      { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 16, 24);
+
+   createBufferSet(objects_modelPipeline.capacity * sizeof(SSBO_ModelObject),
       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
@@ -376,7 +382,7 @@
                         }, {
                            mat4(1.0f)
-                        }, storageBuffers_modelPipeline, true);
-
-                  updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare.ssbo);
+                        }, storageBuffers_modelPipeline);
+
+                  objects_modelPipeline.numObjects++;
 
                   texturedSquare.model_base =
@@ -446,6 +452,5 @@
 
 void VulkanGame::updateScene() {
-   // TODO: These two for loops could probably be combined into one
-
+   // Rotate the textured squares
    for (SceneObject<ModelVertex, SSBO_ModelObject>& model : this->modelObjects) {
       model.model_transform =
@@ -455,13 +460,12 @@
    }
 
-   // TODO: Instead, update entire sections (up to 64k) of the dynamic ubo if some objects there have changed
-   // Also, update the objects modelMat and center in the loop above instead of here
+   // TODO: Probably move the resizing to the VulkanBuffer class
+   if (objects_modelPipeline.numObjects > objects_modelPipeline.capacity) {
+      resizeStorageBufferSet(storageBuffers_modelPipeline, objects_modelPipeline, modelPipeline, resourceCommandPool,
+                             graphicsQueue);
+   }
+
    for (size_t i = 0; i < modelObjects.size(); i++) {
       if (modelObjects[i].modified) {
-         // TODO: Think about changing the SSBO-related code to also use a contiguous array
-         // to store the data on the cpu side instead of storing it per-object
-         // Then, I could also copy it to the GPU in one go
-         // Also, double-check if the alignment restrictions also hold for SSBOs
-
          updateObject(modelObjects, modelPipeline, i);
          updateStorageBuffer(storageBuffers_modelPipeline, i, modelObjects[i].ssbo);
@@ -845,5 +849,5 @@
    return VulkanUtils::findSupportedFormat(
       physicalDevice,
-      { VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT },
+      { VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D32_SFLOAT, VK_FORMAT_D24_UNORM_S8_UINT },
       VK_IMAGE_TILING_OPTIMAL,
       VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
