Strange Phenomenom in DirectX Wrapper
I''m having an unusual benefit/problem with my current
DirectX wrapper. In my main file I have a basic loop
that just makes sure the current window is alive, and
if it is alive then it clears the screen to a purple
color. graphicDevice is just a normal pointer to a
Direct3d9 device. mainWnd is a basic win32 wrapper for
a window class, that was acquired from the engine.
The engine also has a reference to it.
while( mainEngine.getWindowStatus(0) )
{
mainWnd->beginAPIScene();
graphicDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(90,0,120), 1.0f, 0 );
mainWnd->endAPIScene();
mainEngine.update();
}
Now the calls beginAPIScene and endAPIScene are just
handlers that set some booleans to state that a
scene is being drawn, and call BeginScene() and
EndScene(). When mainEngine.update() is called it
queries the window mainWnd and forces it to update.
When mainWnd updates it tests if a scene has been
drawn (ie- beginAPIScene and endAPIScene both called)
and if so, it calls the normal Direct3d Present(....).
STRANGE THING: I figured that due to the overhead on
the above loop that it would be much faster to run
the loop using only the direct3d device pointer,
which I do in the following code dump:
while( mainEngine.getWindowStatus(0) )
{
graphicDevice->BeginScene();
graphicDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(90,0,120), 1.0f, 0 );
graphicDevice->EndScene();
graphicDevice->Present( NULL, NULL, hWnd, NULL );
}
Anyhow, the strange thing is that second implementation
that has only the standard overhead of the direct3d
implementation actually runs slower and I have no clue
why. It averages 10-20updates per second slower than the
original loop with all the "overhead". Both loops do
the exact same thing. It seems to me that the original
loop would just simply have more instructions to accomplish
the same task.
ON TOP OF ALL OF THAT: mainWnd is a DirectX implementation
that implements a virtual window class, and beginAPIScene and endAPIScene are implementations of virtual functions, which
are supposed to be slower due to more pointer dereferencing.
I''m trying to speed up things in my code and this has
me seriously boggled, so any hypothesis would be much
appreciated!
Thanks.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement