[OpenGL] Fix implicit int-to-float-conversion compiler warning.
This CL fixes a minor compiler warning related to the use of 0xFFFFFFFF
to divide a float value. It turns out that this integer value cannot be
converted to a float without losing one bit of accuracy.
Bug: None
Change-Id: I34fefd91afb526edbfafd3d8a2378fa6b7bf325d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38448
Reviewed-by: Ben Clayton <bclayton@google.com>
Tested-by: David Turner <digit@google.com>
Kokoro-Presubmit: David Turner <digit@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/OpenGL/common/Image.cpp b/src/OpenGL/common/Image.cpp
index 4f84bcb..138f371 100644
--- a/src/OpenGL/common/Image.cpp
+++ b/src/OpenGL/common/Image.cpp
@@ -940,7 +940,10 @@
for(int x = 0; x < width; x++)
{
- destF[x] = (float)sourceD32[x] / 0xFFFFFFFF;
+ // NOTE: Second (float) cast is required to avoid compiler warning:
+ // error: implicit conversion from 'unsigned int' to 'float' changes value from
+ // 4294967295 to 4294967296 [-Werror,-Wimplicit-int-float-conversion]
+ destF[x] = (float)sourceD32[x] / (float)0xFFFFFFFF;
}
}