Archive

Archive for April, 2009

Further improved the ConstantBufferSystem

I spend some time improving my ConstantBufferSystem.
As shown in the last post I had to define the ConstantBufferBuilder in Code(C++) to match the ConstantBuffer in the shader.

I was able to remove this intermediate step, without changing the underlying system shown in the last post.
We now just load the Shader and create the ConstantBuffer from the ConstantBufferBuilder created for us.
Lets have a look at the code:

contentManager->LoadShaderEffect(L"Content\\test3.fx", &shaderEffect);      
graphicsDevice->CreateConstantBuffer(                                       
    shaderEffect->GetConstantBufferBuilderByUpdateRate(L"PerObjectStatic"), 
    &VSPerObjectStaticCB);                                                  

This is everything left we have to do, to create a ConstantBuffer.

The rest of system remains unchanged. So no further code changes are necessary, it will just work as before.

Now we just have to change the ConstantBuffers in the Shader itself and don’t have to worry about changing the C++ Code representation as well. This will be done automatically for us.

Categories: all