@@ -118,6 +118,7 @@ struct SPPMIntegrator{C<:Camera} <: Integrator
118
118
n_iterations:: Int64 , photons_per_iteration:: Int64 = - 1 ,
119
119
write_frequency:: Int64 = 1 ,
120
120
) where C<: Camera
121
+
121
122
photons_per_iteration = (
122
123
photons_per_iteration > 0
123
124
? photons_per_iteration : area (get_film (camera). crop_bounds)
@@ -129,7 +130,11 @@ struct SPPMIntegrator{C<:Camera} <: Integrator
129
130
end
130
131
end
131
132
133
+
134
+
135
+
132
136
function (i:: SPPMIntegrator )(scene:: Scene )
137
+
133
138
pixel_bounds = get_film (i. camera). crop_bounds
134
139
135
140
b_sides = inclusive_sides (pixel_bounds)
@@ -149,7 +154,7 @@ function (i::SPPMIntegrator)(scene::Scene)
149
154
n_tiles:: Point2 = Int64 .(floor .((pixel_extent .+ tile_size) ./ tile_size))
150
155
151
156
sampler = UniformSampler (1 )
152
- mempools = [MemoryPool (round (Int, 100_000 )) for _ in 1 : Threads. maxthreadid ()]
157
+ mempools = [MemoryPool (round (Int, 100000 )) for _ in 1 : Threads. maxthreadid ()]
153
158
for iteration in 1 : i. n_iterations
154
159
_generate_visible_sppm_points! (
155
160
mempools, i, pixels, scene,
@@ -322,13 +327,20 @@ function _populate_grid!(
322
327
grid_bounds, grid_resolution
323
328
end
324
329
330
+ function trace_photon_kernel ()
331
+
332
+
333
+
334
+ end
335
+
336
+
325
337
function _trace_photons! (
326
- mempools, i:: SPPMIntegrator , scene:: Scene , iteration:: Int64 ,
327
- light_distribution:: Distribution1D ,
328
- grid:: Vector{Maybe{SPPMPixelListNode}} ,
329
- grid_bounds:: Bounds3 , grid_resolution:: Point3 ,
330
- n_pixels:: UInt64 ,
331
- )
338
+ mempools, i:: SPPMIntegrator , scene:: Scene , iteration:: Int64 ,
339
+ light_distribution:: Distribution1D ,
340
+ grid:: Vector{Maybe{SPPMPixelListNode}} ,
341
+ grid_bounds:: Bounds3 , grid_resolution:: Point3 ,
342
+ n_pixels:: UInt64 ,
343
+ )
332
344
# Trace photons and accumulate contributions.
333
345
halton_base = UInt64 (iteration - 1 ) * UInt64 (i. photons_per_iteration)
334
346
bar = get_progress_bar (
@@ -377,7 +389,11 @@ function _trace_photons!(
377
389
378
390
# Follow photon path through scene and record intersections.
379
391
depth = 1
392
+ _photon_ray = photon_ray[] # load it from mempool
380
393
while depth ≤ i. max_depth
394
+ free_all (pool)
395
+ # put it back after free
396
+ photon_ray = allocate (pool, _photon_ray)
381
397
hit, primitive, interaction = intersect! (pool, scene, photon_ray)
382
398
! hit && break
383
399
if depth > 1
@@ -435,7 +451,7 @@ function _trace_photons!(
435
451
end
436
452
halton_dim += 1
437
453
# β = β_new / (1f0 - q)
438
- photon_ray = allocate (pool, RayDifferentials, spawn_ray (pool, interaction, wi))
454
+ _photon_ray = allocate (pool, RayDifferentials, spawn_ray (pool, interaction, wi))[]
439
455
depth += 1
440
456
end
441
457
next! (bar)
0 commit comments