Regression: Tiled rendering is not applied to texture baking in 3.x onwards, causing crash on large bakes #100626
Operating system: Win10
Graphics card: AMD Radeon R9 280x
System RAM: 32gb
Broken: 3.2.2, branch: master, commit date: 2022-08-02 18:15, hash:
bcfdb14560, type: release
(also tested Daily 3.2.2 and beta 3.3)
Worked: 2.8x, 2.9x, 2.9 LTS
Short description of error
Previously tile based rendering was applied when using the bake to texture feature, allowing baking to very large canvases. As of version 3.x tiled rendering no longer applies when baking textures and crashes on large canvases. In my case I can no longer bake to a texture larger than 2^14 (16384x16384).
Exact steps for others to reproduce the error
- Open attached file or
- From a new blend file, delete default cube,
- switch renderer to Cycles (CPU).
- Create a plane,
- switch to UV and create a very large texture (in my case anything larger than 16384x16384, my previously and still working in 2.9x size is 19310x) with float precision and no alpha.
- Create a new material,
- remove the principled Shader,
- connect the color output of a noise texture to the material output Surface,
- add an Image Texture node and select the previously created canvas. In my case I disable bounces (set all to zero) and set samples to 1, Filtering to Box filtering.
- Switch bake type to Emit.
- Hit bake and blender crashes trying to allocate the memory for the render target canvas. Setting Tiled rendering to other sizes does not work either.
I'm prebaking complex noise channels as it dramatically reduces render time on the final texture bake.
You may need to create an excessively large target canvas if you have a lot of ram.
When stopping a bake half way through on 2.9x and lower version you can see tile based rendering has taken effect and the sizes declared are used.
When stopping a texture bake on 3.x versions you can see that it is filling the entire canvas at once and not using tile based rendering, no matter what the tile size is set to.
Changed status from 'Needs Triage' to: 'Confirmed'
I can confirm the crash. It looks like the allocator doesn't support something with size
ucrtbase.dll!00007ffbf3f4dd7e() Unknown ucrtbase.dll!00007ffbf3f4d499() Unknown vcruntime140_1.dll!00007ffb7dfe1aab() Unknown vcruntime140_1.dll!00007ffb7dfe2317() Unknown vcruntime140_1.dll!00007ffb7dfe4119() Unknown ntdll.dll!00007ffbf6208b1f() Unknown ntdll.dll!00007ffbf6195b9a() Unknown ntdll.dll!00007ffbf6207b2e() Unknown KernelBase.dll!00007ffbf3a2474c() Unknown vcruntime140.dll!00007ffb7b8d66c0() Unknown > blender.exe!ccl::device_memory::host_alloc(unsigned __int64 size) Line 52 C++ [Inline Frame] blender.exe!ccl::device_vector<float>::alloc(unsigned __int64 width, unsigned __int64 height, unsigned __int64) Line 381 C++ blender.exe!ccl::RenderBuffers::reset(const ccl::BufferParams & params_) Line 281 C++ [Inline Frame] blender.exe!ccl::PathTrace::update_allocated_work_buffer_params::__l2::<lambda_1>::operator()(ccl::PathTraceWork *) Line 279 C++ blender.exe!ccl::foreach_sliced_buffer_params<`ccl::PathTrace::update_allocated_work_buffer_params'::`2'::<lambda_1>>(const ccl::vector<std::unique_ptr<ccl::PathTraceWork,std::default_delete<ccl::PathTraceWork>>,ccl::GuardedAllocator<std::unique_ptr<ccl::PathTraceWork,std::default_delete<ccl::PathTraceWork>>>> & path_trace_works, const ccl::vector<ccl::WorkBalanceInfo,ccl::GuardedAllocator<ccl::WorkBalanceInfo>> & work_balance_infos, const ccl::BufferParams & buffer_params, const int overscan, const ccl::PathTrace::update_allocated_work_buffer_params::__l2::<lambda_1> & callback) Line 266 C++ blender.exe!ccl::PathTrace::update_allocated_work_buffer_params() Line 281 C++ blender.exe!ccl::PathTrace::update_work_buffer_params_if_needed(const ccl::RenderWork & render_work) Line 333 C++ blender.exe!ccl::PathTrace::init_render_buffers(const ccl::RenderWork & render_work) Line 347 C++ blender.exe!ccl::PathTrace::render_pipeline(ccl::RenderWork render_work) Line 186 C++ blender.exe!ccl::PathTrace::render(const ccl::RenderWork & render_work) Line 166 C++ blender.exe!ccl::Session::run_main_render_loop() Line 194 C++ blender.exe!ccl::Session::thread_render() Line 258 C++ blender.exe!ccl::Session::thread_run() Line 233 C++ [Inline Frame] blender.exe!std::_Func_class<void>::operator()() Line 878 C++ blender.exe!ccl::thread::run(void * arg) Line 37 C++ [External Code]
I didn't know that Bake took advantage of "tile based rendering", but if that's the case, it makes sense to crash due to high memory usage.
One guess is that the problem was introduced in
0803119725, but i need to check.
Memory was reduced significantly with support for tiled rendering, even if there is more room for optimization. Will reduce priority here since it's not a show stopper anymore.
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?