-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_sampler_simd.h
More file actions
68 lines (51 loc) · 1.29 KB
/
random_sampler_simd.h
File metadata and controls
68 lines (51 loc) · 1.29 KB
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
61
62
63
64
65
66
67
68
// Copyright 2015 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "math/vec2.h"
#include "math/hash.h"
namespace prt {
class RandomSampler;
class RandomSamplerSimd
{
private:
unsigned int seed = 0;
public:
typedef RandomSampler Scalar;
struct State
{
vuint lcg;
};
void init(unsigned int dimensionCount, unsigned int sampleCount, unsigned int seed)
{
this->seed = seed;
}
prt_inline void setSample(vbool m, State& state, vuint sampleIndex, vuint pixelId)
{
vuint hash = seed;
hash = murmurHash3Mix(hash, pixelId);
hash = murmurHash3Mix(hash, sampleIndex);
hash = murmurHash3Finalize(hash);
state.lcg = hash;
}
prt_inline void resetSample(vbool m, State& state, vuint sampleIndex, vuint pixelId)
{
}
prt_inline vfloat get1D(vbool m, State& state, int dimension)
{
return lcgGetFloat(state.lcg);
}
prt_inline Vec2vf get2D(vbool m, State& state, int dimension)
{
vfloat x = lcgGetFloat(state.lcg);
vfloat y = lcgGetFloat(state.lcg);
return Vec2vf(x, y);
}
prt_inline Vec3vf get3D(vbool m, State& state, int dimension)
{
vfloat x = lcgGetFloat(state.lcg);
vfloat y = lcgGetFloat(state.lcg);
vfloat z = lcgGetFloat(state.lcg);
return Vec3vf(x, y, z);
}
};
} // namespace prt