Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

CreateVertexBuffer length question and onlost devive question

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

Hi in the dxsdk docs for CreateVertexBuffer, its says:
Quote:
Length [in] Size of the vertex buffer, in bytes. For FVF vertex buffers, Length must be large enough to contain at least one vertex, but it need not be a multiple of the vertex size. Length is not validated for non-FVF buffers. See Remarks.
I'm not using fvfs, but vertex streams or whatever the new way is called, at first I thought this meant I didn't have to specify the maximum size of the vb,but it crashes when I enter 0, so what exactly does this quote mean? And when the d3d device is lost, do i have to release the vb and call the CreateVertexBuffer again? Thanks! Also from the first quote, I didn't see anything in the Remarks about it...
Quote:
Remarks A vertex buffer can be used with either hardware or software vertex processing. This is determined by how the device and the vertex buffer are created. When a device is created, CreateDevice uses the behavior flag to determine whether to process vertices in hardware or software. There are three possibilities: Process vertices in hardware by setting D3DCREATE_HARDWARE_VERTEXPROCESSING. Process vertices in software by setting D3DCREATE_SOFTWARE_VERTEXPROCESSING. Process vertices in either hardware or software by setting D3DCREATE_MIXED_VERTEXPROCESSING. Mixed-mode devices might need to switch between software and hardware processing (using SetSoftwareVertexProcessing) after the device is created. When a vertex buffer is created, CreateVertexBuffer uses the usage parameter to decide whether to process vertices in hardware or software. If CreateDevice uses D3DCREATE_HARDWARE_VERTEXPROCESSING, CreateVertexBuffer must use 0. If CreateDevice uses D3DCREATE_SOFTWARE_VERTEXPROCESSING, CreateVertexBuffer must use either 0 or D3DUSAGE_SOFTWAREPROCESSING. For either value, vertices will be processed in software. If CreateDevice uses D3DCREATE_MIXED_VERTEXPROCESSING, CreateVertexBuffer can use either 0 or D3DUSAGE_SOFTWAREPROCESSING. To use a vertex buffer with a mixed mode device, create a single vertex buffer which can be used for both hardware or software processing. Use SetStreamSource to set the current vertex buffer and use SetRenderState, if necessary, to change the device behavior to match. It is recommended that the vertex buffer usage matches the device behavior. Note that a vertex buffer created for software processing cannot be located in video memory. The IDirect3DDevice9 interface supports rendering of primitives using vertex data stored in vertex buffer objects. Vertex buffers are created from the IDirect3DDevice9, and are usable only with the IDirect3DDevice9 object from which they are created. When set to a nonzero value, which must be a valid FVF code, the FVF.xml parameter indicates that the buffer content is to be characterized by an FVF code. A vertex buffer that is created with an FVF code is referred to as an FVF vertex buffer. For more information, see FVF Vertex Buffers. Non-FVF buffers can be used to interleave data during multipass rendering or multitexture rendering in a single pass. To do this, one buffer contains geometry data and the others contain texture coordinates for each texture to be rendered. When rendering, the buffer containing the geometry data is interleaved with each of the buffers containing the texture coordinates. If FVF buffers were used instead, each of them would need to contain identical geometry data in addition to the texture coordinate data specific to each texture rendered. This would result in either a speed or memory penalty, depending on the strategy used. For more information about texture coordinates, see Texture Coordinates.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by johnnyBravo
Hi in the dxsdk docs for CreateVertexBuffer, its says:
Quote:

Length
[in] Size of the vertex buffer, in bytes. For FVF vertex buffers, Length must be large enough to contain at least one vertex, but it need not be a multiple of the vertex size. Length is not validated for non-FVF buffers. See Remarks.


I'm not using fvfs, but vertex streams or whatever the new way is called, at first I thought this meant I didn't have to specify the maximum size of the vb,but it crashes when I enter 0, so what exactly does this quote mean?
The "new way" is referred to as "vertex declarations" if anything...

The size you specify is always going to be required as it has to allocate a certain amount of System/Video memory to store your data. What that remark essentially means is that with declaration-based buffers its not as rigid as it used to be. Not being validated is different to being irrelevant.

Using FVF-less buffers you should be able to put blocks of differently formatted data in, provided that you set it to be decoded correctly in your Draw**() calls.

Quote:
Original post by johnnyBravo
And when the d3d device is lost, do i have to release the vb and call the CreateVertexBuffer again?
If it is in D3DPOOL_DEFAULT, yes - same as with any other resource in the default pool.

hth
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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!