Skip to content

Commit a4bf0ec

Browse files
committed
Refactor RenderPassGLES state caches into structs and split out sampler caching
1 parent 00ed46d commit a4bf0ec

5 files changed

Lines changed: 302 additions & 335 deletions

File tree

‎engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ FML_TEST_CLASS(BufferBindingsGLESTest,
2525
BindsTexturesAcrossThePerStageUnitBoundary);
2626
FML_TEST_CLASS(BufferBindingsGLESTest, RejectsTexturesBeyondThePerStageLimit);
2727
FML_TEST_CLASS(BufferBindingsGLESTest, RejectsTexturesBeyondTheCombinedLimit);
28-
FML_TEST_CLASS(BufferBindingsGLESTest,
29-
SkipsRedundantSamplerConfigurationOnSameTexture);
3028
} // namespace testing
3129

3230
//------------------------------------------------------------------------------
@@ -78,8 +76,6 @@ class BufferBindingsGLES {
7876
RejectsTexturesBeyondThePerStageLimit);
7977
FML_FRIEND_TEST(testing::BufferBindingsGLESTest,
8078
RejectsTexturesBeyondTheCombinedLimit);
81-
FML_FRIEND_TEST(testing::BufferBindingsGLESTest,
82-
SkipsRedundantSamplerConfigurationOnSameTexture);
8379
//----------------------------------------------------------------------------
8480
/// @brief The arguments to glVertexAttribPointer.
8581
///

‎engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles_unittests.cc‎

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -500,65 +500,5 @@ TEST(BufferBindingsGLESTest, RejectsTexturesBeyondTheCombinedLimit) {
500500
Range{0, fixture.bound_textures.size()}, Range{0, 0}));
501501
}
502502

503-
TEST(BufferBindingsGLESTest, SkipsRedundantSamplerConfigurationOnSameTexture) {
504-
auto impl = MakeSixteenUnitMockImpl();
505-
auto* raw_impl = impl.get();
506-
std::shared_ptr<MockGLES> mock_gl = MockGLES::Init(std::move(impl));
507-
BoundTexturesFixture fixture(
508-
std::make_unique<ProcTableGLES>(kMockResolverGLES));
509-
fixture.AddTextures(ShaderStage::kFragment, 1);
510-
ASSERT_TRUE(fixture.reactor->React());
511-
512-
BufferBindingsGLES bindings;
513-
bindings.SetUniformBindings(std::move(fixture.uniform_bindings));
514-
std::vector<BufferResource> bound_buffers;
515-
516-
// First bind on ES 3.0 configures MIN_FILTER, MAG_FILTER, MAX_LEVEL, WRAP_S,
517-
// WRAP_T (5 calls). Second bind with the same sampler descriptor skips all
518-
// TexParameteri calls.
519-
EXPECT_CALL(*raw_impl, TexParameteri(GL_TEXTURE_2D, _, _)).Times(5);
520-
521-
EXPECT_TRUE(bindings.BindUniformData(
522-
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
523-
Range{0, fixture.bound_textures.size()}, Range{0, 0}));
524-
EXPECT_TRUE(bindings.BindUniformData(
525-
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
526-
Range{0, fixture.bound_textures.size()}, Range{0, 0}));
527-
528-
// Changing the sampler descriptor must re-configure the texture (5 calls).
529-
SamplerDescriptor linear_desc;
530-
linear_desc.min_filter = MinMagFilter::kLinear;
531-
linear_desc.mag_filter = MinMagFilter::kLinear;
532-
fixture.bound_textures[0].sampler =
533-
fixture.sampler_library->GetSampler(linear_desc);
534-
EXPECT_CALL(*raw_impl, TexParameteri(GL_TEXTURE_2D, _, _)).Times(5);
535-
EXPECT_TRUE(bindings.BindUniformData(
536-
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
537-
Range{0, fixture.bound_textures.size()}, Range{0, 0}));
538-
539-
// Wrapped external textures must bypass the sampler parameter cache and
540-
// re-emit TexParameteri on every bind (5 calls per bind = 10 calls for 2
541-
// consecutive binds with the same sampler descriptor).
542-
TextureDescriptor wrapped_desc;
543-
wrapped_desc.storage_mode = StorageMode::kDevicePrivate;
544-
wrapped_desc.type = TextureType::kTexture2D;
545-
wrapped_desc.format = PixelFormat::kR8G8B8A8UNormInt;
546-
wrapped_desc.size = {1, 1};
547-
wrapped_desc.mip_count = 1u;
548-
wrapped_desc.usage = TextureUsage::kShaderRead;
549-
auto wrapped_texture = TextureGLES::WrapTexture(
550-
fixture.reactor, wrapped_desc,
551-
fixture.reactor->CreateHandle(HandleType::kTexture, 99u));
552-
fixture.bound_textures[0].texture =
553-
TextureResource(fixture.metadata[0].get(), std::move(wrapped_texture));
554-
EXPECT_CALL(*raw_impl, TexParameteri(GL_TEXTURE_2D, _, _)).Times(10);
555-
EXPECT_TRUE(bindings.BindUniformData(
556-
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
557-
Range{0, fixture.bound_textures.size()}, Range{0, 0}));
558-
EXPECT_TRUE(bindings.BindUniformData(
559-
fixture.reactor->GetProcTable(), fixture.bound_textures, bound_buffers,
560-
Range{0, fixture.bound_textures.size()}, Range{0, 0}));
561-
}
562-
563503
} // namespace testing
564504
} // namespace impeller

0 commit comments

Comments
 (0)