Changeset 603b5bc in opengl-game for vulkan-ref.cpp
- Timestamp:
- Oct 22, 2019, 7:53:48 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 34bdf3a
- Parents:
- e83b155
- git-author:
- Dmitry Portnoy <dmitry.portnoy@…> (10/22/19 19:10:44)
- git-committer:
- Dmitry Portnoy <dmitry.portnoy@…> (10/22/19 19:53:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-ref.cpp
re83b155 r603b5bc 178 178 vector<VkImage> swapChainImages; 179 179 VkFormat swapChainImageFormat; 180 /*** END OF REFACTORED CODE ***/181 // (This was taken out of vulkan-game for now and replaced with Viewport)182 // It will definitely be needed when creating command buffers and I could use it in a few other places183 // TODO: Check above ^184 180 VkExtent2D swapChainExtent; 185 /*** START OF REFACTORED CODE ***/186 181 vector<VkImageView> swapChainImageViews; 187 /*** END OF REFACTORED CODE ***/188 182 vector<VkFramebuffer> swapChainFramebuffers; 189 183 190 /*** START OF REFACTORED CODE ***/191 184 VkRenderPass renderPass; 192 185 193 186 VkCommandPool commandPool; 194 /*** END OF REFACTORED CODE ***/195 187 vector<VkCommandBuffer> commandBuffers; 196 188 197 /*** START OF REFACTORED CODE ***/198 189 // The images and the sampler are used to store data for specific attributes. I probably 199 190 // want to keep them separate from the GraphicsPipelineInfo objects and start passing … … 203 194 VkDeviceMemory depthImageMemory; 204 195 VkImageView depthImageView; 205 /*** END OF REFACTORED CODE ***/206 196 207 197 VkImage textureImage; … … 213 203 VkImageView sdlOverlayImageView; 214 204 215 /*** START OF REFACTORED CODE ***/216 205 VkSampler textureSampler; 217 206 … … 222 211 vector<VkBuffer> uniformBuffers; 223 212 vector<VkDeviceMemory> uniformBuffersMemory; 224 /*** END OF REFACTORED CODE ***/225 213 226 214 VkDescriptorImageInfo sceneImageInfo; 227 215 VkDescriptorImageInfo overlayImageInfo; 228 216 229 /*** START OF REFACTORED CODE ***/230 217 vector<VkDescriptorBufferInfo> uniformBufferInfoList; 231 /*** END OF REFACTORED CODE ***/232 218 233 219 GraphicsPipelineInfo scenePipeline; 234 220 GraphicsPipelineInfo overlayPipeline; 221 /*** END OF REFACTORED CODE ***/ 235 222 236 223 vector<VkSemaphore> imageAvailableSemaphores; … … 339 326 340 327 createCommandPool(); 341 /*** END OF REFACTORED CODE ***/342 328 343 329 createImageResources("textures/texture.jpg", textureImage, textureImageMemory, textureImageView); 344 /*** START OF REFACTORED CODE ***/345 330 createImageResourcesFromSDLTexture(uiOverlay, sdlOverlayImage, sdlOverlayImageMemory, sdlOverlayImageView); 346 331 createTextureSampler(); … … 413 398 414 399 createDescriptorSetLayout(overlayPipeline); 400 401 createBufferResources(); 415 402 /*** END OF REFACTORED CODE ***/ 416 417 createBufferResources();418 403 419 404 createSyncObjects(); … … 818 803 } 819 804 } 820 /*** END OF REFACTORED CODE ***/821 805 822 806 void initGraphicsPipelineInfo(GraphicsPipelineInfo& info, 823 807 const void* vertexData, int vertexSize, size_t numVertices, 824 808 const void* indexData, int indexSize, size_t numIndices) { 825 /*** START OF REFACTORED CODE ***/826 809 // Since there is only one array of vertex data, we use binding = 0 827 810 // I'll probably do that for the foreseeable future … … 1015 998 vkDestroyShaderModule(device, fragShaderModule, nullptr); 1016 999 } 1017 /*** END OF REFACTORED CODE ***/1018 1000 1019 1001 VkShaderModule createShaderModule(const vector<char>& code) { … … 1035 1017 1036 1018 for (size_t i = 0; i < swapChainImageViews.size(); i++) { 1037 array 1019 array<VkImageView, 2> attachments = { 1038 1020 swapChainImageViews[i], 1039 1021 depthImageView … … 1055 1037 } 1056 1038 1057 /*** START OF REFACTORED CODE ***/1058 1039 void createCommandPool() { 1059 1040 QueueFamilyIndices queueFamilyIndices = findQueueFamilies(physicalDevice); … … 1100 1081 return indices; 1101 1082 } 1102 /*** END OF REFACTORED CODE ***/1103 1083 1104 1084 void createDepthResources() { … … 1112 1092 } 1113 1093 1114 /*** START OF REFACTORED CODE ***/1115 1094 VkFormat findDepthFormat() { 1116 1095 return findSupportedFormat( … … 1239 1218 } 1240 1219 1220 /*** START OF REFACTORED CODE ***/ 1241 1221 void createImage(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, 1242 1222 VkMemoryPropertyFlags properties, VkImage& image, VkDeviceMemory& imageMemory) { … … 1364 1344 } 1365 1345 1366 /*** START OF REFACTORED CODE ***/1367 1346 VkImageView createImageView(VkImage image, VkFormat format, VkImageAspectFlags aspectFlags) { 1368 1347 VkImageViewCreateInfo viewInfo = {}; … … 1649 1628 } 1650 1629 } 1651 /*** END OF REFACTORED CODE ***/1652 1630 1653 1631 void createCommandBuffers() { … … 1690 1668 vkCmdBeginRenderPass(commandBuffers[i], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE); 1691 1669 1670 /*** END OF REFACTORED CODE ***/ 1692 1671 createGraphicsPipelineCommands(scenePipeline, i); 1693 1672 createGraphicsPipelineCommands(overlayPipeline, i); 1673 /*** START OF REFACTORED CODE ***/ 1694 1674 1695 1675 vkCmdEndRenderPass(commandBuffers[i]); … … 1705 1685 vkCmdBindDescriptorSets(commandBuffers[currentImage], VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipelineLayout, 0, 1, 1706 1686 &info.descriptorSets[currentImage], 0, nullptr); 1687 /*** END OF REFACTORED CODE ***/ 1707 1688 1708 1689 VkBuffer vertexBuffers[] = { info.vertexBuffer }; … … 1713 1694 1714 1695 vkCmdDrawIndexed(commandBuffers[currentImage], static_cast<uint32_t>(info.numIndices), 1, 0, 0, 0); 1715 } 1696 /*** START OF REFACTORED CODE ***/ 1697 } 1698 /*** END OF REFACTORED CODE ***/ 1716 1699 1717 1700 void createSyncObjects() { … … 1955 1938 } 1956 1939 1940 /*** START OF REFACTORED CODE ***/ 1957 1941 void createBufferResources() { 1958 // TODO: The three functions below will be called in vulkan-game following the1959 // pipeline creation (createDescriptorSets()), and before createCommandBuffers()1960 1942 createDepthResources(); 1961 1943 createFramebuffers(); 1962 1944 createUniformBuffers(); 1963 1945 1964 /*** START OF REFACTORED CODE ***/1965 1946 createGraphicsPipeline("shaders/scene-vert.spv", "shaders/scene-frag.spv", scenePipeline); 1966 1947 createDescriptorPool(scenePipeline); … … 1970 1951 createDescriptorPool(overlayPipeline); 1971 1952 createDescriptorSets(overlayPipeline); 1972 /*** END OF REFACTORED CODE ***/1973 1953 1974 1954 createCommandBuffers(); … … 1976 1956 1977 1957 void cleanup() { 1978 /*** START OF REFACTORED CODE ***/1979 1958 cleanupSwapChain(); 1980 1959 … … 2042 2021 2043 2022 void cleanupSwapChain() { 2044 /*** END OF REFACTORED CODE ***/2045 2023 vkDestroyImageView(device, depthImageView, nullptr); 2046 2024 vkDestroyImage(device, depthImage, nullptr); … … 2053 2031 vkFreeCommandBuffers(device, commandPool, static_cast<uint32_t>(commandBuffers.size()), commandBuffers.data()); 2054 2032 2055 /*** START OF REFACTORED CODE ***/2056 2033 cleanupPipeline(scenePipeline); 2057 2034 cleanupPipeline(overlayPipeline);
Note:
See TracChangeset
for help on using the changeset viewer.