Jump to content
  • Advertisement
Sign in to follow this  
blue-ice2002

drawprimitive 10000 times

This topic is 4876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, i have a question,or maybe a problem.For some reason,i need to draw trianglestrips. s=-512; D3DXMatrixTranslation (&matTranslation, s,384.0f, 0.0f); s--; for(int v=0;v<10000;v++) { g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, x, 2); x+=4; } i do this in the main game loop,every iteration.Calling this function makes the program run slowly i think? Is it the problem? and i also make translation to scroll my tiles.Please help!!!

Share this post


Link to post
Share on other sites
Advertisement
Thats far too many DP calls.

If i knew more of how ur code operates i would suggest optimisation ideas.

ace

Share this post


Link to post
Share on other sites
Quote:
Original post by blue-ice2002
s=-512;
D3DXMatrixTranslation (&matTranslation, s,384.0f, 0.0f);
s--;
for(int v=0;v<10000;v++)
{
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, x, 2);
x+=4;
}

From looking at the code, you don't actually change the matrix for each pair of triangles drawn. Unless you intentionally *dont* want them to be connected (are each pair a seperate entity?) you can reduce that down to a single draw call unless I'm much mistaken:
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 20000 );

If they are unconnected, and rendering them all together screws things up, convert them to triangle lists instead.

Bottom line - get rid of that loop! it is what is killing you, and while you have it there you're gonna get sucky performance [smile].

hth
Jack

Share this post


Link to post
Share on other sites
If you use PureDevice during hardware device creation then DrawPrimitive Calls have generally little or no overhead. Anyway I don't think that's your direct problem at all (although you should keep your draw primitive calls to a minimum), it could be a number of things such as overdraw, but you said they are tiles. Anyway I don't understand the need for a loop that does absolutely nothing except increase the start index by 4 , i mean you are not transforming inside the loop or applying different textures ?? maybe i'm missing something. If you have more code pls. post more.

Share this post


Link to post
Share on other sites
Quote:
Original post by Codemonger
If you use PureDevice during hardware device creation then DrawPrimitive Calls have generally little or no overhead. Anyway I don't think that's your direct problem at all (although you should keep your draw primitive calls to a minimum), it could be a number of things such as overdraw

hmm, gotta say I disagree... rendering 2 triangles per call (whatever the type of device) will probably make ATI and Nvidia developers cry [smile]. Read up on some of their technote presentations on how to get the most from their respective hardware. I don't have time to search through them all right now - but numbers like 1000-triangles-per-call, no more than 10,000 calls per frame etc pop-up. I don't think I've ever read anywhere that, under any circumstances, a DP call is "generally no overhead" [sad]. Sorry!

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
In the one I posted, it says "DrawPrimitive() permissible if warranted."

Yeah, having read on a bit further - thats a more relevent paper than the one I quoted. Got a lot of good stuff, although the numerous batch/triangle graphs are too cluttered to be easily readable.

I like Slide #14 - "Small batches murder your performance" [smile]

Cheers,
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!