Beginner: DrawIndexedPrimitive slow

Started by
5 comments, last by Zoomby 16 years, 5 months ago
Hi, sorry for this, but is it ok that 1000 transformed quads rendered with DrawIndexedPrimitive eat 10% CPU power in an windowed app? My hardware isn't to old and i'm using D3DDEVTYPE_HAL. Am I making a dumb mistake somewhere or are my expectations to high? Bye Zoomby
Advertisement
Are you calling DrawIndexedPrimitive once, or 1000 times?
Sirob Yes.» - status: Work-O-Rama.
1000 times, since I like to transform these quads.
I know, I could batch the vertices etc. ,but imagine there would be no other way than transformation. Then I had to call it 1000 times. Do I?

Well, calling DrawIndexedPrimitives 1000 times per frame explaines the performance of you program. You should definitely batch your vertices. If you want to transform them one by one you can use d3dx, it has some nice functions for transformations.
Another option would be to use IDirect3DDevice9::ProcessVertices I guess, but I never used it, so I don't know what you have to do exactly to get your vertices transformed, but from what I've read in the documentation it should transform those vertices you define.
For you it would mean to call ProcessVertices 1000 times and DrawIndexedPrimitive just once, but I don't know if that is any enhancement as I have never used ProcessVertices.
If you use the d3dx functions for transformation (which is basically software vertex processing done by you at that point) the performance should be fine, though.
Thanks Cranky,
what d3dx functions do you mean?

>>which is basically software vertex processing done by you at that point...

I always thought the hardware could do the processing.
If I understood correctly ProcessVertices also does software vertex processing.

I wonder, Is there a way to transform a set of vertices in a vertex buffer by hardware? (Without rendering it)
Quote:Original post by Zoomby
I wonder, Is there a way to transform a set of vertices in a vertex buffer by hardware? (Without rendering it)


There isn't - there's no way on current graphics cards to read back from the post transform vertex cache. If you want to pre-transform verts you'll have to do it on the CPU.

As for the CPU, with 1000 draw calls I'm surprised it's as low as 10%, D3D is not very good at handling a lot of draw calls. You should batch everything up into one vertex buffer, software transform the lot and submit it as a single batch.
Thanks for enlighten me Jerax :-)

This topic is closed to new replies.

Advertisement