Changeset 1187ef5 in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Aug 20, 2019, 8:36:41 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
ad31ec7
Parents:
28c13da
Message:

Minor code reformatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r28c13da r1187ef5  
    192192
    193193      VkRenderPass renderPass;
     194
    194195      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
    195201
    196202      VkImage depthImage;
     
    212218      VkSampler textureSampler;
    213219
     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
    214227      GraphicsPipelineInfo scenePipeline;
    215228      GraphicsPipelineInfo overlayPipeline;
    216 
    217       vector<VkBuffer> uniformBuffers;
    218       vector<VkDeviceMemory> uniformBuffersMemory;
    219 
    220       vector<VkCommandBuffer> commandBuffers;
    221229
    222230      vector<VkSemaphore> imageAvailableSemaphores;
     
    323331         createDepthResources();
    324332         createFramebuffers();
     333
    325334         createImageResources("textures/texture.jpg", textureImage, textureImageMemory, textureImageView);
    326335         createImageResourcesFromSDLTexture(uiOverlay, sdlOverlayImage, sdlOverlayImageMemory, sdlOverlayImageView);
     
    16321641      }
    16331642
    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);
    16381647
    16391648         VkBuffer vertexBuffers[] = { info.vertexBuffer };
    16401649         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);
    16461655      }
    16471656
     
    16601669         for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
    16611670            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) {
    16641673               throw runtime_error("failed to create synchronization objects for a frame!");
    16651674            }
     
    16841693               }
    16851694               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) {
    16891697                     framebufferResized = true;
    16901698                  }
Note: See TracChangeset for help on using the changeset viewer.