diff --git a/include/vkcv/GraphicsPipelineConfig.hpp b/include/vkcv/GraphicsPipelineConfig.hpp index 6d466c4aa3893049eb0b3e770c2e4dde6b6199e3..be3ba8ef6f611c0901c561302a8fed4d45487d0d 100644 --- a/include/vkcv/GraphicsPipelineConfig.hpp +++ b/include/vkcv/GraphicsPipelineConfig.hpp @@ -39,6 +39,7 @@ namespace vkcv { DepthTest m_depthTest = DepthTest::LessEqual; bool m_depthWrite = true; bool m_alphaToCoverage = false; + uint32_t m_tessellationControlPoints = 0; }; } \ No newline at end of file diff --git a/src/vkcv/GraphicsPipelineManager.cpp b/src/vkcv/GraphicsPipelineManager.cpp index a461051f9784e7d95de7c15c965caa633d3bb35c..8a12ba65230965089d6c0e2f9b4c3b74aa35baa5 100644 --- a/src/vkcv/GraphicsPipelineManager.cpp +++ b/src/vkcv/GraphicsPipelineManager.cpp @@ -195,6 +195,15 @@ namespace vkcv return pipelineInputAssemblyStateCreateInfo; } + vk::PipelineTessellationStateCreateInfo createPipelineTessellationStateCreateInfo(const GraphicsPipelineConfig &config) { + vk::PipelineTessellationStateCreateInfo pipelineTessellationStateCreateInfo( + {}, + config.m_tessellationControlPoints + ); + + return pipelineTessellationStateCreateInfo; + } + /** * Creates a Pipeline Viewport State Create Info Struct with default set viewport and scissor settings. * @param config provides with and height of the output window @@ -424,7 +433,13 @@ namespace vkcv const bool existsVertexShader = config.m_ShaderProgram.existsShader(ShaderStage::VERTEX); const bool existsFragmentShader = config.m_ShaderProgram.existsShader(ShaderStage::FRAGMENT); const bool existsGeometryShader = config.m_ShaderProgram.existsShader(ShaderStage::GEOMETRY); - const bool validGeometryStages = existsVertexShader || (existsTaskShader && existsMeshShader); + const bool existsTessellationControlShader = config.m_ShaderProgram.existsShader(ShaderStage::TESS_CONTROL); + const bool existsTessellationEvaluationShader = config.m_ShaderProgram.existsShader(ShaderStage::TESS_EVAL); + + const bool validGeometryStages = ( + (existsVertexShader && (existsTessellationControlShader == existsTessellationEvaluationShader)) || + (existsTaskShader && existsMeshShader) + ); if (!validGeometryStages) { @@ -529,6 +544,40 @@ namespace vkcv return GraphicsPipelineHandle(); } } + + if (existsTessellationControlShader) { + vk::PipelineShaderStageCreateInfo createInfo; + const bool success = createPipelineShaderStageCreateInfo( + config.m_ShaderProgram, + ShaderStage::TESS_CONTROL, + m_Device, + &createInfo); + + if (success) { + shaderStages.push_back(createInfo); + } + else { + destroyShaderModules(); + return GraphicsPipelineHandle(); + } + } + + if (existsTessellationEvaluationShader) { + vk::PipelineShaderStageCreateInfo createInfo; + const bool success = createPipelineShaderStageCreateInfo( + config.m_ShaderProgram, + ShaderStage::TESS_EVAL, + m_Device, + &createInfo); + + if (success) { + shaderStages.push_back(createInfo); + } + else { + destroyShaderModules(); + return GraphicsPipelineHandle(); + } + } // vertex input state // Fill up VertexInputBindingDescription and VertexInputAttributeDescription Containers @@ -545,6 +594,10 @@ namespace vkcv vk::PipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateCreateInfo = createPipelineInputAssemblyStateCreateInfo(config); + // tesselation state + vk::PipelineTessellationStateCreateInfo pipelineTessellationStateCreateInfo = + createPipelineTessellationStateCreateInfo(config); + // viewport state vk::PipelineViewportStateCreateInfo pipelineViewportStateCreateInfo = createPipelineViewportStateCreateInfo(config); @@ -601,7 +654,7 @@ namespace vkcv shaderStages.data(), &pipelineVertexInputStateCreateInfo, &pipelineInputAssemblyStateCreateInfo, - nullptr, + &pipelineTessellationStateCreateInfo, &pipelineViewportStateCreateInfo, &pipelineRasterizationStateCreateInfo, &pipelineMultisampleStateCreateInfo,