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] Cache location in metadata. #46640
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0896930
[Impeller] Cache location in metadata.
66f8d19
Update buffer_bindings_gles.cc
0793d8b
Add docs
2d5618d
sneaky cache.
a8553da
Merge branch 'sneaky_cache' of github.com:jonahwilliams/engine into s…
bb57fc5
++
db573bf
Update buffer_bindings_gles_unittests.cc
ab498d1
Merge branch 'main' of github.com:flutter/engine into sneaky_cache
a82e1a9
++
dcfcf76
Merge branch 'sneaky_cache' of github.com:jonahwilliams/engine into s…
ce75363
Merge branch 'main' of github.com:flutter/engine into sneaky_cache
205a600
++
414299b
Merge branch 'main' into sneaky_cache
9799b65
Update buffer_bindings_gles.cc
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
sneaky cache.
- Loading branch information
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
78 changes: 78 additions & 0 deletions
78
impeller/renderer/backend/gles/test/buffer_bindings_gles_unittests.cc
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,78 @@ | ||
| // 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 "flutter/testing/testing.h" // IWYU pragma: keep | ||
| #include "gtest/gtest.h" | ||
| #include "impeller/core/shader_types.h" | ||
| #include "impeller/renderer/backend/gles/buffer_bindings_gles.h" | ||
| #include "impeller/renderer/backend/gles/proc_table_gles.h" | ||
| #include "impeller/renderer/backend/gles/test/mock_gles.h" | ||
|
|
||
| namespace impeller { | ||
| namespace testing { | ||
|
|
||
| ShaderType type; | ||
| std::string name; | ||
| size_t offset; | ||
| size_t size; | ||
| size_t byte_length; | ||
| std::optional<size_t> array_elements; | ||
|
|
||
| TEST(BufferBindingsGLES, CanCacheLocationDataInShaderMetadata) { | ||
| // Uniform metadata for | ||
| // struct Foo { | ||
| // float Bar; | ||
| // float Baz; | ||
| // } | ||
| const ShaderMetadata metadata = | ||
| ShaderMetadata{.name = "Foo", | ||
| .members = {ShaderStructMemberMetadata{ | ||
| .type = ShaderType::kFloat, | ||
| .name = "Bar", | ||
| .offset = 0u, | ||
| .size = sizeof(Scalar), | ||
| .byte_length = sizeof(Scalar), | ||
| .array_elements = std::nullopt, | ||
| }, | ||
| ShaderStructMemberMetadata{ | ||
| .type = ShaderType::kFloat, | ||
| .name = "Baz", | ||
| .offset = sizeof(Scalar), | ||
| .size = sizeof(Scalar), | ||
| .byte_length = sizeof(Scalar), | ||
| .array_elements = std::nullopt, | ||
| }}}; | ||
| // Uniform metadata for | ||
| // sampler2D Fizz; | ||
| const ShaderMetadata sampler_metadata = ShaderMetadata{.name = "Fizz"}; | ||
|
|
||
| auto buffer_bindings = std::make_shared<BufferBindingsGLES>(); | ||
|
|
||
| // Mock uniform locations. | ||
| buffer_bindings->GetUniformLocationsForTesting()["FOO.BAR"] = 0; | ||
| buffer_bindings->GetUniformLocationsForTesting()["FOO.BAZ"] = 1; | ||
| buffer_bindings->GetUniformLocationsForTesting()["FIZZ"] = 2; | ||
|
|
||
| // Lookup locations. | ||
|
|
||
| auto bar_location = buffer_bindings->LookupUniformLocation( | ||
| &metadata, metadata.members[0], false); | ||
| auto baz_location = buffer_bindings->LookupUniformLocation( | ||
| &metadata, metadata.members[1], false); | ||
| auto fizz_location = | ||
| buffer_bindings->LookupTextureLocation(&sampler_metadata); | ||
|
|
||
| EXPECT_EQ(bar_location.value_or(-1), 0); | ||
| EXPECT_EQ(baz_location.value_or(-1), 1); | ||
| EXPECT_EQ(fizz_location, 2); | ||
|
|
||
| // values have been cached. | ||
|
|
||
| EXPECT_EQ(metadata.members[0].location.value_or(-1), 0); | ||
| EXPECT_EQ(metadata.members[1].location.value_or(-1), 1); | ||
| EXPECT_EQ(sampler_metadata.location.value_or(-1), 2); | ||
| } | ||
|
|
||
| } // namespace testing | ||
| } // namespace impeller |
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.
This seems fine to me. But when this was written, the metadata was meant to be static const. So I am not sure about the lifecycle of this. I am also worried (perhaps incorrectly) about interactive with multiple OpenGL drivers at some point in the future.
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.
From Triage: lets just store it in the "PSO" instead.