diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-04-29 10:10:07 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-04-29 10:10:07 +0300 |
commit | fcb0090842d6f5c6ae78d3b6f10dc9cdbc1d3736 (patch) | |
tree | a768eae56611d00f6552c8ea2a80fdfc5f1a9131 /source/blender/gpu/opengl | |
parent | 65e7219706ece1d08c7a1e0c93497235ae6782b1 (diff) |
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).
Diffstat (limited to 'source/blender/gpu/opengl')
-rw-r--r-- | source/blender/gpu/opengl/gl_state.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc index 264e605798f..68a88938f69 100644 --- a/source/blender/gpu/opengl/gl_state.cc +++ b/source/blender/gpu/opengl/gl_state.cc @@ -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)); } |