forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Impeller] Cache render target texture allocations across frames. (fl…
…utter#44527) When allocating a non-host visible texture for a render target, the allocator will hold onto a reference to this texture descriptor. On the immediate next frame, this texture is made available to replace requested allocations for new render target textures. if this texture is not used, then at the end of the next frame it is discarded. This removes the vast majority of allocations in most flutter gallery and wonderous. This does not attempt to use different sized textures for the cache. There are two caveats noted in the PR contents. Fixes flutter/flutter#131515
- Loading branch information
1 parent
824bb0d
commit cf8eaa6
Showing
25 changed files
with
432 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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,83 @@ | ||
// 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" | ||
#include "impeller/core/allocator.h" | ||
#include "impeller/core/formats.h" | ||
#include "impeller/core/texture_descriptor.h" | ||
#include "impeller/geometry/size.h" | ||
#include "impeller/renderer/testing/mocks.h" | ||
|
||
namespace impeller { | ||
namespace testing { | ||
|
||
TEST(AllocatorTest, TextureDescriptorCompatibility) { | ||
// Size. | ||
{ | ||
TextureDescriptor desc_a = {.size = ISize(100, 100)}; | ||
TextureDescriptor desc_b = {.size = ISize(100, 100)}; | ||
TextureDescriptor desc_c = {.size = ISize(101, 100)}; | ||
|
||
ASSERT_EQ(desc_a, desc_b); | ||
ASSERT_NE(desc_a, desc_c); | ||
} | ||
// Storage Mode. | ||
{ | ||
TextureDescriptor desc_a = {.storage_mode = StorageMode::kDevicePrivate}; | ||
TextureDescriptor desc_b = {.storage_mode = StorageMode::kDevicePrivate}; | ||
TextureDescriptor desc_c = {.storage_mode = StorageMode::kHostVisible}; | ||
|
||
ASSERT_EQ(desc_a, desc_b); | ||
ASSERT_NE(desc_a, desc_c); | ||
} | ||
// Format. | ||
{ | ||
TextureDescriptor desc_a = {.format = PixelFormat::kR8G8B8A8UNormInt}; | ||
TextureDescriptor desc_b = {.format = PixelFormat::kR8G8B8A8UNormInt}; | ||
TextureDescriptor desc_c = {.format = PixelFormat::kB10G10R10A10XR}; | ||
|
||
ASSERT_EQ(desc_a, desc_b); | ||
ASSERT_NE(desc_a, desc_c); | ||
} | ||
// Sample Count. | ||
{ | ||
TextureDescriptor desc_a = {.sample_count = SampleCount::kCount4}; | ||
TextureDescriptor desc_b = {.sample_count = SampleCount::kCount4}; | ||
TextureDescriptor desc_c = {.sample_count = SampleCount::kCount1}; | ||
|
||
ASSERT_EQ(desc_a, desc_b); | ||
ASSERT_NE(desc_a, desc_c); | ||
} | ||
// Sample Count. | ||
{ | ||
TextureDescriptor desc_a = {.type = TextureType::kTexture2DMultisample}; | ||
TextureDescriptor desc_b = {.type = TextureType::kTexture2DMultisample}; | ||
TextureDescriptor desc_c = {.type = TextureType::kTexture2D}; | ||
|
||
ASSERT_EQ(desc_a, desc_b); | ||
ASSERT_NE(desc_a, desc_c); | ||
} | ||
// Compression. | ||
{ | ||
TextureDescriptor desc_a = {.compression_type = CompressionType::kLossless}; | ||
TextureDescriptor desc_b = {.compression_type = CompressionType::kLossless}; | ||
TextureDescriptor desc_c = {.compression_type = CompressionType::kLossy}; | ||
|
||
ASSERT_EQ(desc_a, desc_b); | ||
ASSERT_NE(desc_a, desc_c); | ||
} | ||
// Mip Count. | ||
{ | ||
TextureDescriptor desc_a = {.mip_count = 1}; | ||
TextureDescriptor desc_b = {.mip_count = 1}; | ||
TextureDescriptor desc_c = {.mip_count = 4}; | ||
|
||
ASSERT_EQ(desc_a, desc_b); | ||
ASSERT_NE(desc_a, desc_c); | ||
} | ||
} | ||
|
||
} // namespace testing | ||
} // namespace impeller |
This file contains 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 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 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 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 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 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.