Changeset 996dd3e in opengl-game for vulkan-game.hpp


Ignore:
Timestamp:
May 14, 2021, 1:09:34 AM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
a3cefaa
Parents:
9d21aac
Message:

Completely remove storage buffers from the GraphicsPipeline_Vulkan class and start moving storage buffer operations out of the addObject() and updateObject() functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.hpp

    r9d21aac r996dd3e  
    9696   alignas(16) mat4 proj;
    9797   alignas(4) float cur_time;
     98};
     99
     100// TODO: Use this struct for uniform buffers as well and probably combine it with the VulkanBuffer class
     101// Also, probably better to make this a vector of structs where each struct
     102// has a VkBuffer, VkDeviceMemory, and VkDescriptorBufferInfo
     103struct StorageBufferSet {
     104   vector<VkBuffer> buffers;
     105   vector<VkDeviceMemory> memory;
     106   vector<VkDescriptorBufferInfo> infoSet;
    98107};
    99108
     
    305314      GraphicsPipeline_Vulkan<LaserVertex> laserPipeline;
    306315      GraphicsPipeline_Vulkan<ExplosionVertex> explosionPipeline;
     316
     317      StorageBufferSet storageBuffers_modelPipeline;
     318      StorageBufferSet storageBuffers_shipPipeline;
     319      StorageBufferSet storageBuffers_asteroidPipeline;
     320      StorageBufferSet storageBuffers_laserPipeline;
     321      StorageBufferSet storageBuffers_explosionPipeline;
    307322
    308323      // TODO: Maybe make the ubo objects part of the pipeline class since there's only one ubo
     
    440455                                                   GraphicsPipeline_Vulkan<VertexType>& pipeline,
    441456                                                   const vector<VertexType>& vertices, vector<uint16_t> indices,
    442                                                    SSBOType ssbo, bool pipelinesCreated);
     457                                                   SSBOType ssbo, StorageBufferSet& storageBuffers,
     458                                                   bool pipelinesCreated);
    443459
    444460      template<class VertexType>
     
    544560                                                         GraphicsPipeline_Vulkan<VertexType>& pipeline,
    545561                                                         const vector<VertexType>& vertices, vector<uint16_t> indices,
    546                                                          SSBOType ssbo, bool pipelinesCreated) {
     562                                                         SSBOType ssbo, StorageBufferSet& storageBuffers,
     563                                                         bool pipelinesCreated) {
    547564   // TODO: Use the model field of ssbo to set the object's model_base
    548565   // currently, the passed in model is useless since it gets overridden in updateObject() anyway
     
    566583   pipeline.addObject(obj.vertices, obj.indices, resourceCommandPool, graphicsQueue);
    567584
     585   // TODO: Probably move the resizing to the VulkanBuffer class
     586   // First, try moving this out of addObject
    568587   bool resizeStorageBuffer = pipeline.numObjects == pipeline.objectCapacity;
    569588
    570589   if (resizeStorageBuffer) {
    571       resizeStorageBufferSet<VertexType, SSBOType>(pipeline.storageBufferSet, resourceCommandPool, graphicsQueue, pipeline);
     590      resizeStorageBufferSet<VertexType, SSBOType>(storageBuffers, resourceCommandPool, graphicsQueue, pipeline);
    572591      pipeline.cleanup();
    573592
    574593      // Assume the SSBO is always the 2nd binding
    575       pipeline.updateDescriptorInfo(1, &pipeline.storageBufferSet.infoSet);
     594      // TODO: Figure out a way to make this more flexible
     595      pipeline.updateDescriptorInfo(1, &storageBuffers.infoSet);
    576596   }
    577597
    578598   pipeline.numObjects++;
    579 
    580    updateStorageBuffer(pipeline.storageBufferSet, pipeline.numObjects - 1, obj.ssbo);
    581599
    582600   // TODO: Figure out why I am destroying and recreating the ubos when the swap chain is recreated,
     
    584602
    585603   if (pipelinesCreated) {
     604      // TODO: See if I can avoid doing this when recreating the pipeline
    586605      vkDeviceWaitIdle(device);
    587606
     
    699718   obj.center = vec3(obj.ssbo.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
    700719
    701    updateStorageBuffer(pipeline.storageBufferSet, index, obj.ssbo);
    702 
    703720   obj.modified = false;
    704721}
Note: See TracChangeset for help on using the changeset viewer.