mmp / pbrt-v4

Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the "Physically Based Rendering: From Theory to Implementation" book.
https://pbrt.org
Apache License 2.0
2.8k stars 429 forks source link

InlinedVector sometimes behave differently than std::vector #371

Closed w3ntao closed 10 months ago

w3ntao commented 1 year ago

After replacing InlinedVector<Point3f> with std::vector<Point3f>, I got different result rendering pbrt-v4-scenes/killeroos/killeroo-gold.pbrt. The difference is subtle:

compare left: rendered by official PBRT, mid: diff image, right: after replacing InlinedVector<Point3f> with std::vector<Point3f>

diff diff image: different pixels are highlighted with red dots

Code change can be found at https://github.com/w3ntao/pbrt-v4-inlinedvector/commit/c245fde62d94e7cc39ae3e7fe7d5a962938cb8c3 and it is the only different commit compared with PBRT.

Is this a bug or intended? Does InlinedVector supposed to work exactly like std::vector (when ignoring perfomance issues)?

My guess is InlinedVector might change memory layout.

mmp commented 11 months ago

Sorry for not looking at this sooner...

InlinedVector should give the same results as std::vector. I tried rendering this scene with your change, however, and am not seeing any pixel differences. Can you say more about which OS / CPU/GPU you are using?

w3ntao commented 11 months ago

I was using Debian 11 on ThinkPad L14 Gen 2 (forgot the exact CPU spec but it's i7-X 11 gen) when submitting this issue. That laptop has been gifted to a friend so it will take a while for me to reproduce this bug.

The weird thing is, I couldn't reproduce this bug with either my desktop (Debian 12, i5-13600K) or docker (Debian 11 and Debian 12).

Regarding to the scene killeroo-gold, I think the name was changed to "killeroo-gold.png" and pixelsamples changed to probably one of [16, 32, 64].

It was all CPU rendering, no GPU used. I will come back to this issue when I have access to the original hardware.

w3ntao commented 10 months ago

The bug was originally triggerd on Debian 11 with CPU 11th Gen Intel i7-1165G7 (8) @ 2.800GHz.

Now it can't be reproduced after upgrading to Debian 12. Closing this issue.