Jump to content
  • Advertisement
Sign in to follow this  
Thaligar

Beginpaint, Endpaint...

This topic is 4747 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

hey folks, my in-game-profiling tool says beginpaint & endpaint eats up to 20% of the time, the message-processing eats once more up to 20% of the time, and so I ask, how can I increase the speed of both, can I circumvent the lame beginpaint/endpaint, or can I kick some messages, or should I process them within the main game loop and not in an extra func. thx in advance, greets tgar

Share this post


Link to post
Share on other sites
Advertisement
Is this is in a heavy loaded scene? Because in a relatively low-duty application even light-weight function calls might end up high in the list (Imagine a program doing only 'i++'; it would take about 100% of the program's time).

Greetz,

Illco

Share this post


Link to post
Share on other sites
uh, an answer, yehaa...

no, i render at the moment about 1 million tris per scene + ~120k tris

thx
tgar

Share this post


Link to post
Share on other sites
Ok. What kind of message processing do you do? And what do BeginPaint() and EndPaint() do and come from? I don't recall them being basic GL but then again it is over a year since my last GL program.

Share this post


Link to post
Share on other sites
BeginPaint & EndPaint are the functions from windows to redraw your window if it's invalidated,

and for the messageprocessing i use this:


if(peekmessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_PAINT)
{
BeginPaint(Wnd, &ps);
EndPaint(Wnd, &ps);
break;
}
else if(msg.message == WM_QUIT)
{
Exit; // end the loop
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}



is this the fastest way or is there a faster one

thx
tgar

Share this post


Link to post
Share on other sites
Quote:
Original post by Thaligar
BeginPaint & EndPaint are the functions from windows to redraw your window if it's invalidated,

and for the messageprocessing i use this:

*** Source Snippet Removed ***

is this the fastest way or is there a faster one

thx
tgar

The best way to deal with WM_PAINT messages if you have an OpenGL window you're continuously updating is to just call ValidateRect(hWnd, NULL); inside your WM_PAINT handler. Passing NULL validates the whole window, and stops Windows from sending any more WM_PAINT messages.

Also, you don't need a break command in an if statement.

Plus, the processing you're doing there is best done inside your WindowProc, not the message loop.

Share this post


Link to post
Share on other sites
i'll go look for it, thanks iNsAn1tY,

another one ;)
why is "SwapBuffers" so awesome slow, it's even slower then the rest, can i improve performance there,

thx
tgar

Share this post


Link to post
Share on other sites
That'll be because a glSwapBuffers(..) command flushes the pipeline. So it only returns once the GPU has nothing left to do. If you give the GPU a lot to do, that might take some time depending on how you have it all setup.

Share this post


Link to post
Share on other sites
yeah,

but i heard that after the glswapbuffer i can do much cpu processing while the gpu is busy,

but why then the command lasts so long, i mean, the cpu waits, it should do something or??

greets
tgar

Share this post


Link to post
Share on other sites
If you switch it around then you can do this. So just before you start rendering, call glSwapBuffers(..). Then render everything, and after this is done do NOT call glSwapBuffers(..). Now perform all your other calculations (AI, gamelogic, etc) while the GPU is busy. Then when you are ready to render again, you'll call glSwapBuffers(..) again just before rendering. This should give you the maximum amount of parallellism.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!