How are identically named constant buffers handled?

Mar 18, 2016 at 3:56 PM

first off: Great engine. I learned a lot by reading through the source code and i am thinking about getting your Book aswell.
Here is one question about the management of parameters, especially about constant buffers:

How is the engine handling constant buffers having the same name, but which are defined in different shaders (e.g. Vertex and Pixel)? As far as i can see the ParameterRef for a Constant Buffer is created by it's name and is in no way associated with the type of the shader..

ConstantBufferLayout BufferLayout;
            BufferLayout.Description = bufferDesc;
            BufferLayout.pParamRef = pParamMgr->GetConstantBufferParameterRef( 
                GlyphString::ToUnicode( std::string( BufferLayout.Description.Name ) ) );
So the Parameter Manager only holds one Constant Buffer with that name, but how are the variables of each constant buffers mapped to the right memory region without overwriting the other?

I hope my question became clear. If not, then please don't hesitate to ask!
Thank you
Mar 22, 2016 at 5:01 PM
Hi there,

Thanks for the comments - I'm happy that you got some use from and have enjoyed the engine.

You are exactly correct about the handling of the constant buffers. Currently it is only checking for the name of the buffer and retrieving it regardless of its size or contents (it actually doesn't matter about the shader stage, as the same constant buffer can be used at any stage without issue). If you try to use two different shaders that have the same name, but different sized contents, then there will be a popup window saying that an error occurred and it will describe the issue.

In general, this hasn't been an issue for me. Whenever I had two buffers with the same name, I just renamed one of them. This makes it so that each name only has a single set of contents, and the mapping is will always match.

Does that clarify the topic?
Mar 23, 2016 at 11:50 AM
That has indeed answered my question. I was only wondering if i missed something! Thanks for your time and response!