Changeset 1187ef5 in opengl-game for vulkan-game.cpp
- Timestamp:
- Aug 20, 2019, 8:36:41 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- ad31ec7
- Parents:
- 28c13da
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r28c13da r1187ef5 192 192 193 193 VkRenderPass renderPass; 194 194 195 VkCommandPool commandPool; 196 vector<VkCommandBuffer> commandBuffers; 197 198 // The images and the sampler are used to store data for specific attributes. I probably 199 // want to keep them separate from the GraphicsPipelineInfo objects and start passing 200 // references to them once I start defining uniform and varying attributes in GraphicsPipelineInfo objects 195 201 196 202 VkImage depthImage; … … 212 218 VkSampler textureSampler; 213 219 220 // These are currently to store the MVP matrix 221 // I should figure out if it makes sense to use them for other uniforms in the future 222 // If not, I should rename them to better indicate their puprose. 223 // I should also decide if I can use these for all shaders, or if I need a separapte set of buffers for each one 224 vector<VkBuffer> uniformBuffers; 225 vector<VkDeviceMemory> uniformBuffersMemory; 226 214 227 GraphicsPipelineInfo scenePipeline; 215 228 GraphicsPipelineInfo overlayPipeline; 216 217 vector<VkBuffer> uniformBuffers;218 vector<VkDeviceMemory> uniformBuffersMemory;219 220 vector<VkCommandBuffer> commandBuffers;221 229 222 230 vector<VkSemaphore> imageAvailableSemaphores; … … 323 331 createDepthResources(); 324 332 createFramebuffers(); 333 325 334 createImageResources("textures/texture.jpg", textureImage, textureImageMemory, textureImageView); 326 335 createImageResourcesFromSDLTexture(uiOverlay, sdlOverlayImage, sdlOverlayImageMemory, sdlOverlayImageView); … … 1632 1641 } 1633 1642 1634 void createGraphicsPipelineCommands(GraphicsPipelineInfo& info, size_t imageIdx) {1635 vkCmdBindPipeline(commandBuffers[ imageIdx], VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline);1636 vkCmdBindDescriptorSets(commandBuffers[ imageIdx], VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipelineLayout, 0, 1,1637 &info.descriptorSets[ imageIdx], 0, nullptr);1643 void createGraphicsPipelineCommands(GraphicsPipelineInfo& info, uint32_t currentImage) { 1644 vkCmdBindPipeline(commandBuffers[currentImage], VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline); 1645 vkCmdBindDescriptorSets(commandBuffers[currentImage], VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipelineLayout, 0, 1, 1646 &info.descriptorSets[currentImage], 0, nullptr); 1638 1647 1639 1648 VkBuffer vertexBuffers[] = { info.vertexBuffer }; 1640 1649 VkDeviceSize offsets[] = { 0 }; 1641 vkCmdBindVertexBuffers(commandBuffers[ imageIdx], 0, 1, vertexBuffers, offsets);1642 1643 vkCmdBindIndexBuffer(commandBuffers[ imageIdx], info.indexBuffer, 0, VK_INDEX_TYPE_UINT16);1644 1645 vkCmdDrawIndexed(commandBuffers[ imageIdx], static_cast<uint32_t>(info.numIndices), 1, 0, 0, 0);1650 vkCmdBindVertexBuffers(commandBuffers[currentImage], 0, 1, vertexBuffers, offsets); 1651 1652 vkCmdBindIndexBuffer(commandBuffers[currentImage], info.indexBuffer, 0, VK_INDEX_TYPE_UINT16); 1653 1654 vkCmdDrawIndexed(commandBuffers[currentImage], static_cast<uint32_t>(info.numIndices), 1, 0, 0, 0); 1646 1655 } 1647 1656 … … 1660 1669 for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) { 1661 1670 if (vkCreateSemaphore(device, &semaphoreInfo, nullptr, &imageAvailableSemaphores[i]) != VK_SUCCESS || 1662 vkCreateSemaphore(device, &semaphoreInfo, nullptr, &renderFinishedSemaphores[i]) != VK_SUCCESS ||1663 vkCreateFence(device, &fenceInfo, nullptr, &inFlightFences[i]) != VK_SUCCESS) {1671 vkCreateSemaphore(device, &semaphoreInfo, nullptr, &renderFinishedSemaphores[i]) != VK_SUCCESS || 1672 vkCreateFence(device, &fenceInfo, nullptr, &inFlightFences[i]) != VK_SUCCESS) { 1664 1673 throw runtime_error("failed to create synchronization objects for a frame!"); 1665 1674 } … … 1684 1693 } 1685 1694 if (e.type == SDL_WINDOWEVENT) { 1686 if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { 1687 framebufferResized = true; 1688 } else if (e.window.event == SDL_WINDOWEVENT_MINIMIZED) { 1695 if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED || 1696 e.window.event == SDL_WINDOWEVENT_MINIMIZED) { 1689 1697 framebufferResized = true; 1690 1698 }
Note:
See TracChangeset
for help on using the changeset viewer.