Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 19:00

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 17.07.2008, 17:02 
Offline

Joined: 03.07.2008, 01:23
Posts: 50
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?


Top
 Profile  
Reply with quote  
PostPosted: 17.07.2008, 17:10 
Offline

Joined: 03.07.2008, 01:23
Posts: 50
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.


Top
 Profile  
Reply with quote  
PostPosted: 17.07.2008, 18:12 
Offline

Joined: 03.07.2008, 01:23
Posts: 50
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.


Top
 Profile  
Reply with quote  
PostPosted: 20.07.2008, 15:36 
Offline

Joined: 03.07.2008, 01:23
Posts: 50
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
Top
 Profile  
Reply with quote  
PostPosted: 21.07.2008, 22:28 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group