This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] avoid heap allocation in RenderTarget object. #56829
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8e740b5
[Impeller] avoid heap allocation in RenderTarget object.
5b4d07e
fix missing color attachments in vk render_pass.
24450c4
Update render_target.cc
61c4ff5
lint workarounds.
b6de222
Update render_target.cc
c65046a
++
938b279
Merge branch 'render_pass_stuff' of github.com:jonahwilliams/engine i…
132748a
fixup flutter gpu.
2f912f6
hide specialization of color0 attachment.
52d2674
add comment.
2190282
++
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,14 +48,27 @@ RenderPassBuilderVK& RenderPassBuilderVK::SetColorAttachment( | |
| desc.initialLayout = vk::ImageLayout::eUndefined; | ||
| } | ||
| desc.finalLayout = vk::ImageLayout::eGeneral; | ||
| colors_[index] = desc; | ||
|
|
||
| if (StoreActionPerformsResolve(store_action)) { | ||
| desc.storeOp = ToVKAttachmentStoreOp(store_action, true); | ||
| desc.samples = vk::SampleCountFlagBits::e1; | ||
| resolves_[index] = desc; | ||
| const bool performs_resolves = StoreActionPerformsResolve(store_action); | ||
| if (index == 0u) { | ||
| color0_ = desc; | ||
|
|
||
| if (performs_resolves) { | ||
| desc.storeOp = ToVKAttachmentStoreOp(store_action, true); | ||
| desc.samples = vk::SampleCountFlagBits::e1; | ||
| color0_resolve_ = desc; | ||
| } else { | ||
| color0_resolve_ = std::nullopt; | ||
| } | ||
| } else { | ||
| resolves_.erase(index); | ||
| colors_[index] = desc; | ||
| if (performs_resolves) { | ||
| desc.storeOp = ToVKAttachmentStoreOp(store_action, true); | ||
| desc.samples = vk::SampleCountFlagBits::e1; | ||
| resolves_[index] = desc; | ||
| } else { | ||
| resolves_.erase(index); | ||
| } | ||
| } | ||
| return *this; | ||
| } | ||
|
|
@@ -100,8 +113,11 @@ vk::UniqueRenderPass RenderPassBuilderVK::Build( | |
| const vk::Device& device) const { | ||
| // This must be less than `VkPhysicalDeviceLimits::maxColorAttachments` but we | ||
| // are not checking. | ||
| const auto color_attachments_count = | ||
| auto color_attachments_count = | ||
| colors_.empty() ? 0u : colors_.rbegin()->first + 1u; | ||
| if (color0_.has_value()) { | ||
| color_attachments_count++; | ||
| } | ||
|
|
||
| std::vector<vk::AttachmentDescription> attachments; | ||
|
|
||
|
|
@@ -111,6 +127,22 @@ vk::UniqueRenderPass RenderPassBuilderVK::Build( | |
| kUnusedAttachmentReference); | ||
| vk::AttachmentReference depth_stencil_ref = kUnusedAttachmentReference; | ||
|
|
||
| if (color0_.has_value()) { | ||
| vk::AttachmentReference color_ref; | ||
| color_ref.attachment = attachments.size(); | ||
| color_ref.layout = vk::ImageLayout::eGeneral; | ||
| color_refs[0] = color_ref; | ||
| attachments.push_back(color0_.value()); | ||
|
|
||
| if (color0_resolve_.has_value()) { | ||
| vk::AttachmentReference resolve_ref; | ||
| resolve_ref.attachment = attachments.size(); | ||
| resolve_ref.layout = vk::ImageLayout::eGeneral; | ||
| resolve_refs[0] = resolve_ref; | ||
| attachments.push_back(color0_resolve_.value()); | ||
| } | ||
|
Comment on lines
+131
to
+143
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove duplication
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you use the Iterate method here to avoid the duplication?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't the render_target, this is the internal implementation of the RenderPassBuilderVK |
||
| } | ||
|
|
||
| for (const auto& color : colors_) { | ||
| vk::AttachmentReference color_ref; | ||
| color_ref.attachment = attachments.size(); | ||
|
|
@@ -207,4 +239,16 @@ RenderPassBuilderVK::GetDepthStencil() const { | |
| return depth_stencil_; | ||
| } | ||
|
|
||
| // Visible for testing. | ||
| std::optional<vk::AttachmentDescription> RenderPassBuilderVK::GetColor0() | ||
| const { | ||
| return color0_; | ||
| } | ||
|
|
||
| // Visible for testing. | ||
| std::optional<vk::AttachmentDescription> RenderPassBuilderVK::GetColor0Resolve() | ||
| const { | ||
| return color0_resolve_; | ||
| } | ||
|
|
||
| } // namespace impeller | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we instead change this to
.GetColorAttachment(0u). That way the way the render target is storing the first color attachment isn't being leaked to its clients.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