| Summary: | SDL_GetPerformanceFrequency - returns 0 | ||
|---|---|---|---|
| Product: | SDL | Reporter: | PoopiSan <poopisan> |
| Component: | timer | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sofmz |
| Version: | don't know | ||
| Hardware: | iPhone/iPod touch | ||
| OS: | iOS (All) | ||
|
Description
PoopiSan
2013-06-21 09:00:13 UTC
Thanks for the report! This should be fixed: http://hg.libsdl.org/SDL/rev/c3052ed2c310 it doesn't seem to be fixed yet. I've downloaded the latest snapshot(SDL-2.0.0-7602), it doesn't return 0 anymore but a weird number.
I've fixed it by changing it to :
#elif defined(__APPLE__)
return (mach_base_info.denom * 1000000) / mach_base_info.numer;
#endif
from
#elif defined(__APPLE__)
Uint64 freq = mach_base_info.numer;
freq *= 1000000000;
freq /= mach_base_info.denom;
return freq;
#endif
It works for me here.
What's the output of this code for you?
Uint32 start32, now32;
Uint64 start, now;
printf("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency());
start32 = SDL_GetTicks();
start = SDL_GetPerformanceCounter();
SDL_Delay(1000);
now = SDL_GetPerformanceCounter();
now32 = SDL_GetTicks();
printf("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
(In reply to comment #3) > It works for me here. > > What's the output of this code for you? > Uint32 start32, now32; > Uint64 start, now; > > printf("Performance counter frequency: %llu\n", (unsigned long long) > SDL_GetPerformanceFrequency()); > start32 = SDL_GetTicks(); > start = SDL_GetPerformanceCounter(); > SDL_Delay(1000); > now = SDL_GetPerformanceCounter(); > now32 = SDL_GetTicks(); > printf("Delay 1 second = %d ms in ticks, %f ms according to performance > counter\n", (now32-start32), (double)((now - start)*1000) / > SDL_GetPerformanceFrequency()); The SDL_GetPerformanceFrequency code in snapshot SDL-2.0.0-7602 works correctly on simulator only but not on real iOS devices. Btw, this is the output I've tested on my iPad : Delay 1 second = 1025 ms in ticks, 0.590138 ms according to performance counter Performance counter frequency: 41666666666 Fixed, thanks for checking this! :) http://hg.libsdl.org/SDL/rev/ebf5f6859e40 No problem! I'm glad it helps. :) |