I'm having cross renderer (D3D9 and OGL). To my surpries I founded that D3D9 works approximately 25-40% faster than OGL. So I started digging. I know it's not pixel-processing problem, it's vertex. Right now I render about 120, each around 20k faces. With small viewport set (to eliminate pixel-processing influence) I get around 30 fps for OGL, and 40 fps for D3D9.
After many tests I really don't know what's goind on. One interesting thing is that for OGL I tested to approaches in specifying data. One approach is to have an array of vertices lined up (with structure describing vertex, just like in D3D9). The other approach is to have first specified all vertices positions, then normals, then other data (I guess it's not possible to arrange data in that way in D3D9). And when I tried this second approach the fps grew to around 32. So the arrangement of data matters and I'm wondering if DX is doing something "magical" to gain better performance when sending vertex data?
My init code for vertex buffer (for index buffer it's similar):
CRenderer::D3DDevice->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &id, NULL);
}
#else
{
glGenBuffers(1, &id);
glBindBuffer(GL_ARRAY_BUFFER, id);
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
Code for mapping:
id->Lock(0, 0, (void**)&data, 0);
}
#else
{
glBindBuffer(GL_ARRAY_BUFFER, id);
data = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
I guess the configuration of buffer is the same for both D3D9 and OGL. Or maybe I'm missing something?