Multiple Datablocks per HLMS with variable sizes possible?

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
white_waluigi
Goblin
Posts: 253
Joined: Sat Sep 28, 2013 3:46 pm
x 10

Multiple Datablocks per HLMS with variable sizes possible?

Post by white_waluigi »

I'm currently trying to make a Deferred Shading HLMS. This HLMS has 3 material Types: GBuffer (for materials which are rendered into the GBuffer MRT), Light (for materials which are used to render the lights), and Forward (For special materials which require Forward Rendering, ie transperant materials, other HLMS materials, etc).

Each one of those has their own shader files since they work very different from each other.
They also require their own datablock-data in the shader with varying sizes and their own Datablock Class.

But Looking at the current version of ConstBufferPool it seams to only accept one single static size for Datablocks.

My question is: Is variable Datablock Materialbuffer size possible, or should I just define a maximum Materialbuffer size that fits all Datablocks?

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4260
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 831
Contact:

Re: Multiple Datablocks per HLMS with variable sizes possibl

Post by dark_sylinc »

Yeah, ConstBufferPool wasn't really thought for variable sizes like you want.

Aside from your solution (use the max size for everything); I can think of two more:
  • ConstBufferPool is a helper class. It's not mandatory. Copy paste it into your own folders, change the class name, and modify its source code to fit your needs. Dunno how hard/easy that would be for you.
  • Since ConstBufferPool is not mandatory, and it doesn't contain pure virtual calls; it may be possible to have multiple instances of it in your Hlms. i.e. instead of deriving from ConstBufferPool directly in HlmsMyImplementation; declare it this way:

    Code: Select all

    class HlmsMyImplementation : public HlmsBufferManager
    {
        ConstBufferPool mGBufferPool;
        ConstBufferPool mLightsPool;
        ConstBufferPool mForwardPool;
    public:
        HlmsMyImplementation() :
            mGBufferPool( bytesPerSlot0, ConstBufferPool::ExtraBufferParams() )
            mLightsPool( bytesPerSlot1, ConstBufferPool::ExtraBufferParams() )
            mForwardPool( bytesPerSlot2, ConstBufferPool::ExtraBufferParams() )
        {
        }
    };
    Also remember that when creating the HlmsDatablock, you need to pass the right pool (i.e. the HlmsPbsDatablock implementation assumes HlmsPbs derives from ConstBufferPool, now you would have to pass both HlmsMyImplementation and ConstBufferPool as separate pointers, and make the necessary adjustments when the base members are used so that the variables & functions of mGBufferPool/mLightsPool/mForwardPool are used)
    This ought to work and looks simple enough. The little details might get you (i.e. you end up binding the wrong pool, forgot to bind one of the pools, etc); so I suppose you should first start with your approach (use the max size) then once you get it working, start optimizing.
Cheers
Matias

white_waluigi
Goblin
Posts: 253
Joined: Sat Sep 28, 2013 3:46 pm
x 10

Re: Multiple Datablocks per HLMS with variable sizes possibl

Post by white_waluigi »

Yeah I'll probably define a universal Material Size using padding and optimize it later (I'll prorbably just make an alternative ConstBufferPool with variable sizes later).
Thanks a lot.

Post Reply