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.83k stars 440 forks source link

Illegal memory was encountered when mixed textures are used. #420

Open Zhenyi-Liu opened 6 months ago

Zhenyi-Liu commented 6 months ago

When mixed textures (such as the watercolor scene in pbrt-v4-scenes) are used with NSpectralSamples larger than 20, I encounter a CUDA error.:


FATAL CUDA error: an illegal memory access was encountered
(./pbrt                                  )      0x0x5c4127f22c7a - pbrt::PrintStackTrace() + 0x3a
(./pbrt                                  )      0x0x5c4127f22f11 - pbrt::CheckCallbackScope::Fail() + 0x21
(./pbrt                                  )      0x0x5c4127f95be2 - pbrt::LogFatal(pbrt::LogLevel, char const*, int, char const*) + 0xf2
(./pbrt                                  )      0x0x5c41282408ff - int pbrt::GetBlockSize<void (*)(__nv_hdl_wrapper_t<false, false, __nv_dl_tag<void (pbrt::WavefrontPathIntegrator::*)(), &pbrt::WavefrontPathIntegrator::UpdateFilm, 1u>, void (int), pbrt::WavefrontPathIntegrator* const>, int)>(char const*, void (*)(__nv_hdl_wrapper_t<false, false, __nv_dl_tag<void (pbrt::WavefrontPathIntegrator::*)(), &pbrt::WavefrontPathIntegrator::UpdateFilm, 1u>, void (int), pbrt::WavefrontPathIntegrator* const>, int)) + 0x1ff
(./pbrt                                  )      0x0x5c4128240c7d - void pbrt::GPUParallelFor<__nv_hdl_wrapper_t<false, false, __nv_dl_tag<void (pbrt::WavefrontPathIntegrator::*)(), &pbrt::WavefrontPathIntegrator::UpdateFilm, 1u>, void (int), pbrt::WavefrontPathIntegrator* const> >(char const*, int, __nv_hdl_wrapper_t<false, false, __nv_dl_tag<void (pbrt::WavefrontPathIntegrator::*)(), &pbrt::WavefrontPathIntegrator::UpdateFilm, 1u>, void (int), pbrt::WavefrontPathIntegrator* const>) + 0x5d
(./pbrt                                  )      0x0x5c4128240271 - pbrt::WavefrontPathIntegrator::UpdateFilm() + 0x91
(./pbrt                                  )      0x0x5c4128249118 - pbrt::WavefrontPathIntegrator::Render() + 0xaf8
(./pbrt                                  )      0x0x5c41280557bb - pbrt::RenderWavefront(pbrt::BasicScene&) + 0x29b
(./pbrt                                  )      0x0x5c4127d4cc20 - main + 0x1af0
(/lib/x86_64-linux-gnu/libc.so.6         )      0x0x7aacb5a29d90 - (unknown) + 0x29d90
(/lib/x86_64-linux-gnu/libc.so.6         )      0x0x7aacb5a29e40 - __libc_start_main + 0x80
(./pbrt                                  )      0x0x5c4127d54155 - _start + 0x25
Wavefront rendering failed at sample 0. Debug with "--debugstart 0"

With NSpectralSamples = 20, I got a different error:

FATAL CUDA error: an illegal memory access was encountered
(./pbrt                                  )      0x0x5a18bac00f8a - pbrt::PrintStackTrace() + 0x3a
(./pbrt                                  )      0x0x5a18bac01221 - pbrt::CheckCallbackScope::Fail() + 0x21
(./pbrt                                  )      0x0x5a18bac73ef2 - pbrt::LogFatal(pbrt::LogLevel, char const*, int, char const*) + 0xf2
(./pbrt                                  )      0x0x5a18baafd97c - void pbrt::LogFatal<char const*>(pbrt::LogLevel, char const*, int, char const*, char const*&&) + 0x5c
(./pbrt                                  )      0x0x5a18bafb7c4e - pbrt::OptiXAggregate::getParamBuffer(pbrt::RayIntersectParameters const&) const + 0x18e
(./pbrt                                  )      0x0x5a18bafb8466 - pbrt::OptiXAggregate::IntersectShadowTr(int, pbrt::WorkQueue<pbrt::ShadowRayWorkItem>*, pbrt::SOA<pbrt::PixelSampleState>*) const + 0x276
(./pbrt                                  )      0x0x5a18baf14039 - pbrt::WavefrontPathIntegrator::TraceShadowRays(int) + 0x49
(./pbrt                                  )      0x0x5a18baf14f14 - pbrt::WavefrontPathIntegrator::Render() + 0xa34
(./pbrt                                  )      0x0x5a18bad3355b - pbrt::RenderWavefront(pbrt::BasicScene&) + 0x29b
(./pbrt                                  )      0x0x5a18baa42900 - main + 0x1af0
(/lib/x86_64-linux-gnu/libc.so.6         )      0x0x7b2e91029d90 - (unknown) + 0x29d90
(/lib/x86_64-linux-gnu/libc.so.6         )      0x0x7b2e91029e40 - __libc_start_main + 0x80
(./pbrt                                  )      0x0x5a18baa49e35 - _start + 0x25
Wavefront rendering failed at sample 0. Debug with "--debugstart 0"

this error can be reproduced when using this material:

Texture "rgb:textures/Concrete_2_Base_Color_i04042021" "spectrum" "imagemap" "string filename" "textures/Concrete_2_Base_Color_i04042021.png" "float scale" [0.9000] "bool invert" [false]
Texture "rgb:textures/Concrete_2_Base_Color_i04042021-mix" "spectrum" "mix" "texture tex1" "rgb:textures/Concrete_2_Base_Color_i04042021" "rgb tex2" [0.5000 0.4500 0.4000] "float amount" [0.2000]
MakeNamedMaterial "Material.2" "string type" [ "coateddiffuse" ] "texture reflectance" "rgb:textures/Concrete_2_Base_Color_i04042021-mix"

Everything works fine with NSpectralSamples <=16.

Any clue will be helpful, I will keep looking into this issue.

Thanks!