Help with slow rendering

Started by
6 comments, last by onnel 22 years, 9 months ago
I've been working on a fairly basic D3D engine and am having some problems with slow rendering in extremely simple cases. I have an X mesh as well as an array of 100 objects (squares). these objects (excluding the x mesh which doesn't slow rendering at all) translate into a total of 200 triangles. I am using an octree to determine the visible triangles, etc...I then render them in groups using DrawIndexedPrimitive and TriangleLists All of this works fine, but when I add a texture to everything (specifically my array of triangles), the speed plummets. The texture I am using is not overly complicated (though not simple), a 66k bmp. Without the texture, the speed is over 400 FPS, with the texture, it plummets to 1 FPS when close up, but is better the farther away the camera is from the textures. My lighting and texture setup is as follows: // Set up the textures m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR ); // Set miscellaneous render states m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, FALSE ); m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE ); m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE ); m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00444444 ); m_pd3dDevice->SetRenderState( D3DRS_CLIPPING, TRUE); Also, I am not (f course!) resetting the texture each time (or even each render). I set it once on initialization and leave it alone (this is just for testing). So it isn't an image swapping problem. This is on a P750 with 256 megs ram that handles games like NOLF without a problem. Any suggestions of where to look? All ideas welcome! Thanks, Onnel Edited by - onnel on July 19, 2001 12:37:26 PM
Advertisement
1. When creating the texture, place it in MANAGED memory or if you really must, DEFAULT memory (sounds like it could be trying to texture from system memory).

2. Check the hardware supports the texture size and dimension - if the card only supports square power of 2 textures of 512x512 and below, then passing in a 1024x768 texture gets you problems - and some drivers won''t even complain too much, they''ll just set about doing a really slow arithmetic scale to make it fit the ideal size.

3. If the texture is much bigger than the polys its being applied to, then use mipmapping!!! - texture minification kills some cards performancewise.

4. You''re not trying to do any Lock, CopyRect etc to the texture per frame are you ?

5. Just so I''m clear, if you comment out the SetTexture call or change it to SetTexture(NULL) your FPS is normal ?! - or have you changed any other code ?

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Thanks for the amazingly quick reply! I''ll put some time in to testing it this weekend and try and figure it out based on the hlep you gave. It may be a problem with my octree code, though I''m not sure. that problem may be unrelated, but I want to solve it first!

Thanks again, this group is the best!

Onnel
Do you have mip-mapping enabled? Mip-mapping can make a huge difference to performance. Done like so-

g_pD3DDevice->SetTextureStageState ( 0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR );

The D3DX texture loading functions automatically create mip-map chains. Also as S1CA said, check your texture isn''t in system memory.
Brilliant! It was the mip mapping I was missing!

Things are now flying along and I can start on the next portion of the project.

As always, thanks to the awesome members of gamedev forums for the quick and accurate assistance!

Onnel
A followup question on the mip mapping:

Is the DX8 mip mapping good enough, or should I look into implementing my own solution where I provide the various levels of images myself? Can I do better in quality/speed?

Thanks as always!
Onnel
A followup question on the mip mapping:

Is the DX8 mip mapping good enough, or should I look into implementing my own solution where I provide the various levels of images myself? Can I do better in quality/speed?

Thanks as always!
Onnel
The auto-mipmap generation can lead to problems when you get down to the 4*4, 2*2 and 1*1 textures. You can control how many mipmap levels the D3DX function creates though, so you could make sure the smallest texture was 8*8.

Generally I find the mip-mapping in D3D pretty good, although it can look a little blurry. I would say it was optimized for speed rather than quality.

Anisotropic filtering can reduce the blurriness, but support for that is a little sketchy. GF2, GF3, plus probably the Radeon and Kyro 2 will do anisotropic filtering, but not the older cards.

This topic is closed to new replies.

Advertisement