Original Post
Hey guys, I'm having a bad performance problem when trying to concatenate some DirectX vertex buffers using memcpy. The particular code I'm having issues with isn't DirectX-specific, so that's why I'm posting here instead. I'm wondering if anyone can spot any obvious bugs in these few lines: Thanks for any help you can possibly give. If you need any more explaination of the problem or my algorithms here, please ask. Thanks,
// Concatenate the missile trail vertex buffers into one big buffer
for (m = 0; m < pr_num_missile_tubes; m++)
{
for (i = 0; i < MAXAMMO; i++)
{
for (int c = 0; c < MAX_VAPORTRAIL_SECTIONS; c++)
{
pr_vaporVerts[(m * (MAXAMMO * MAX_VAPORTRAIL_SECTIONS * 2)) + (MAX_VAPORTRAIL_SECTIONS * 2 * i) + (c * 2)] = pr_missile[m].vaporVerts[(MAX_VAPORTRAIL_SECTIONS * i + c) * 2];
pr_vaporVerts[((m * (MAXAMMO * MAX_VAPORTRAIL_SECTIONS * 2)) + (MAX_VAPORTRAIL_SECTIONS * 2 * i) + (c * 2)) + 1] = pr_missile[m].vaporVerts[((MAX_VAPORTRAIL_SECTIONS * i + c) * 2) + 1];
}
}
}
// Activate the main vertex buffer
VOID* pVertices;
if (FAILED(pr_missileTrailsVB->Lock(0, sizeof(pr_vaporVerts), (BYTE**)&pVertices, 0)))
MessageBox(NULL, "Missile trail vertex buffer locking failure.", "Error", MB_OK);
memcpy(pVertices, pr_vaporVerts, sizeof(pr_vaporVerts)); // THIS IS THE OFFENDING LINE!!!!
pr_missileTrailsVB->Unlock();