Index buffer....no improved fps?

Started by
8 comments, last by DarkSaint 19 years, 11 months ago
I''m workin on a tile engine in d3d and recently switched my rendering funciton to use an index buffer and only calling drawindexprimitive once per frame instead of using a dynamic vertex buffer calling drawprimitive for every tile per frame, however I havn''t noticed a single fps of difference. Explainable?
Advertisement
VSync is enabled.
Not giving is not stealing.
False.
Everything is explainable. It could be as simple as being fill-rate limited if you''re layering lots of large tiles.

It could be a LOT of things.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
Most apps are fillrate limited... so saving a bit of transform time might not help you. Indexing can help with highly tesselated meshes, or with memory footprint, or for some extra CPU cycles if doing software transform, or for a slight gain in GPU performance in that less data needs fetching.

When doing tiles you''re going to benefit from 50% of your vertices being reused once, and only needing 2/3 of the vertices of the non-indexed quads. In a more complex mesh, many (if not most) vertices are often reused 3, 4, or more times, and reduce the needed vertices to 20-30% of what would be needed for non-indexed vertices... plus the transform cost will be more important in a complex mesh, since many faces are backfacing. Because these faces have no fill time, the transform time is more important. This isn''t going to happen with tiles.

So in your case, you might not see an increase in FPS, but you may be seeing less CPU use and less memory use, which are both good. A more complex mesh saves even more transform time, and saves more RAM.

So yes, it''s explainable... expected even.
ok.... it looks like some code posting is in order.

void RenderTiles (char CrntLayer, short CrntLocX, short CrntLocY){	short VertCurPosX[2], VertCurPosY[2], TileShiftX = SCREENTILESX * TILEWIDTH;	short v1 = 0,v2 = 1, v3 = 2, v4 = 3;	unsigned int pIndices[1920],i = 0;	static short CrntTileX = CrntLocX;	static short CrntTileY = CrntLocY;	CamBndryPosiX = CrntTileX + SCREENTILESX;	CamBndryNegX = CrntTileX;	CamBndryPosiY = CrntTileY + SCREENTILESY;	CamBndryNegY = CrntTileY;		VertCurPosX[0] = Vert1StartX;	VertCurPosX[1] = Vert3StartX;	VertCurPosY[0] = Vert1StartY;	VertCurPosY[1] = Vert2StartY;	mapdata.pTileImageSet = g_pTexture;	//Set the texture for the map.		g_pd3dDevice->SetTexture( 0, mapdata.pTileImageSet);	for (short y = 0; y < SCREENTILESY; y++)	{		for (short x = 0; x < SCREENTILESX; x++)		{			vertices[v1].position = D3DXVECTOR3 (VertCurPosX[0], VertCurPosY[0], 1.0f);			vertices[v1].normal   = D3DXVECTOR3 (0,0, -1.0f);			vertices[v1].tu	= 0;			vertices[v1].tv = 1;			vertices[v2].position = D3DXVECTOR3 (VertCurPosX[0], VertCurPosY[1], 1.0f);			vertices[v2].normal   = D3DXVECTOR3 (0, 0, -1.0f);			vertices[v2].tu = 0;			vertices[v2].tv = 0;			vertices[v3].position = D3DXVECTOR3 (VertCurPosX[1], VertCurPosY[0], 1.0f);			vertices[v3].normal   = D3DXVECTOR3 (0, 0, -1.0f);			vertices[v3].tu = 1;			vertices[v3].tv = 1;			vertices[v4].position = D3DXVECTOR3 (VertCurPosX[1], VertCurPosY[1], 1.0f);			vertices[v4].normal   = D3DXVECTOR3 (0, 0, -1.0f);			vertices[v4].tu = 1;			vertices[v4].tv = 0;			pIndices[i]   = v1;			pIndices[i+1] = v2;			pIndices[i+2] = v3;			pIndices[i+3] = v4;			pIndices[i+4] = v3;			pIndices[i+5] = v2;			v1 += 4; v2 += 4, v3 += 4, v4 += 4;			i += 6;			if (y == 0)			{				ScreenLocX[x] = VertCurPosX[0] + (TILEWIDTH / 2);				RenderLocX[x] = CrntTileX;			}			VertCurPosX[0] += TILEWIDTH;			VertCurPosX[1] += TILEWIDTH;			CrntTileX += 1;		}			if (x == SCREENTILESX)			{				ScreenLocY[y] = VertCurPosY[0] + (TILEHEIGHT / 2);				RenderLocY[y] = CrntTileY;			}			VertCurPosY[0] -= TILEHEIGHT;			VertCurPosY[1] -= TILEHEIGHT;			VertCurPosX[0] -= TileShiftX;			VertCurPosX[1] -= TileShiftX;			CrntTileY += 1;			CrntTileX -= SCREENTILESX;	}		void* pVertices;		( g_pVB->Lock( 0, sizeof(vertices), (void**)&pVertices, D3DLOCK_DISCARD ) );		memcpy( pVertices, vertices, sizeof(vertices) );		g_pVB->Unlock();		void* pBuffIndices;		( g_pIB->Lock(0,sizeof(pIndices), (void**)&pBuffIndices, 0 ) );		memcpy(pBuffIndices, pIndices,sizeof(pIndices));		g_pIB->Unlock();		g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(VERTSTRUCT) );		g_pd3dDevice->SetFVF( D3DFVF_VERTSTRUCT );		g_pd3dDevice->SetIndices(g_pIB);		g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,(SCREENTILESX*SCREENTILESY)*4,0,(SCREENTILESX*SCREENTILESY)*2);		CrntTileY -= SCREENTILESY;}
Is your index buffer dynamic? Why no DISCARD flag on the lock for it?
I was messing with the lock flags before I posted but even with discard there''s still no fps gain.
Anyway I guess it doesn''t matter I was just a little curious as to why there would be no fps improvement when I''ve heard from so many that there would be an improvement. Although if it is the fill rate that''s app specific and not vid-card specific, is there anyway I can increase this? Anyways I guess I shouldn''t start worrying about the fps until it drops below 30 which It''s pretty far from being at.
how many verts/primitives are you drawing?

Bobboau, bringing you products that work... in theory
Bobboau, bringing you products that work... in theory

This topic is closed to new replies.

Advertisement