diff options
author | marha <marha@users.sourceforge.net> | 2012-06-08 14:29:46 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-06-08 14:50:37 +0200 |
commit | 72ec0e3bb2d7fc6b77b2a75873792f781679da6a (patch) | |
tree | 0a736ab9a8c26276929ab077dc661e3625b54884 /mesalib/src/glsl/ir_constant_expression.cpp | |
parent | 5e865910f0ce672295bd60460631339be5e311a0 (diff) | |
parent | 990bc3f015a4f8fce2eb918375defcd44980a845 (diff) | |
download | vcxsrv-72ec0e3bb2d7fc6b77b2a75873792f781679da6a.tar.gz vcxsrv-72ec0e3bb2d7fc6b77b2a75873792f781679da6a.tar.bz2 vcxsrv-72ec0e3bb2d7fc6b77b2a75873792f781679da6a.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
fontconfig/.gitignore
libX11/src/ConvSel.c
libX11/src/CrGlCur.c
libX11/src/CrWindow.c
libX11/src/GetDflt.c
libX11/src/Window.c
libX11/src/xlibi18n/XimProto.h
libX11/src/xlibi18n/lcDynamic.c
libxcb/src/.gitignore
libxcb/src/xcb_ext.c
libxcb/src/xcb_xid.c
mesalib/src/glsl/.gitignore
mesalib/src/glsl/glcpp/.gitignore
mesalib/src/mapi/glapi/gen/glX_API.xml
mesalib/src/mapi/glapi/glapi_getproc.c
mesalib/src/mesa/main/.gitignore
mesalib/src/mesa/main/syncobj.c
mesalib/src/mesa/program/.gitignore
xkbcomp/listing.c
xkbcomp/xkbpath.c
xorg-server/.gitignore
xorg-server/Xext/xvmain.c
xorg-server/dix/dispatch.c
xorg-server/hw/xwin/glx/winpriv.h
xorg-server/hw/xwin/winprefsyacc.y
xorg-server/hw/xwin/winscrinit.c
xorg-server/xkeyboard-config/rules/bin/ml1_s.sh
xorg-server/xkeyboard-config/rules/bin/ml1v1_s.sh
xorg-server/xkeyboard-config/rules/bin/ml1v_s.sh
xorg-server/xkeyboard-config/rules/bin/ml_s.sh
xorg-server/xkeyboard-config/rules/bin/mlv_s.sh
xorg-server/xkeyboard-config/rules/compat/.gitignore
Diffstat (limited to 'mesalib/src/glsl/ir_constant_expression.cpp')
-rw-r--r-- | mesalib/src/glsl/ir_constant_expression.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp index 08a33285b..7a4d15f43 100644 --- a/mesalib/src/glsl/ir_constant_expression.cpp +++ b/mesalib/src/glsl/ir_constant_expression.cpp @@ -71,6 +71,29 @@ dot(ir_constant *op0, ir_constant *op1) return result; } +/* This method is the only one supported by gcc. Unions in particular + * are iffy, and read-through-converted-pointer is killed by strict + * aliasing. OTOH, the compiler sees through the memcpy, so the + * resulting asm is reasonable. + */ +static float +bitcast_u2f(unsigned int u) +{ + assert(sizeof(float) == sizeof(unsigned int)); + float f; + memcpy(&f, &u, sizeof(f)); + return f; +} + +static unsigned int +bitcast_f2u(float f) +{ + assert(sizeof(float) == sizeof(unsigned int)); + unsigned int u; + memcpy(&u, &f, sizeof(f)); + return u; +} + ir_constant * ir_rvalue::constant_expression_value(struct hash_table *variable_context) { @@ -207,6 +230,30 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) data.u[c] = op[0]->value.i[c]; } break; + case ir_unop_bitcast_i2f: + assert(op[0]->type->base_type == GLSL_TYPE_INT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = bitcast_u2f(op[0]->value.i[c]); + } + break; + case ir_unop_bitcast_f2i: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.i[c] = bitcast_f2u(op[0]->value.f[c]); + } + break; + case ir_unop_bitcast_u2f: + assert(op[0]->type->base_type == GLSL_TYPE_UINT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = bitcast_u2f(op[0]->value.u[c]); + } + break; + case ir_unop_bitcast_f2u: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.u[c] = bitcast_f2u(op[0]->value.f[c]); + } + break; case ir_unop_any: assert(op[0]->type->is_boolean()); data.b[0] = false; |