Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well I can see your problem you are copying data into an locked vertex buffer and then rendering that data. You can't do this. The data in the locked vertex buffer is not actually valid yet. It only becomes valid once you unlock it. This is because the data you are filling in is in main memory and may actually be shadowing memory on the graphics card. When you unlock it copies the data across to the graphics card.</p> <p>As such if you lock/unlock for each draw call everything works fine because you are forcing the copy back.</p> <p>As you have found, though, this is far from optimal.</p> <p>What you should be doing is calculating all your quad vertex positions in one pass. Then you need to go through and render all the quads (Ideally without swapping texture/shader/etc every call).</p> <p>One way to do this would be to fill your vertex buffer as you are doing and then store the draw commands in a vertex buffer. This would require you storing things like texture, effect used etc. You can then run through the list and render everything from the vertex buffer you have already filled.</p> <p>If you then sort things by texture and shader constants (to minimise state changes) you will find your performance is many many times better. Although you will need to mark your vertex buffer as "dynamic" and its advisable to use the D3DLOCK_DISCARD flag when you lock the vertex buffer as this will discard the data currently in the vertex buffer (Basically it will return you a totally new block of memory to fill and won't copy anything from the card) instead of blocking and waiting for the GPU to finish using it.</p> <p>I hope thats some help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload