Index: sdl-game.hpp
===================================================================
--- sdl-game.hpp	(revision b8072d392d78f98f83ee7c10e3f50a901a29dff2)
+++ sdl-game.hpp	(revision 9d21aac42227b516c5df135b6ff2266349c321e4)
@@ -207,5 +207,5 @@
       // the same pipeline, but use different textures, the approach I took when initially creating GraphicsPipeline_Vulkan
       // wouldn't work since the whole pipeline couldn't have a common set of descriptors for the textures
-      GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject> modelPipeline;
+      GraphicsPipeline_Vulkan<ModelVertex> modelPipeline;
 
       // TODO: Maybe make the ubo objects part of the pipeline class since there's only one ubo
@@ -276,7 +276,18 @@
       void cleanupImGuiOverlay();
 
-      void createBufferSet(vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory, VkDeviceSize bufferSize,
-                           VkBufferUsageFlags flags, VkMemoryPropertyFlags properties,
+      // TODO: Maybe move these to a different class, possibly VulkanBuffer or some new related class
+
+      void createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags, VkMemoryPropertyFlags properties,
+                           vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory,
                            vector<VkDescriptorBufferInfo>& bufferInfoList);
+
+      // TODO: See if it makes sense to rename this to resizeBufferSet() and use it to resize other types of buffers as well
+      // TODO: Remove the need for templating, which is only there so a GraphicsPupeline_Vulkan can be passed in
+      template<class VertexType, class SSBOType>
+      void resizeStorageBufferSet(StorageBufferSet& set, VkCommandPool commandPool, VkQueue graphicsQueue,
+                                  GraphicsPipeline_Vulkan<VertexType>& pipeline);
+
+      template<class SSBOType>
+      void updateStorageBuffer(StorageBufferSet& storageBufferSet, size_t objIndex, SSBOType& ssbo);
 
       // TODO: Since addObject() returns a reference to the new object now,
@@ -284,5 +295,5 @@
       template<class VertexType, class SSBOType>
       SceneObject<VertexType, SSBOType>& addObject(vector<SceneObject<VertexType, SSBOType>>& objects,
-                                                   GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline,
+                                                   GraphicsPipeline_Vulkan<VertexType>& pipeline,
                                                    const vector<VertexType>& vertices, vector<uint16_t> indices,
                                                    SSBOType ssbo, bool pipelinesCreated);
@@ -298,6 +309,6 @@
 
       template<class VertexType, class SSBOType>
-      void updateObject(vector<SceneObject<VertexType, SSBOType>>& objects, GraphicsPipeline_Vulkan<VertexType,
-                        SSBOType>& pipeline, size_t index);
+      void updateObject(vector<SceneObject<VertexType, SSBOType>>& objects,
+                        GraphicsPipeline_Vulkan<VertexType>& pipeline, size_t index);
 
       void renderFrame(ImDrawData* draw_data);
@@ -320,7 +331,45 @@
 };
 
+template<class VertexType, class SSBOType>
+void VulkanGame::resizeStorageBufferSet(StorageBufferSet& set, VkCommandPool commandPool, VkQueue graphicsQueue,
+                                        GraphicsPipeline_Vulkan<VertexType>& pipeline) {
+   pipeline.objectCapacity *= 2;
+   VkDeviceSize bufferSize = pipeline.objectCapacity * sizeof(SSBOType);
+
+   for (size_t i = 0; i < set.buffers.size(); i++) {
+      VkBuffer newStorageBuffer;
+      VkDeviceMemory newStorageBufferMemory;
+
+      VulkanUtils::createBuffer(device, physicalDevice, bufferSize,
+         VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
+         VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+         newStorageBuffer, newStorageBufferMemory);
+
+      VulkanUtils::copyBuffer(device, commandPool, set.buffers[i], newStorageBuffer,
+         0, 0, pipeline.numObjects * sizeof(SSBOType), graphicsQueue);
+
+      vkDestroyBuffer(device, set.buffers[i], nullptr);
+      vkFreeMemory(device, set.memory[i], nullptr);
+
+      set.buffers[i] = newStorageBuffer;
+      set.memory[i] = newStorageBufferMemory;
+
+      set.infoSet[i].buffer = set.buffers[i];
+      set.infoSet[i].offset = 0; // This is the offset from the start of the buffer, so always 0 for now
+      set.infoSet[i].range = bufferSize; // Size of the update starting from offset, or VK_WHOLE_SIZE
+   }
+}
+
+// TODO: See if it makes sense to pass in the current swapchain index instead of updating all of them
+template<class SSBOType>
+void VulkanGame::updateStorageBuffer(StorageBufferSet& storageBufferSet, size_t objIndex, SSBOType& ssbo) {
+   for (size_t i = 0; i < storageBufferSet.memory.size(); i++) {
+      VulkanUtils::copyDataToMemory(device, ssbo, storageBufferSet.memory[i], objIndex * sizeof(SSBOType));
+   }
+}
+
 // TODO: Right now, it's basically necessary to pass the identity matrix in for ssbo.model
 // and to change the model matrix later by setting model_transform and then calling updateObject()
