<div dir="ltr">It seems unnecessarily complicated. If you call <font face="monospace, monospace">session->draw() </font>that will mostly just pass the <font face="monospace, monospace">session->display</font> buffer to <font face="monospace, monospace">draw_pixels</font> on the device. So why not just get the pixels from that display buffer directly? Something like this:<div><div><div><br></div><div><font face="monospace, monospace">thread_scoped_lock display_lock(session->display_mutex);<br></font></div></div></div><div><font face="monospace, monospace">if(session->display->draw_ready()) {</font></div><div><font face="monospace, monospace">    uint width = <span style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">session-></span>display->draw_width;</font></div><div><font face="monospace, monospace">    <span style="color:rgb(34,34,34);font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">uint height = <span style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">session-></span>display->draw_height;</span></font></div><div><span style="color:rgb(34,34,34);font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><font face="monospace, monospace"><span style="color:rgb(34,34,34);font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">    uchar4 *pixels = <span style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">session-></span>display->rgba_byte.data();</span><br></font></span></div><div><font face="monospace, monospace">    ... do something ...</font></div><div><font face="monospace, monospace">}</font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 18, 2018 at 11:43 AM, Guillaume Chéreau <span dir="ltr"><<a href="mailto:guillaume.chereau@gmail.com" target="_blank">guillaume.chereau@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">OK after some more tests it seems to me that the easiest would be to<br>
create my own CPUDevice subclass and overload the draw_pixels method<br>
to render into my own texture, then somehow set this as the session<br>
device.<br>
Does that make sense, or am I going to run into some subtle bugs with<br>
this approach?<br>
<br>
Regards,<br>
- Gui<br>
<div class="HOEnZb"><div class="h5"><br>
On Sun, Mar 18, 2018 at 2:31 AM, Lukas Stockner<br>
<<a href="mailto:lukas.stockner@freenet.de">lukas.stockner@freenet.de</a>> wrote:<br>
> Answers inline.<br>
><br>
> On 17.03.2018 18:10, Guillaume Chéreau wrote:<br>
>><br>
>> On Sat, Mar 17, 2018 at 11:01 PM, Lukas Stockner<br>
>> <<a href="mailto:lukas.stockner@freenet.de">lukas.stockner@freenet.de</a>> wrote:<br>
>>><br>
>>> - Are you fine with getting a raw float buffer?<br>
>><br>
>> Yes that's fine, I can easily do the conversion to RGB.<br>
><br>
> Okay, that makes things easier because you can just process the<br>
> RenderBuffers directly and don't have to mess around with the film_convert<br>
> kernels.<br>
>>><br>
>>> - Are you using interactive rendering?<br>
>><br>
>> Yes, I am looking for the same kind of rendering as in Blender, where<br>
>> we start we a low res version and progressively improve it, if the<br>
>> user changes the scene of the camera position, the rendering is reset.<br>
>> It works more or less out of the box with the session->draw method,<br>
>> but it is using OpenGL to do the rendering directly on screen. What -I<br>
>> think- I want is to get the raw data and add put it into a dynamic<br>
>> texture that I can integrate into goxel rendering.<br>
>><br>
>>> - Do you want to support multiple devices?<br>
>><br>
>> Not sure what that means.  I only want to render on screen, and also<br>
>> into a file for export.<br>
><br>
> I was referring to the MultiDevice functionality, which is currently used<br>
> for rendering on multiple GPUs at once (and might in the future be used for<br>
> network rendering). The problem with that is that each device has its own<br>
> memory space, so you can't just write all tiles into a single buffer - you'd<br>
> have to allocate per-tile buffers, copy them back to the host and then<br>
> combine them there (which is what Blender does when doing a non-interactve<br>
> render).<br>
><br>
> Technically it is possible to allocate a single large buffer (on every<br>
> device), have them write into it and then copy the right parts from the<br>
> right devices to assemble it directly without moving stuff around, but since<br>
> you can only copy back linear memory regions you'd have to modify tiling to<br>
> split the image into horizontal slices (one slice per device). In fact, that<br>
> is what Cycles currently does for viewport previews since OpenGL drawing<br>
> also works better that way.<br>
>>><br>
>>> The easiest approaches I can think of right now are either using a shared<br>
>>> RenderBuffer for all tiles (already sort of implemented in session.cpp)<br>
>>> or<br>
>>> just copying the pixels from their buffers into your shared buffer<br>
>>> similar<br>
>>> to how Cycles for Blender does it in<br>
>>> BlenderSession::do_write_<wbr>update_render_result.<br>
>><br>
>> OK thanks for the tips, I will have a look at that.<br>
>> - Gui<br>
>> ______________________________<wbr>_________________<br>
>> Bf-cycles mailing list<br>
>> <a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
>> <a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/<wbr>mailman/listinfo/bf-cycles</a><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> Bf-cycles mailing list<br>
> <a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
> <a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/<wbr>mailman/listinfo/bf-cycles</a><br>
<br>
<br>
<br>
</div></div><span class="im HOEnZb">--<br>
Guillaume<br>
<a href="mailto:guillaume.chereau@gmail.com">guillaume.chereau@gmail.com</a><br>
<a href="tel:%2B886%20970422910" value="+886970422910">+886 970422910</a><br>
</span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
<a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/<wbr>mailman/listinfo/bf-cycles</a><br>
</div></div></blockquote></div><br></div>