Hash :
5dd4ad89
Author :
Date :
2018-01-29T13:53:43
Vulkan: Add a perf test for the Pipeline cache. This micro-benchmark can be used to measure the performance impact of changing the Pipeline cache. For instance, we can check if changing the size of the hash key affects performance significantly. Also updates the build files so angle_perftests can see vulkan.h, and makes the Vulkan headers an explicit source set. This test currently shows that a lot of time is spent in PMurmurHash, with some time also spent in memcmp. Bug: angleproject:2163 Change-Id: Ie8bb3e31d58590f373d28cbbb59f7e372b80cc29 Reviewed-on: https://chromium-review.googlesource.com/884882 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// random_utils:
// Helper functions for random number generation.
//
#ifndef UTIL_RANDOM_UTILS_H
#define UTIL_RANDOM_UTILS_H
// TODO(jmadill): Rework this if Chromium decides to ban <random>
#include <random>
#include <export.h>
namespace angle
{
class ANGLE_EXPORT RNG
{
public:
// Seed from clock
RNG();
// Seed from fixed number.
RNG(unsigned int seed);
~RNG();
void reseed(unsigned int newSeed);
int randomInt();
int randomIntBetween(int min, int max);
unsigned int randomUInt();
float randomFloat();
float randomFloatBetween(float min, float max);
float randomNegativeOneToOne();
private:
std::default_random_engine mGenerator;
};
// Implemented inline to avoid cross-module allocation issues.
inline void FillVectorWithRandomUBytes(RNG *rng, std::vector<uint8_t> *data)
{
for (size_t i = 0; i < data->size(); ++i)
{
(*data)[i] = static_cast<uint8_t>(rng->randomIntBetween(0, 255));
}
}
inline void FillVectorWithRandomUBytes(std::vector<uint8_t> *data)
{
RNG rng;
FillVectorWithRandomUBytes(&rng, data);
}
} // namespace angle
#endif // UTIL_RANDOM_UTILS_H