About depth-stencil attachments(layouts)

Hello
In Vulkan, we usually use depthStencilAttachment in pipeline and command buffers.
In pipeline creation, it is VkPipelineDepthStencilStateCreateInfo, not just VkPipelineDepthStateCreateInfo
Also, whenever depth layout or function or flag is mentioned, stencil one is also mentioned together

But, in general, we only need depthattachment or depth layout for depth test

Then why do we use depthStencilAttachment, not depthAttachment only
even in cases we don’t need stencil functions ?

Perhaps, do we need stencil functions in any cases?

I will appreciate if you can help me with this inquiry
Thank you

I don’t understand the question. Are you asking why the API combines depth and stencil state? This is because most hardware generally does both tests as part of the same process. When you turn on, for example, early fragment tests, that includes both depth and stencil tests.

Perhaps, do we need stencil functions in any cases?

… yes, the stencil test is useful.

1 Like

Hello, Alfonse

It’s because I am new to graphics programming
I didn’t study depth and stencil functions before

But now I understand, thanks to your explanation
So thank you again and see you, Alfonse