@@ -242,13 +242,14 @@ MI_VARIANT void ImageBlock<Float, Spectrum>::put(const Point2f &pos,
242
242
243
243
// Compute the number of filter evaluations needed along each axis
244
244
ScalarVector2u count;
245
+ uint32_t count_max = dr::ceil2int<uint32_t >(2 .f * radius);
245
246
if constexpr (!JIT) {
246
247
if (dr::any (pos_0_u > pos_1_u))
247
248
return ;
248
249
count = count_u;
249
250
} else {
250
251
// Conservative bounds must be used in the vectorized case
251
- count = dr::ceil2int< uint32_t >( 2 . f * radius) ;
252
+ count = count_max ;
252
253
active &= dr::all (pos_0_u <= pos_1_u);
253
254
}
254
255
@@ -264,16 +265,15 @@ MI_VARIANT void ImageBlock<Float, Spectrum>::put(const Point2f &pos,
264
265
*weights_y = (Float *) alloca (sizeof (Float) * count.y ());
265
266
266
267
// Evaluate filters weights along the X and Y axes
267
-
268
- for (uint32_t i = 0 ; i < count.x (); ++i) {
269
- new (weights_x + i)
268
+ for (uint32_t x = 0 ; x < count.x (); ++x) {
269
+ new (weights_x + x)
270
270
Float (JIT ? m_rfilter->eval (rel_f.x ())
271
271
: m_rfilter->eval_discretized (rel_f.x ()));
272
272
rel_f.x () += 1 .f ;
273
273
}
274
274
275
- for (uint32_t i = 0 ; i < count.y (); ++i ) {
276
- new (weights_y + i )
275
+ for (uint32_t y = 0 ; y < count.y (); ++y ) {
276
+ new (weights_y + y )
277
277
Float (JIT ? m_rfilter->eval (rel_f.y ())
278
278
: m_rfilter->eval_discretized (rel_f.y ()));
279
279
rel_f.y () += 1 .f ;
@@ -283,11 +283,14 @@ MI_VARIANT void ImageBlock<Float, Spectrum>::put(const Point2f &pos,
283
283
if (unlikely (m_normalize)) {
284
284
Float wx = 0 .f , wy = 0 .f ;
285
285
286
- for (uint32_t i = 0 ; i < count.x (); ++i)
287
- wx += weights_x[i];
288
-
289
- for (uint32_t i = 0 ; i < count.y (); ++i)
290
- wy += weights_y[i];
286
+ Point2f rel_f2 = dr::ceil (pos_0_f) - pos_f;
287
+ for (uint32_t i = 0 ; i < count_max; ++i) {
288
+ wx += JIT ? m_rfilter->eval (rel_f2.x ())
289
+ : m_rfilter->eval_discretized (rel_f2.x ());
290
+ wy += JIT ? m_rfilter->eval (rel_f2.y ())
291
+ : m_rfilter->eval_discretized (rel_f2.y ());
292
+ rel_f2 += 1 .f ;
293
+ }
291
294
292
295
Float factor = dr::detach (wx * wy);
293
296
@@ -416,17 +419,11 @@ MI_VARIANT void ImageBlock<Float, Spectrum>::put(const Point2f &pos,
416
419
*weights_y = (Float *) alloca (sizeof (Float) * count);
417
420
418
421
for (uint32_t i = 0 ; i < count; ++i) {
419
- Float weight_x = m_rfilter->eval (rel_f.x ()),
420
- weight_y = m_rfilter->eval (rel_f.y ());
421
-
422
- if (unlikely (m_normalize)) {
423
- dr::masked (weight_x, x + i >= size.x ()) = 0 .f ;
424
- dr::masked (weight_y, y + i >= size.y ()) = 0 .f ;
425
- }
422
+ Float weight_x = m_rfilter->eval (rel_f.x ());
423
+ Float weight_y = m_rfilter->eval (rel_f.y ());
426
424
427
425
new (weights_x + i) Float (weight_x);
428
426
new (weights_y + i) Float (weight_y);
429
-
430
427
rel_f += 1 ;
431
428
}
432
429
0 commit comments