OpenQMC API
Loading...
Searching...
No Matches
bntables.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright Contributors to the OpenQMC Project.
3
12
13#pragma once
14
15#include "encode.h"
16#include "gpu.h"
17
18#include <cstdint>
19
20namespace oqmc
21{
22
23namespace bntables
24{
25
31{
32 std::uint32_t key;
33 std::uint32_t rank;
34};
35
50template <int XBits, int YBits, int ZBits>
51OQMC_HOST_DEVICE constexpr TableReturnValue
52tableValue(std::uint16_t pixel, std::uint16_t shift,
53 const std::uint32_t keyTable[], const std::uint32_t rankTable[])
54{
55 const auto pixelOffset = decodeBits16<XBits, YBits, ZBits>(pixel);
57
58 const auto x = pixelOffset.x + shiftOffset.x;
59 const auto y = pixelOffset.y + shiftOffset.y;
60 const auto z = pixelOffset.z + shiftOffset.z;
61 const auto index = encodeBits16<XBits, YBits, ZBits>({x, y, z});
62
63 return {
64 keyTable[index],
65 rankTable[index],
66 };
67}
68
69constexpr auto xBits = 8;
70constexpr auto yBits = 8;
71constexpr auto size = 1 << (xBits + yBits);
72
73static_assert(xBits == yBits,
74 "Optimisation tables have equal resolution in x and y");
75
76// Following optimised blue noise randomisation values were generated using the
77// optimise cli tool found in the source file src/tools/lib/optimise.cpp.
78
79namespace pmj
80{
81
83inline constexpr std::uint32_t keyTable[] = {
84#include "data/pmj/keys.txt"
85};
86
88inline constexpr std::uint32_t rankTable[] = {
89#include "data/pmj/ranks.txt"
90};
91
92} // namespace pmj
93
94namespace sobol
95{
96
98inline constexpr std::uint32_t keyTable[] = {
99#include "data/sobol/keys.txt"
100};
101
103inline constexpr std::uint32_t rankTable[] = {
104#include "data/sobol/ranks.txt"
105};
106
107} // namespace sobol
108
109namespace lattice
110{
111
113inline constexpr std::uint32_t keyTable[] = {
114#include "data/lattice/keys.txt"
115};
116
118inline constexpr std::uint32_t rankTable[] = {
119#include "data/lattice/ranks.txt"
120};
121
122} // namespace lattice
123
124} // namespace bntables
125
126} // namespace oqmc
constexpr std::uint32_t keyTable[]
Optimised blue noise key table for pmj.
Definition bntables.h:83
constexpr auto size
2^16 table size.
Definition bntables.h:71
constexpr auto yBits
256 pixels in y.
Definition bntables.h:70
constexpr auto xBits
256 pixels in x.
Definition bntables.h:69
constexpr TableReturnValue tableValue(std::uint16_t pixel, std::uint16_t shift, const std::uint32_t keyTable[], const std::uint32_t rankTable[])
Lookup value pair from table.
Definition bntables.h:52
constexpr std::uint32_t rankTable[]
Optimised blue noise rank table for pmj.
Definition bntables.h:88
int y
y axis coordinate.
Definition encode.h:27
int z
z axis coordinate.
Definition encode.h:28
int x
x axis coordinate.
Definition encode.h:26
EncodeKey decodeBits16(std::uint16_t value)
Decode a value back into a key.
Definition encode.h:81
Return type for table value.
Definition bntables.h:31
std::uint32_t rank
rank value to shuffle.
Definition bntables.h:33
std::uint32_t key
key value to randomise.
Definition bntables.h:32