4

I'm trying to accelerate the drawing of a full-screen texture which changes every frame. On my system, I can get around 1000 FPS using GDI and BitBlt(), but I thought I could improve performance by using Direct3D and dynamic textures. Instead I'm only getting around 250 FPS.

I'm running on a Mac Pro with an ATI HD 4870 with current drivers.

I've tried using dynamic textures and that gives me a small gain (~15FPS) and I've tried using a texture chain to avoid pipeline stalls and that has no effect.

I've looked around quite a bit and there's very little information on using dynamic textures this way.

Am I missing something fundamental?

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);
... write texture data
texture->UnlockRect(0);
device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, vertices, sizeof(*vertices));
...

You can get the work in progress code from http://www.libsdl.org/tmp/SDL-1.3.zip

Thanks!

Sam Lantinga
  • 141
  • 1
  • 5

2 Answers2

3

If you don't need to read back the texture, then you can create a texture with (D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY) flag.

Jiho Choi
  • 119
  • 1
  • 8
1

DrawPrimitiveUP is very slow. You should use a dynamic vertex buffer (update with nooverwrite, discard if full).

Axel Gneiting
  • 5,293
  • 25
  • 30
  • I tried that a long time ago when I wasn't using dynamic textures and because there's only one DrawPrimitiveUP per frame it didn't seem to matter. Would it have more of an impact with dynamic textures? – Sam Lantinga Feb 06 '11 at 09:29
  • If DrawPrimitiveUP is not the problem then I would guess that there is a driver overhead for each frame that limits your maximum speedup. You should try to increase the work done each frame in your benchmark. – Axel Gneiting Feb 06 '11 at 09:36