Changeset 860a0da in opengl-game
- Timestamp:
- Feb 18, 2020, 9:36:51 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 2da64ef
- Parents:
- d25381b
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
graphics-pipeline_vulkan.hpp
rd25381b r860a0da 5 5 6 6 #include <fstream> 7 #include <iostream> 7 8 #include <stdexcept> 8 9 #include <vector> … … 31 32 }; 32 33 34 struct StorageBufferSet { 35 vector<VkBuffer> buffers; 36 vector<VkDeviceMemory> memory; 37 vector<VkDescriptorBufferInfo> infoSet; 38 }; 39 33 40 template<class VertexType, class SSBOType> 34 41 class GraphicsPipeline_Vulkan : public GraphicsPipeline { 35 42 public: 36 43 GraphicsPipeline_Vulkan(); 44 45 // TODO: swapChainImages is only ever used to get its size. Check how that is determined and, 46 // if it will never change, just pass it in the constructor and save it 47 // If it does change, I could add an updateSwapchainImageCount() function 37 48 GraphicsPipeline_Vulkan(VkPhysicalDevice physicalDevice, VkDevice device, VkRenderPass renderPass, 38 Viewport viewport, size_t vertexCapacity, size_t indexCapacity); 49 Viewport viewport, vector<VkImage>& swapChainImages, 50 size_t vertexCapacity, size_t indexCapacity, size_t objectCapacity); 39 51 ~GraphicsPipeline_Vulkan(); 40 52 … … 46 58 47 59 void addAttribute(VkFormat format, size_t offset); 60 61 void addStorageDescriptor(); 48 62 49 63 void addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, vector<VkDescriptorBufferInfo>* bufferData); … … 62 76 void cleanup(); 63 77 void cleanupBuffers(); 78 79 StorageBufferSet storageBufferSet; 64 80 65 81 private: … … 90 106 VkDeviceMemory indexBufferMemory; 91 107 108 size_t numObjects; 109 size_t objectCapacity; 110 92 111 VkShaderModule createShaderModule(const vector<char>& code); 93 112 vector<char> readFile(const string& filename); … … 107 126 GraphicsPipeline_Vulkan<VertexType, SSBOType>::GraphicsPipeline_Vulkan( 108 127 VkPhysicalDevice physicalDevice, VkDevice device, 109 VkRenderPass renderPass, Viewport viewport, size_t vertexCapacity, size_t indexCapacity) { 128 VkRenderPass renderPass, Viewport viewport, vector<VkImage>& swapChainImages, 129 size_t vertexCapacity, size_t indexCapacity, size_t objectCapacity) { 110 130 this->physicalDevice = physicalDevice; 111 131 this->device = device; … … 133 153 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, 134 154 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, indexBuffer, indexBufferMemory); 135 } 136 155 156 this->numObjects = 0; 157 this->objectCapacity = objectCapacity; 158 159 // Hacky way to allow an SSBO to be optional 160 // Specifying void* as the SSBOType will skip allocating the related buffers 161 if (!is_same_v<SSBOType, void*>) { 162 VkDeviceSize bufferSize = objectCapacity * sizeof(SSBOType); 163 cout << "NUM SWAP CHAIN IMAGES: " << swapChainImages.size() << endl; 164 165 storageBufferSet.buffers.resize(swapChainImages.size()); 166 storageBufferSet.memory.resize(swapChainImages.size()); 167 storageBufferSet.infoSet.resize(swapChainImages.size()); 168 169 for (size_t i = 0; i < swapChainImages.size(); i++) { 170 VulkanUtils::createBuffer(this->device, this->physicalDevice, bufferSize, 171 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 172 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 173 storageBufferSet.buffers[i], storageBufferSet.memory[i]); 174 175 storageBufferSet.infoSet[i].buffer = storageBufferSet.buffers[i]; 176 storageBufferSet.infoSet[i].offset = 0; // This is the offset from the start of the buffer, so always 0 for now 177 storageBufferSet.infoSet[i].range = bufferSize; // Size of the update starting from offset, or VK_WHOLE_SIZE 178 } 179 } 180 } 181 182 // TODO: Move as much cleanup as I can into the destructor 137 183 template<class VertexType, class SSBOType> 138 184 GraphicsPipeline_Vulkan<VertexType, SSBOType>::~GraphicsPipeline_Vulkan() { … … 162 208 163 209 template<class VertexType, class SSBOType> 164 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, vector<VkDescriptorBufferInfo>* bufferData) { 210 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addStorageDescriptor() { 211 if (!is_same_v<SSBOType, void*>) { 212 addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 213 VK_SHADER_STAGE_VERTEX_BIT, &storageBufferSet.infoSet); 214 } 215 } 216 217 template<class VertexType, class SSBOType> 218 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addDescriptorInfo(VkDescriptorType type, 219 VkShaderStageFlags stageFlags, vector<VkDescriptorBufferInfo>* bufferData) { 165 220 this->descriptorInfoList.push_back({ type, stageFlags, bufferData, nullptr }); 166 221 } 167 222 168 223 template<class VertexType, class SSBOType> 169 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, VkDescriptorImageInfo* imageData) { 224 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addDescriptorInfo(VkDescriptorType type, 225 VkShaderStageFlags stageFlags, VkDescriptorImageInfo* imageData) { 170 226 this->descriptorInfoList.push_back({ type, stageFlags, nullptr, imageData }); 171 227 } … … 351 407 } 352 408 409 // TODO: Since I only need the size of the swapChainImages array, I should just pass that in instead of the whole array 353 410 template<class VertexType, class SSBOType> 354 411 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::createDescriptorSets(vector<VkImage>& swapChainImages) { … … 398 455 399 456 template<class VertexType, class SSBOType> 400 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::createRenderCommands(VkCommandBuffer& commandBuffer, uint32_t currentImage) { 457 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::createRenderCommands(VkCommandBuffer& commandBuffer, 458 uint32_t currentImage) { 401 459 vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); 402 460 vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, … … 436 494 vkDestroyPipeline(device, pipeline, nullptr); 437 495 vkDestroyDescriptorPool(device, descriptorPool, nullptr); 496 497 // TODO: I read that the pipeline layout does not have to be recreated every time 498 // Try only creating it once 438 499 vkDestroyPipelineLayout(device, pipelineLayout, nullptr); 439 500 } … … 447 508 vkDestroyBuffer(device, indexBuffer, nullptr); 448 509 vkFreeMemory(device, indexBufferMemory, nullptr); 510 511 if (!is_same_v<SSBOType, void*>) { 512 for (size_t i = 0; i < storageBufferSet.buffers.size(); i++) { 513 vkDestroyBuffer(device, storageBufferSet.buffers[i], nullptr); 514 vkFreeMemory(device, storageBufferSet.memory[i], nullptr); 515 } 516 } 449 517 } 450 518 … … 486 554 487 555 template<class VertexType, class SSBOType> 488 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::resizeVertexBuffer(VkCommandPool commandPool, VkQueue graphicsQueue) { 556 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::resizeVertexBuffer(VkCommandPool commandPool, 557 VkQueue graphicsQueue) { 489 558 VkBuffer newVertexBuffer; 490 559 VkDeviceMemory newVertexBufferMemory; 491 vertexCapacity *= 2;492 493 VulkanUtils::createBuffer( device, physicalDevice,vertexCapacity * sizeof(VertexType),560 this->vertexCapacity *= 2; 561 562 VulkanUtils::createBuffer(this->device, this->physicalDevice, this->vertexCapacity * sizeof(VertexType), 494 563 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, 495 564 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, newVertexBuffer, newVertexBufferMemory); 496 565 497 VulkanUtils::copyBuffer( device, commandPool, vertexBuffer, newVertexBuffer, 0, 0, numVertices * sizeof(VertexType), graphicsQueue);498 499 vkDestroyBuffer( device, vertexBuffer, nullptr);500 vkFreeMemory( device, vertexBufferMemory, nullptr);566 VulkanUtils::copyBuffer(this->device, commandPool, vertexBuffer, newVertexBuffer, 0, 0, numVertices * sizeof(VertexType), graphicsQueue); 567 568 vkDestroyBuffer(this->device, vertexBuffer, nullptr); 569 vkFreeMemory(this->device, vertexBufferMemory, nullptr); 501 570 502 571 vertexBuffer = newVertexBuffer; … … 505 574 506 575 template<class VertexType, class SSBOType> 507 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::resizeIndexBuffer(VkCommandPool commandPool, VkQueue graphicsQueue) { 576 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::resizeIndexBuffer(VkCommandPool commandPool, 577 VkQueue graphicsQueue) { 508 578 VkBuffer newIndexBuffer; 509 579 VkDeviceMemory newIndexBufferMemory; 510 indexCapacity *= 2;511 512 VulkanUtils::createBuffer( device, physicalDevice,indexCapacity * sizeof(uint16_t),580 this->indexCapacity *= 2; 581 582 VulkanUtils::createBuffer(this->device, this->physicalDevice, this->indexCapacity * sizeof(uint16_t), 513 583 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, 514 584 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, newIndexBuffer, newIndexBufferMemory); 515 585 516 VulkanUtils::copyBuffer( device, commandPool, indexBuffer, newIndexBuffer, 0, 0, numIndices * sizeof(uint16_t), graphicsQueue);517 518 vkDestroyBuffer( device, indexBuffer, nullptr);519 vkFreeMemory( device, indexBufferMemory, nullptr);586 VulkanUtils::copyBuffer(this->device, commandPool, indexBuffer, newIndexBuffer, 0, 0, numIndices * sizeof(uint16_t), graphicsQueue); 587 588 vkDestroyBuffer(this->device, indexBuffer, nullptr); 589 vkFreeMemory(this->device, indexBufferMemory, nullptr); 520 590 521 591 indexBuffer = newIndexBuffer; -
vulkan-game.cpp
rd25381b r860a0da 194 194 initGraphicsPipelines(); 195 195 196 overlayPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&OverlayVertex::pos)); 197 overlayPipeline.addAttribute(VK_FORMAT_R32G32_SFLOAT, offset_of(&OverlayVertex::texCoord)); 198 199 overlayPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 200 VK_SHADER_STAGE_FRAGMENT_BIT, &sdlOverlayImageDescriptor); 201 202 addObject(overlayObjects, overlayPipeline, 203 { 204 {{-1.0f, 1.0f, 0.0f}, {0.0f, 1.0f}}, 205 {{ 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f}}, 206 {{ 1.0f, -1.0f, 0.0f}, {1.0f, 0.0f}}, 207 {{-1.0f, -1.0f, 0.0f}, {0.0f, 0.0f}} 208 }, { 209 0, 1, 2, 2, 3, 0 210 }, {}); 211 212 overlayPipeline.createDescriptorSetLayout(); 213 overlayPipeline.createPipeline("shaders/overlay-vert.spv", "shaders/overlay-frag.spv"); 214 overlayPipeline.createDescriptorPool(swapChainImages); 215 overlayPipeline.createDescriptorSets(swapChainImages); 216 196 217 modelPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ModelVertex::pos)); 197 218 modelPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ModelVertex::color)); … … 201 222 createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 202 223 uniformBuffers_modelPipeline, uniformBuffersMemory_modelPipeline, uniformBufferInfoList_modelPipeline); 203 // TODO: Calculate the size of this buffer (and all the other SSBOs) based on the number of objects204 createBufferSet(10 * sizeof(SSBO_ModelObject), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,205 storageBuffers_modelPipeline, storageBuffersMemory_modelPipeline, storageBufferInfoList_modelPipeline);206 224 207 225 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 208 226 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_modelPipeline); 209 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 210 VK_SHADER_STAGE_VERTEX_BIT, &storageBufferInfoList_modelPipeline); 227 modelPipeline.addStorageDescriptor(); 211 228 212 229 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, … … 242 259 modelPipeline.createDescriptorSets(swapChainImages); 243 260 244 overlayPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&OverlayVertex::pos));245 overlayPipeline.addAttribute(VK_FORMAT_R32G32_SFLOAT, offset_of(&OverlayVertex::texCoord));246 247 overlayPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,248 VK_SHADER_STAGE_FRAGMENT_BIT, &sdlOverlayImageDescriptor);249 250 addObject(overlayObjects, overlayPipeline,251 {252 {{-1.0f, 1.0f, 0.0f}, {0.0f, 1.0f}},253 {{ 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},254 {{ 1.0f, -1.0f, 0.0f}, {1.0f, 0.0f}},255 {{-1.0f, -1.0f, 0.0f}, {0.0f, 0.0f}}256 }, {257 0, 1, 2, 2, 3, 0258 }, {});259 260 overlayPipeline.createDescriptorSetLayout();261 overlayPipeline.createPipeline("shaders/overlay-vert.spv", "shaders/overlay-frag.spv");262 overlayPipeline.createDescriptorPool(swapChainImages);263 overlayPipeline.createDescriptorSets(swapChainImages);264 265 261 shipPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ShipVertex::pos)); 266 262 shipPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ShipVertex::color)); … … 270 266 createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 271 267 uniformBuffers_shipPipeline, uniformBuffersMemory_shipPipeline, uniformBufferInfoList_shipPipeline); 272 createBufferSet(10 * sizeof(SSBO_ModelObject), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,273 storageBuffers_shipPipeline, storageBuffersMemory_shipPipeline, storageBufferInfoList_shipPipeline);274 268 275 269 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 276 270 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_shipPipeline); 277 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 278 VK_SHADER_STAGE_VERTEX_BIT, &storageBufferInfoList_shipPipeline); 271 shipPipeline.addStorageDescriptor(); 279 272 280 273 // TODO: With the normals, indexing basically becomes pointless since no vertices will have exactly … … 526 519 createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 527 520 uniformBuffers_asteroidPipeline, uniformBuffersMemory_asteroidPipeline, uniformBufferInfoList_asteroidPipeline); 528 createBufferSet(10 * sizeof(SSBO_Asteroid), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,529 storageBuffers_asteroidPipeline, storageBuffersMemory_asteroidPipeline, storageBufferInfoList_asteroidPipeline);530 521 531 522 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 532 523 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_asteroidPipeline); 533 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 534 VK_SHADER_STAGE_VERTEX_BIT, &storageBufferInfoList_asteroidPipeline); 524 asteroidPipeline.addStorageDescriptor(); 535 525 536 526 addObject(asteroidObjects, asteroidPipeline, … … 631 621 void VulkanGame::initGraphicsPipelines() { 632 622 overlayPipeline = GraphicsPipeline_Vulkan<OverlayVertex, void*>(physicalDevice, device, renderPass, 633 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, 4, 6);623 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 4, 6, 0); 634 624 635 625 modelPipeline = GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject>(physicalDevice, device, renderPass, 636 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, 16, 24);626 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 16, 24, 10); 637 627 638 628 shipPipeline = GraphicsPipeline_Vulkan<ShipVertex, SSBO_ModelObject>(physicalDevice, device, renderPass, 639 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, 138, 138);629 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 138, 138, 10); 640 630 641 631 asteroidPipeline = GraphicsPipeline_Vulkan<AsteroidVertex, SSBO_Asteroid>(physicalDevice, device, renderPass, 642 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, 24, 36);632 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 24, 36, 10); 643 633 } 644 634 … … 790 780 791 781 for (size_t i = 0; i < modelObjects.size(); i++) { 792 VulkanUtils::copyDataToMemory(device, storageBuffersMemory_modelPipeline[currentImage],782 VulkanUtils::copyDataToMemory(device, modelPipeline.storageBufferSet.memory[currentImage], 793 783 i, so_Object); 794 784 } … … 796 786 VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_shipPipeline[currentImage], 0, ship_VP_mats); 797 787 798 VulkanUtils::copyDataToMemory(device, s torageBuffersMemory_shipPipeline[currentImage], 0, so_Ship);788 VulkanUtils::copyDataToMemory(device, shipPipeline.storageBufferSet.memory[currentImage], 0, so_Ship); 799 789 800 790 VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_asteroidPipeline[currentImage], 0, asteroid_VP_mats); 801 791 802 VulkanUtils::copyDataToMemory(device, storageBuffersMemory_asteroidPipeline[currentImage], 0, so_Asteroid);792 VulkanUtils::copyDataToMemory(device, asteroidPipeline.storageBufferSet.memory[currentImage], 0, so_Asteroid); 803 793 } 804 794 … … 1461 1451 createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 1462 1452 uniformBuffers_modelPipeline, uniformBuffersMemory_modelPipeline, uniformBufferInfoList_modelPipeline); 1463 createBufferSet(10 * sizeof(SSBO_ModelObject), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,1464 storageBuffers_modelPipeline, storageBuffersMemory_modelPipeline, storageBufferInfoList_modelPipeline);1465 1453 1466 1454 modelPipeline.updateRenderPass(renderPass); … … 1476 1464 createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 1477 1465 uniformBuffers_shipPipeline, uniformBuffersMemory_shipPipeline, uniformBufferInfoList_shipPipeline); 1478 createBufferSet(10 * sizeof(SSBO_ModelObject), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,1479 storageBuffers_shipPipeline, storageBuffersMemory_shipPipeline, storageBufferInfoList_shipPipeline);1480 1466 1481 1467 shipPipeline.updateRenderPass(renderPass); … … 1486 1472 createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 1487 1473 uniformBuffers_asteroidPipeline, uniformBuffersMemory_asteroidPipeline, uniformBufferInfoList_asteroidPipeline); 1488 createBufferSet(10 * sizeof(SSBO_Asteroid), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,1489 storageBuffers_asteroidPipeline, storageBuffersMemory_asteroidPipeline, storageBufferInfoList_asteroidPipeline);1490 1474 1491 1475 asteroidPipeline.updateRenderPass(renderPass); … … 1506 1490 vkFreeCommandBuffers(device, commandPool, static_cast<uint32_t>(commandBuffers.size()), commandBuffers.data()); 1507 1491 1492 overlayPipeline.cleanup(); 1508 1493 modelPipeline.cleanup(); 1509 overlayPipeline.cleanup();1510 1494 shipPipeline.cleanup(); 1511 1495 asteroidPipeline.cleanup(); 1512 1513 vkDestroyRenderPass(device, renderPass, nullptr);1514 1515 for (VkImageView imageView : swapChainImageViews) {1516 vkDestroyImageView(device, imageView, nullptr);1517 }1518 1519 vkDestroySwapchainKHR(device, swapChain, nullptr);1520 1496 1521 1497 for (size_t i = 0; i < uniformBuffers_modelPipeline.size(); i++) { … … 1524 1500 } 1525 1501 1526 for (size_t i = 0; i < storageBuffers_modelPipeline.size(); i++) {1527 vkDestroyBuffer(device, storageBuffers_modelPipeline[i], nullptr);1528 vkFreeMemory(device, storageBuffersMemory_modelPipeline[i], nullptr);1529 }1530 1531 1502 for (size_t i = 0; i < uniformBuffers_shipPipeline.size(); i++) { 1532 1503 vkDestroyBuffer(device, uniformBuffers_shipPipeline[i], nullptr); … … 1534 1505 } 1535 1506 1536 for (size_t i = 0; i < storageBuffers_shipPipeline.size(); i++) {1537 vkDestroyBuffer(device, storageBuffers_shipPipeline[i], nullptr);1538 vkFreeMemory(device, storageBuffersMemory_shipPipeline[i], nullptr);1539 }1540 1541 1507 for (size_t i = 0; i < uniformBuffers_asteroidPipeline.size(); i++) { 1542 1508 vkDestroyBuffer(device, uniformBuffers_asteroidPipeline[i], nullptr); … … 1544 1510 } 1545 1511 1546 for (size_t i = 0; i < storageBuffers_asteroidPipeline.size(); i++) { 1547 vkDestroyBuffer(device, storageBuffers_asteroidPipeline[i], nullptr); 1548 vkFreeMemory(device, storageBuffersMemory_asteroidPipeline[i], nullptr); 1549 } 1550 } 1512 vkDestroyRenderPass(device, renderPass, nullptr); 1513 1514 for (VkImageView imageView : swapChainImageViews) { 1515 vkDestroyImageView(device, imageView, nullptr); 1516 } 1517 1518 vkDestroySwapchainKHR(device, swapChain, nullptr); 1519 } -
vulkan-game.hpp
rd25381b r860a0da 142 142 bool framebufferResized; 143 143 144 // TODO: I should probably rename the uniformBuffer* and storageBuffer*145 // variables to better reflect the data they hold146 147 // TODO: Create a struct that holds the buffers, memory, and info objects (Probably in VulkanUtils)148 149 144 GraphicsPipeline_Vulkan<OverlayVertex, void*> overlayPipeline; 150 145 vector<SceneObject<OverlayVertex, void*>> overlayObjects; 146 147 // TODO: Maybe make the ubo objects part of the pipeline class since there's only one ubo 148 // per pipeline. 149 // Or maybe create a higher level wrapper around GraphicsPipeline_Vulkan to hold things like 150 // the objects vector, the ubo, and the ssbo 151 151 152 152 GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject> modelPipeline; … … 157 157 vector<VkDescriptorBufferInfo> uniformBufferInfoList_modelPipeline; 158 158 159 vector<VkBuffer> storageBuffers_modelPipeline;160 vector<VkDeviceMemory> storageBuffersMemory_modelPipeline;161 vector<VkDescriptorBufferInfo> storageBufferInfoList_modelPipeline;162 163 159 UBO_VP_mats object_VP_mats; 164 160 SSBO_ModelObject so_Object; … … 171 167 vector<VkDescriptorBufferInfo> uniformBufferInfoList_shipPipeline; 172 168 173 vector<VkBuffer> storageBuffers_shipPipeline;174 vector<VkDeviceMemory> storageBuffersMemory_shipPipeline;175 vector<VkDescriptorBufferInfo> storageBufferInfoList_shipPipeline;176 177 169 UBO_VP_mats ship_VP_mats; 178 170 SSBO_ModelObject so_Ship; … … 184 176 vector<VkDeviceMemory> uniformBuffersMemory_asteroidPipeline; 185 177 vector<VkDescriptorBufferInfo> uniformBufferInfoList_asteroidPipeline; 186 187 vector<VkBuffer> storageBuffers_asteroidPipeline;188 vector<VkDeviceMemory> storageBuffersMemory_asteroidPipeline;189 vector<VkDescriptorBufferInfo> storageBufferInfoList_asteroidPipeline;190 178 191 179 UBO_VP_mats asteroid_VP_mats;
Note:
See TracChangeset
for help on using the changeset viewer.