Changeset 1abebc1 in opengl-game for vulkan-game.hpp
- Timestamp:
- May 19, 2021, 4:49:43 PM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- c163d81
- Parents:
- a3cefaa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.hpp
ra3cefaa r1abebc1 103 103 // has a VkBuffer, VkDeviceMemory, and VkDescriptorBufferInfo 104 104 // TODO: Maybe change the structure here since VkDescriptorBufferInfo already stores a reference to the VkBuffer 105 struct StorageBufferSet {105 struct BufferSet { 106 106 vector<VkBuffer> buffers; 107 107 vector<VkDeviceMemory> memory; … … 317 317 GraphicsPipeline_Vulkan<ExplosionVertex> explosionPipeline; 318 318 319 StorageBufferSet storageBuffers_modelPipeline;319 BufferSet storageBuffers_modelPipeline; 320 320 VulkanBuffer<SSBO_ModelObject> objects_modelPipeline; 321 321 322 StorageBufferSet storageBuffers_shipPipeline;322 BufferSet storageBuffers_shipPipeline; 323 323 VulkanBuffer<SSBO_ModelObject> objects_shipPipeline; 324 324 325 StorageBufferSet storageBuffers_asteroidPipeline;325 BufferSet storageBuffers_asteroidPipeline; 326 326 VulkanBuffer<SSBO_Asteroid> objects_asteroidPipeline; 327 327 328 StorageBufferSet storageBuffers_laserPipeline;328 BufferSet storageBuffers_laserPipeline; 329 329 VulkanBuffer<SSBO_Laser> objects_laserPipeline; 330 330 331 StorageBufferSet storageBuffers_explosionPipeline;331 BufferSet storageBuffers_explosionPipeline; 332 332 VulkanBuffer<SSBO_Explosion> objects_explosionPipeline; 333 333 … … 454 454 // TODO: Remove the need for templating, which is only there so a GraphicsPupeline_Vulkan can be passed in 455 455 template<class VertexType, class SSBOType> 456 void resize StorageBufferSet(StorageBufferSet& set, VulkanBuffer<SSBOType>& buffer,457 GraphicsPipeline_Vulkan<VertexType>& pipeline,458 VkCommandPool commandPool,VkQueue graphicsQueue);456 void resizeBufferSet(BufferSet& set, VulkanBuffer<SSBOType>& buffer, 457 GraphicsPipeline_Vulkan<VertexType>& pipeline, VkCommandPool commandPool, 458 VkQueue graphicsQueue); 459 459 460 460 template<class SSBOType> 461 void update StorageBuffer(StorageBufferSet& storageBufferSet, size_t objIndex, SSBOType& ssbo);461 void updateBufferSet(BufferSet& set, size_t objIndex, SSBOType& ssbo); 462 462 463 463 // TODO: Since addObject() returns a reference to the new object now, … … 467 467 GraphicsPipeline_Vulkan<VertexType>& pipeline, 468 468 const vector<VertexType>& vertices, vector<uint16_t> indices, 469 SSBOType ssbo , StorageBufferSet& storageBuffers);469 SSBOType ssbo); 470 470 471 471 template<class VertexType> … … 479 479 480 480 template<class VertexType, class SSBOType> 481 void updateObject(vector<SceneObject<VertexType, SSBOType>>& objects, 482 GraphicsPipeline_Vulkan<VertexType>& pipeline, size_t index); 481 void updateObject(SceneObject<VertexType, SSBOType>& obj); 483 482 484 483 template<class VertexType, class SSBOType> … … 522 521 523 522 template<class VertexType, class SSBOType> 524 void VulkanGame::resize StorageBufferSet(StorageBufferSet& set, VulkanBuffer<SSBOType>& buffer,525 GraphicsPipeline_Vulkan<VertexType>& pipeline,526 VkCommandPool commandPool,VkQueue graphicsQueue) {523 void VulkanGame::resizeBufferSet(BufferSet& set, VulkanBuffer<SSBOType>& buffer, 524 GraphicsPipeline_Vulkan<VertexType>& pipeline, VkCommandPool commandPool, 525 VkQueue graphicsQueue) { 527 526 size_t numObjects = buffer.numObjects < buffer.capacity ? buffer.numObjects : buffer.capacity; 528 527 … … 563 562 // TODO: See if it makes sense to pass in the current swapchain index instead of updating all of them 564 563 template<class SSBOType> 565 void VulkanGame::update StorageBuffer(StorageBufferSet& storageBufferSet, size_t objIndex, SSBOType& ssbo) {566 for (size_t i = 0; i < s torageBufferSet.memory.size(); i++) {567 VulkanUtils::copyDataToMemory(device, ssbo, s torageBufferSet.memory[i], objIndex * sizeof(SSBOType));564 void VulkanGame::updateBufferSet(BufferSet& set, size_t objIndex, SSBOType& ssbo) { 565 for (size_t i = 0; i < set.memory.size(); i++) { 566 VulkanUtils::copyDataToMemory(device, ssbo, set.memory[i], objIndex * sizeof(SSBOType)); 568 567 } 569 568 } … … 576 575 GraphicsPipeline_Vulkan<VertexType>& pipeline, 577 576 const vector<VertexType>& vertices, vector<uint16_t> indices, 578 SSBOType ssbo , StorageBufferSet& storageBuffers) {577 SSBOType ssbo) { 579 578 // TODO: Use the model field of ssbo to set the object's model_base 580 579 // currently, the passed in model is useless since it gets overridden in updateObject() anyway … … 684 683 // TODO: Just pass in the single object instead of a list of all of them 685 684 template<class VertexType, class SSBOType> 686 void VulkanGame::updateObject(vector<SceneObject<VertexType, SSBOType>>& objects, 687 GraphicsPipeline_Vulkan<VertexType>& pipeline, size_t index) { 688 SceneObject<VertexType, SSBOType>& obj = objects[index]; 689 685 void VulkanGame::updateObject(SceneObject<VertexType, SSBOType>& obj) { 690 686 obj.ssbo.model = obj.model_transform * obj.model_base; 691 687 obj.center = vec3(obj.ssbo.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
Note:
See TracChangeset
for help on using the changeset viewer.