OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/logging.h" |
| 6 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
| 7 #include <cpu-features.h> |
| 8 #include "cc/resources/texture_compress/arm/atc_dxt_neon.h" |
| 9 #include "cc/resources/texture_compress/arm/etc1_neon.h" |
| 10 #endif |
| 11 #include "cc/debug/lap_timer.h" |
| 12 #include "cc/resources/texture_compress/atc_dxt.h" |
| 13 #include "cc/resources/texture_compress/etc1.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "testing/perf/perf_test.h" |
| 16 |
| 17 namespace cc { |
| 18 namespace { |
| 19 |
| 20 static const int kTimeLimitMillis = 2000; |
| 21 static const int kWarmupRuns = 5; |
| 22 static const int kTimeCheckInterval = 10; |
| 23 |
| 24 class TextureCompressionPerfTest : public testing::Test { |
| 25 public: |
| 26 TextureCompressionPerfTest() |
| 27 : timer_(kWarmupRuns, |
| 28 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 29 kTimeCheckInterval) {} |
| 30 |
| 31 void SetUp() override { texture_compress::Init_ATC_DXT(); } |
| 32 |
| 33 protected: |
| 34 LapTimer timer_; |
| 35 }; |
| 36 |
| 37 TEST_F(TextureCompressionPerfTest, Compress256x256Image) { |
| 38 const int kImageWidth = 256; |
| 39 const int kImageHeight = 256; |
| 40 const int kImageSizeInBytes = kImageWidth * kImageHeight * 4; |
| 41 uint8_t src[kImageSizeInBytes]; |
| 42 uint8_t dst[kImageSizeInBytes / 4]; |
| 43 |
| 44 for (int i = 0; i < kImageSizeInBytes; ++i) |
| 45 src[i] = i % 256; |
| 46 |
| 47 timer_.Reset(); |
| 48 do { |
| 49 texture_compress::CompressDXT1_Generic(src, dst, kImageWidth, kImageHeight); |
| 50 timer_.NextLap(); |
| 51 } while (!timer_.HasTimeLimitExpired()); |
| 52 |
| 53 perf_test::PrintResult("compress_256x256_image", "", "DXT1 Generic", |
| 54 timer_.MsPerLap(), "us", true); |
| 55 |
| 56 timer_.Reset(); |
| 57 do { |
| 58 texture_compress::CompressDXT5_Generic(src, dst, kImageWidth, kImageHeight); |
| 59 timer_.NextLap(); |
| 60 } while (!timer_.HasTimeLimitExpired()); |
| 61 |
| 62 perf_test::PrintResult("compress_256x256_image", "", "DXT5 Generic", |
| 63 timer_.MsPerLap(), "us", true); |
| 64 |
| 65 timer_.Reset(); |
| 66 do { |
| 67 etc1::CompressTexture(src, dst, kImageWidth, kImageHeight); |
| 68 timer_.NextLap(); |
| 69 } while (!timer_.HasTimeLimitExpired()); |
| 70 |
| 71 perf_test::PrintResult("compress_256x256_image", "", "ETC1 Generic", |
| 72 timer_.MsPerLap(), "us", true); |
| 73 |
| 74 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
| 75 if ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0) { |
| 76 timer_.Reset(); |
| 77 do { |
| 78 texture_compress::CompressDXT1_NEON(src, dst, kImageWidth, kImageHeight); |
| 79 timer_.NextLap(); |
| 80 } while (!timer_.HasTimeLimitExpired()); |
| 81 |
| 82 perf_test::PrintResult("compress_256x256_image", "", "DXT1 NEON", |
| 83 timer_.MsPerLap(), "us", true); |
| 84 |
| 85 timer_.Reset(); |
| 86 do { |
| 87 texture_compress::CompressDXT5_NEON(src, dst, kImageWidth, kImageHeight); |
| 88 timer_.NextLap(); |
| 89 } while (!timer_.HasTimeLimitExpired()); |
| 90 |
| 91 perf_test::PrintResult("compress_256x256_image", "", "DXT5 NEON", |
| 92 timer_.MsPerLap(), "us", true); |
| 93 |
| 94 timer_.Reset(); |
| 95 do { |
| 96 etc1_neon::CompressTexture(src, dst, kImageWidth, kImageHeight); |
| 97 timer_.NextLap(); |
| 98 } while (!timer_.HasTimeLimitExpired()); |
| 99 |
| 100 perf_test::PrintResult("compress_256x256_image", "", "ETC1 NEON", |
| 101 timer_.MsPerLap(), "us", true); |
| 102 } |
| 103 #endif |
| 104 } |
| 105 |
| 106 TEST_F(TextureCompressionPerfTest, Compress256x256SolidImage) { |
| 107 const int kImageWidth = 256; |
| 108 const int kImageHeight = 256; |
| 109 const int kImageSizeInBytes = kImageWidth * kImageHeight * 4; |
| 110 uint8_t src[kImageSizeInBytes]; |
| 111 uint8_t dst[kImageSizeInBytes / 4]; |
| 112 |
| 113 memset(src, 0, sizeof(src)); |
| 114 |
| 115 timer_.Reset(); |
| 116 do { |
| 117 texture_compress::CompressDXT1_Generic(src, dst, kImageWidth, kImageHeight); |
| 118 timer_.NextLap(); |
| 119 } while (!timer_.HasTimeLimitExpired()); |
| 120 |
| 121 perf_test::PrintResult("compress_256x256_solid_image", "", "DXT1", |
| 122 timer_.MsPerLap(), "us", true); |
| 123 |
| 124 timer_.Reset(); |
| 125 do { |
| 126 texture_compress::CompressDXT5_Generic(src, dst, kImageWidth, kImageHeight); |
| 127 timer_.NextLap(); |
| 128 } while (!timer_.HasTimeLimitExpired()); |
| 129 |
| 130 perf_test::PrintResult("compress_256x256_solid_image", "", "DXT5", |
| 131 timer_.MsPerLap(), "us", true); |
| 132 |
| 133 timer_.Reset(); |
| 134 do { |
| 135 etc1::CompressTexture(src, dst, kImageWidth, kImageHeight); |
| 136 timer_.NextLap(); |
| 137 } while (!timer_.HasTimeLimitExpired()); |
| 138 |
| 139 perf_test::PrintResult("compress_256x256_solid_image", "", "ETC1 Generic", |
| 140 timer_.MsPerLap(), "us", true); |
| 141 |
| 142 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
| 143 if ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0) { |
| 144 timer_.Reset(); |
| 145 do { |
| 146 texture_compress::CompressDXT1_NEON(src, dst, kImageWidth, kImageHeight); |
| 147 timer_.NextLap(); |
| 148 } while (!timer_.HasTimeLimitExpired()); |
| 149 |
| 150 perf_test::PrintResult("compress_256x256_solid_image", "", "DXT1 NEON", |
| 151 timer_.MsPerLap(), "us", true); |
| 152 |
| 153 timer_.Reset(); |
| 154 do { |
| 155 texture_compress::CompressDXT5_NEON(src, dst, kImageWidth, kImageHeight); |
| 156 timer_.NextLap(); |
| 157 } while (!timer_.HasTimeLimitExpired()); |
| 158 |
| 159 perf_test::PrintResult("compress_256x256_solid_image", "", "DXT5 NEON", |
| 160 timer_.MsPerLap(), "us", true); |
| 161 |
| 162 timer_.Reset(); |
| 163 do { |
| 164 etc1_neon::CompressTexture(src, dst, kImageWidth, kImageHeight); |
| 165 timer_.NextLap(); |
| 166 } while (!timer_.HasTimeLimitExpired()); |
| 167 |
| 168 perf_test::PrintResult("compress_256x256_solid_image", "", "ETC1 NEON", |
| 169 timer_.MsPerLap(), "us", true); |
| 170 } |
| 171 #endif |
| 172 } |
| 173 |
| 174 } // namespace |
| 175 } // namespace cc |
OLD | NEW |