High-resolution thread sleep

Steven Schveighoffer schveiguy at yahoo.com
Fri Dec 15 13:30:42 UTC 2017


On 12/15/17 5:43 AM, Rene Zwanenburg wrote:
> On Friday, 15 December 2017 at 01:49:56 UTC, Steven Schveighoffer wrote:
>>
>> So... you plan on rendering more than 1000 frames per second?
>>
>> I think in any case, even if the API allows it, you are probably not 
>> getting much better resolution on your non-windows systems.
>>
>> Have you tried it anyway and see how it works? I think it might 
>> actually work just fine.
>>
> 
> The higher precision would be needed b/c updating and rendering takes 
> time, so the sleep time would be timePerFrame - timeSpendOnRendering.

And this would be sub-millisecond? Even at 120Hz framerate, that's 8ms 
per frame to render and display. If your margin for error is less than 
1ms, then I think you shouldn't be sleeping :)

> Problem is you'll need vsync anyway to avoid tearing. Applications that 
> use their own timing to limit the framerate without using vsync are easy 
> to recognise: they have a tear slowly moving around on the screen. It's 
> visually even more annoying than regular tearing.

OK. I'm not steeped in graphics development. It just seemed odd to me 
that millisecond resolution isn't fine enough. Clearly better sleep 
mechanisms wouldn't be the solution anyway!

-Steve


More information about the Digitalmars-d-learn mailing list