Changeset 996dd3e in opengl-game for sdl-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
  • sdl-game.hpp

    r9d21aac r996dd3e  
    7272   alignas(16) mat4 view;
    7373   alignas(16) mat4 proj;
     74};
     75
     76// TODO: Use this struct for uniform buffers as well and probably combine it with the VulkanBuffer class
     77// Also, probably better to make this a vector of structs where each struct
     78// has a VkBuffer, VkDeviceMemory, and VkDescriptorBufferInfo
     79struct StorageBufferSet {
     80   vector<VkBuffer> buffers;
     81   vector<VkDeviceMemory> memory;
     82   vector<VkDescriptorBufferInfo> infoSet;
    7483};
    7584
     
    208217      // wouldn't work since the whole pipeline couldn't have a common set of descriptors for the textures
    209218      GraphicsPipeline_Vulkan<ModelVertex> modelPipeline;
     219
     220      StorageBufferSet storageBuffers_modelPipeline;
    210221
    211222      // TODO: Maybe make the ubo objects part of the pipeline class since there's only one ubo
     
    297308                                                   GraphicsPipeline_Vulkan<VertexType>& pipeline,
    298309                                                   const vector<VertexType>& vertices, vector<uint16_t> indices,
    299                                                    SSBOType ssbo, bool pipelinesCreated);
     310                                                   SSBOType ssbo, StorageBufferSet& storageBuffers,
     311                                                   bool pipelinesCreated);
    300312
    301313      template<class VertexType>
     
    381393                                                         GraphicsPipeline_Vulkan<VertexType>& pipeline,
    382394                                                         const vector<VertexType>& vertices, vector<uint16_t> indices,
    383                                                          SSBOType ssbo, bool pipelinesCreated) {
     395                                                         SSBOType ssbo, StorageBufferSet& storageBuffers,
     396                                                         bool pipelinesCreated) {
    384397   // TODO: Use the model field of ssbo to set the object's model_base
    385398   // currently, the passed in model is useless since it gets overridden in updateObject() anyway
     
    403416   pipeline.addObject(obj.vertices, obj.indices, resourceCommandPool, graphicsQueue);
    404417
     418   // TODO: Probably move the resizing to the VulkanBuffer class
     419   // First, try moving this out of addObject
    405420   bool resizeStorageBuffer = pipeline.numObjects == pipeline.objectCapacity;
    406421
    407422   if (resizeStorageBuffer) {
    408       resizeStorageBufferSet<VertexType, SSBOType>(pipeline.storageBufferSet, resourceCommandPool, graphicsQueue, pipeline);
     423      resizeStorageBufferSet<VertexType, SSBOType>(storageBuffers, resourceCommandPool, graphicsQueue, pipeline);
    409424      pipeline.cleanup();
    410425
    411426      // Assume the SSBO is always the 2nd binding
    412       pipeline.updateDescriptorInfo(1, &pipeline.storageBufferSet.infoSet);
     427      // TODO: Figure out a way to make this more flexible
     428      pipeline.updateDescriptorInfo(1, &storageBuffers.infoSet);
    413429   }
    414430
    415431   pipeline.numObjects++;
    416 
    417    updateStorageBuffer(pipeline.storageBufferSet, pipeline.numObjects - 1, obj.ssbo);
    418432
    419433   // TODO: Figure out why I am destroying and recreating the ubos when the swap chain is recreated,
     
    421435
    422436   if (pipelinesCreated) {
     437      // TODO: See if I can avoid doing this when recreating the pipeline
    423438      vkDeviceWaitIdle(device);
    424439
     
    531546   obj.center = vec3(obj.ssbo.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
    532547
    533    updateStorageBuffer(pipeline.storageBufferSet, index, obj.ssbo);
    534 
    535548   obj.modified = false;
    536549}
Note: See TracChangeset for help on using the changeset viewer.