Can I squeze more out of this?

It is about directX

ive got this function which is run each frame.
1
2
3
4
5
void gameMain()
{
	graphics->clear();
	graphics->swap();
}


clear()
1
2
3
4
void GraphicsManager::clear()
{
	devcon->ClearRenderTargetView(backbuffer, D3DXCOLOR(0.0f, 0.2f, 0.4f, 1.0f));
}


swap()
1
2
3
4
void GraphicsManager::swap()
{
	swapchain->Present(0, 0);
}


Now, even though it looks simple, I still want to make sure if I cannot save any more speed out of this.
Last edited on
Without knowing how this compiled it's impossible to say. Usually at this level you put your faith in the compilers ability to optimize otherwise you end up constantly reviewing your code and you never get anything done.

Technically speaking every time you call a function the system pushes its current address to the stack then it has to jump to the location of the function being executed and I think there is one other thing that I am having trouble remembering right now. So if you were to make a single function out of "clear()" and "swap()" it may save some cycles but, short of de-compiling the executable there is no way of knowing that your compiler has not already done something like this or better.

tl;dr: Don't worry about it, the gain if any would be insignificant.
Topic archived. No new replies allowed.