diff --git a/example/Vulkan/VKPipeline.cpp b/example/Vulkan/VKPipeline.cpp index 9b09b91e..e9d76c23 100644 --- a/example/Vulkan/VKPipeline.cpp +++ b/example/Vulkan/VKPipeline.cpp @@ -37,20 +37,49 @@ PipelineCreater::PipelineCreater(Device *dev) pipelineInfo.pViewportState = &viewportState; + depthStencilState.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; + depthStencilState.pNext = nullptr; + depthStencilState.flags = 0; + depthStencilState.depthTestEnable = VK_TRUE; + depthStencilState.depthWriteEnable = VK_TRUE; + depthStencilState.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL; + depthStencilState.depthBoundsTestEnable = VK_FALSE; + depthStencilState.minDepthBounds = 0; + depthStencilState.maxDepthBounds = 0; + depthStencilState.stencilTestEnable = VK_FALSE; + depthStencilState.back.failOp = VK_STENCIL_OP_KEEP; + depthStencilState.back.passOp = VK_STENCIL_OP_KEEP; + depthStencilState.back.compareOp = VK_COMPARE_OP_ALWAYS; + depthStencilState.back.compareMask = 0; + depthStencilState.back.reference = 0; + depthStencilState.back.depthFailOp = VK_STENCIL_OP_KEEP; + depthStencilState.back.writeMask = 0; + depthStencilState.front = depthStencilState.back; + + pipelineInfo.pDepthStencilState=&depthStencilState; + rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; + rasterizer.pNext = nullptr; + rasterizer.flags = 0; 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_COUNTER_CLOCKWISE; rasterizer.depthBiasEnable = VK_FALSE; + rasterizer.lineWidth = 1.0f; pipelineInfo.pRasterizationState = &rasterizer; multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; - multisampling.sampleShadingEnable = VK_FALSE; + multisampling.pNext = nullptr; + multisampling.flags = 0; multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; + multisampling.sampleShadingEnable = VK_FALSE; + multisampling.minSampleShading = 0.0; + multisampling.pSampleMask = nullptr; + multisampling.alphaToCoverageEnable = VK_FALSE; + multisampling.alphaToOneEnable = VK_FALSE; pipelineInfo.pMultisampleState = &multisampling; @@ -66,10 +95,20 @@ PipelineCreater::PipelineCreater(Device *dev) colorBlending.blendConstants[1] = 0.0f; colorBlending.blendConstants[2] = 0.0f; colorBlending.blendConstants[3] = 0.0f; - + pipelineInfo.pColorBlendState = &colorBlending; + memset(dynamicStateEnables, 0, sizeof dynamicStateEnables); + dynamicState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; + dynamicState.pNext = nullptr; + dynamicState.flags = 0; + dynamicState.pDynamicStates = dynamicStateEnables; + dynamicState.dynamicStateCount = 0; + + pipelineInfo.pDynamicState=&dynamicState; + pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; + pipelineInfo.basePipelineIndex = 0; } bool PipelineCreater::Set(const Shader *s) diff --git a/example/Vulkan/VKPipeline.h b/example/Vulkan/VKPipeline.h index 164093de..40a9dd88 100644 --- a/example/Vulkan/VKPipeline.h +++ b/example/Vulkan/VKPipeline.h @@ -36,6 +36,7 @@ class PipelineCreater VkViewport viewport; VkRect2D scissor; VkPipelineViewportStateCreateInfo viewportState; + VkPipelineDepthStencilStateCreateInfo depthStencilState; VkPipelineRasterizationStateCreateInfo rasterizer; @@ -44,6 +45,9 @@ class PipelineCreater VkPipelineColorBlendAttachmentState colorBlendAttachment; VkPipelineColorBlendStateCreateInfo colorBlending; + VkDynamicState dynamicStateEnables[VK_DYNAMIC_STATE_RANGE_SIZE]; + VkPipelineDynamicStateCreateInfo dynamicState; + private: const Shader * shader =nullptr;