I've been fiddling with a 3D engine for visualization of complex data. The core of the engine requires finding the intersection of a clipping plane through a series of parallelopipeds.
The problem has been that performing the clipping and finding the vertices in the cut surface is quite involved - and I'd originally done it in software (because it required quite a lot of pain, including having to sort the transformed vertices into clockwise order).
I did eventually modify it to precalculate the awkward bits (vertex orders, etc.) and then just use the hints for each polygon. I was doing this in software, which meant rebuilding the vertex buffer 100-odd times per frame, i.e. once per object. As the bulk of this final stage was just a few dot-products, I thought I'd just try porting it to a vertex shader.
I built the shader and set it off - I got quite a surprise when the vertex shader enabled engine ran 10x slower than the pure software version. Realising that the prob was the DirectX debug runtimes I reinstalled the normal runtimes. The engine performance jumped hugely, but the vertex setup time was still 2x-3x slower than the pure software version.
So, why is my vertex processing so slow? Is it because I only draw one polygon at a time (max 6 vertices) - each object will be intersected exactly once, so will yield a convex hull with up to 6 vertices, and each object uses a different texture - so multiple objects can't be batched together.
Any hints/tips for making it faster?
Cliffs:
1. 3D engine uses complex algorithm to determine visibility
2. Rendering converted to 2 step process - a) painful software algorithm + b) simple final setup
3. Sofware version of the simple final setup is way slower than hardware accelerated version on 8800GTX
The problem has been that performing the clipping and finding the vertices in the cut surface is quite involved - and I'd originally done it in software (because it required quite a lot of pain, including having to sort the transformed vertices into clockwise order).
I did eventually modify it to precalculate the awkward bits (vertex orders, etc.) and then just use the hints for each polygon. I was doing this in software, which meant rebuilding the vertex buffer 100-odd times per frame, i.e. once per object. As the bulk of this final stage was just a few dot-products, I thought I'd just try porting it to a vertex shader.
I built the shader and set it off - I got quite a surprise when the vertex shader enabled engine ran 10x slower than the pure software version. Realising that the prob was the DirectX debug runtimes I reinstalled the normal runtimes. The engine performance jumped hugely, but the vertex setup time was still 2x-3x slower than the pure software version.
So, why is my vertex processing so slow? Is it because I only draw one polygon at a time (max 6 vertices) - each object will be intersected exactly once, so will yield a convex hull with up to 6 vertices, and each object uses a different texture - so multiple objects can't be batched together.
Any hints/tips for making it faster?
Cliffs:
1. 3D engine uses complex algorithm to determine visibility
2. Rendering converted to 2 step process - a) painful software algorithm + b) simple final setup
3. Sofware version of the simple final setup is way slower than hardware accelerated version on 8800GTX