February 11th, 2014 - Optimization
The ability to cleanly profile things and learning more about the intricacies of D3D11 has enabled me to vastly, vastly increase rendering performance. How much faster? Well, about 500%. Now it’s not uncommon to have typical viewport scenes running at 1000-1100+ fps.
Some of the optimizations:
— Switching from raw RGBA textures to BC3_UNORM compressed textures
— Moving away from a single vertex format. Every model type now has a vertex format only exactly the size that it needs. Distant terrain for example is now position only. Vertex buffers have lost a ton of weight because of this.
— Speeding up quadtree culling immensely by marking a leaf calculated so it never gets recalcuated that frame, pre-calculating 4 map-tile sub-quadrants, and also making sure water rendering uses the same quadrant marking that terrain did rather than recalculating it.
— Water was being drawn twice, simple bug
— Portals were not properly marking attached-models in order to avoid rendering them, only the geometry. Portals are still IP and they’re off by default right now, but this is a huge boost.
— Running over shaders with a fine toothed comb and noticing years-old inefficiencies. For example the terrain/decal/largeterrain shaders were doing world matrix calculations despite the fact that the vertices are already in world space.
— Not multiplying vertex positions through bone matrices with 0 bone weights.
— Being incredibly anal going through the rendering loop to find areas not passing by reference.
— Trying to get rid of all string-related work in the loop
— Changing from the decade-old zthreads to the C++11 thread classes, which alone yielded performance improvements.
The interesting thing is that there is still a lot more optimization to be done, like packing row major matrices for the shaders so I don’t need to transpose matrices in code anymore, improving portals, etc.
The part I enjoy most about working on this project is that there’s always things to do, and new ideas come to me all the time.