Changeset d2d9286 in opengl-game for vulkan-ref.cpp


Ignore:
Timestamp:
Nov 7, 2019, 2:05:17 AM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
f985231
Parents:
87c8f1a
Message:

In vulkangame, implement the renderScene function to draw a frame in Vulkan and implement a test UI overlay

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-ref.cpp

    r87c8f1a rd2d9286  
    823823      }
    824824
    825 /*** START OF REFACTORED CODE ***/
    826825      void addDescriptorInfo(GraphicsPipelineInfo& info, VkDescriptorType type, VkShaderStageFlags stageFlags, vector<VkDescriptorBufferInfo>* bufferData, VkDescriptorImageInfo* imageData) {
    827826         info.descriptorInfoList.push_back({ type, stageFlags, bufferData, imageData });
     
    11601159         view = createImageView(image, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT);
    11611160      }
    1162 /*** END OF REFACTORED CODE ***/
    11631161
    11641162      void populateImageFromSDLTexture(SDL_Texture* texture, VkImage& image) {
     
    12051203      }
    12061204
    1207 /*** START OF REFACTORED CODE ***/
    12081205      void createImage(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage,
    12091206            VkMemoryPropertyFlags properties, VkImage& image, VkDeviceMemory& imageMemory) {
     
    16531650            vkCmdBeginRenderPass(commandBuffers[i], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
    16541651
    1655 /*** END OF REFACTORED CODE ***/
    16561652            createGraphicsPipelineCommands(scenePipeline, i);
    16571653            createGraphicsPipelineCommands(overlayPipeline, i);
    1658 /*** START OF REFACTORED CODE ***/
    16591654
    16601655            vkCmdEndRenderPass(commandBuffers[i]);
     
    16701665         vkCmdBindDescriptorSets(commandBuffers[currentImage], VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipelineLayout, 0, 1,
    16711666            &info.descriptorSets[currentImage], 0, nullptr);
    1672 /*** END OF REFACTORED CODE ***/
    16731667
    16741668         VkBuffer vertexBuffers[] = { info.vertexBuffer };
     
    16791673
    16801674         vkCmdDrawIndexed(commandBuffers[currentImage], static_cast<uint32_t>(info.numIndices), 1, 0, 0, 0);
    1681 /*** START OF REFACTORED CODE ***/
    16821675      }
    16831676
     
    17911784
    17921785         uint32_t imageIndex;
    1793 /*** END OF REFACTORED CODE ***/
    17941786
    17951787         VkResult result = vkAcquireNextImageKHR(device, swapChain, numeric_limits<uint64_t>::max(),
     
    18021794            throw runtime_error("failed to acquire swap chain image!");
    18031795         }
     1796/*** END OF REFACTORED CODE ***/
    18041797
    18051798         updateUniformBuffer(imageIndex);
    18061799
     1800/*** START OF REFACTORED CODE ***/
    18071801         VkSubmitInfo submitInfo = {};
    18081802         submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
     
    18481842         }
    18491843
    1850 /*** START OF REFACTORED CODE ***/
    18511844         currentFrame = (currentFrame + 1) % MAX_FRAMES_IN_FLIGHT;
    18521845         currentFrame = (currentFrame + 1) % MAX_FRAMES_IN_FLIGHT;
     
    18541847
    18551848      void drawUI() {
    1856 /*** END OF REFACTORED CODE ***/
    18571849         // TODO: Since I currently don't use any other render targets,
    18581850         // I may as well set this once before the render loop
     
    18611853         SDL_SetRenderDrawColor(gRenderer, 0x00, 0x00, 0x00, 0x00);
    18621854         SDL_RenderClear(gRenderer);
     1855/*** END OF REFACTORED CODE ***/
    18631856
    18641857         SDL_Rect rect;
     
    18771870         SDL_RenderCopy(gRenderer, uiImage, nullptr, &rect);
    18781871
     1872/*** START OF REFACTORED CODE ***/
    18791873         SDL_SetRenderDrawColor(gRenderer, 0x00, 0x00, 0xFF, 0xFF);
    18801874         SDL_RenderDrawLine(gRenderer, 50, 5, 150, 500);
    18811875
    18821876         populateImageFromSDLTexture(uiOverlay, sdlOverlayImage);
    1883 /*** START OF REFACTORED CODE ***/
    18841877      }
    18851878/*** END OF REFACTORED CODE ***/
     
    19031896      }
    19041897
     1898/*** START OF REFACTORED CODE ***/
    19051899      void recreateSwapChain() {
    19061900         gui->refreshWindowSize();
     
    19131907
    19141908         vkDeviceWaitIdle(device);
     1909/*** END OF REFACTORED CODE ***/
    19151910
    19161911         cleanupSwapChain();
     
    19211916
    19221917         createBufferResources();
    1923       }
    1924 
    19251918/*** START OF REFACTORED CODE ***/
     1919      }
     1920
    19261921      void createBufferResources() {
    19271922         createDepthResources();
     
    20452040         vkFreeMemory(device, pipeline.indexBufferMemory, nullptr);
    20462041      }
    2047 /*** END OF REFACTORED CODE ***/
    20482042
    20492043      static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
     
    20762070};
    20772071
    2078 /*** START OF REFACTORED CODE ***/
    20792072int main(int argc, char* argv[]) {
    20802073
Note: See TracChangeset for help on using the changeset viewer.