mutter/fixed-to-float-patches/clutter-alpha.c.0.patch

307 lines
9.0 KiB
Diff
Raw Normal View History

First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c
index 60ef0d3..dda0f6c 100644
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
--- a/clutter/clutter-alpha.c
+++ b/clutter/clutter-alpha.c
@@ -697,6 +697,11 @@ clutter_ramp_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
}
}
+#if 0
+/*
+ * The following three functions are left in place for reference
+ * purposes.
+ */
static guint32
sincx1024_func (ClutterAlpha *alpha,
float angle,
@@ -716,7 +721,7 @@ sincx1024_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
x -= (512 * 512 / angle);
- sine = ((sinf (x * (G_PI/180.0)) + offset) / 2)
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
+ sine = ((cogl_angle_sin (x) + offset) / 2)
* CLUTTER_ALPHA_MAX_ALPHA;
sine = sine >> COGL_FIXED_Q;
@@ -724,11 +729,6 @@ sincx1024_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
return sine;
}
-#if 0
-/*
- * The following two functions are left in place for reference
- * purposes.
- */
static guint32
sincx_func (ClutterAlpha *alpha,
ClutterFixed angle,
@@ -747,7 +747,7 @@ sincx_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
x = CLUTTER_FIXED_MUL (x, CFX_PI)
- CLUTTER_FIXED_DIV (CFX_PI, angle);
- sine = (sinf (x) + offset) / 2;
+ sine = (cogl_angle_sin (x) + offset) / 2;
CLUTTER_NOTE (ALPHA, "sine: %2f\n", CLUTTER_FIXED_TO_DOUBLE (sine));
@@ -806,9 +806,28 @@ guint32
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
clutter_sine_func (ClutterAlpha *alpha,
gpointer dummy)
{
-#if 0
+#if 1
+ ClutterTimeline *timeline;
+ gint current_frame_num, n_frames;
+ float radians, sine;
+
+ timeline = clutter_alpha_get_timeline (alpha);
+
+ current_frame_num = clutter_timeline_get_current_frame (timeline);
+ n_frames = clutter_timeline_get_n_frames (timeline);
+
+ radians = ((float)current_frame_num / n_frames) * (2.0 * G_PI);
+ sine = sinf (radians);
+
+ /* shift from range [-1, 1] -> [0, 1] */
+ sine = (sine + 1.0) / 2.0;
+
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
+ CLUTTER_NOTE (ALPHA, "sine: %2f\n", sine);
+
+ return sine * CLUTTER_ALPHA_MAX_ALPHA;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
+#elif 0
return sinc_func (alpha, 2.0, 1.0);
-#else
+#elif 0
/* 2.0 above represents full circle */
return sincx1024_func (alpha, 1024, 1.0);
#endif
@@ -842,18 +861,17 @@ clutter_sine_inc_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
ClutterTimeline * timeline;
gint frame;
gint n_frames;
- float x;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = 256 * frame / n_frames;
-
- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
+ radians = ((float)frame / n_frames) * (G_PI / 2);
+ sine = sinf (radians);
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
@@ -884,18 +902,17 @@ clutter_sine_dec_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
ClutterTimeline * timeline;
gint frame;
gint n_frames;
- float x;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = 256 * frame / n_frames + 256;
-
- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
+ radians = ((float)frame / n_frames) * (G_PI / 2);
+ sine = sinf (radians + (G_PI / 2));
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
@@ -926,18 +943,17 @@ clutter_sine_half_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- float x;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = 512 * frame / n_frames;
+ radians = ((float)frame / n_frames) * G_PI;
+ sine = sinf (radians);
- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA;
-
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
@@ -962,19 +978,20 @@ clutter_sine_in_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- float x;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- /* XXX- if we use 768 we overflow */
- x = 256 * frame / n_frames + 767;
+ radians = ((float)frame / n_frames) * (G_PI / 2);
+ sine = sinf (radians - (G_PI / 2));
- sine = (sinf (x * (G_PI/180.0)) + 1) * CLUTTER_ALPHA_MAX_ALPHA;
+ /* shift from range [-1, 0] -> [0, 1] */
+ sine = sine + 1.0;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
@@ -998,18 +1015,17 @@ clutter_sine_out_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- float x;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = 256 * frame / n_frames;
-
- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
+ radians = ((float)frame / n_frames) * (G_PI / 2);
+ sine = sinf (radians);
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
@@ -1034,18 +1050,20 @@ clutter_sine_in_out_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- float x;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = -256 * frame / n_frames + 256;
+ radians = ((float)frame / n_frames) * G_PI;
+ sine = sinf (radians - (G_PI / 2));
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- sine = (sinf (x * (G_PI/180.0)) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA;
+ /* shift from range [-1, 1] -> [0, 1] */
+ sine = (sine + 1.0) / 2.0;
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
@@ -1113,30 +1131,23 @@ clutter_smoothstep_inc_func (ClutterAlpha *alpha,
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- guint32 r;
- guint32 x;
+ float r;
+ float x;
/*
* The smoothstep function uses f(x) = -2x^3 + 3x^2 where x is from <0,1>,
- * and precission is critical -- we use 8.24 fixed format for this operation.
- * The earlier operations involve division, which we cannot do in 8.24 for
- * numbers in <0,1> we use ClutterFixed.
+ * and precission is critical.
*/
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- /*
- * Convert x to 8.24 for next step.
- */
- x = CLUTTER_FIXED_DIV (frame, n_frames) << 8;
+ x = (float)frame / n_frames;
/*
* f(x) = -2x^3 + 3x^2
- *
- * Convert result to ClutterFixed to avoid overflow in next step.
*/
- r = ((x >> 12) * (x >> 12) * 3 - (x >> 15) * (x >> 16) * (x >> 16)) >> 8;
+ r = -2 * x * x * x + 3 * x * x;
return (r * CLUTTER_ALPHA_MAX_ALPHA);
}
@@ -1204,9 +1215,9 @@ clutter_exp_inc_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
*
* (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA
*/
-#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff
-#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA
-#endif
+ /* XXX: If this fails:
+ * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */
+ g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0);
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
@@ -1214,7 +1225,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
x = x_alpha_max * frame / n_frames;
- result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
+ result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
return result;
}
@@ -1255,9 +1266,9 @@ clutter_exp_dec_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
*
* (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA
*/
-#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff
-#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA
-#endif
+ /* XXX: If this fails:
+ * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */
+ g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0);
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
@@ -1265,7 +1276,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha,
First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
2008-12-19 16:55:35 -05:00
x = (x_alpha_max * (n_frames - frame)) / n_frames;
- result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
+ result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
return result;
}