Remove use of std::random_shuffle
authorPyry Haulos <phaulos@google.com>
Tue, 24 Nov 2015 20:41:46 +0000 (12:41 -0800)
committerPyry Haulos <phaulos@google.com>
Tue, 24 Nov 2015 20:41:46 +0000 (12:41 -0800)
std::random_shuffle algorithm is implementation-defined,
de::Random::shuffle() must be used instead.

This was causing pipeline blend and stencil test groups to be different
depending on platform.

Change-Id: I21ee6d9cf78ea0466c63d6e9498a6f485edd4d8b

external/vulkancts/modules/vulkan/pipeline/vktPipelineUniqueRandomIterator.hpp

index 7ad6b30..da67bf2 100644 (file)
@@ -63,30 +63,12 @@ private:
        size_t                                  m_currentIndex;
 };
 
-class RandomFunction
-{
-private:
-       de::Random m_random;
-
-public:
-       RandomFunction(int seed)
-               : m_random(seed)
-       {}
-
-       virtual ~RandomFunction() {}
-
-       deUint32 operator()(deUint32 max)
-       {
-               return m_random.getUint32() % max;
-       }
-};
-
 template <typename T>
 UniqueRandomIterator<T>::UniqueRandomIterator (deUint32 numItems, deUint32 numValues, int seed)
 {
-       DE_ASSERT(numItems <= numValues);
+       de::Random rnd(seed);
 
-       RandomFunction randomFunc(seed);
+       DE_ASSERT(numItems <= numValues);
 
        if (numItems == numValues)
        {
@@ -102,14 +84,14 @@ UniqueRandomIterator<T>::UniqueRandomIterator (deUint32 numItems, deUint32 numVa
 
                // Populate set with "numItems" unique values between 0 and numValues - 1
                while (uniqueIndices.size() < numItems)
-                       uniqueIndices.insert(randomFunc(numValues));
+                       uniqueIndices.insert(rnd.getUint32() % numValues);
 
                // Copy set into index sequence
                m_indices = std::vector<deUint32>(uniqueIndices.begin(), uniqueIndices.end());
        }
 
        // Scramble the indices
-       std::random_shuffle(m_indices.begin(), m_indices.end(), randomFunc);
+       rnd.shuffle(m_indices.begin(), m_indices.end());
 
        reset();
 }