Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Update BlitPass::AddCopy to use destination_region instead of origin for buffer to texture copies. #52555

Merged
merged 8 commits into from
May 8, 2024

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented May 4, 2024

Based on #52510

Work towards flutter/flutter#138798

Change IPoint destination_origin to IRect destination_region, which allows us to specify an area smaller than the entire texture to replace. This will eventually allow us to only upload individual glyphs. This fixes the cubemap issue I previously hit: each face needs to track initialization separately.

// For non cubemap textures, 0 indicates uninitialized and 1 indicates
// initialized. For cubemap textures, each face is initialized separately with
// each bit tracking the initialization of the corresponding slice.
void MarkSliceInitialized(size_t slice) const;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I was missing last time. For the GLES cube map textures we need to tracking initialization per slice


[encoder copyFromBuffer:source_mtl
sourceOffset:source.range.offset
sourceBytesPerRow:destination_bytes_per_row
sourceBytesPerImage:destination_bytes_per_image
sourceBytesPerImage:0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to https://developer.apple.com/documentation/metal/mtlblitcommandencoder/1400752-copyfrombuffer , we can set sourceBytesPerImage to 0 for 2d textures

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an inline comment to that effect? That just reads wrong lol.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, I mean "Done"

@jonahwilliams jonahwilliams marked this pull request as ready for review May 8, 2024 00:47
@jonahwilliams jonahwilliams requested a review from chinmaygarde May 8, 2024 00:49
@flutter-dashboard
Copy link

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.

Changes reported for pull request #52555 at sha 3fb3d5c

@jonahwilliams
Copy link
Member Author

Goldens look good:

image

Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits and suggestions.

blit_pass->AddCopy(DeviceBuffer::AsBufferView(device_buffer), bridge,
IRect::MakeLTRB(50, 50, 150, 150));

if (!blit_pass->EncodeCommands(GetContext()->GetResourceAllocator()) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious. Why not ASSERT_TRUE? The GTEST_FAIL doesn't print out the assertion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


private:
ReactorGLES::Ref reactor_;
const Type type_;
HandleGLES handle_;
mutable bool contents_initialized_ = false;
mutable uint32_t contents_initialized_ = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using std::bitset<6> and renaming to slices_initialized_. That gives you nice utilites to set and check these things.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL


[encoder copyFromBuffer:source_mtl
sourceOffset:source.range.offset
sourceBytesPerRow:destination_bytes_per_row
sourceBytesPerImage:destination_bytes_per_image
sourceBytesPerImage:0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an inline comment to that effect? That just reads wrong lol.

std::string label,
uint32_t slice) {
auto command = std::make_unique<BlitCopyBufferToTextureCommandGLES>();
command->label = label;
command->source = std::move(source);
command->destination = std::move(destination);
command->destination_origin = destination_origin;
command->destination_region = destination_region;
command->label = label;
command->slice = slice;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and elsewhere, we should check that slices are from 0 to 5. And, if not, either return false or clamp to the values. I prefer the former.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this check it blit_pass.cc and a test case.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label May 8, 2024
@auto-submit auto-submit bot merged commit 20ea633 into flutter:main May 8, 2024
29 checks passed
@jonahwilliams jonahwilliams deleted the add_region_copy branch May 8, 2024 15:46
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 8, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 8, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 8, 2024
…147994)

flutter/engine@f3ce5a5...9cb60de

2024-05-08 [email protected] Roll Skia from c7794fee8063 to d8427844b843 (2 revisions) (flutter/engine#52671)
2024-05-08 [email protected] Manual roll Dart SDK from a9cf6a411c71 to b7cad2edae4b (7 revisions) (flutter/engine#52669)
2024-05-08 [email protected] [Impeller] Update BlitPass::AddCopy to use destination_region instead of origin for buffer to texture copies. (flutter/engine#52555)
2024-05-08 [email protected] DisplayListBuilder internal reorganization with better rendering op overlap detection (flutter/engine#52646)
2024-05-08 [email protected] Roll reclient forward (flutter/engine#52632)

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] 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants