Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Index buffer....no improved fps?

This topic is 5307 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''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?

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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;

ScreenLocY[y] = VertCurPosY[0] + (TILEHEIGHT / 2);
RenderLocY[y] = CrntTileY;

VertCurPosY[0] -= TILEHEIGHT;
VertCurPosY[1] -= TILEHEIGHT;

VertCurPosX[0] -= TileShiftX;
VertCurPosX[1] -= TileShiftX;

CrntTileY += 1;

void* pVertices;
( g_pVB->Lock( 0, sizeof(vertices), (void**)&pVertices, D3DLOCK_DISCARD ) );
memcpy( pVertices, vertices, sizeof(vertices) );

void* pBuffIndices;
( g_pIB->Lock(0,sizeof(pIndices), (void**)&pBuffIndices, 0 ) );
memcpy(pBuffIndices, pIndices,sizeof(pIndices));

g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(VERTSTRUCT) );
g_pd3dDevice->SetFVF( D3DFVF_VERTSTRUCT );


Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
how many verts/primitives are you drawing?

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

Share this post

Link to post
Share on other sites

  • 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!