Changeset a52ba87 in opengl-game
- Timestamp:
- Apr 17, 2020, 3:03:40 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 6385d0f
- Parents:
- 0ecab17
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
graphics-pipeline_vulkan.hpp
r0ecab17 ra52ba87 32 32 }; 33 33 34 // TODO: Use this struct for uniform buffers as well (maybe move it to VulkanUtils) 34 35 struct StorageBufferSet { 35 36 vector<VkBuffer> buffers; … … 61 62 void addAttribute(VkFormat format, size_t offset); 62 63 63 void addStorageDescriptor( );64 void addStorageDescriptor(VkShaderStageFlags stageFlags); 64 65 65 66 void addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, vector<VkDescriptorBufferInfo>* bufferData); … … 77 78 78 79 void updateObject(size_t objIndex, SSBOType& ssbo); 80 81 void updateObjectVertices(size_t objIndex, const vector<VertexType>& vertices, VkCommandPool commandPool, 82 VkQueue graphicsQueue); 79 83 80 84 void cleanup(); … … 214 218 } 215 219 216 template<class VertexType, class SSBOType> 217 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addStorageDescriptor() { 220 // TODO: The SSBOType check isn't really needed since I call this function in VulkanGame explicitly 221 template<class VertexType, class SSBOType> 222 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addStorageDescriptor(VkShaderStageFlags stageFlags) { 218 223 if (!is_same_v<SSBOType, void*>) { 219 224 addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 220 VK_SHADER_STAGE_VERTEX_BIT, &storageBufferSet.infoSet);225 stageFlags, &storageBufferSet.infoSet); 221 226 } 222 227 } … … 495 500 // - don't resize, but rewrite data in the buffer to only have non-deleted objects 496 501 497 if ( numVertices + vertices.size() >vertexCapacity) {502 if (this->numVertices + vertices.size() > this->vertexCapacity) { 498 503 resizeVertexBuffer(commandPool, graphicsQueue); 499 504 } 500 VulkanUtils::copyDataToBuffer( device, physicalDevice, commandPool, vertices, vertexBuffer, numVertices,501 graphicsQueue);502 numVertices += vertices.size();503 504 if ( numIndices + indices.size() >indexCapacity) {505 VulkanUtils::copyDataToBuffer(this->device, this->physicalDevice, commandPool, vertices, 506 this->vertexBuffer, this->numVertices, graphicsQueue); 507 this->numVertices += vertices.size(); 508 509 if (this->numIndices + indices.size() > this->indexCapacity) { 505 510 resizeIndexBuffer(commandPool, graphicsQueue); 506 511 } 507 VulkanUtils::copyDataToBuffer( device, physicalDevice, commandPool, indices, indexBuffer, numIndices,508 graphicsQueue);509 numIndices += indices.size();512 VulkanUtils::copyDataToBuffer(this->device, this->physicalDevice, commandPool, indices, 513 this->indexBuffer, this->numIndices, graphicsQueue); 514 this->numIndices += indices.size(); 510 515 511 516 bool resizedStorageBuffer = false; … … 540 545 if (!is_same_v<SSBOType, void*>) { 541 546 for (size_t i = 0; i < storageBufferSet.memory.size(); i++) { 542 VulkanUtils::copyDataToMemory( device, storageBufferSet.memory[i], objIndex, ssbo);547 VulkanUtils::copyDataToMemory(this->device, storageBufferSet.memory[i], objIndex, ssbo); 543 548 } 544 549 } 550 } 551 552 // Should only be used if the number of vertices has not changed 553 template<class VertexType, class SSBOType> 554 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::updateObjectVertices(size_t objIndex, 555 const vector<VertexType>& vertices, VkCommandPool commandPool, VkQueue graphicsQueue) { 556 VulkanUtils::copyDataToBuffer(this->device, this->physicalDevice, commandPool, vertices, 557 this->vertexBuffer, objIndex * vertices.size(), graphicsQueue); 545 558 } 546 559
Note:
See TracChangeset
for help on using the changeset viewer.