On my system on Mac OS X and Linux, this doubled performance!
Mac OS X
- SDL 1.2 testsprite: 514.22 FPS
- SDL 1.3 testsprite texture streaming with OpenGL: 1259.62 FPS
- SDL 1.3 testsprite2 (hardware accelerated): 3865.16 FPS
- SDL 1.2 testsprite: 495.48 FPS
- SDL 1.3 testsprite texture streaming with OpenGL: 1244.55 FPS
- SDL 1.3 testsprite2 (hardware accelerated): 2556.85 FPS
On my system the Windows performance got worse!
Windows
- SDL 1.2 testsprite using GDI: 1030.71 FPS
- SDL 1.3 testsprite using GDI: 1077.81 FPS
- SDL 1.3 testsprite texture streaming with OpenGL: 623.08 FPS
- SDL 1.3 testsprite texture streaming with Direct3D: 233.97 FPS
- SDL 1.3 testsprite2 (hardware accelerated with OpenGL): 3027.26 FPS
- SDL 1.3 testsprite2 (hardware accelerated with Direct3D): 4259.48 FPS
Clearly the Windows GDI drivers are heavily optimized for 2D performance, but why is the Direct3D streaming performance so poor?
Here's what I'm doing for OpenGL:
Texture format: GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV
Texture update:
glBindTexture()
glTexSubImage2D()
glBegin(GL_TRIANGLE_STRIP)
...
I'm not doing anything fancy with pixel buffer objects, I'm just making sure that my data is in the optimal format for processing by the OpenGL drivers.
Here's what I'm doing for Direct3D:
Device Setup:
pparams.BackBufferCount = 1;
pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
Texture create:
device->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
Texture update:
texture->LockRect(0, &locked, NULL, D3DLOCK_DISCARD);
texture->UnlockRect(0);
device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2,
vertices, sizeof(*vertices));
...
For those who are curious, the full code can be found here:
http://www.libsdl.org/tmp/SDL-1.3.zip
So... does anyone know how to improve Direct3D texture streaming performance?
Thanks for sharing the code I downloaded it from the link you provided.I would have a look into it whenever I get time.I agree that Windows GDI drivers are heavily optimized for 2D performance, and the Direct3D streaming performance is really very poor
ReplyDelete