Changeset bb76950 in opengl-game for vulkan-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
  • vulkan-game.hpp

    r6bac215 rbb76950  
    124124   vec3 center; // currently only matters for asteroids
    125125   float radius; // currently only matters for asteroids
     126
     127   // Move the targetAsteroid stuff out of this class since it is very specific to lasers
     128   // and makes moving SceneObject into its own header file more problematic
    126129   SceneObject<ModelVertex, SSBO_Asteroid>* targetAsteroid; // currently only used for lasers
    127130};
     
    432435                           BufferSet& set);
    433436
    434       template<class VertexType, class SSBOType>
    435       void resizeBufferSet(BufferSet& set, VulkanBuffer<SSBOType>& buffer,
    436                            GraphicsPipeline_Vulkan<VertexType>& pipeline, VkCommandPool commandPool,
    437                            VkQueue graphicsQueue);
     437      void resizeBufferSet(BufferSet& set, VkDeviceSize newSize, VkCommandPool commandPool, VkQueue graphicsQueue,
     438                           bool copyData);
    438439
    439440      template<class SSBOType>
     
    498499
    499500// End of specialized no-op functions
    500 
    501 template<class VertexType, class SSBOType>
    502 void VulkanGame::resizeBufferSet(BufferSet& set, VulkanBuffer<SSBOType>& buffer,
    503                                  GraphicsPipeline_Vulkan<VertexType>& pipeline, VkCommandPool commandPool,
    504                                  VkQueue graphicsQueue) {
    505    VkDeviceSize newSize = buffer.capacity * sizeof(SSBOType);
    506 
    507    for (size_t i = 0; i < set.buffers.size(); i++) {
    508       VkBuffer newBuffer;
    509       VkDeviceMemory newMemory;
    510 
    511       VulkanUtils::createBuffer(device, physicalDevice, newSize, set.usages, set.properties, newBuffer, newMemory);
    512 
    513       VulkanUtils::copyBuffer(device, commandPool, set.buffers[i], newBuffer, 0, 0, set.infoSet[i].range,
    514                               graphicsQueue);
    515 
    516       vkDestroyBuffer(device, set.buffers[i], nullptr);
    517       vkFreeMemory(device, set.memory[i], nullptr);
    518 
    519       set.buffers[i] = newBuffer;
    520       set.memory[i] = newMemory;
    521 
    522       set.infoSet[i].buffer = set.buffers[i];
    523       set.infoSet[i].offset = 0; // This is the offset from the start of the buffer, so always 0 for now
    524       set.infoSet[i].range = newSize; // Size of the update starting from offset, or VK_WHOLE_SIZE
    525    }
    526 
    527    // Assume the SSBO is always the 2nd binding
    528    // TODO: Figure out a way to make this more flexible
    529    pipeline.updateDescriptorInfo(1, &set.infoSet, swapChainImages.size());
    530 }
    531501
    532502// 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.