| Summary: | UWP/WinRT does not set thread priority when using SDL_SetThreadPriority | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Jeff Loiselle <jeff> |
| Component: | *don't know* | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | flibitijibibo |
| Version: | 2.0.10 | Keywords: | target-2.0.12 |
| Hardware: | x86 | ||
| OS: | Windows 10 | ||
| Attachments: | Patch to implement WinRT SetThreadPriority | ||
|
Description
Jeff Loiselle
2020-02-18 03:57:49 UTC
Do you have a tested patch for this? I know for earlier SDKs it was not possible to compile UWP code using SetThreadPriority. I do not. We've got a workaround for our version of SDL, but we're only using it for UWP. However our patch does not clamp priorities, so we also changed a few calls to make SDL use Highest instead of Realtime. It also does not use the return value of SetThreadPriority as it's non-zero for success, instead of non-zero for failure which I believe is what SDL assumes.
Our code is below with the following caveats:
1. Not ifdef'd for WinRT
2. Priorities above High will not be set. (Setting to real time for instance will cause thread to remain normal priority).
3. Return code is not using return code of SetThreadPriority.
extern "C"
int
SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
{
SetThreadPriority(GetCurrentThread(), priority);
return (0);
}
We should bump this to 2.0.13. --ryan. Created attachment 4230 [details]
Patch to implement WinRT SetThreadPriority
Attached is a diff that I used to get SetThreadPriority working locally. I still have no idea what the minimum SDK version is since Microsoft never documented it, but it's worth pointing out that they're much more aggressive about using the latest VS and UWP SDK anyway (for example, an updated Xbox is no longer compatible with VS2017, and updates are required to have a network connection of any kind).
Okay, Ethan, your patch is in for release. https://hg.libsdl.org/SDL/rev/61b564f66050 Thanks! |