Finished off fixed functions
This commit is contained in:
parent
0a4cb972e2
commit
3d48656705
1 changed files with 53 additions and 2 deletions
55
src/main.c
55
src/main.c
|
|
@ -55,6 +55,7 @@ typedef struct Application {
|
||||||
VkExtent2D swapChainExtent;
|
VkExtent2D swapChainExtent;
|
||||||
VkImageView *swapChainImageViews;
|
VkImageView *swapChainImageViews;
|
||||||
uint32_t swapChainImageViewCount;
|
uint32_t swapChainImageViewCount;
|
||||||
|
VkPipelineLayout pipelineLayout;
|
||||||
} Application;
|
} Application;
|
||||||
|
|
||||||
typedef struct SwapChainSupportDetails {
|
typedef struct SwapChainSupportDetails {
|
||||||
|
|
@ -733,10 +734,59 @@ void createGraphicsPipeline(Application *app) {
|
||||||
viewportState.scissorCount = 1;
|
viewportState.scissorCount = 1;
|
||||||
|
|
||||||
VkRect2D scissor = {0};
|
VkRect2D scissor = {0};
|
||||||
scissor.offset.x = 0;
|
scissor.offset.x = 0;
|
||||||
scissor.offset.y = 0;
|
scissor.offset.y = 0;
|
||||||
scissor.extent = app->swapChainExtent;
|
scissor.extent = app->swapChainExtent;
|
||||||
|
|
||||||
|
VkPipelineRasterizationStateCreateInfo rasterizer = {0};
|
||||||
|
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;
|
||||||
|
rasterizer.depthBiasConstantFactor = 0.0f; // Optional
|
||||||
|
rasterizer.depthBiasClamp = 0.0f; // Optional
|
||||||
|
rasterizer.depthBiasSlopeFactor = 0.0f; // Optional
|
||||||
|
|
||||||
|
// disable multisampling for now
|
||||||
|
VkPipelineMultisampleStateCreateInfo multisampling = {0};
|
||||||
|
multisampling.sType =
|
||||||
|
VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||||
|
multisampling.sampleShadingEnable = VK_FALSE;
|
||||||
|
multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
multisampling.minSampleShading = 1.0f; // Optional
|
||||||
|
multisampling.pSampleMask = NULL; // Optional
|
||||||
|
multisampling.alphaToCoverageEnable = VK_FALSE; // Optional
|
||||||
|
multisampling.alphaToOneEnable = VK_FALSE; // Optional
|
||||||
|
|
||||||
|
VkPipelineColorBlendAttachmentState colorBlendAttachment = {0};
|
||||||
|
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;
|
||||||
|
colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; // Optional
|
||||||
|
colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO; // Optional
|
||||||
|
colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD; // Optional
|
||||||
|
colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; // Optional
|
||||||
|
colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; // Optional
|
||||||
|
colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD; // Optional
|
||||||
|
|
||||||
|
VkPipelineLayoutCreateInfo pipelineLayoutInfo = {0};
|
||||||
|
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||||
|
pipelineLayoutInfo.setLayoutCount = 0; // Optional
|
||||||
|
pipelineLayoutInfo.pSetLayouts = NULL; // Optional
|
||||||
|
pipelineLayoutInfo.pushConstantRangeCount = 0; // Optional
|
||||||
|
pipelineLayoutInfo.pPushConstantRanges = NULL; // Optional
|
||||||
|
|
||||||
|
if (vkCreatePipelineLayout(app->device, &pipelineLayoutInfo, NULL,
|
||||||
|
&app->pipelineLayout) != VK_SUCCESS) {
|
||||||
|
fprintf(stderr, "Failed to create pipeline layout!");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
vkDestroyShaderModule(app->device, fragShaderModule, NULL);
|
vkDestroyShaderModule(app->device, fragShaderModule, NULL);
|
||||||
vkDestroyShaderModule(app->device, vertShaderModule, NULL);
|
vkDestroyShaderModule(app->device, vertShaderModule, NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -759,6 +809,7 @@ void mainLoop(Application *app) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup(Application *app) {
|
void cleanup(Application *app) {
|
||||||
|
vkDestroyPipelineLayout(app->device, app->pipelineLayout, NULL);
|
||||||
for (size_t i = 0; i < app->swapChainImageViewCount; i++) {
|
for (size_t i = 0; i < app->swapChainImageViewCount; i++) {
|
||||||
vkDestroyImageView(app->device, app->swapChainImageViews[i], NULL);
|
vkDestroyImageView(app->device, app->swapChainImageViews[i], NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue