Changeset bb76950 in opengl-game for sdl-game.hpp


Ignore:
Timestamp:
Jun 9, 2021, 6:41:48 PM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
b7fc3c2
Parents:
6bac215
git-author:
Dmitry Portnoy <dportnoy@…> (06/09/21 18:41:20)
git-committer:
Dmitry Portnoy <dportnoy@…> (06/09/21 18:41:48)
Message:

Change VulkanGame::resizeBufferSet() to take a buffer size instead of an entire
VulkanBuffer object, and to not update descriptor sets, which obviates the need
to pass in a GraphicsPipeline_Vulkan object. Descriptor set updates must
now be handled separetly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.hpp

    r6bac215 rbb76950  
    108108   vec3 center; // currently only matters for asteroids
    109109   float radius; // currently only matters for asteroids
     110
     111   // Move the targetAsteroid stuff out of this class since it is very specific to lasers
     112   // and makes moving SceneObject into its own header file more problematic
    110113   SceneObject<ModelVertex, SSBO_Asteroid>* targetAsteroid; // currently only used for lasers
    111114};
     
    297300                           BufferSet& set);
    298301
    299       template<class VertexType, class SSBOType>
    300       void resizeBufferSet(BufferSet& set, VulkanBuffer<SSBOType>& buffer,
    301                            GraphicsPipeline_Vulkan<VertexType>& pipeline, VkCommandPool commandPool,
    302                            VkQueue graphicsQueue);
     302      void resizeBufferSet(BufferSet& set, VkDeviceSize newSize, VkCommandPool commandPool, VkQueue graphicsQueue,
     303                           bool copyData);
    303304
    304305      template<class SSBOType>
     
    343344      void quitGame();
    344345};
    345 
    346 template<class VertexType, class SSBOType>
    347 void VulkanGame::resizeBufferSet(BufferSet& set, VulkanBuffer<SSBOType>& buffer,
    348                                  GraphicsPipeline_Vulkan<VertexType>& pipeline, VkCommandPool commandPool,
    349                                  VkQueue graphicsQueue) {
    350    VkDeviceSize newSize = buffer.capacity * sizeof(SSBOType);
    351 
    352    for (size_t i = 0; i < set.buffers.size(); i++) {
    353       VkBuffer newBuffer;
    354       VkDeviceMemory newMemory;
    355 
    356       VulkanUtils::createBuffer(device, physicalDevice, newSize, set.usages, set.properties, newBuffer, newMemory);
    357 
    358       VulkanUtils::copyBuffer(device, commandPool, set.buffers[i], newBuffer, 0, 0, set.infoSet[i].range,
    359                               graphicsQueue);
    360 
    361       vkDestroyBuffer(device, set.buffers[i], nullptr);
    362       vkFreeMemory(device, set.memory[i], nullptr);
    363 
    364       set.buffers[i] = newBuffer;
    365       set.memory[i] = newMemory;
    366 
    367       set.infoSet[i].buffer = set.buffers[i];
    368       set.infoSet[i].offset = 0; // This is the offset from the start of the buffer, so always 0 for now
    369       set.infoSet[i].range = newSize; // Size of the update starting from offset, or VK_WHOLE_SIZE
    370    }
    371 
    372    // Assume the SSBO is always the 2nd binding
    373    // TODO: Figure out a way to make this more flexible
    374    pipeline.updateDescriptorInfo(1, &set.infoSet, swapChainImages.size());
    375 }
    376346
    377347// TODO: See if it makes sense to pass in the current swapchain index instead of updating all of them
Note: See TracChangeset for help on using the changeset viewer.