Implement update independent rendering (revisited)

First small performance test. Code
var compList = new List<SceneComponent>
{
new Transform(),
MakeEffect.FromDiffuseSpecular(new float4(.5f,0f,.5f,1f)),
new Cube()
};
var rnd = new Random();
var cube = new Cube();
for (var i = 0; i < 1000; i++)
{
compList.Add(new Transform
{
Translation =
new float3(
(float)((rnd.NextDouble() * 2.0f) - 1.0f ) * 5.0f,
(float)((rnd.NextDouble() * 2.0f) - 1.0f ) * 5.0f,
(float)((rnd.NextDouble() * 2.0f) - 1.0f) * 5.0f
)
});
compList.Add(cube);
}
_cubeScene = new SceneContainer
{
Children = new List<SceneNode>
{
new SceneNode
{
Components = compList
}
}
};

The GPU usage is usually at 4%. The spike is caused by the Windows Snipping tool
This looks really concerning, we can't render 1000 cubes due to some strange overhead?
Disabling the actual draw call leaves us at the max frame rate. The performance loss is somewhere inside the [OnVisit] Render() method

Disabling nearlly all checks during the actual render call boosts the frame rate quite a bit

Seems like frustum culling does not hurt the frame rate.
Disabling the globalFXVarCheck and something else boosts the frame rate, again.

We need to revisit our hot path. Imoh, too much work is done here.
private void SetShaderParamT(FxParam param)
can be reworked. Enhance FxParam with an action which is set by the correct SetShaderParam method for the type.
This part can be deleted, as it already happens during creation

Some proposals (for myself 😉 )
- [ ] remove as many branches inside the hot path as possible
- [ ] remove all exception handling in hot path
- [ ] replace
SetShaderParamTviatypeof()with already computed method - [ ] do not set shader program / state for each mesh if nothing has changed!
- [ ] remove all LINQ-statements
- [ ] remove all
for eachcalls over collections for each collection that does not return astructwhenGetEnumeratoris called - [ ] check
GetEnumeratorin the scene tranversal if any memory is allocated there - [ ] try to use
stackallocandSpan/Memorywhere possible