Jump to content
  • Advertisement
Sign in to follow this  
Yelmond

Frame rate slow after device reset if vertex shader input struct exceeds 52 bytes

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

Hello,

I have a trivial shader that simply draws quads. If the combined size of the vertex shader input struct (input layout) exceeds 52 bytes my application becomes signifcantly slower after a device reset (ie. resizing the window). When the application starts, I get close to ~600 fps, regardless of input layout size (within reason). As soon as I reset the device the frame rate goes down to ~50 fps.

I know I've seen input layouts much larger than mine in use so I know it's not a limitation of DX9. What could I be doing wrong?

Some of my code:

The vertex shader input struct looks like this:


struct VS_IN
{
float3 posL : POSITION0;
float3 tangentL : TANGENT0;
float3 normalL : NORMAL0;
float2 texC : TEXCOORD0;
float4 colour : TEXCOORD1;
};


and my input layout for it:


D3DVERTEXELEMENT9 genericVertexDesc_DX9[] = {
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
{ 0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 0, 36, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 44, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
D3DDECL_END()
};
HR( AC3DX9Device->CreateVertexDeclaration( genericVertexDesc_DX9, &generic_DX9 ) );


If I change the size of "colour" to float2 frame rate no longer drops after a device reset.

Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I managed to "fix" the issue by reducing my max vertex buffer size. I noticed that the size of the input layout didn't really matter. It was more to do with the stride size (size of my CPU vertex struct).

But this is very much still magic for me as I don't understand how the maximum vertex buffer size is related to stride size. This also doesn't explain why I had still high frame rates before a device reset with the original vertex buffer sizes and only lost fps after the device reset. (I don't change vertex buffer sizes during device resets).

It's no longer a pressing issue but I'm curious as to what's going on here.

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!