-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] generate mip level N from N-1 in Vulkan backend. #51749
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
When I first wrote this, my mental model was that generating data for mip level N from N-1 was similar to making a JPEG from a JPEG. Instead of making a JPEG of increasingly smaller size from a base original. In the OpenGL spec, this is all implementation dependent. So I can't tell which one is correct. But if this matches what the other backends are doing, we should go for it. |
In writing a test for this I found #51761 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added suggestions for comments to make the barriers easier to understand.
barrier.srcAccessMask = vk::AccessFlagBits::eTransferWrite; | ||
barrier.dstAccessMask = vk::AccessFlagBits::eTransferRead; | ||
|
||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make this easier to read, add a comment about why the barrier is necessary. I'll attempt to jot down how I read it but please proofread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment Suggestion:
We just finished writing to the previous (N-1) mip level. These were initialized to
TransferDst
earler. We are now going to read from it to write to the current level (N) . So it must be converted toTransferSrc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
barrier.srcAccessMask = vk::AccessFlagBits::eTransferRead; | ||
barrier.dstAccessMask = vk::AccessFlagBits::eShaderRead; | ||
|
||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment Suggestion:
Now that the blit is done, the image at the previous level (N-1) is done reading from (
TransferSrc
). Now we must prepare it to be read from a shader (ShaderReadOnly
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
// Transition the base mip level to transfer-src layout so we can read from | ||
// it and transition the rest to dst-optimal since they are going to be | ||
// written to. | ||
InsertImageMemoryBarrier( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment Suggestion:
Initialize all mip levels to be in
TransferDst
mode. Later, in a loop, after writing to that mip level, we'll first switch its layout toTransferSrc
to prepare the mip level after it, use the image as the source of the blit, before finally switching it toShaderReadOnly
so its available for sampling in a shader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
barrier.srcAccessMask = vk::AccessFlagBits::eTransferWrite; | ||
barrier.dstAccessMask = vk::AccessFlagBits::eShaderRead; | ||
|
||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment SUggestion:
The very last mip level is still in
TransferDst
and must be converted toShaderReadOnly
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
mip_count - 1 // mip level count | ||
); | ||
0u, // mip level | ||
mip_count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Missing last comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. |
…145994) flutter/engine@b16c0f1...7176173 2024-03-29 [email protected] [Impeller] generate mip level N from N-1 in Vulkan backend. (flutter/engine#51749) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Uses the mipmap implementation from https://vulkan-tutorial.com/Generating_Mipmaps .
Today we generate all mip levels from mip level 0, which results in lost data. Instead we need to use the previous mip level