Changeset 84216c7 in opengl-game


Ignore:
Timestamp:
Jul 14, 2019, 9:40:27 PM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
be34c9a
Parents:
e09ad38
Message:

Finish creating the rendering pipeline

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    re09ad38 r84216c7  
    113113
    114114      vector<VkImageView> swapChainImageViews;
     115      VkPipelineLayout pipelineLayout;
    115116
    116117      // both SDL and GLFW create window functions return NULL on failure
     
    578579
    579580         VkPipelineShaderStageCreateInfo shaderStages[] = { vertShaderStageInfo, fragShaderStageInfo };
     581
     582         VkPipelineVertexInputStateCreateInfo vertexInputInfo = {};
     583         vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
     584         vertexInputInfo.vertexBindingDescriptionCount = 0;
     585         vertexInputInfo.vertexAttributeDescriptionCount = 0;
     586
     587         VkPipelineInputAssemblyStateCreateInfo inputAssembly = {};
     588         inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
     589         inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
     590         inputAssembly.primitiveRestartEnable = VK_FALSE;
     591
     592         VkViewport viewport = {};
     593         viewport.x = 0.0f;
     594         viewport.y = 0.0f;
     595         viewport.width = (float) swapChainExtent.width;
     596         viewport.height = (float) swapChainExtent.height;
     597         viewport.minDepth = 0.0f;
     598         viewport.maxDepth = 1.0f;
     599
     600         VkRect2D scissor = {};
     601         scissor.offset = { 0, 0 };
     602         scissor.extent = swapChainExtent;
     603
     604         VkPipelineViewportStateCreateInfo viewportState = {};
     605         viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
     606         viewportState.viewportCount = 1;
     607         viewportState.pViewports = &viewport;
     608         viewportState.scissorCount = 1;
     609         viewportState.pScissors = &scissor;
     610
     611         VkPipelineRasterizationStateCreateInfo rasterizer = {};
     612         rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
     613         rasterizer.depthClampEnable = VK_FALSE;
     614         rasterizer.rasterizerDiscardEnable = VK_FALSE;
     615         rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
     616         rasterizer.lineWidth = 1.0f;
     617         rasterizer.cullMode = VK_CULL_MODE_BACK_BIT;
     618         rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
     619         rasterizer.depthBiasEnable = false;
     620
     621         VkPipelineMultisampleStateCreateInfo multisampling = {};
     622         multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
     623         multisampling.sampleShadingEnable = VK_FALSE;
     624         multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
     625
     626         VkPipelineColorBlendAttachmentState colorBlendAttachment = {};
     627         colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
     628         colorBlendAttachment.blendEnable = VK_FALSE;
     629
     630         VkPipelineColorBlendStateCreateInfo colorBlending = {};
     631         colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
     632         colorBlending.logicOpEnable = VK_FALSE;
     633         colorBlending.logicOp = VK_LOGIC_OP_COPY;
     634         colorBlending.attachmentCount = 1;
     635         colorBlending.pAttachments = &colorBlendAttachment;
     636         colorBlending.blendConstants[0] = 0.0f;
     637         colorBlending.blendConstants[1] = 0.0f;
     638         colorBlending.blendConstants[2] = 0.0f;
     639         colorBlending.blendConstants[3] = 0.0f;
     640
     641         VkPipelineLayoutCreateInfo pipelineLayoutInfo = {};
     642         pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
     643         pipelineLayoutInfo.setLayoutCount = 0;
     644         pipelineLayoutInfo.pushConstantRangeCount = 0;
     645
     646         if (vkCreatePipelineLayout(device, &pipelineLayoutInfo, nullptr, &pipelineLayout) != VK_SUCCESS) {
     647            throw runtime_error("failed to create pipeline layout!");
     648         }
    580649
    581650         vkDestroyShaderModule(device, vertShaderModule, nullptr);
     
    624693
    625694      void cleanup() {
     695         vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
     696
    626697         for (auto imageView : swapChainImageViews) {
    627698            vkDestroyImageView(device, imageView, nullptr);
Note: See TracChangeset for help on using the changeset viewer.