filament icon indicating copy to clipboard operation
filament copied to clipboard

Support for transient attachments

Open mdagois opened this issue 1 year ago • 5 comments

Changes

  • Added support for transient attachment in the VulkanTexture class.
  • Used transient attachment for the MSAA sidecar texture.

Testing on a Pixel 8 Pro, AGI traces show a difference of roughly 100MB in GPU memory consumption. The device was rebooted after each test to reduce the noise.

Figure 1: Transient disabled transient_disabled

Figure 2: Transient enabled transient_enabled

The actual difference is likely smaller. The resolution is 1008x1920 with 4 samples and a 32-bit format (VK_FORMAT_B10G11R11_UFLOAT_PACK32). In that configuration, the reduction in memory consumption should be around 30MB.

For reference, here are the perfetto traces: perfetto_traces.zip.

mdagois avatar Aug 07 '24 08:08 mdagois

As an additional note, I used the vkGetDeviceMemoryCommitment function to make sure the memory was not committed when using the transient attachment. The results are that, for the allocation size was 30,965,760 bytes, the committed size is zero. This is the expected behavior. Unfortunately, the vkGetDeviceMemoryCommitment function cannot be used for non-lazily allocated memory, so we cannot do a apple-to-apple comparison.

mdagois avatar Aug 08 '24 04:08 mdagois

I think this looks good, but it might be missing a bit, which is the part that was undone in #7680. See also the "// DONT_CARE is critical here" comment in this document: https://arm-software.github.io/vulkan-sdk/multisampling.html

That means the number I got showing a 100MB saving is probably just happenstance then. :) Let me try with the method you told me about offline (adb shell dumpsys meminfo app.name).

mdagois avatar Aug 13 '24 04:08 mdagois

I think this looks good, but it might be missing a bit, which is the part that was undone in #7680. See also the "// DONT_CARE is critical here" comment in this document: https://arm-software.github.io/vulkan-sdk/multisampling.html

I fixed the issue by setting the loadOp based on whether the attachement uses lazily allocated memory. Please have a look.

mdagois avatar Aug 14 '24 04:08 mdagois

With the discard storeop, I can see the committed memory stays at zero for the MSAA attachement for as long as the application runs. When switching to a store storeop, I can see the committed memory turning to 30MB. So, the transient system seems to work as intended.

mdagois avatar Aug 14 '24 04:08 mdagois

@mdagois could you rebase the branch and resolve the conflicts? thanks!

pixelflinger avatar Aug 28 '24 20:08 pixelflinger

@mdagois could you rebase the branch and resolve the conflicts? thanks!

I rebased the branch. I also simplified the code in the constructor (like removing the preferTransient boolean) since we don't have the blittable flags raised by default anymore.

mdagois avatar Sep 02 '24 07:09 mdagois

@pixelflinger @poweifeng I rebased the branch and tested it again. It still work as intended. :) Only minor changes were necessary (around the new texture state). Please check the PR again.

mdagois avatar Oct 03 '24 03:10 mdagois