A weird(?) behavior of shapes_dr
#637
-
In the below code, I guess snippet (1) and snippet (2) both work exactly the same way, by the definition of For reproducing the problem: import drjit as dr
import mitsuba as mi
import torch
mi.set_variant("cuda_ad_rgb")
"""
wget https://benedikt-bitterli.me/resources/mitsuba/staircase.zip -P data/
unzip "data/*.zip" -d data/
rm data/*.zip
"""
scene = mi.load_file("/YOURPATH/data/staircase/scene_v3.xml")
shapes = scene.shapes_dr()
idx = []
for i, shape in enumerate(scene.shapes()):
try:
ps = shape.sample_position(0.5, [0.5, 0.5]).p.torch()
print(i, ps.mean(), shape.surface_area())
idx.append(i)
except:
continue
shapes_reduced = dr.gather(mi.ShapePtr, scene.shapes_dr(), idx)
"""Snippet (1) This does not work"""
shapes_reduced.sample_position(0.5, [0.5, 0.5])
"""Snippet (2) This does work"""
# for i, j in zip(range(len(shapes_reduced)), idx):
# print(j)
# shapes_reduced[i].sample_position(0.5, [0.5, 0.5]) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @Mephisto405 Basically In your case, even though some target function will not actually be executed, it is still recorded and during the recording an error happens. I've looked at the error myself, it seems that some of the meshes in the scene are "broken". For example You have 3 options:
|
Beta Was this translation helpful? Give feedback.
Hi @Mephisto405
Basically
shapes.reduces.sample_position
is a virtual function call. Unless you disable vcall recording withdr.set_flag(dr.JitFlag.VCallRecord, False)
, Dr.Jit will "trace/read" through every possible target function and then assemble a single optimized kernel which is finally executed.In your case, even though some target function will not actually be executed, it is still recorded and during the recording an error happens. I've looked at the error myself, it seems that some of the meshes in the scene are "broken". For example
Mesh432.obj
is just a line of vertices.You have 3 options: