<div dir="ltr">Hi Sergey,<br><br>when I removed the output_path name &quot;to force it outside of the <span style="color:rgb(80,0,80);font-size:12.8000001907349px">if(!(params.background &amp;&amp; params.output_path.empty())) , it worked fine, so I guess it needs more checks.<br>so now it works fine with buckets updating, checking progressive refine &quot;it should work fine also!!&quot;<br><br>thanks for help so far.<br><br>cheers,<br>Mohamed Sakr</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 19, 2015 at 1:17 PM, Mohamed Sakr <span dir="ltr">&lt;<a href="mailto:3dsakr@gmail.com" target="_blank">3dsakr@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Sergey,<br><br>I can confirm that the above part is the problem, I added those 2 lines to see if it is the cause of the issue:<span class=""><br><br><span style="font-size:12.8000001907349px"><div>void Session::release_tile(RenderTile&amp; rtile)</div><div>{</div><div><span style="white-space:pre-wrap">        </span>thread_scoped_lock tile_lock(tile_mutex);</div><div><br></div><div><span style="white-space:pre-wrap">        </span>if(write_render_tile_cb) {</div><div><span style="white-space:pre-wrap">                </span>if(params.progressive_refine == false) {</div><div><span style="white-space:pre-wrap">                        </span>/* todo: optimize this by making it thread safe and removing lock */</div></span><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">                        //</span>write_render_tile_cb(rtile); //no call at all</div><div style="font-size:12.8000001907349px"><br></div></span><div style="font-size:12.8000001907349px"><span class=""><span style="white-space:pre-wrap">                        </span>delete rtile.buffers;// this is why it crashes!! , it deletes the buffers<br></span>                        rtile.buffers = nullptr; //here!!</div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">                </span>}</div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">        </span>}</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">        </span>update_status_time();</div><div style="font-size:12.8000001907349px">}<br><br><div style="font-size:12.8000001907349px"><span class=""><span style="white-space:pre-wrap">        </span>if(!(params.background &amp;&amp; params.output_path.empty())) {//enters here<br></span>                if(!rtile.buffers)<br>                     std::cout &lt;&lt; &quot;nullptr buffer!!&quot; &lt;&lt; std::endl; // it enters here, as they are pointers so the buffers is also empty, and it is re assigned so it crashes, it needs recreation or another logic, you know better than me at this point.<br><br></div><span class=""><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">                </span>tile_manager.state.buffer.get_offset_stride(rtile.offset, rtile.stride);</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">                </span>rtile.buffer = buffers-&gt;buffer.device_pointer;</div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">                </span>rtile.rng_state = buffers-&gt;rng_state.device_pointer;</div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">                </span>rtile.buffers = buffers;// these buffers are already deleted, bam!!</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">                </span>device-&gt;map_tile(tile_device, rtile);</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">                </span>return true;</div><div style="font-size:12.8000001907349px"><span style="white-space:pre-wrap">        </span>}</div></span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 19, 2015 at 12:58 PM, Mohamed Sakr <span dir="ltr">&lt;<a href="mailto:3dsakr@gmail.com" target="_blank">3dsakr@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">@Jasper , the constructor is sizing it , std::vector&lt;float&gt; pixels(params.width*params.height * 4);<br>and BTW it crashes even if I didn&#39;t call this function &quot;just by entering the function pointer part&quot;<br><br>@Sergey, please confirm!!<br>so it crashes with this:<span><br><div>void Session::release_tile(RenderTile&amp; rtile)</div><div>{</div><div><span style="white-space:pre-wrap">        </span>thread_scoped_lock tile_lock(tile_mutex);</div><div><br></div><div><span style="white-space:pre-wrap">        </span>if(write_render_tile_cb) {</div><div><span style="white-space:pre-wrap">                </span>if(params.progressive_refine == false) {</div><div><span style="white-space:pre-wrap">                        </span>/* todo: optimize this by making it thread safe and removing lock */</div></span><div><span style="white-space:pre-wrap">                        //</span>write_render_tile_cb(rtile); //no call at all</div><div><br></div><div><span style="white-space:pre-wrap">                        </span>delete rtile.buffers;// this is why it crashes!! , it deletes the buffers</div><div><span style="white-space:pre-wrap">                </span>}</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div><span style="white-space:pre-wrap">        </span>update_status_time();</div><div>}</div><br>AND<br><br><div><span style="white-space:pre-wrap">        </span>if(!(params.background &amp;&amp; params.output_path.empty())) {//enters here</div><div><span style="white-space:pre-wrap">                </span>tile_manager.state.buffer.get_offset_stride(rtile.offset, rtile.stride);</div><div><br></div><div><span style="white-space:pre-wrap">                </span>rtile.buffer = buffers-&gt;buffer.device_pointer;</div><div><span style="white-space:pre-wrap">                </span>rtile.rng_state = buffers-&gt;rng_state.device_pointer;</div><div><span style="white-space:pre-wrap">                </span>rtile.buffers = buffers;// these buffers are already deleted, bam!!</div><div><br></div><div><span style="white-space:pre-wrap">                </span>device-&gt;map_tile(tile_device, rtile);</div><div><br></div><div><span style="white-space:pre-wrap">                </span>return true;</div><div><span style="white-space:pre-wrap">        </span>}</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 19, 2015 at 12:42 PM, Jasper Kindt <span dir="ltr">&lt;<a href="mailto:jasper.kindt@gmail.com" target="_blank">jasper.kindt@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Not an STL expert but shouldn&#39;t you reserve space in the pixels vector first before you pass it?</p><div><div>
<div class="gmail_quote">On 19 May 2015 12:25, &quot;Mohamed Sakr&quot; &lt;<a href="mailto:3dsakr@gmail.com" target="_blank">3dsakr@gmail.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">but I&#39;m sure it doesn&#39;t crash from the function content, even if the function is empty &quot;just return; &quot; , it crashes</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 19, 2015 at 12:17 PM, Mohamed Sakr <span dir="ltr">&lt;<a href="mailto:3dsakr@gmail.com" target="_blank">3dsakr@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Sergey,<br><br>it didn&#39;t solve the issue &quot;although I guess it is a part of the crash, so there is another part that crashes it here too&quot; , it crashes in both CPU and CUDA, when I tested with CUDA it throws this message:<br>ILLEGAL_ADDRESS in cuCtxSynchronize()<br><br>here is the code that I&#39;m using for the function callback:<br><br><div>void rContextHandler::r_C4D_write_tile(RenderTile&amp; rtile)</div><div>{</div><div><span style="white-space:pre-wrap">        </span>BufferParams&amp; params = rtile.buffers-&gt;params;</div><div><span style="white-space:pre-wrap">        </span>int x = params.full_x - options.session-&gt;tile_manager.params.full_x;</div><div><span style="white-space:pre-wrap">        </span>int y = params.full_y - options.session-&gt;tile_manager.params.full_y;</div><div><span style="white-space:pre-wrap">        </span>int w = params.width;</div><div><span style="white-space:pre-wrap">        </span>int h = params.height;</div><div><br></div><div><span style="white-space:pre-wrap">        </span>RenderBuffers *buffers = rtile.buffers;</div><div><br></div><div><span style="white-space:pre-wrap">        </span>/* copy data from device */</div><div><span style="white-space:pre-wrap">        </span>if (!buffers-&gt;copy_from_device())</div><div><span style="white-space:pre-wrap">                </span>return;</div><div><br></div><div><span style="white-space:pre-wrap">        </span>float exposure = scene-&gt;film-&gt;exposure;</div><div><span style="white-space:pre-wrap">        </span>std::vector&lt;float&gt; pixels(params.width*params.height * 4);</div><div><br></div><div><span style="white-space:pre-wrap">        </span>if (buffers-&gt;get_pass_rect(PASS_COMBINED, exposure, rtile.sample, 4, &amp;pixels[0]))</div><div><span style="white-space:pre-wrap">                </span>write_c4d(&amp;pixels[0], x, y, w, h);</div><div><br></div><div><span style="white-space:pre-wrap">        </span>return;</div><div>}</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 19, 2015 at 9:40 AM, Sergey Sharybin <span dir="ltr">&lt;<a href="mailto:sergey.vfx@gmail.com" target="_blank">sergey.vfx@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I can&#39;t reproduce issue with missing update/write callbacks call here, this all works just fine here by the looks of it. Also not sure why would commenting buffers deletion make things work to you. Either you&#39;re referencing buffers in the callback or maybe it is related to the next issue.<div><br></div><div>Bet you&#39;ve got default start resolution of 64 in the settings. This makes it so frame first renders with lower resolution and then goes to a final resolutions. This for sure causes number of tiles to be changed, which is not supported by progressive refine in the background mode.</div><div><br></div><div>Surely we can add some checks in the session constructor to verify the settings, but for until then just manually control the settings on your side.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Tue, May 19, 2015 at 3:21 AM, Mohamed Sakr <span dir="ltr">&lt;<a href="mailto:3dsakr@gmail.com" target="_blank">3dsakr@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi,<br><br>    I&#39;m creating a render engine based on Cycles, right now everything is fine except that the function callbacks &quot;<font color="#4b4d51" face="Segoe UI, Segoe UI Web Regular, Segoe UI Symbol, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="line-height:16.0030002593994px">write_render_tile_cb, update_render_tile_cb&quot; and variables &quot;progressive, progressive_refine&quot; are making a problem!!</span></font><br><br><font color="#4b4d51" face="Segoe UI, Segoe UI Web Regular, Segoe UI Symbol, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="line-height:16.0030002593994px">the problem is:</span></font><br><font color="#4b4d51" face="Segoe UI, Segoe UI Web Regular, Segoe UI Symbol, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="line-height:16.0030002593994px">case (1):<br></span></font><div><div><span style="white-space:pre-wrap">        </span>options.session_params.progressive = true;</div><div><span style="white-space:pre-wrap">        </span>options.session_params.progressive_refine = true;</div><div><span style="white-space:pre-wrap">        </span>options.session_params.progressive_update_timeout = 0.1;</div><div><span style="white-space:pre-wrap">        </span>options.session_params.background = true;</div><br><font color="#4b4d51" face="Segoe UI, Segoe UI Web Regular, Segoe UI Symbol, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="line-height:16.0030002593994px">no feedback is given &quot;from both functions, so they are not called&quot; , at the end of the render it saves the image on destructor.</span></font><br><br><font color="#4b4d51" face="Segoe UI, Segoe UI Web Regular, Segoe UI Symbol, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="line-height:16.0030002593994px">case (2):</span></font><br><div><span style="white-space:pre-wrap">        </span>options.session_params.progressive = false;</div><div><span style="white-space:pre-wrap">        </span>options.session_params.progressive_refine = false;</div><div><span style="white-space:pre-wrap">        </span>options.session_params.progressive_update_timeout = 0.1;</div><div><span style="white-space:pre-wrap">        </span>options.session_params.background = true;<br><br>crash!! after first tile, shows 12/192 in tiles and crashes.<br><br>case (3):<br><div><span style="white-space:pre-wrap">        </span>options.session_params.progressive = false;</div><div><span style="white-space:pre-wrap">        </span>options.session_params.progressive_refine = false;</div><div><span style="white-space:pre-wrap">        </span>options.session_params.progressive_update_timeout = 0.1;</div><div><span style="white-space:pre-wrap">        </span>options.session_params.background = true;<br><br>and in session.cpp:<br><br><div>void Session::release_tile(RenderTile&amp; rtile)</div><div>{</div><div><span style="white-space:pre-wrap">        </span>thread_scoped_lock tile_lock(tile_mutex);</div><div><br></div><div><span style="white-space:pre-wrap">        </span>if(write_render_tile_cb) {</div><div><span style="white-space:pre-wrap">                </span>if(params.progressive_refine == false) {</div><div><span style="white-space:pre-wrap">                        </span>/* todo: optimize this by making it thread safe and removing lock */</div><div><span style="white-space:pre-wrap">                        </span>write_render_tile_cb(rtile);</div><div><br></div><div><span style="white-space:pre-wrap">                        //</span>delete rtile.buffers;  // I commented this line!!</div><div><span style="white-space:pre-wrap">                </span>}</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div><span style="white-space:pre-wrap">        </span>update_status_time();</div><div>}<br><br>with commenting delete rtile.buffers; , it doesn&#39;t crash, and updates fine!! &quot;although with some problems in gamma in updating, but at the end the written image is gamma correct&quot;<br><br>I&#39;m not sure where is the problem.<br><br>cheers,<br>Mohamed Sakr</div></div></div></div></div>
<br></div></div>_______________________________________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org" target="_blank">Bf-cycles@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-cycles" target="_blank">http://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><div><span style="color:rgb(102,102,102)">With best regards, Sergey Sharybin</span></div></div>
</font></span></div>
<br>_______________________________________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org" target="_blank">Bf-cycles@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-cycles" target="_blank">http://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
<br>_______________________________________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org" target="_blank">Bf-cycles@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-cycles" target="_blank">http://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
<br></blockquote></div>
</div></div><br>_______________________________________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org" target="_blank">Bf-cycles@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-cycles" target="_blank">http://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>