Changeset be34c9a in opengl-game


Ignore:
Timestamp:
Jul 15, 2019, 1:35:53 PM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
fd70015
Parents:
84216c7
git-author:
Dmitry Portnoy <dmp1488@…> (07/15/19 13:35:42)
git-committer:
Dmitry Portnoy <dmp1488@…> (07/15/19 13:35:53)
Message:

Create the render pass

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r84216c7 rbe34c9a  
    113113
    114114      vector<VkImageView> swapChainImageViews;
     115      VkRenderPass renderPass;
    115116      VkPipelineLayout pipelineLayout;
    116117
     
    147148         createSwapChain();
    148149         createImageViews();
     150         createRenderPass();
    149151         createGraphicsPipeline();
    150152      }
     
    556558               throw runtime_error("failed to create image views!");
    557559            }
     560         }
     561      }
     562
     563      void createRenderPass() {
     564         VkAttachmentDescription colorAttachment = {};
     565         colorAttachment.format = swapChainImageFormat;
     566         colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
     567         colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
     568         colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
     569         colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
     570         colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
     571         colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
     572         colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
     573
     574         VkAttachmentReference colorAttachmentRef = {};
     575         colorAttachmentRef.attachment = 0;
     576         colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
     577
     578         VkSubpassDescription subpass = {};
     579         subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
     580         subpass.colorAttachmentCount = 1;
     581         subpass.pColorAttachments = &colorAttachmentRef;
     582
     583         VkRenderPassCreateInfo renderPassInfo = {};
     584         renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
     585         renderPassInfo.attachmentCount = 1;
     586         renderPassInfo.pAttachments = &colorAttachment;
     587         renderPassInfo.subpassCount = 1;
     588         renderPassInfo.pSubpasses = &subpass;
     589
     590         if (vkCreateRenderPass(device, &renderPassInfo, nullptr, &renderPass) != VK_SUCCESS) {
     591            throw runtime_error("failed to create render pass!");
    558592         }
    559593      }
     
    694728      void cleanup() {
    695729         vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
     730         vkDestroyRenderPass(device, renderPass, nullptr);
    696731
    697732         for (auto imageView : swapChainImageViews) {
Note: See TracChangeset for help on using the changeset viewer.