-// Figure out a better way to allow the model matrix to be set during objecting creation
+// Figure out a better way to allow the model matrix to be set during object creation
 
 // TODO: Maybe return a reference to the object from this method if I decide that updating it
@@ -329,9 +378,8 @@
 // to account for scaling
 template<class VertexType, class SSBOType>
-SceneObject<VertexType, SSBOType>& VulkanGame::addObject(
-   vector<SceneObject<VertexType, SSBOType>>& objects,
-   GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline,
-   const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo,
-   bool pipelinesCreated) {
+SceneObject<VertexType, SSBOType>& VulkanGame::addObject(vector<SceneObject<VertexType, SSBOType>>& objects,
+                                                         GraphicsPipeline_Vulkan<VertexType>& pipeline,
+                                                         const vector<VertexType>& vertices, vector<uint16_t> indices,
+                                                         SSBOType ssbo, bool pipelinesCreated) {
    // TODO: Use the model field of ssbo to set the object's model_base
    // currently, the passed in model is useless since it gets overridden in updateObject() anyway
@@ -353,6 +401,22 @@
    }
 
-   bool storageBufferResized = pipeline.addObject(obj.vertices, obj.indices, obj.ssbo,
-      resourceCommandPool, graphicsQueue);
+   pipeline.addObject(obj.vertices, obj.indices, resourceCommandPool, graphicsQueue);
+
+   bool resizeStorageBuffer = pipeline.numObjects == pipeline.objectCapacity;
+
+   if (resizeStorageBuffer) {
+      resizeStorageBufferSet<VertexType, SSBOType>(pipeline.storageBufferSet, resourceCommandPool, graphicsQueue, pipeline);
+      pipeline.cleanup();
+
+      // Assume the SSBO is always the 2nd binding
+      pipeline.updateDescriptorInfo(1, &pipeline.storageBufferSet.infoSet);
+   }
+
+   pipeline.numObjects++;
+
+   updateStorageBuffer(pipeline.storageBufferSet, pipeline.numObjects - 1, obj.ssbo);
+
+   // TODO: Figure out why I am destroying and recreating the ubos when the swap chain is recreated,
+   // but am reusing the same ssbos. Maybe I don't need to recreate the ubos.
 
    if (pipelinesCreated) {
@@ -367,5 +431,8 @@
       // Refactor the logic to check for any resized SSBOs after all objects for the frame
       // are created and then recreate each of the corresponding pipelines only once per frame
-      if (storageBufferResized) {
+
+      // TODO: Also, verify if I actually need to recreate all of these, or maybe just the descriptor sets, for instance
+
+      if (resizeStorageBuffer) {
          pipeline.createPipeline(pipeline.vertShaderFile, pipeline.fragShaderFile);
          pipeline.createDescriptorPool(swapChainImages);
@@ -457,6 +524,6 @@
 // TODO: Just pass in the single object instead of a list of all of them
 template<class VertexType, class SSBOType>
-void VulkanGame::updateObject(vector<SceneObject<VertexType, SSBOType>>& objects, GraphicsPipeline_Vulkan<VertexType,
-                              SSBOType>& pipeline, size_t index) {
+void VulkanGame::updateObject(vector<SceneObject<VertexType, SSBOType>>& objects,
+                              GraphicsPipeline_Vulkan<VertexType>& pipeline, size_t index) {
    SceneObject<VertexType, SSBOType>& obj = objects[index];
 
@@ -464,5 +531,5 @@
    obj.center = vec3(obj.ssbo.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
 
-   pipeline.updateObject(index, obj.ssbo);
+   updateStorageBuffer(pipeline.storageBufferSet, index, obj.ssbo);
 
    obj.modified = false;
