command_processor: Resolve undefined behavior type punning
We can use std::memcpy to achieve the same behavior without undefined behavior. Once Citra moves to C++20 we can convert this over to std::bit_cast.
This commit is contained in:
parent
5ac4636a14
commit
41b7df4a32
1 changed files with 6 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
@ -86,8 +87,11 @@ static void WriteUniformFloatReg(ShaderRegs& config, Shader::ShaderSetup& setup,
|
||||||
|
|
||||||
// NOTE: The destination component order indeed is "backwards"
|
// NOTE: The destination component order indeed is "backwards"
|
||||||
if (uniform_setup.IsFloat32()) {
|
if (uniform_setup.IsFloat32()) {
|
||||||
for (auto i : {0, 1, 2, 3})
|
for (auto i : {0, 1, 2, 3}) {
|
||||||
uniform[3 - i] = float24::FromFloat32(*(float*)(&uniform_write_buffer[i]));
|
float buffer_value;
|
||||||
|
std::memcpy(&buffer_value, &uniform_write_buffer[i], sizeof(float));
|
||||||
|
uniform[3 - i] = float24::FromFloat32(buffer_value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: Untested
|
// TODO: Untested
|
||||||
uniform.w = float24::FromRaw(uniform_write_buffer[0] >> 8);
|
uniform.w = float24::FromRaw(uniform_write_buffer[0] >> 8);
|
||||||
|
|
Loading…
Reference in a new issue