Changeset e8445f0 in opengl-game for graphics-pipeline_vulkan.hpp


Ignore:
Timestamp:
Apr 22, 2021, 1:54:17 AM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
b8072d3
Parents:
4a777d2
git-author:
Dmitry Portnoy <dportnoy@…> (04/22/21 01:54:07)
git-committer:
Dmitry Portnoy <dportnoy@…> (04/22/21 01:54:17)
Message:

Modify the parameter order of VulkanUtils::copyDataToMemory and add an overload
that takes the data size as a parameter instead of getting it from the template type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • graphics-pipeline_vulkan.hpp

    r4a777d2 re8445f0  
    3232};
    3333
    34 // TODO: Use this struct for uniform buffers as well (maybe move it to VulkanUtils)
     34// TODO: Use this struct for uniform buffers as well and rename it to VulkanBuffer (maybe move it to VulkanUtils)
     35// Also, probably better to make this a vector of structs where each struct
     36// has a VkBuffer, VkDeviceMemory, and VkDescriptorBufferInfo
    3537struct StorageBufferSet {
    3638   vector<VkBuffer> buffers;
     
    6466      void addStorageDescriptor(VkShaderStageFlags stageFlags);
    6567
    66       void addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, vector<VkDescriptorBufferInfo>* bufferData);
     68      // TODO: I might be able to use a single VkDescriptorBufferInfo here and reuse it when creating the descriptor sets
     69      void addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags,
     70                             vector<VkDescriptorBufferInfo>* bufferData);
    6771      void addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, VkDescriptorImageInfo* imageData);
    6872
     
    7579
    7680      bool addObject(const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType& ssbo,
    77          VkCommandPool commandPool, VkQueue graphicsQueue);
     81                     VkCommandPool commandPool, VkQueue graphicsQueue);
    7882
    7983      void updateObject(size_t objIndex, SSBOType& ssbo);
    8084
    8185      void updateObjectVertices(size_t objIndex, const vector<VertexType>& vertices, VkCommandPool commandPool,
    82          VkQueue graphicsQueue);
     86                                VkQueue graphicsQueue);
    8387
    8488      void cleanup();
     
    456460         switch (descriptorWrites[j].descriptorType) {
    457461            case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
     462            case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
    458463            case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
    459464               descriptorWrites[j].pBufferInfo = &(*this->descriptorInfoList[j].bufferDataList)[i];
     
    474479void GraphicsPipeline_Vulkan<VertexType, SSBOType>::createRenderCommands(VkCommandBuffer& commandBuffer,
    475480      uint32_t currentImage) {
     481
    476482   vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
     483
    477484   vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1,
    478485      &descriptorSets[currentImage], 0, nullptr);
     
    543550}
    544551
     552// TODO: Allow a swapchain index to be passed in instead of updating all of them
     553// Actually, since I'm in the process of replacing SSBOs with dynamic UBOs, I can ignore that for this function
    545554template<class VertexType, class SSBOType>
    546555void GraphicsPipeline_Vulkan<VertexType, SSBOType>::updateObject(size_t objIndex, SSBOType& ssbo) {
    547556   if (!is_same_v<SSBOType, void*>) {
    548557      for (size_t i = 0; i < storageBufferSet.memory.size(); i++) {
    549          VulkanUtils::copyDataToMemory(this->device, storageBufferSet.memory[i], objIndex * sizeof(SSBOType), ssbo);
     558         VulkanUtils::copyDataToMemory(this->device, ssbo, storageBufferSet.memory[i], objIndex * sizeof(SSBOType));
    550559      }
    551560   }
Note: See TracChangeset for help on using the changeset viewer.