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] makes UniformBindData 15% faster and adds unit test #56844
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bf32bbd
Added testing for uniform binding on gles
gaaclarke 69935b1
added benchmark
gaaclarke cba3c1b
moved to absl flat hash map
gaaclarke a543c98
format
gaaclarke 73a6de8
deleted microbenchmark
gaaclarke e7010c7
updated licenses
gaaclarke 51613c9
removed allocator arg
gaaclarke 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
50 changes: 50 additions & 0 deletions
50
impeller/renderer/backend/gles/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,50 @@ | ||
| // 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/renderer/backend/gles/buffer_bindings_gles.h" | ||
| #include "impeller/renderer/backend/gles/device_buffer_gles.h" | ||
| #include "impeller/renderer/backend/gles/test/mock_gles.h" | ||
| #include "impeller/renderer/testing/mocks.h" | ||
|
|
||
| namespace impeller { | ||
| namespace testing { | ||
|
|
||
| TEST(BufferBindingsGLESTest, BindUniformData) { | ||
| BufferBindingsGLES bindings; | ||
| absl::flat_hash_map<std::string, GLint> uniform_bindings; | ||
| uniform_bindings["SHADERMETADATA.FOOBAR"] = 1; | ||
| bindings.SetUniformBindings(std::move(uniform_bindings)); | ||
| std::shared_ptr<MockGLES> mock_gl = MockGLES::Init(); | ||
| Bindings vertex_bindings; | ||
|
|
||
| ShaderMetadata shader_metadata = { | ||
| .name = "shader_metadata", | ||
| .members = {ShaderStructMemberMetadata{.type = ShaderType::kFloat, | ||
| .name = "foobar", | ||
| .offset = 0, | ||
| .size = sizeof(float), | ||
| .byte_length = sizeof(float)}}}; | ||
| std::shared_ptr<ReactorGLES> reactor; | ||
| std::shared_ptr<Allocation> backing_store = std::make_shared<Allocation>(); | ||
| ASSERT_TRUE(backing_store->Truncate(Bytes{sizeof(float)})); | ||
| DeviceBufferGLES device_buffer(DeviceBufferDescriptor{.size = sizeof(float)}, | ||
| reactor, backing_store); | ||
| BufferView buffer_view(&device_buffer, Range(0, sizeof(float))); | ||
| vertex_bindings.buffers.push_back(BufferAndUniformSlot{ | ||
| .slot = | ||
| ShaderUniformSlot{ | ||
| .name = "foobar", .ext_res_0 = 0, .set = 0, .binding = 0}, | ||
| .view = BufferResource(&shader_metadata, buffer_view)}); | ||
| Bindings fragment_bindings; | ||
| EXPECT_TRUE(bindings.BindUniformData(mock_gl->GetProcTable(), vertex_bindings, | ||
| fragment_bindings)); | ||
| std::vector<std::string> captured_calls = mock_gl->GetCapturedCalls(); | ||
| EXPECT_TRUE(std::find(captured_calls.begin(), captured_calls.end(), | ||
| "glUniform1fv") != captured_calls.end()); | ||
| } | ||
|
|
||
| } // 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
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.
Since you're using a real allocator here I would use this in place of the mock allocator above. In fact, the
transients_allocatorarg is actually unused so you could also just delete it.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