Depth buffer in framebuffer and as resource texture - is it legal?

Planning to implement something like ‘soft-z particles’ - need to do z-test, and to access depth buffer in pixel shader at the same time.
Will it work in Vulkan, if I just turn off zwrite, and then bind current depth buffer view as resource?

It depends on what you’re talking about doing.

If you make the depth buffer an input attachment for that subpass, and you turn off depth writes, then it will work. So long as you can live within the restrictions of an input attachment, that is. Which means you always fetch from the texel that corresponds to the fragment in the FS invocation you’re working with.

If you can’t live within those restrictions, then you’re going to have to break the render pass, since you’re not allowed to arbitrarily read from a texture that’s being used as an attachment.

Thanks!
Very interesting information, I didn’t know about that.