squash reallocs in command buffers by using large prealloced buffer, directly use virtual memory with it so os allocs on demand

mark raw clock functions as noinline, the way msvc was inlining them and ordering the branches meant that rdtsc would often be speculatively executed
add alternative clock impl for win, instead of using queryperformancecounter we grab systemtime from kusershared. it does not have the same precision as queryperformancecounter, we only have 100 nanosecond precision, but we round to milliseconds so it never made sense to use the performance counter in the first place
stubbed out the "guest clock mutex"... (the entirety of clock.cc needs a rewrite)
added some helpers for minf/maxf without the nan handling behavior
This commit is contained in:
chss95cs@gmail.com
2022-08-14 13:42:08 -07:00
parent c9b2d10e17
commit 7cc364dcb8
11 changed files with 263 additions and 38 deletions

View File

@@ -376,6 +376,29 @@ template <int N>
int64_t m128_i64(const __m128& v) {
return m128_i64<N>(_mm_castps_pd(v));
}
/*
std::min/max float has handling for nans, where if either argument is nan the first argument is returned
minss/maxss are different, if either argument is nan the second operand to the instruction is returned
this is problematic because we have no assurances from the compiler on the argument ordering
so only use in places where nan handling is not needed
*/
static float xe_minf(float x, float y) {
return _mm_cvtss_f32(_mm_min_ss(_mm_set_ss(x), _mm_set_ss(y)));
}
static float xe_maxf(float x, float y) {
return _mm_cvtss_f32(_mm_max_ss(_mm_set_ss(x), _mm_set_ss(y)));
}
static float xe_rcpf(float den) {
return _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ss(den)));
}
#else
static float xe_minf(float x, float y) { return std::min<float>(x, y); }
static float xe_maxf(float x, float y) { return std::max<float>(x, y); }
static float xe_rcpf(float den) { return 1.0f / den; }
#endif
// Similar to the C++ implementation of XMConvertFloatToHalf and