PSSetConstantBuffers, GSSetConstantBufers, and PSSetConstantBuffers with StartSlot param

Editor
Apr 2, 2013 at 4:13 PM
I was poking through your engine again last night and noticed that you always specify 0 for the StartSlot param for each of the shader stages SetConstantBuffers method. Some of your shader files have up to 3 constant buffers in them. If each of the 3 constant buffers are used in the vertex shader, you should have 3 calls to the VSSetConstantBuffers method with 0, 1, and 2 for the start slot correct?
Coordinator
Apr 2, 2013 at 10:06 PM
Nope - you can actually bind multiple buffers with a single call to *SSetConstantBuffers methods. This is utilized in the engine - since the state monitoring updates were added to the engine, the default should no longer be based on starting with 0 as the start slot. For example, here is a code snippet from the GS stage:
void GeometryStageDX11::BindConstantBuffers( ID3D11DeviceContext* pContext, int count )
{
    pContext->GSSetConstantBuffers( 
        DesiredState.ConstantBuffers.GetStartSlot(),
        DesiredState.ConstantBuffers.GetRange(),
        DesiredState.ConstantBuffers.GetFirstSlotLocation() );
}
The start slot is determined by the 'DesiredState' and the other parameters are updated so that only the needed state changes occur, but all states will be updated in a minimum number of API calls.

Where did you see that defaults to the start slot of 0?
Editor
Apr 2, 2013 at 11:15 PM
Doh! I'm running an older version of Hieroglyph3. You must have made the above changes recently? I see the code below in my trunk.
void GeometryStageDX11::BindConstantBuffers( ID3D11DeviceContext* pContext, int count )
{
    pContext->GSSetConstantBuffers( 0, count, DesiredState.ConstantBuffers );
}
I'll download the latest codebase and look at how you're setting the constant buffers now :). Thanks!
Coordinator
Apr 3, 2013 at 3:32 AM
It wasn't too long ago - but you have to keep up! :)

Actually, even in that old version I would only call the method once, and set all of the buffers from 0 through to the last one all in one shot. But anyways, if anything is unclear about the implementation, please let me know!
Editor
Apr 3, 2013 at 2:46 PM
Ok cool, I'm not too far behind then :). I'm running build 82511. I've been slacking ;).

Yes, I realize now that you were doing the same thing with the version I had, minus the state monitoring. I'm just a goof. Everything makes complete since. Thanks!