|
SylvainTV
|
 |
« on: May 22, 2004, 07:54:11 AM » |
|
Hello, some updates on what I have been doing on tv6.5 and tv6.2/3!
TV3D6.2 : -> Lots of small things, present in the bug tracker.. Use it people, use it ! It guarantees that your bugs will be fixed. Get ready for a small TV3d6.3 patch soon ! It won't be an entire SDK but just a DLL fix probably.
TV3D6.5 : -> A lot of bugs fixes, especially in the Collision system/ mousepciking system. All seems ok and working now. -> simple internal Reflection/Refraction water effect has been added. Screenshot later. -> Stencil Shadows for meshs have been optimized (2x sometimes, I guess I can still do better) -> A profiler has been added to the DLL, it helps to see where the bottleneck is. -> And of course bottleneck was in...Mesh.Render for a big scale project...
We are CPU limited.
So much CPU limited.
This is quite annoying because usually, you have to render a lot of meshs in a game. Granted it's better to cull the invisible ones first. However if you have still 100 meshs to render and each mesh can have up to 2 or 4 groups with different textures/materials. At the moment the Tv6.2 engine doesn't sort by mesh nor by materials. Which can result in really bad scenarios :
Mesh1.Render SetTransform SetVertexBuffer/IndexBuffer Group1 Render -> SetTexture Group1 Group2 Render -> SetTexture Group2 Group3.Render -> SetTexture Group3 Mesh1.EndRender
Mesh2.Render SetTransform SetVertexBuffer/IndexBuffer Group1 Render -> SetTexture Group1 Group2 Render -> SetTexture Group2 Mesh2.EndRender
Mesh1.Render (duplicate) SetTransform SetVertexBuffer/IndexBuffer (same as 1) Group1 Render -> SetTexture Group1 Group2 Render -> SetTexture Group2 Group3.Render -> SetTexture Group3 Mesh1.EndRender
Let's see how we can optimize this : 1 - Remove the SetVertexBuffer/IndexBuffer : How that ? By putting every static mesh in the same vertex/index buffer for rendering might help... IHV papers on this topic tell us about minimizing the numbers of vertex buffers/ index buffers. This can be a first optimization (maybe won't improve too much but the hardware prefers big buffers....)
2 - Reduce the number of mesh groups : this one can be tricky but really useful. It implies that you will use less different textures per mesh, or that you will have to group them. This could be doable unless you tile your texture...
3 - Reduce the number of texture/state changes. How that? By rendering by mesh type, then by mesh group ! So the render stage would be organized like that :
MeshOPtimizeRendering Mesh1TypeRender ChangeTexture/Stage
SetTransform RenderGroup1.
SetTransform (other mesh position) RenderGroup1
SetTransform (other mesh position) RenderGroup1.
ChangeTexture SetTransform RenderGroup2
etc...
You get LESS VB/IB changes, LESS texture change, LESS group changes. However you get more SetTransform things. Which can lead to a call to Device.SetTransform() or a call to Device.SetVertexShaderConstant... Probably less expensive than the other group state thingys...
That's I think the best optimization possible in TV3D so far, with the less hassle. That's I'm gonna implement during the next week for meshs and actors possibly. A Render Cache. Stay tuned to know the result !
But the main thing is :
I repeat : Y O U R . G A M E . G O N N A . B E . C P U . L I M I T E D .. No matter what you do. So what can you do against it ?
1-> Reduce the number of different meshs/textures/shaders. 2-> Use the optimization features of TV3D at the max. They are semi automatic so you need to help them a little. 3 -> Use the TV3D6.5 internal profiler to see where the bottleneck is, and adapt.
If you're CPU limited, what about the GPU ?? That's the good thing about it, you can throw more things at the GPU since it's IDLE ! You can send more triangles for FREE, more pixel shaders FOR FREE, until you see that the TV.RenderToScreen starts to take more than 5% of the frame, this means you become GPU limited again. Of course this applies for high end hardware with T&L and pixel shader abilities.
Anyway... It's not easy to add general optimizations to the engine, as several optimizations can be good for some apps and bad for others... so you will have to hint the engine and help it to have the best performance..
and By the way, patience is the (beta) key to success...
Thanks for reading all.
|