Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Junk_Master

What'll be faster Lock() or SetTransform()

This topic is 6150 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

If i need to draw many rectangles in different places of the screen, what should i do to draw each next rectangle? Lock vertex buffer and then change coordinates, or maybe it''ll be better if i will use matrix translation for moving my shapes. Who knows what method is faster, tell me please...

Share this post


Link to post
Share on other sites
Advertisement
SetTransform every time. Modifying the vertex buffer requires keeping it in system memory, (reading it from video memory by DMA transfer would be so obscenely slow it isnt funny) meaning your frame rate will suffer from having to pass all the verts over the bus every frame. You might not care about this for your rectangles (four verts? who cares about that) but anything else in that VB would be affected too. Then there is the overhead of Lock() itself. In order to change the verts, you have to wait until the chip is no longer using them, which means they have to pass completely through the pipeline before you can even start drawing the next rectangle. With SetTransform the verts are transformed and queued up one after the other in the chip. SetTransform is definitely the way you want to go. Use Lock and your framerate will plummet like a stone.

Edited by - Sandman on July 18, 2001 7:38:27 AM

Share this post


Link to post
Share on other sites
I tested this. My terrain renderer went from 25fps to 70fps!!! I should have believed those NeXe tutorials all along..... Stupid thing is that I read 3 books on Direct3D (one D3D8 book) and not one of them even mentions that this is way better. Thanks sandman!

Share this post


Link to post
Share on other sites
Ok, thanks guys!!! I think this was a stupid question, but i have to ask it because i can''t understand how OpenGL do this - each frame i can simply call glVertex as many times as i want with differennt coordinates and all works very fast. I think i know why - DirectX is child of MICROSOFT!

Share this post


Link to post
Share on other sites
That''s unfair...

in OpenGL, the equivalent to locking is to create a display list that will be precompiled and much faster on certain hardware. If you compile a display list "around" a set of vertices, that is analogous to creating a DX8 vertex buffer that lives "on the card".

I''m guessing that your OpenGL code would be faster if you used display lists...

Share this post


Link to post
Share on other sites
One second... If Lock() equal to glBuildList(), then what is DX code egual, for examle this:

glBegin(GL_TRIANGLES);

//glVertex some many times
glEnd();

Share this post


Link to post
Share on other sites
The closest thing is DrawPrimitiveUP(). This takes an array of verts from system memory (using a User defined Pointer) and sends the whole lot to the card. This rather slower than using Vertex Buffers though.

Share this post


Link to post
Share on other sites
Junk_Master - There''s no exact equivalent, but consider this:

if you make the call
glVertex3f(1.0, 1.0, 1.0);

Then those three floats have to be moved across the bus, to the video card, and then output to the rest of the pipeline.

Optimally, if you have vertex buffers that already live on the card, you can skip that transfer step. In DX8, you mostly want to use VBs. The closest equivalent, mentioned by Sandman, is probably slower than glVertex, but that''s the sort of trade off you get with different APIs.

Share this post


Link to post
Share on other sites

  • 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!