Changeset 996dd3e in opengl-game for vulkan-game.hpp
- Timestamp:
- May 14, 2021, 1:09:34 AM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- a3cefaa
- Parents:
- 9d21aac
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.hpp
r9d21aac r996dd3e 96 96 alignas(16) mat4 proj; 97 97 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 103 struct StorageBufferSet { 104 vector<VkBuffer> buffers; 105 vector<VkDeviceMemory> memory; 106 vector<VkDescriptorBufferInfo> infoSet; 98 107 }; 99 108 … … 305 314 GraphicsPipeline_Vulkan<LaserVertex> laserPipeline; 306 315 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; 307 322 308 323 // TODO: Maybe make the ubo objects part of the pipeline class since there's only one ubo … … 440 455 GraphicsPipeline_Vulkan<VertexType>& pipeline, 441 456 const vector<VertexType>& vertices, vector<uint16_t> indices, 442 SSBOType ssbo, bool pipelinesCreated); 457 SSBOType ssbo, StorageBufferSet& storageBuffers, 458 bool pipelinesCreated); 443 459 444 460 template<class VertexType> … … 544 560 GraphicsPipeline_Vulkan<VertexType>& pipeline, 545 561 const vector<VertexType>& vertices, vector<uint16_t> indices, 546 SSBOType ssbo, bool pipelinesCreated) { 562 SSBOType ssbo, StorageBufferSet& storageBuffers, 563 bool pipelinesCreated) { 547 564 // TODO: Use the model field of ssbo to set the object's model_base 548 565 // currently, the passed in model is useless since it gets overridden in updateObject() anyway … … 566 583 pipeline.addObject(obj.vertices, obj.indices, resourceCommandPool, graphicsQueue); 567 584 585 // TODO: Probably move the resizing to the VulkanBuffer class 586 // First, try moving this out of addObject 568 587 bool resizeStorageBuffer = pipeline.numObjects == pipeline.objectCapacity; 569 588 570 589 if (resizeStorageBuffer) { 571 resizeStorageBufferSet<VertexType, SSBOType>( pipeline.storageBufferSet, resourceCommandPool, graphicsQueue, pipeline);590 resizeStorageBufferSet<VertexType, SSBOType>(storageBuffers, resourceCommandPool, graphicsQueue, pipeline); 572 591 pipeline.cleanup(); 573 592 574 593 // 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); 576 596 } 577 597 578 598 pipeline.numObjects++; 579 580 updateStorageBuffer(pipeline.storageBufferSet, pipeline.numObjects - 1, obj.ssbo);581 599 582 600 // TODO: Figure out why I am destroying and recreating the ubos when the swap chain is recreated, … … 584 602 585 603 if (pipelinesCreated) { 604 // TODO: See if I can avoid doing this when recreating the pipeline 586 605 vkDeviceWaitIdle(device); 587 606 … … 699 718 obj.center = vec3(obj.ssbo.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 700 719 701 updateStorageBuffer(pipeline.storageBufferSet, index, obj.ssbo);702 703 720 obj.modified = false; 704 721 }
Note:
See TracChangeset
for help on using the changeset viewer.