|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be
|
3 | 3 | // found in the LICENSE file.
|
4 | 4 |
|
| 5 | +#include <algorithm> |
5 | 6 | #include <cstring>
|
6 | 7 | #include <memory>
|
7 | 8 | #include <optional>
|
@@ -2606,7 +2607,9 @@ class TestRenderTargetAllocator : public RenderTargetAllocator {
|
2606 | 2607 |
|
2607 | 2608 | void End() override { RenderTargetAllocator::End(); }
|
2608 | 2609 |
|
2609 |
| - std::vector<TextureDescriptor> GetDescriptors() const { return allocated_; } |
| 2610 | + std::vector<TextureDescriptor> GetAllocatedTextureDescriptors() const { |
| 2611 | + return allocated_; |
| 2612 | + } |
2610 | 2613 |
|
2611 | 2614 | void ResetDescriptors() { allocated_.clear(); }
|
2612 | 2615 |
|
@@ -2651,39 +2654,19 @@ TEST_P(EntityTest, AdvancedBlendCoverageHintIsNotResetByEntityPass) {
|
2651 | 2654 |
|
2652 | 2655 | EXPECT_TRUE(pass->Render(content_context, rt));
|
2653 | 2656 |
|
2654 |
| - if (test_allocator->GetDescriptors().size() == 6u) { |
2655 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[0].size, ISize(1000, 1000)); |
2656 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[1].size, ISize(1000, 1000)); |
2657 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[2].size, ISize(1000, 1000)); |
2658 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[3].size, ISize(1000, 1000)); |
2659 |
| - |
2660 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[4].size, ISize(200, 200)); |
2661 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[5].size, ISize(200, 200)); |
2662 |
| - } else if (test_allocator->GetDescriptors().size() == 7u) { |
2663 |
| - // Onscreen render target. |
2664 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[0].size, ISize(1000, 1000)); |
2665 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[1].size, ISize(1000, 1000)); |
2666 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[2].size, ISize(1000, 1000)); |
2667 |
| - |
2668 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[3].size, ISize(200, 200)); |
2669 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[4].size, ISize(200, 200)); |
2670 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[5].size, ISize(200, 200)); |
2671 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[6].size, ISize(200, 200)); |
2672 |
| - } else if (test_allocator->GetDescriptors().size() == 4u) { |
2673 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[0].size, ISize(1000, 1000)); |
2674 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[1].size, ISize(1000, 1000)); |
2675 |
| - |
2676 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[2].size, ISize(200, 200)); |
2677 |
| - EXPECT_EQ(test_allocator->GetDescriptors()[3].size, ISize(200, 200)); |
2678 |
| - } else { |
2679 |
| - std::stringstream sizes; |
2680 |
| - for (const auto& desc : test_allocator->GetDescriptors()) { |
2681 |
| - sizes << "\nISize" << desc.size; |
2682 |
| - } |
2683 |
| - EXPECT_TRUE(false) << "Unexpected number of render targets. Total: " |
2684 |
| - << test_allocator->GetDescriptors().size() |
2685 |
| - << "\nExpected sizes: " << sizes.str(); |
2686 |
| - } |
| 2657 | + std::vector<TextureDescriptor> descriptors = |
| 2658 | + test_allocator->GetAllocatedTextureDescriptors(); |
| 2659 | + |
| 2660 | + auto contains_size = [&descriptors](ISize size) -> bool { |
| 2661 | + return std::find_if(descriptors.begin(), descriptors.end(), |
| 2662 | + [&size](auto desc) { return desc.size == size; }) != |
| 2663 | + descriptors.end(); |
| 2664 | + }; |
| 2665 | + |
| 2666 | + EXPECT_TRUE(contains_size(ISize(1000, 1000))) |
| 2667 | + << "The root texture wasn't allocated"; |
| 2668 | + EXPECT_TRUE(contains_size(ISize(200, 200))) |
| 2669 | + << "The ColorBurned texture wasn't allocated (100x100 scales up 2x)"; |
2687 | 2670 | }
|
2688 | 2671 |
|
2689 | 2672 | TEST_P(EntityTest, SpecializationConstantsAreAppliedToVariants) {
|
|
0 commit comments