GLState: Avoid possible undefined behavior in state comparison

The bitwise XOR used to compute the delta (`changed`) might produce NaN and
thus produce undefined behavior when comparing to another float (because of
float promotion).
This commit is contained in:
Clément Foucault
2022-04-29 09:10:07 +02:00
parent 65e7219706
commit fcb0090842

View File

@@ -152,12 +152,12 @@ void GLStateManager::set_mutable_state(const GPUStateMutable &state)
}
}
if (changed.line_width != 0) {
if (float_as_uint(changed.line_width) != 0) {
/* TODO: remove, should use wide line shader. */
glLineWidth(clamp_f(state.line_width, line_width_range_[0], line_width_range_[1]));
}
if (changed.depth_range[0] != 0 || changed.depth_range[1] != 0) {
if (float_as_uint(changed.depth_range[0]) != 0 || float_as_uint(changed.depth_range[1]) != 0) {
/* TODO: remove, should modify the projection matrix instead. */
glDepthRange(UNPACK2(state.depth_range));
}