>>800648
>a hell of functions taking 10 arguments that are structs of 50 arguments full of NULLs
That's nothing, check THIS out:
void vkr_init_pipeline(vkr_t *vkr,jmp_buf jump){
//init pipeline
VkResult res = 0;
VkDynamicState dyn_state_list[VK_DYNAMIC_STATE_RANGE_SIZE] = {0};
VkPipelineDynamicStateCreateInfo dyn_state_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
.pDynamicStates = dyn_state_list,
};
VkPipelineVertexInputStateCreateInfo vi_state_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
.vertexBindingDescriptionCount = 1,
.pVertexBindingDescriptions = &vkr->vi_binding,
.vertexAttributeDescriptionCount = 3,
.pVertexAttributeDescriptions = vkr->vi_attribs,
};
VkPipelineInputAssemblyStateCreateInfo asm_state_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
.primitiveRestartEnable = VK_FALSE,
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
};
VkPolygonMode mode = VK_POLYGON_MODE_FILL;
if(vkr->dev_features.fillModeNonSolid == VK_FALSE){
con_printf("WARNING: Non-solid fill modes are not supported by your video card! The value of r_wireframe has been discarded!");
}
else{
if(cvar_geti("r_wireframe")){
mode = VK_POLYGON_MODE_LINE;
}
}
VkPipelineRasterizationStateCreateInfo rst_state_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
.polygonMode = mode,
.cullMode = VK_CULL_MODE_NONE,
.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE,
.depthClampEnable = VK_TRUE, //Selym says he had to change this to prevent errors. Why?
.rasterizerDiscardEnable = VK_FALSE,
.depthBiasEnable = VK_FALSE,
.lineWidth = 1.0f,
};
VkPipelineColorBlendAttachmentState att_state[1] = {(VkPipelineColorBlendAttachmentState){
.colorWriteMask = 0xf,
.blendEnable = VK_TRUE,
.alphaBlendOp = VK_BLEND_OP_ADD,
.colorBlendOp = VK_BLEND_OP_ADD,
.srcColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
.dstColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA,
.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE,
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
},};
VkPipelineColorBlendStateCreateInfo cb_state_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
.attachmentCount = 1,
.pAttachments = att_state,
.logicOpEnable = VK_FALSE,
.logicOp = VK_LOGIC_OP_NO_OP,
.blendConstants[0] = 1.0f,
.blendConstants[1] = 1.0f,
.blendConstants[2] = 1.0f,
.blendConstants[3] = 1.0f,
};
VkPipelineViewportStateCreateInfo vp_state_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
.viewportCount = 1,
.scissorCount = 1,
};
dyn_state_list[dyn_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_VIEWPORT;
dyn_state_list[dyn_state_info.dynamicStateCount++] = VK_DYNAMIC_STATE_SCISSOR;
VkPipelineDepthStencilStateCreateInfo ds_state_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
.depthTestEnable = VK_TRUE,
.depthWriteEnable = VK_TRUE,
.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL,
.depthBoundsTestEnable = VK_FALSE,
.stencilTestEnable = VK_FALSE,
.back = {
.failOp = VK_STENCIL_OP_KEEP,
.passOp = VK_STENCIL_OP_KEEP,
.compareOp = VK_COMPARE_OP_ALWAYS,
.depthFailOp = VK_STENCIL_OP_KEEP,
},
.front = {
.failOp = VK_STENCIL_OP_KEEP,
.passOp = VK_STENCIL_OP_KEEP,
.compareOp = VK_COMPARE_OP_ALWAYS,
.depthFailOp = VK_STENCIL_OP_KEEP,
},
};
VkPipelineMultisampleStateCreateInfo ms_state_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT,
.sampleShadingEnable = VK_FALSE,
.alphaToCoverageEnable = VK_FALSE,
.alphaToOneEnable = VK_FALSE,
.minSampleShading = 0.0,
};
VkGraphicsPipelineCreateInfo pipeline = {
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
.layout = vkr->pipeline_layout,
.basePipelineHandle = VK_NULL_HANDLE,
.pVertexInputState = &vi_state_info,
.pInputAssemblyState = &asm_state_info,
.pRasterizationState = &rst_state_info,
.pColorBlendState = &cb_state_info,
.pTessellationState = NULL,
.pMultisampleState = &ms_state_info,
.pDynamicState = &dyn_state_info,
.pViewportState = &vp_state_info,
.pDepthStencilState = &ds_state_info,
.pStages = vkr->shader_stages,
.stageCount = 2,
.renderPass = vkr->render_pass,
.subpass = 0,
};
res = vkCreateGraphicsPipelines(vkr->device,VK_NULL_HANDLE,1,&pipeline,NULL,&vkr->pipeline);
if(res != VK_SUCCESS){
longjmp(jump,vkr_error_vmem);
}
}