如何提高 Direct3D 流纹理性能?
我正在尝试加速全屏纹理的绘制,该纹理会改变每一帧。在我的系统上,使用 GDI 和 BitBlt() 可以获得大约 1000 FPS,但我认为可以通过使用 Direct3D 和动态纹理来提高性能。相反,我只能获得 250 FPS 左右。
我在配备 ATI HD 4870 和最新驱动程序的 Mac Pro 上运行。
我尝试过使用动态纹理,这给了我一个小的增益(~15FPS),我尝试过使用纹理链来避免管道停顿,但这没有效果。
我环顾四周,关于以这种方式使用动态纹理的信息很少。
我错过了一些基本的东西吗?
设备设置:
pparams.BackBufferCount = 1; pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
纹理创建:
device->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
纹理更新:
texture->LockRect(0, &locked, NULL, D3DLOCK_DISCARD); ... write texture data texture->UnlockRect(0); device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, vertices, sizeof(*vertices)); ...
您可以从以下位置获取正在进行的代码 http://www.libsdl.org/tmp/SDL-1.3.zip
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果不需要读回纹理,则可以使用 (D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY) 标志创建纹理。
If you don't need to read back the texture, then you can create a texture with (D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY) flag.
DrawPrimitiveUP 非常慢。您应该使用动态顶点缓冲区(不覆盖更新,如果已满则丢弃)。
DrawPrimitiveUP is very slow. You should use a dynamic vertex buffer (update with nooverwrite, discard if full).