Radium-Engine icon indicating copy to clipboard operation
Radium-Engine copied to clipboard

Update texture data from a different thread is missing

Open hiergaut opened this issue 3 years ago • 7 comments

After speaking with Mathias on PR #901. It was said to fix/add in Engine classes (Texture, TextureManager) the functionality of modifying the texture data on the cpu side by using the dirty parameter and making sure to update on the gpu side before rendering a frame with the renderer thread.

hiergaut avatar May 25 '22 15:05 hiergaut

I'm not able to add assignee, I don't know why.

hiergaut avatar May 25 '22 15:05 hiergaut

The PR #976 corrects this issue. If you use BaseApplication in your application, you have to use TextureManager::updateTextureContent function to update the texture. The texture data is sent to the gpu by the base application during the rendering process with the render thread. Take care if your texture data in cpu side is updating during the rendering (pending textures : cpu -> gpu). There is example added by the PR #976 : see TextureQuadDynamic examples.

hiergaut avatar Jul 25 '22 13:07 hiergaut

PR is not merged yet. Reopening.

nmellado avatar Jul 25 '22 19:07 nmellado

After discussing with @MathiasPaulin, an alternative solution to #976 could be:

  • Add a dirtybit attribute to the texture class.
  • In texture::bind(), the dirtybit is checked. If yes, the texture updates the data from the CPU to the GPU.

With this approach, any system modifying the texture just has to set the dirtybit to true, as it is done for other objects in Radium. Also, this does not require any other change.

@hiergaut could you come up with a proposal implementing this approach ?

nmellado avatar Jul 26 '22 06:07 nmellado

There is a question on which class own the data (even if the current proposal, but since the raw ptr is just kept until update, that seems quite good).

dlyr avatar Jul 26 '22 07:07 dlyr

Yes, I can try, not today but probably tomorrow. I'll create another PR to do that.

hiergaut avatar Jul 26 '22 08:07 hiergaut

Great thanks

nmellado avatar Jul 26 '22 08:07 nmellado

I think now everything is merged.

dlyr avatar Jul 14 '23 00:07 dlyr