summaryrefslogtreecommitdiff
path: root/source/core/slang-random-generator.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-11-08 09:13:44 -0500
committerGitHub <noreply@github.com>2019-11-08 09:13:44 -0500
commit0ac010a72e777b2c284583fcb8554abee83d8ff5 (patch)
tree7133e5c3117c180d19ce11841187ff3f9d2ec5fe /source/core/slang-random-generator.h
parent99c295477fa1f6c5ce47e0d1c8fb3eea9d5e5f98 (diff)
Riff Container Stream Writing (#1116)
* * Added option to get random bytes from RandomGenerator * Added ability to allocate only in current block on MemoryArena * Allowed RiffContainer to not allocate new Data blocks, if can just extend the Data it has (because it's at the end of current block and there is space for the new data). * Added coverage for change on Riff unit test * Add test coverage for allocations over multiple Data blocks. * Improve comment on riff unit tests.
Diffstat (limited to 'source/core/slang-random-generator.h')
-rw-r--r--source/core/slang-random-generator.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/source/core/slang-random-generator.h b/source/core/slang-random-generator.h
index 57f0e8630..392b4cb4c 100644
--- a/source/core/slang-random-generator.h
+++ b/source/core/slang-random-generator.h
@@ -30,6 +30,9 @@ class RandomGenerator: public RefObject
/// Get the next bool
virtual bool nextBool();
+ /// Get multiple int32s
+ virtual void nextInt32s(int32_t* dst, size_t count) = 0;
+
/// Next uint32_t
uint32_t nextUInt32() { return uint32_t(nextInt32()); }
@@ -53,6 +56,10 @@ class RandomGenerator: public RefObject
/// Returns value from min up to BUT NOT INCLUDING max
int64_t nextInt64InRange(int64_t min, int64_t max);
+ /// Fill with random data.
+ /// NOTE! Output is only identical bytes if generator in same state *and* size_t(dst) & 3 is the same on calls.
+ void nextData(void* dst, size_t size);
+
/// Create a RandomGenerator with specified seed using default generator type
static RandomGenerator* create(int32_t seed);
};
@@ -73,7 +80,8 @@ class Mt19937RandomGenerator: public RandomGenerator
Mt19937RandomGenerator* clone() SLANG_OVERRIDE { return new ThisType(*this); }
void reset(int32_t seed) SLANG_OVERRIDE;
int32_t nextInt32() SLANG_OVERRIDE;
-
+ void nextInt32s(int32_t* dst, size_t count) SLANG_OVERRIDE;
+
/// Ctor
Mt19937RandomGenerator();
Mt19937RandomGenerator(const ThisType& rhs);