Jump to content
  • Advertisement
Sign in to follow this  
ph33r

Getting a warning whenever I pad my vertex structure.

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

I try to keep my vertex structure padded to a multiple of 32 bytes but whenever I do that I get this warning, spammed in my output window 100's of times a second. "D3D(WARN): Stream 0 stride and vertex size, computed from the current vertex declaration or FVF, are different, which might not work with pre-DX8 drivers" If I take out the padding it wont give me that warning. Here is the code I use for creating a vb and setting the stream
#define D3DFVF_CUSTOM   ( D3DFVF_XYZ | D3DFVF_DIFFUSE )
struct CUSTOM_FVF
{
	D3DXVECTOR3		m_position;
	D3DCOLOR		m_color;
	char			pad[16];
};


g_pDevice->CreateVertexBuffer(
		8 * sizeof( CUSTOM_FVF ),    // byte size of buffer
		0,                           // flags
		D3DFVF_CUSTOM,                  // FVF format
		D3DPOOL_DEFAULT,             // memory pool
		&g_pVertexBuffer,            // stored buffer
		NULL );   

g_pDevice->SetStreamSource( 0, g_pVertexBuffer, 0, sizeof( CUSTOM_FVF ) );

So how do I pad my structure to a multiple of 32 bytes without getting that annoying warning?

Share this post


Link to post
Share on other sites
Advertisement
Take your D3D debug output level down a notch [wink]

EDIT: I just tried that (adding padding) and you need to take the warning level down to the lowest but one to get rid of it. So maybe its not such a good idea...

Share this post


Link to post
Share on other sites
If you're using the pre-DX9 FVF and the fixed function pipeline instead of Vertex Declarations and shaders, he warning makes sense. DX uses the flags to determine the size of the vertex and the location of the data. It's giving the warning because the sizes are different from expected.

Why do you pad the vertex size? Are you planning on adding more data later? Just curious.

Dominque Douglas
www.miraclemanstudios.com

---

you know i'm getting frustrated when i start naming my variables "please_work" and "for_the_love_of_god"
:-(

Share this post


Link to post
Share on other sites
I use padding because the docs say it's more effecient to pad thte structure to an interval of 32 bytes

Share this post


Link to post
Share on other sites
Quote:
Original post by ph33r
I use padding because the docs say it's more effecient to pad thte structure to an interval of 32 bytes

You have to take this advice in stride. Your current vertex structure is laid out like this:


D3DXVECTOR3 // 12 bytes
D3DCOLOR // 4 bytes
char[16] // 16 bytes


You are *doubling* the vertex size here, just to make it 32-byte aligned. This means that you are doubling the memory usage of each vertex buffer, and doubling the amount of data that you are sending to the card every frame.

However, let's say your vertex structure was laid out like this:

D3DXVECTOR3 position // 12 bytes
D3DXVECTOR3 normal // 12 bytes
D3DCOLOR color // 4 bytes
float emptyData // 4 bytes


In this scenario, padding the vertices would be more benificial, since you are only adding 4 bytes to each vertex (only 12.5% more data, insead of 50%).

I usually never pad my vertices, just to save the most amount of memory as possible (especially when doing keyframe animation). Have you benchmarked padded/aligned performance against unaligned performance?

Share this post


Link to post
Share on other sites
I don't see why you feel the need to pad it. Take the padding out. If, when you have a working app, you find that padding your vertices gives an increase in framerate then you can pad them. But don't bother until then.
Optmisations like this are tips, not rules. You never perform an optimisation unless you can measure the difference it makes to your [working] application.

Share this post


Link to post
Share on other sites
Quote:
Original post by circlesoft
In this scenario, padding the vertices would be more benificial, since you are only adding 4 bytes to each vertex (only 12.5% more data, insead of 50%).


Actually, it'd be ~16% and 100%(ew!) increase in size from the padding. Adding a whole 16 bytes per vertex probably isn't a good idea... and while I'm not entirely sure about this, I think the fact that your vertices are power-of-two size almost nullifies the fact that they aren't the magic size of 32 bytes (2 of your vertices fit perfectly in the space of 32 bytes, there shouldn't be any problems that arise due to memory alignment that might be an issue if your verts were, say, 24 or 28 bytes)

As for profilers... DirectX 9.0c SDK comes with a version of PIX (which is a graphics profiler). Never used it though, so I can't say how much information it would give you about something like this... it's probably more helpful for finding your bottlenecks, which is what you should be focusing on before worrying about padding your vertices for optimality :)

-nohbdy

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The D3DFVFCAPS_DONOTSTRIPELEMENTS device cap in D3DCAPS9.FVFCaps relates to this.

Whether padding/stripping elements improves performance is increadibly hardware and even driver revision specific.

ISTR someone at nVidia did a presentation comparing the peformance of different vertex sizes on their hardware - you should be able to find it on their developer website (search for FVF).

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!