diff options
| author | 2021-12-18 13:57:14 +0800 | |
|---|---|---|
| committer | 2021-12-18 13:57:14 +0800 | |
| commit | e49184e6069a9d791d2df3c1958f5c4b1187e124 (patch) | |
| tree | b776caf722e0be0e680f67b0ad0842628162ef1c /src/common/x64 | |
| parent | Implement convert legacy to generic (diff) | |
| parent | Merge pull request #7570 from ameerj/favorites-expanded (diff) | |
| download | yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.gz yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.xz yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.zip | |
Merge branch 'yuzu-emu:master' into convert_legacy
Diffstat (limited to 'src/common/x64')
| -rw-r--r-- | src/common/x64/cpu_detect.cpp | 12 | ||||
| -rw-r--r-- | src/common/x64/native_clock.cpp | 36 |
2 files changed, 18 insertions, 30 deletions
diff --git a/src/common/x64/cpu_detect.cpp b/src/common/x64/cpu_detect.cpp index fccd2eee5..fbeacc7e2 100644 --- a/src/common/x64/cpu_detect.cpp +++ b/src/common/x64/cpu_detect.cpp | |||
| @@ -71,9 +71,6 @@ static CPUCaps Detect() { | |||
| 71 | else | 71 | else |
| 72 | caps.manufacturer = Manufacturer::Unknown; | 72 | caps.manufacturer = Manufacturer::Unknown; |
| 73 | 73 | ||
| 74 | u32 family = {}; | ||
| 75 | u32 model = {}; | ||
| 76 | |||
| 77 | __cpuid(cpu_id, 0x80000000); | 74 | __cpuid(cpu_id, 0x80000000); |
| 78 | 75 | ||
| 79 | u32 max_ex_fn = cpu_id[0]; | 76 | u32 max_ex_fn = cpu_id[0]; |
| @@ -84,15 +81,6 @@ static CPUCaps Detect() { | |||
| 84 | // Detect family and other miscellaneous features | 81 | // Detect family and other miscellaneous features |
| 85 | if (max_std_fn >= 1) { | 82 | if (max_std_fn >= 1) { |
| 86 | __cpuid(cpu_id, 0x00000001); | 83 | __cpuid(cpu_id, 0x00000001); |
| 87 | family = (cpu_id[0] >> 8) & 0xf; | ||
| 88 | model = (cpu_id[0] >> 4) & 0xf; | ||
| 89 | if (family == 0xf) { | ||
| 90 | family += (cpu_id[0] >> 20) & 0xff; | ||
| 91 | } | ||
| 92 | if (family >= 6) { | ||
| 93 | model += ((cpu_id[0] >> 16) & 0xf) << 4; | ||
| 94 | } | ||
| 95 | |||
| 96 | if ((cpu_id[3] >> 25) & 1) | 84 | if ((cpu_id[3] >> 25) & 1) |
| 97 | caps.sse = true; | 85 | caps.sse = true; |
| 98 | if ((cpu_id[3] >> 26) & 1) | 86 | if ((cpu_id[3] >> 26) & 1) |
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 87de40624..82ee2c8a1 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp | |||
| @@ -15,26 +15,26 @@ | |||
| 15 | namespace Common { | 15 | namespace Common { |
| 16 | 16 | ||
| 17 | u64 EstimateRDTSCFrequency() { | 17 | u64 EstimateRDTSCFrequency() { |
| 18 | const auto milli_10 = std::chrono::milliseconds{10}; | 18 | // Discard the first result measuring the rdtsc. |
| 19 | // get current time | ||
| 20 | _mm_mfence(); | 19 | _mm_mfence(); |
| 21 | const u64 tscStart = __rdtsc(); | 20 | __rdtsc(); |
| 22 | const auto startTime = std::chrono::high_resolution_clock::now(); | 21 | std::this_thread::sleep_for(std::chrono::milliseconds{1}); |
| 23 | // wait roughly 3 seconds | 22 | _mm_mfence(); |
| 24 | while (true) { | 23 | __rdtsc(); |
| 25 | auto milli = std::chrono::duration_cast<std::chrono::milliseconds>( | 24 | |
| 26 | std::chrono::high_resolution_clock::now() - startTime); | 25 | // Get the current time. |
| 27 | if (milli.count() >= 3000) | 26 | const auto start_time = std::chrono::steady_clock::now(); |
| 28 | break; | 27 | _mm_mfence(); |
| 29 | std::this_thread::sleep_for(milli_10); | 28 | const u64 tsc_start = __rdtsc(); |
| 30 | } | 29 | // Wait for 200 milliseconds. |
| 31 | const auto endTime = std::chrono::high_resolution_clock::now(); | 30 | std::this_thread::sleep_for(std::chrono::milliseconds{200}); |
| 31 | const auto end_time = std::chrono::steady_clock::now(); | ||
| 32 | _mm_mfence(); | 32 | _mm_mfence(); |
| 33 | const u64 tscEnd = __rdtsc(); | 33 | const u64 tsc_end = __rdtsc(); |
| 34 | // calculate difference | 34 | // Calculate differences. |
| 35 | const u64 timer_diff = | 35 | const u64 timer_diff = static_cast<u64>( |
| 36 | std::chrono::duration_cast<std::chrono::nanoseconds>(endTime - startTime).count(); | 36 | std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count()); |
| 37 | const u64 tsc_diff = tscEnd - tscStart; | 37 | const u64 tsc_diff = tsc_end - tsc_start; |
| 38 | const u64 tsc_freq = MultiplyAndDivide64(tsc_diff, 1000000000ULL, timer_diff); | 38 | const u64 tsc_freq = MultiplyAndDivide64(tsc_diff, 1000000000ULL, timer_diff); |
| 39 | return tsc_freq; | 39 | return tsc_freq; |
| 40 | } | 40 | } |