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

Started by
2 comments, last by Yelmond 11 years, 7 months ago
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.
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.
Out of interest, what kind of GPU and drivers are you using?

Out of interest, what kind of GPU and drivers are you using?


Card: GeForce GTX 480
Drivers: 301.42

This topic is closed to new replies.

Advertisement