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] implement external texture gl for embedder. #56277
Merged
auto-submit
merged 7 commits into
flutter:main
from
jonahwilliams:external_texture_embedder_gl
Nov 1, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1664e5a
[Impeller] implement external texture gl for embedder.
e7cdea8
Attach clean up live handles.
8fb86e8
Add testing.
01e5667
++
5bf89e2
use C++ closure type for reactor API.
e7eadf7
++
d813b5a
use ScopedCleanupClosure.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include <memory> | ||
| #include "flutter/testing/testing.h" // IWYU pragma: keep | ||
| #include "gtest/gtest.h" | ||
| #include "impeller/renderer/backend/gles/handle_gles.h" | ||
| #include "impeller/renderer/backend/gles/proc_table_gles.h" | ||
| #include "impeller/renderer/backend/gles/reactor_gles.h" | ||
| #include "impeller/renderer/backend/gles/test/mock_gles.h" | ||
|
|
||
| namespace impeller { | ||
| namespace testing { | ||
|
|
||
| class TestWorker : public ReactorGLES::Worker { | ||
| public: | ||
| bool CanReactorReactOnCurrentThreadNow( | ||
| const ReactorGLES& reactor) const override { | ||
| return true; | ||
| } | ||
| }; | ||
|
|
||
| TEST(ReactorGLES, CanAttachCleanupCallbacksToHandles) { | ||
| auto mock_gles = MockGLES::Init(); | ||
| ProcTableGLES::Resolver resolver = kMockResolverGLES; | ||
| auto proc_table = std::make_unique<ProcTableGLES>(resolver); | ||
| auto worker = std::make_shared<TestWorker>(); | ||
| auto reactor = std::make_shared<ReactorGLES>(std::move(proc_table)); | ||
| reactor->AddWorker(worker); | ||
|
|
||
| int value = 0; | ||
| auto handle = reactor->CreateHandle(HandleType::kTexture, 1123); | ||
| auto added = | ||
| reactor->RegisterCleanupCallback(handle, [&value]() { value++; }); | ||
|
|
||
| EXPECT_TRUE(added); | ||
| EXPECT_TRUE(reactor->React()); | ||
|
|
||
| reactor->CollectHandle(handle); | ||
| EXPECT_TRUE(reactor->AddOperation([](const ReactorGLES& reactor) {})); | ||
| EXPECT_TRUE(reactor->React()); | ||
| EXPECT_EQ(value, 1); | ||
| } | ||
|
|
||
| } // namespace testing | ||
| } // namespace impeller |
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
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.
@chinmaygarde do we have an existing way to track handles / a place for me to attach to a destruction callback? Otherwise I was just going to add an optional member to texture_gles.
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.
This is a case of the embedder giving us a texture handle, us using it, and then asking the embedder to collect it for us when we are done.
The most accurate way to do this is using the reactor. It knows when the texture handle is no longer in use. Attaching it to TextureGLES isn't going to be safe because of the skew between the destruction of the texture (which can happen on any thread) and the collection of the handle in the reactor (which must happen on one of the GL threads).
I did something similar (but not the same) here where the ownership of the handle is transferred in. See the wrap here of an
external_handle. You could augment reactor handles to pass in a callback instead of a known destructor by handle (which essentially calls glDeleteTextures). That way, the handle will be collected at the right time on the right thread.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.
Got it, thank you!