summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward O'Callaghan <funfunctor@folklore1984.net>2017-02-08 00:05:08 +1100
committerEdward O'Callaghan <funfunctor@folklore1984.net>2017-02-08 00:05:08 +1100
commitedab36b749a218e53552a0e90c48aa7b3650ae7d (patch)
tree34a5fffc2780f23d17b70dce256fc6a97f03a147
parentb4a0b0f3bb80925c2d4757d2f2c80e8443e42e87 (diff)
src/main.cpp: Implement PipelineLayout
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
-rw-r--r--src/main.cpp69
1 files changed, 68 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fd444f3..f8cff8f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -29,6 +29,7 @@ private:
VDeleter<VkInstance> instance {vkDestroyInstance};
VDeleter<VkSurfaceKHR> surface{instance, vkDestroySurfaceKHR};
+ VDeleter<VkPipelineLayout> pipelineLayout{device, vkDestroyPipelineLayout};
VDeleter<VkRenderPass> renderPass{device, vkDestroyRenderPass};
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
@@ -151,7 +152,73 @@ private:
fragShaderStageInfo.pName = "main";
VkPipelineShaderStageCreateInfo shaderStages[] = {vertShaderStageInfo, fragShaderStageInfo};
- // shaderStages ??
+
+ VkPipelineVertexInputStateCreateInfo vertexInputInfo = {};
+ vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
+ vertexInputInfo.vertexBindingDescriptionCount = 0;
+ vertexInputInfo.vertexAttributeDescriptionCount = 0;
+
+ VkPipelineInputAssemblyStateCreateInfo inputAssembly = {};
+ inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
+ inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
+ inputAssembly.primitiveRestartEnable = VK_FALSE;
+
+ VkViewport viewport = {};
+ viewport.x = 0.0f;
+ viewport.y = 0.0f;
+ viewport.width = (float) swapChainExtent.width;
+ viewport.height = (float) swapChainExtent.height;
+ viewport.minDepth = 0.0f;
+ viewport.maxDepth = 1.0f;
+
+ VkRect2D scissor = {};
+ scissor.offset = {0, 0};
+ scissor.extent = swapChainExtent;
+
+ VkPipelineViewportStateCreateInfo viewportState = {};
+ viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
+ viewportState.viewportCount = 1;
+ viewportState.pViewports = &viewport;
+ viewportState.scissorCount = 1;
+ viewportState.pScissors = &scissor;
+
+ VkPipelineRasterizationStateCreateInfo rasterizer = {};
+ rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
+ rasterizer.depthClampEnable = VK_FALSE;
+ rasterizer.rasterizerDiscardEnable = VK_FALSE;
+ rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
+ rasterizer.lineWidth = 1.0f;
+ rasterizer.cullMode = VK_CULL_MODE_BACK_BIT;
+ rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
+ rasterizer.depthBiasEnable = VK_FALSE;
+
+ VkPipelineMultisampleStateCreateInfo multisampling = {};
+ multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
+ multisampling.sampleShadingEnable = VK_FALSE;
+ multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
+
+ VkPipelineColorBlendAttachmentState colorBlendAttachment = {};
+ colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT
+ | VK_COLOR_COMPONENT_G_BIT
+ | VK_COLOR_COMPONENT_B_BIT
+ | VK_COLOR_COMPONENT_A_BIT;
+ colorBlendAttachment.blendEnable = VK_FALSE;
+
+ VkPipelineColorBlendStateCreateInfo colorBlending = {};
+ colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
+ colorBlending.logicOpEnable = VK_FALSE;
+ colorBlending.logicOp = VK_LOGIC_OP_COPY;
+ colorBlending.attachmentCount = 1;
+ colorBlending.pAttachments = &colorBlendAttachment;
+ for (uint32_t i = 0; i < 4; i++) colorBlending.blendConstants[i] = 0.0f;
+
+ VkPipelineLayoutCreateInfo pipelineLayoutInfo = {};
+ pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
+ pipelineLayoutInfo.setLayoutCount = 0;
+ pipelineLayoutInfo.pushConstantRangeCount = 0;
+
+ if (vkCreatePipelineLayout(device, &pipelineLayoutInfo, nullptr, pipelineLayout.replace()) != VK_SUCCESS)
+ throw std::runtime_error("failed to create pipeline layout!");
}
void createShaderModule(const std::vector<char>& code, VDeleter<VkShaderModule>& shaderModule) {