Changeset 237cbec in opengl-game for vulkan-game.cpp
- Timestamp:
- Apr 19, 2020, 2:35:55 AM (4 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 1f81ecc
- Parents:
- 6104594
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r6104594 r237cbec 27 27 this->ship_VP_mats = {}; 28 28 this->asteroid_VP_mats = {}; 29 this->laser_VP_mats = {}; 29 30 } 30 31 … … 540 541 asteroidPipeline.createDescriptorSets(swapChainImages); 541 542 543 laserPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&LaserVertex::pos)); 544 laserPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&LaserVertex::texCoord)); 545 laserPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&LaserVertex::objIndex)); 546 547 createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 548 uniformBuffers_laserPipeline, uniformBuffersMemory_laserPipeline, uniformBufferInfoList_laserPipeline); 549 550 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 551 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_laserPipeline); 552 laserPipeline.addStorageDescriptor(VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT); 553 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 554 VK_SHADER_STAGE_FRAGMENT_BIT, &laserTextureImageDescriptor); 555 556 laserPipeline.createDescriptorSetLayout(); 557 laserPipeline.createPipeline("shaders/laser-vert.spv", "shaders/laser-frag.spv"); 558 laserPipeline.createDescriptorPool(swapChainImages); 559 laserPipeline.createDescriptorSets(swapChainImages); 560 542 561 cout << "Created all the graphics pipelines" << endl; 543 562 … … 564 583 asteroidPipeline = GraphicsPipeline_Vulkan<AsteroidVertex, SSBO_Asteroid>(physicalDevice, device, renderPass, 565 584 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 24, 36, 10); 585 586 laserPipeline = GraphicsPipeline_Vulkan<LaserVertex, SSBO_Laser>(physicalDevice, device, renderPass, 587 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 8, 18, 2); 566 588 } 567 589 … … 591 613 asteroid_VP_mats.view = viewMat; 592 614 asteroid_VP_mats.proj = projMat; 615 616 laser_VP_mats.view = viewMat; 617 laser_VP_mats.proj = projMat; 593 618 } 594 619 … … 827 852 } 828 853 854 for (size_t i = 0; i < laserObjects.size(); i++) { 855 if (laserObjects[i].modified) { 856 updateObject(laserObjects, laserPipeline, i); 857 } 858 } 859 829 860 VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_modelPipeline[currentImage], 0, object_VP_mats); 830 861 … … 832 863 833 864 VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_asteroidPipeline[currentImage], 0, asteroid_VP_mats); 865 866 VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_laserPipeline[currentImage], 0, laser_VP_mats); 834 867 } 835 868 … … 929 962 VulkanUtils::destroyVulkanImage(device, sdlOverlayImage); 930 963 VulkanUtils::destroyVulkanImage(device, floorTextureImage); 964 VulkanUtils::destroyVulkanImage(device, laserTextureImage); 931 965 932 966 vkDestroySampler(device, textureSampler, nullptr); … … 936 970 shipPipeline.cleanupBuffers(); 937 971 asteroidPipeline.cleanupBuffers(); 972 laserPipeline.cleanupBuffers(); 938 973 939 974 for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) { … … 1325 1360 floorTextureImageDescriptor.imageView = floorTextureImage.imageView; 1326 1361 floorTextureImageDescriptor.sampler = textureSampler; 1362 1363 VulkanUtils::createVulkanImageFromFile(device, physicalDevice, commandPool, "textures/laser.png", 1364 laserTextureImage, graphicsQueue); 1365 1366 laserTextureImageDescriptor = {}; 1367 laserTextureImageDescriptor.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; 1368 laserTextureImageDescriptor.imageView = laserTextureImage.imageView; 1369 laserTextureImageDescriptor.sampler = textureSampler; 1327 1370 } 1328 1371 … … 1419 1462 shipPipeline.createRenderCommands(commandBuffers[i], i); 1420 1463 asteroidPipeline.createRenderCommands(commandBuffers[i], i); 1464 laserPipeline.createRenderCommands(commandBuffers[i], i); 1421 1465 1422 1466 // Always render this pipeline last … … 1523 1567 asteroidPipeline.createDescriptorSets(swapChainImages); 1524 1568 1569 createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 1570 uniformBuffers_laserPipeline, uniformBuffersMemory_laserPipeline, uniformBufferInfoList_laserPipeline); 1571 1572 laserPipeline.updateRenderPass(renderPass); 1573 laserPipeline.createPipeline("shaders/laser-vert.spv", "shaders/laser-frag.spv"); 1574 laserPipeline.createDescriptorPool(swapChainImages); 1575 laserPipeline.createDescriptorSets(swapChainImages); 1576 1525 1577 createCommandBuffers(); 1526 1578 } … … 1539 1591 shipPipeline.cleanup(); 1540 1592 asteroidPipeline.cleanup(); 1593 laserPipeline.cleanup(); 1541 1594 1542 1595 for (size_t i = 0; i < uniformBuffers_modelPipeline.size(); i++) { … … 1555 1608 } 1556 1609 1610 for (size_t i = 0; i < uniformBuffers_laserPipeline.size(); i++) { 1611 vkDestroyBuffer(device, uniformBuffers_laserPipeline[i], nullptr); 1612 vkFreeMemory(device, uniformBuffersMemory_laserPipeline[i], nullptr); 1613 } 1614 1557 1615 vkDestroyRenderPass(device, renderPass, nullptr); 1558 1616
Note:
See TracChangeset
for help on using the changeset viewer.