[GPU] Remove register reinterpret_casts + WAIT_REG_MEM volatility
Hopefully prevents some potential #1971-like situations. WAIT_REG_MEM's implementation also allowed the compiler to load the value only once, which caused an infinite loop with the other changes in the commit (even in debug builds), so it's now accessed as volatile. Possibly it would be even better to replace it with some (acquire/release?) atomic load/store some day at least for the registers actually seen as participating in those waits. Also fixes the endianness being handled only on the first wait iteration in WAIT_REG_MEM.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/memory.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
@@ -118,8 +119,8 @@ float Float7e3To32(uint32_t f10) {
|
||||
exponent = uint32_t(1 - int32_t(mantissa_lzcnt));
|
||||
mantissa = (mantissa << mantissa_lzcnt) & 0x7F;
|
||||
}
|
||||
uint32_t f32 = ((exponent + 124) << 23) | (mantissa << 3);
|
||||
return *reinterpret_cast<const float*>(&f32);
|
||||
return xe::memory::Reinterpret<float>(
|
||||
uint32_t(((exponent + 124) << 23) | (mantissa << 3)));
|
||||
}
|
||||
|
||||
// Based on CFloat24 from d3dref9.dll and the 6e4 code from:
|
||||
@@ -131,7 +132,7 @@ uint32_t Float32To20e4(float f32, bool round_to_nearest_even) {
|
||||
// Positive only, and not -0 or NaN.
|
||||
return 0;
|
||||
}
|
||||
uint32_t f32u32 = *reinterpret_cast<const uint32_t*>(&f32);
|
||||
auto f32u32 = xe::memory::Reinterpret<uint32_t>(f32);
|
||||
if (f32u32 >= 0x3FFFFFF8) {
|
||||
// Saturate.
|
||||
return 0xFFFFFF;
|
||||
@@ -165,8 +166,8 @@ float Float20e4To32(uint32_t f24) {
|
||||
exponent = uint32_t(1 - int32_t(mantissa_lzcnt));
|
||||
mantissa = (mantissa << mantissa_lzcnt) & 0xFFFFF;
|
||||
}
|
||||
uint32_t f32 = ((exponent + 112) << 23) | (mantissa << 3);
|
||||
return *reinterpret_cast<const float*>(&f32);
|
||||
return xe::memory::Reinterpret<float>(
|
||||
uint32_t(((exponent + 112) << 23) | (mantissa << 3)));
|
||||
}
|
||||
|
||||
const char* GetColorRenderTargetFormatName(ColorRenderTargetFormat format) {
|
||||
|
||||
Reference in New Issue
Block a user