Horde3D
http://horde3d.org/forums/

Multiple pipelines able to share render targets?
http://horde3d.org/forums/viewtopic.php?f=2&t=429
Page 1 of 1

Author:  cantele [ 17.07.2008, 17:02 ]
Post subject:  Multiple pipelines able to share render targets?

If I render stuff with pipeline 1 to buffer X, I cannot use that in pipeline 2 materials (==shaders), can I? I think it would be a great idea to be able to share the rendering targets across pipelines, because otherwise I cannot use the previous buffer contents during shading.

How hard would this be to get into the engine?

Author:  cantele [ 17.07.2008, 17:10 ]
Post subject:  Re: Multiple pipelines able to share render targets?

To me, intuitive would be to have attribute "shared" in RenderTarget's, so pipelines would be able to find them. Such a shared target would then have to be defined in the first pipeline (or all pipelines) wishing to use that target. They could just assume it's a shared target if it's not specified in the given pipeline's Setup.

Author:  cantele [ 17.07.2008, 18:12 ]
Post subject:  Re: Multiple pipelines able to share render targets?

I actually implemented this and it works... I can make a patch if you show some interest.

In my version there is an optional "shared"-attribute to RenderTargets. If a shared target with given name exists already, it will not be created again but the old one will be used. The RenderTargets are stored in a singleton class that PipelineResources used, called PipelineShared. It has similar methods that are used as fallbacks and called when appropriate.

For example "findRenderTarget" will first search the local (non-shared) render targets and then fall back to the shared ones. This way, even when there is not "Setup" tag in the pipelines, an existing render target from a previously loaded pipeline can be used just based on the id.

I think the clean design of pipelines made implementing this very painless.

Author:  cantele [ 20.07.2008, 15:36 ]
Post subject:  Re: Multiple pipelines able to share render targets?

Here's the patch. I don't think there are any disadvantages to it, except for possible bugs (that shouldn't affect existing functionality)... I tested it with a few configurations. It's of course 100% backwards compatible.

The only thing I didn't consider was when the shared rendering targets should be destroyed (except when resizing).

And if someone creates duplicate rendering targets with the same name, the same thing happens as with the usual case - only the first rendering target will be returned, so someone could accidentally create two targets with differing parameters, and later on just the first one would be used. Maybe some error check could be added to that... anyway I already created the patch and I had trouble with Windows line breaks so I'm not keen to do it again.

Oh, I forgot one line related to resizing from the patch:

egMain should also resize the shared targets with:

Code:
   DLLEXP void resize( int x, int y, int width, int height )
   {
      if( !initialized ) return;

      Modules::renderer().resize( x, y, width, height );

      // Update pipeline resources
      for( uint32 i = 0; i < Modules::resMan().getResources().size(); ++i )
      {
         Resource *res = Modules::resMan().getResources()[i];

         if( res != 0x0 && res->getType() == ResourceTypes::Pipeline )
         {
            ((PipelineResource *)res)->resize();
         }
      }
      PipelineShared::getInstance()->resize(); // <-- Add this line to patch
   }


Attachments:
File comment: Adds support for shared rendering targets across all pipelines (in loading order).
patch.zip [2.16 KiB]
Downloaded 552 times

Author:  marciano [ 21.07.2008, 22:28 ]
Post subject:  Re: Multiple pipelines able to share render targets?

Thanks a lot for the patch. I think it is a good idea to have shared render targets, we were also thinking about that some time ago. We will check the patch but it can take some time since we are quite busy right now.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/