Writing directly to the vertex buffer

The inherited DirectX 9 application / game uses dynamic vertex buffers. Each frame, he:

  • blocks vertex buffer
  • cycles through the grids and writes vertex data to a temporary buffer (dynamically allocated when the program starts) until it is completely
  • copies the contents of the temporary buffer to the vertex buffer
  • repeats steps 2 and 3 until all data is copied.
  • opens vertex buffer

My question is: do I need a part with a temporary buffer? Is there a reason why I should not write vertex data directly to the vertex buffer?
I did not find any evidence of this practice in the official documentation, and I do not trust the previous programmer.

+3
source share
3

Discaimer: , DirectX, , .

, : , - . , , . , .

+2

, .

DirectX CPU. , . CPU , , 4/8/16 ​​ .

, , , , , .

, .

, , , , , , - , , .

+2

No need for a temporary buffer. The pointer that you pointed out from Lockis essentially a temporary buffer. A driver can really really start any meaningful operations on it as soon as you unlock the buffer.

If you are using D3DLOCK_DISCARD, then the driver is not required to follow checks with any reasonable data. This way, the implementation can return perfectly malloc(size).

If you are not using D3DLOCK_DISCARD, then, well, this is actually a separate issue.

0
source

All Articles