Skip to content

Commit

Permalink
fixed limits for long multi-pass renderings
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Nov 25, 2022
1 parent 204d89b commit a8e6989
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
35 changes: 17 additions & 18 deletions src/render/integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,22 @@ SamplingIntegrator<Float, Spectrum>::render(Scene *scene,
} else {
size_t wavefront_size = (size_t) film_size.x() *
(size_t) film_size.y() * (size_t) spp_per_pass,
wavefront_size_limit =
dr::is_llvm_v<Float> ? 0xffffffffu : 0x40000000u;
wavefront_size_limit = 0xffffffffu;

if (wavefront_size > wavefront_size_limit) {
spp_per_pass /= (uint32_t) ((wavefront_size + wavefront_size_limit - 1) / wavefront_size_limit);
n_passes = spp / spp_per_pass;
spp_per_pass /=
(uint32_t)((wavefront_size + wavefront_size_limit - 1) /
wavefront_size_limit);
n_passes = spp / spp_per_pass;
wavefront_size = (size_t) film_size.x() * (size_t) film_size.y() *
(size_t) spp_per_pass;

Log(Warn,
"The requested rendering task involves %zu Monte Carlo "
"samples, which exceeds the upper limit of 2^%zu = %zu for "
"this variant. Mitsuba will instead split the rendering task "
"%zu smaller passes to avoid exceeding the limits.",
wavefront_size, dr::log2i(wavefront_size_limit + 1),
wavefront_size_limit, n_passes);
"samples, which exceeds the upper limit of 2^32 = 4294967296 "
"for this variant. Mitsuba will instead split the rendering "
"task into %zu smaller passes to avoid exceeding the limits.",
wavefront_size, n_passes);
}

dr::sync_thread(); // Separate from scene initialization (for timings)
Expand Down Expand Up @@ -632,22 +632,21 @@ AdjointIntegrator<Float, Spectrum>::render(Scene *scene,
evaluate = true;
}

size_t wavefront_size_limit =
dr::is_llvm_v<Float> ? 0xffffffffu : 0x40000000u;

constexpr size_t wavefront_size_limit = 0xffffffffu;
if (samples_per_pass > wavefront_size_limit) {
spp_per_pass /= (uint32_t) ((samples_per_pass + wavefront_size_limit - 1) / wavefront_size_limit);
spp_per_pass /=
(uint32_t)((samples_per_pass + wavefront_size_limit - 1) /
wavefront_size_limit);
n_passes = spp / spp_per_pass;
samples_per_pass = (size_t) film_size.x() * (size_t) film_size.y() *
(size_t) spp_per_pass;

Log(Warn,
"The requested rendering task involves %zu Monte Carlo "
"samples, which exceeds the upper limit of 2^%zu = %zu for "
"this variant. Mitsuba will instead split the rendering task "
"%zu smaller passes to avoid exceeding the limits.",
samples_per_pass, dr::log2i(wavefront_size_limit + 1),
wavefront_size_limit, n_passes);
"samples, which exceeds the upper limit of 2^32 = 4294967296 "
"for this variant. Mitsuba will instead split the rendering "
"task into %zu smaller passes to avoid exceeding the limits.",
samples_per_pass, n_passes);
}

Log(Info, "Starting render job (%ux%u, %u sample%s%s)",
Expand Down
2 changes: 1 addition & 1 deletion src/render/sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MI_VARIANT Sampler<Float, Spectrum>::Sampler(const Sampler &sampler)
MI_VARIANT Sampler<Float, Spectrum>::~Sampler() { }

MI_VARIANT void Sampler<Float, Spectrum>::seed(uint32_t /* seed */,
uint32_t wavefront_size) {
uint32_t wavefront_size) {
if constexpr (dr::is_array_v<Float>) {
// Only overwrite when specified
if (wavefront_size != (uint32_t) -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/samplers/independent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ template <typename Float, typename Spectrum>
class IndependentSampler final : public PCG32Sampler<Float, Spectrum> {
public:
MI_IMPORT_BASE(PCG32Sampler, m_sample_count, m_base_seed, m_rng, seed,
seeded, m_samples_per_wavefront, m_wavefront_size,
schedule_state)
seeded, m_samples_per_wavefront, m_wavefront_size,
schedule_state)
MI_IMPORT_TYPES()

IndependentSampler(const Properties &props) : Base(props) { }
Expand Down
4 changes: 2 additions & 2 deletions src/samplers/stratified.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ template <typename Float, typename Spectrum>
class StratifiedSampler final : public PCG32Sampler<Float, Spectrum> {
public:
MI_IMPORT_BASE(PCG32Sampler, m_sample_count, m_base_seed, m_rng, seeded,
m_samples_per_wavefront, m_dimension_index,
current_sample_index, compute_per_sequence_seed)
m_samples_per_wavefront, m_dimension_index,
current_sample_index, compute_per_sequence_seed)
MI_IMPORT_TYPES()

StratifiedSampler(const Properties &props) : Base(props) {
Expand Down

0 comments on commit a8e6989

Please sign in to comment.