Jump to content
  • Advertisement
Sign in to follow this  
MilfredCubicleX

Floor renders slower than ceiling

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

The floor actually renders slower than all other textures combined in a (extremely simple) scene. Even though its so simple, this one polygon (2 triangles, and approximately the same size as the ceiling and walls) should not be 10-15 frames slower than the other 14 or so faces combined (10-15 frames is significant because the whole scene renders about 30 frames per second) I'm absolutely perplexed by this.. I've done everything to try to make them render at around the same rate to see what the problem is, including simplifying the shader so that it basically only outputs the diffuse texture, change the tangent/bitangent/normals to a constant value, changing the diffuse texture, changing the normal texture.. nothing works! I can't figure it out... so i'm looking for some help. What should I try to see what is causing this? Any ideas? What should I post, code? screenshots? I'll start with some rendering code (deferred shader by the way).. to render the bsp:
	D3DXMATRIX matWorldViewProj = ren->m_worldMatrix * ren->m_viewMatrix * ren->m_projMatrix;

	s_pD3DDevice->SetStreamSource( 0, m_pVertexBuffer, 0, sizeof(BSPDXVERTEX) );
	s_pD3DDevice->SetFVF( NULL );
	s_pD3DDevice->SetVertexDeclaration( m_pVertDecl );
	
	D3DXVECTOR4 eyePos ( ren->m_viewPos[ 0 ], ren->m_viewPos[ 1 ], ren->m_viewPos[ 2 ], 1.0f );
	m_pRenEffect->SetVector( "eyePos", &eyePos );

	UINT nPasses;

	for( int i = 0; i < m_nTextureCount; i++ )
	{
		bool lastVisible = false;
		int start = 0, primCount = 0;

		if( !m_pTexIndexBuffer[ i ].m_pIndexBuffer || !m_pTextureBuffer[ i ].texture )
			continue;

		s_pD3DDevice->SetIndices( m_pTexIndexBuffer[ i ].m_pIndexBuffer );

		m_pRenEffect->SetTexture( "diffuseTexture", m_pTextureBuffer[ i ].texture );
		if( m_pTextureBuffer[ i ].flags & 2 )
		{
			m_pRenEffect->SetTechnique( "BSPtoMRT_NormalMap" );
			m_pRenEffect->SetTexture( "normalTexture", m_pTextureBuffer[ i ].normalmap );
		}
		else
		{
			m_pRenEffect->SetTechnique( "BSPtoMRT_NoNormalMap" );
		}

		m_pRenEffect->SetInt( "iStencRef", ren->iStencCount );
		m_pRenEffect->Begin( &nPasses, 0 );
		for( UINT p = 0; p < nPasses; p++ )
		{
			m_pRenEffect->BeginPass( p );

			for( int j = 0; j < m_nClusterCount; j++ )
			{
				if( m_pTexIndexBuffer[ i ].nPrimCount[ j ] == 0 )
					continue;

				bool thisVisible = true;

				if( thisVisible )
				{
					if( !lastVisible )
					{
						start = m_pTexIndexBuffer[ i ].nStartIndex[ j ];
					}
					primCount += m_pTexIndexBuffer[ i ].nPrimCount[ j ];
				}
				else
				{
					if( lastVisible )
					{
						s_pD3DDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, m_nVertexCount, start, primCount );
					}
					primCount = 0;
				}
				lastVisible = thisVisible;
			}
			if( lastVisible )
			{
				s_pD3DDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, m_nVertexCount, start, primCount );
			}

			m_pRenEffect->EndPass( );
		}
		m_pRenEffect->End( );

	}


shader code:
struct VS_INPUT {
	float4 vPos : POSITION;
	float3 vNorm : NORMAL;
	float2 vTex : TEXCOORD0;
	float3 vTan : TEXCOORD1;
	float3 vBin : TEXCOORD2;
};

struct VS_OUTPUT2 {
	float4 pPos : POSITION;
	float4 pPos2 : TEXCOORD0;
	float2 pTex : TEXCOORD1;
	float3 pTan : TEXCOORD2;
	float3 pBin : TEXCOORD3;
	float3 pNorm : TEXCOORD4;
	float3 pEyevec : TEXCOORD5;
};

struct PS_MRT_OUTPUT {
	float4 Color0 : COLOR0;
	float4 Color1 : COLOR1;
	float4 Color2 : COLOR2;
	float4 Color3 : COLOR3;
};

VS_OUTPUT2 VS_NormalMap( VS_INPUT In )
{
	VS_OUTPUT2 Out;
	float4 tPos = mul( In.vPos, matWorldViewProj );
	Out.pPos = tPos;
	Out.pPos2 = In.vPos;
	
	Out.pEyevec = In.vPos.xyz - eyePos.xyz;
	
	Out.pTan = In.vTan;
	Out.pBin = In.vBin;
	Out.pNorm = In.vNorm;
	
	Out.pTex = In.vTex;
	return Out;
}

PS_MRT_OUTPUT PS_NormalMap( VS_OUTPUT2 In )
{
	PS_MRT_OUTPUT Out;
	
	half4 diffuseTex = tex2D( diffuseSampler, In.pTex );
	
	half3 eyeVec = normalize( In.pEyevec );
	half2 offset;
	offset.x = dot( eyeVec, In.pTan );
	offset.y = dot( eyeVec, In.pBin );
	offset = offset * diffuseTex.w * 0.03125;
	
	diffuseTex = tex2D( diffuseSampler, In.pTex + offset );
	half3 normalTex = tex2D( normalSampler, In.pTex + offset ) * 2.0 - 1.0;
	
	float3x3 TBN;
	TBN[ 0 ] = In.pTan;
	TBN[ 1 ] = In.pBin;
	TBN[ 2 ] = In.pNorm;
	half3 norm = mul( normalTex, TBN );
	
	Out.Color0 = diffuseTex; //albedo
	Out.Color1 = float4( norm * 0.5 + 0.5, 0.0 ); //normal
	Out.Color2 = float4( In.pPos2.z, 0.0, 0.0, 0.0 ); //position(z)
	Out.Color3 = float4( In.pPos2.x, In.pPos2.y, 0.0, 0.0 ); //position(x,y)
	return Out;
}


Edit: Here's a picture. The top ones are the original problem bsp. The bottom right is the one I just made and is nearly identical (crate and white wall were taken out) which has no slowdown. Bottom left is a totally different BSP with huge huge slowdown. Any ideas would be great [Edited by - MilfredCubicleX on March 22, 2007 1:13:15 PM]

Share this post


Link to post
Share on other sites
Advertisement
Well, without looking at the code, it occurs to me to wonder whether you have V-synch enabled, based on the numbers that you give. It could be that your frame rate is, with the ceiling rendering in place, dropping below the threshold for the next V-synch step down, and being set to around 15fps instead of 30fps, when it could possibly, if I'm correct, be running at a higher rate with V-synch off.

Share this post


Link to post
Share on other sites
Sorry for not mentioning, vsync is disabled. I disabled it, also thinking it could be part of the problem. I just find it weird that it's this one face, and the others are fine.

Share this post


Link to post
Share on other sites
What's your texture resolution on the floor? I could see some possible slowdowns if you were using something big, like a 2048x2048 texture (tiled).

Share this post


Link to post
Share on other sites
Every texture is 256x256 and the wall, ceiling, and floor texture are textured about 3 times each.

I feel like this could be some sort of cache trashing I don't know about.

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!