31 #include <tiled_sampling.h> 56 uint32 shift_index(
const uint32 idx,
const uint32 dim)
const 58 return dim*tile_size*tile_size + (idx & (tile_size*tile_size - 1u));
62 float sample(
const uint32 idx,
const uint32 dim)
const 64 FERMAT_ASSERT(dim < n_dimensions);
65 return samples[shift_index(idx, dim)];
68 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
69 float shift(
const uint32 idx,
const uint32 dim)
const 71 FERMAT_ASSERT(dim < n_dimensions);
72 return shifts[shift_index(idx, dim)];
75 FERMAT_HOST_DEVICE FERMAT_FORCEINLINE
76 float shift(
const uint32 pixel_x,
const uint32 pixel_y,
const uint32 dim)
const 78 FERMAT_ASSERT(dim < n_dimensions);
79 const uint32 shift_x = pixel_x & (tile_size - 1);
80 const uint32 shift_y = pixel_y & (tile_size - 1);
81 const uint32 shift_i = shift_x + shift_y*tile_size;
82 return shift(shift_i,dim);
86 float sample_1d(
const uint32 tile_idx,
const uint32 idx,
const uint32 dim)
const 88 FERMAT_ASSERT(dim < n_dimensions);
89 return fmodf(sample(idx, dim) + shift(tile_idx, dim), 1.0f);
93 float sample_2d(
const uint32 pixel_x,
const uint32 pixel_y,
const uint32 dim)
const 95 FERMAT_ASSERT(dim < n_dimensions);
96 const uint32 shift_x = pixel_x & (tile_size - 1);
97 const uint32 shift_y = pixel_y & (tile_size - 1);
98 const uint32 shift = shift_x + shift_y*tile_size;
100 const uint32 tile_x = (pixel_x / tile_size) & (tile_size - 1);
101 const uint32 tile_y = (pixel_y / tile_size) & (tile_size - 1);
102 const uint32 tile = tile_x + tile_y*tile_size;
104 return sample_1d(tile, shift, dim);
109 const float* samples;
135 void setup(
const uint32 _n_dimensions,
const uint32 _tile_size,
const bool _random =
false);
137 void set_instance(
const uint32 instance);
142 r.n_dimensions = n_dimensions;
143 r.tile_size = tile_size;
144 r.samples = m_samples.ptr();
146 r.shifts = m_tile_shifts.ptr();
Definition: tiled_sequence.h:53
Definition: tiled_sequence.h:131