[Mesa-dev] Mesa (master): glsl: fix assorted MSVC warnings
Ian Romanick
idr at freedesktop.org
Tue Nov 16 11:55:03 PST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/15/2010 05:48 PM, Brian Paul wrote:
> case ir_unop_b2f:
> assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
> for (unsigned c = 0; c < op[0]->type->components(); c++) {
> - data.f[c] = op[0]->value.b[c] ? 1.0 : 0.0;
> + data.f[c] = op[0]->value.b[c] ? 1.0F : 0.0F;
Please don't do this. This particular MSVC warning should just be
disabled. If this warning were generated for non-literals and for
literals that actually did lose precision being stored to a float, it
might have a chance at having some value. Instead, it's just noise.
Individual warnings can be disabled with a pragma, and this one should
probably be disabled in mesa/compiler.h:
#pragma warning(disable: 4244)
There may be a way to do it from the command line, but I don't know what
it is.
The F suffixes on constants are also worthless, and they make the code
ugly. Expecting that they will be added everywhere when no other
compiler generates this warning is a losing battle.
> }
> break;
> case ir_unop_f2b:
> assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
> for (unsigned c = 0; c < op[0]->type->components(); c++) {
> - data.b[c] = bool(op[0]->value.f[c]);
> + data.b[c] = op[0]->value.f[c] != 0.0F ? true : false;
This warning should also be disabled for the same reason as the above.
This one isn't even a correctness warning, is a performance warning.
The code that is replacing the case may have even worse performance than
the cast! The other changes can stay, but this one needs to be reverted.
> }
> break;
> case ir_unop_b2i:
> @@ -163,7 +163,7 @@ ir_expression::constant_expression_value()
> case ir_unop_i2b:
> assert(op[0]->type->is_integer());
> for (unsigned c = 0; c < op[0]->type->components(); c++) {
> - data.b[c] = bool(op[0]->value.u[c]);
> + data.b[c] = op[0]->value.u[c] ? true : false;
What warning is this? I was unable to reproduce a warning on Visual
Studio 2008 Express Edition. I suspect this should be reverted too.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkzi4ZQACgkQX1gOwKyEAw+GGgCgjEJdaEUQCtifgezcJKFKJqki
xzgAn1zmI6KrJ3+6lyujiY/IIf0LUE9o
=MSjO
-----END PGP SIGNATURE-----
More information about the mesa-dev
mailing list