Results 1 to 6 of 6

Thread: How to resolve multi-sampled depth images?

  1. #1

    Question How to resolve multi-sampled depth images?

    I'm using a Forward+ rendering pipeline with multi-sampled render targets for the depth pre-pass and the main render-pass. I don't need multi-sampled images for post-processing and such, which is why I'd resolve the render targets after the main render-pass and then continue with the resolved images from there.
    In OpenGL you could resolve both color and depth images using glBlitFramebuffer, however it seems that Vulkan doesn't provide any method for resolving depth images, which is problematic since I need the depth buffer for some post-processing effects.

    Is there any way to resolve a depth image manually? If not, what's the proper way of working with MSAA? Should I just use multi-sampled images throughout the entire pipeline and only resolve the color image at the end before presenting? That seems like a waste of resources to me.

  2. #2
    I don't know what problem you're having. The only format restriction that `vkCmdResolveImage` has is that the source and destination image formats must match. There's nothing that says that depth images cannot be resolved.

    Yes, resolve attachments must use color attachments as their source. But since you're already breaking up your rendering into two render passes, you can use `vkCmdResolveImage` between them.

    Should I just use multi-sampled images throughout the entire pipeline and only resolve the color image at the end before presenting?
    Well, that is kind of the point of multisampling. Especially if you're going to do arbitrary computations on the depth values, since those values will impact your aliasing.

  3. #3
    Senior Member
    Join Date
    Mar 2016
    Posts
    331
    There's nothing that says that depth images cannot be resolved.
    VUs:

    The format features of dstImage must contain VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT.
    The aspectMask member of srcSubresource and dstSubresource must only contain VK_IMAGE_ASPECT_COLOR_BIT
    @SilverIan
    It is not clear what you actually want as a result from "resolving" a depth image. Arithmetic mean? That somewhat only makes sense for color. For depth it would average in values from near and far objects, which sounds like a non-sense operation to me.
    Last edited by krOoze; 10-26-2018 at 04:04 PM.

  4. #4
    Quote Originally Posted by krOoze View Post
    VUs:
    Would it not have been easier to just say that the formats for the two images must be color formats? I mean, is there some expectation that there will someday be color/depth textures?

  5. #5
    Quote Originally Posted by Alfonse Reinheart View Post
    Quote Originally Posted by Silverlan View Post
    Should I just use multi-sampled images throughout the entire pipeline and only resolve the color image at the end before presenting?
    Well, that is kind of the point of multisampling. Especially if you're going to do arbitrary computations on the depth values, since those values will impact your aliasing.
    Well, as an example, I need the depth buffer for SSAO. However, since the SSAO image will be blurred anyway, it doesn't really matter whether or not the source images for the SSAO shader are multi-sampled. Since using multi-sampled images is much more expensive, it should be more efficient to resolve the images first, and then work with the single-sampled images. Should I not do that?

    Quote Originally Posted by krOoze View Post
    It is not clear what you actually want as a result from "resolving" a depth image. Arithmetic mean? That somewhat only makes sense for color. For depth it would average in values from near and far objects, which sounds like a non-sense operation to me.
    I suppose that's true, what does OpenGL do when you resolve a depth image?

  6. #6
    Senior Member
    Join Date
    Mar 2016
    Posts
    331
    Quote Originally Posted by Alfonse Reinheart View Post
    Would it not have been easier to just say that the formats for the two images must be color formats? I mean, is there some expectation that there will someday be color/depth textures?
    Well it is what the first VU says in a round-about way. Maybe someone thought it is less brittle to write it that way. "Color", or "depth format" are perhaps somewhat more colloquial terms than a FEATURE flag. It is better to err on the side of unambiguity, even if sometimes it produces offputting wording -- it suits Vulkan nicely.
    Also wrong person to ask; I know as much as you do.

    Quote Originally Posted by Silverlan View Post
    I suppose that's true, what does OpenGL do when you resolve a depth image?
    Quote Originally Posted by The Spec
    If the source formats are depth values, sample values are resolved in an
    implementation-dependent manner where the result will be between the minimum
    and maximum depth values in the pixel.
    Last edited by krOoze; 10-27-2018 at 06:25 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean