Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-04-29 10:10:07 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-04-29 10:10:07 +0300
commitfcb0090842d6f5c6ae78d3b6f10dc9cdbc1d3736 (patch)
treea768eae56611d00f6552c8ea2a80fdfc5f1a9131 /source/blender/gpu
parent65e7219706ece1d08c7a1e0c93497235ae6782b1 (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')
-rw-r--r--source/blender/gpu/opengl/gl_state.cc4
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));
}