Some of these optimizations are pretty obscure and I can't imagine a
real shader hitting them.
What's the cost of checking for these cases? I don't know how expensive
the equals() methods are.
Do we want to litter the optimizer with cases that may never be used in
practice?
-Brian
On 07/15/2014 04:27 PM, Thomas Helland wrote:
So, a little update on these patches.
I've written some shaders for hitting each
specific case in the patch-series.
This shows that:
Patch 1 (X - X) == 0, and
Patch 9 (A - neg(B)) == A + B
have no effect at all.
The rest of the patches do indeed have
a positive effect on the special-case shader.
If anyone wants to have a look at the shaders
then let me know. I could always put them
in a dropbox-folder, or github, or something.
The report from shader-db (sorted by patch-number):
Patch 2:
helped: shaders/mine/a_or_nota.shader_test fs16: 16 -> 5 (-68.75%)
helped: shaders/mine/a_or_nota.shader_test fs8: 16 -> 5 (-68.75%)
helped: shaders/mine/a_or_nota.shader_test vs: 11 -> 5 (-54.55%)
Patch 3:
helped: shaders/mine/a_and_nota.shader_test fs16: 16 -> 5 (-68.75%)
helped: shaders/mine/a_and_nota.shader_test fs8: 16 -> 5 (-68.75%)
helped: shaders/mine/a_and_nota.shader_test vs: 11 -> 5 (-54.55%)
Patch 4:
helped: shaders/mine/or_and.shader_test fs16: 16 -> 14 (-12.50%)
helped: shaders/mine/or_and.shader_test fs8: 16 -> 14 (-12.50%)
helped: shaders/mine/or_and.shader_test vs: 11 -> 10 (-9.09%)
Patch 5:
helped: shaders/mine/minOver.shader_test fs16: 8 -> 5 (-37.50%)
helped: shaders/mine/minOver.shader_test fs8: 8 -> 5 (-37.50%)
helped: shaders/mine/minOver.shader_test vs: 6 -> 5 (-16.67%)
helped: shaders/mine/minUnder.shader_test fs16: 8 -> 5 (-37.50%)
helped: shaders/mine/minUnder.shader_test fs8: 8 -> 5 (-37.50%)
helped: shaders/mine/minUnder.shader_test vs: 6 -> 5 (-16.67%)
Patch 6
helped: shaders/mine/maxOver.shader_test fs16: 8 -> 5 (-37.50%)
helped: shaders/mine/maxOver.shader_test fs8: 8 -> 5 (-37.50%)
helped: shaders/mine/maxOver.shader_test vs: 6 -> 5 (-16.67%)
helped: shaders/mine/maxUnder.shader_test fs16: 8 -> 5 (-37.50%)
helped: shaders/mine/maxUnder.shader_test fs8: 8 -> 5 (-37.50%)
helped: shaders/mine/maxUnder.shader_test vs: 6 -> 5 (-16.67%)
Patch 7:
helped: shaders/mine/loglog.shader_test fs16: 17 -> 11 (-35.29%)
helped: shaders/mine/loglog.shader_test fs8: 17 -> 11 (-35.29%)
helped: shaders/mine/loglog.shader_test vs: 7 -> 6 (-14.29%)
Patch 8:
helped: shaders/mine/expexp.shader_test fs16: 17 -> 11 (-35.29%)
helped: shaders/mine/expexp.shader_test fs8: 17 -> 11 (-35.29%)
helped: shaders/mine/expexp.shader_test vs: 7 -> 6 (-14.29%)
Patch 10:
helped: shaders/mine/pow0x.shader_test fs16: 8 -> 5 (-37.50%)
helped: shaders/mine/pow0x.shader_test fs8: 8 -> 5 (-37.50%)
helped: shaders/mine/pow0x.shader_test vs: 6 -> 5 (-16.67%)
helped: shaders/mine/powx-1.shader_test fs16: 11 -> 5 (-54.55%)
helped: shaders/mine/powx-1.shader_test fs8: 11 -> 5 (-54.55%)
helped: shaders/mine/powx-1.shader_test vs: 7 -> 5 (-28.57%)
helped: shaders/mine/powx0.shader_test fs16: 8 -> 5 (-37.50%)
helped: shaders/mine/powx0.shader_test fs8: 8 -> 5 (-37.50%)
helped: shaders/mine/powx0.shader_test vs: 6 -> 5 (-16.67%)
2014-07-15 0:22 GMT+02:00 <thomashellan...@gmail.com
<mailto:thomashellan...@gmail.com>>:
From: Thomas Helland <thomashellan...@gmail.com
<mailto:thomashellan...@gmail.com>>
When writing that A || (A && B) patch some
days ago I also wrote some other patches
that have no impact on my collection of shaders.
(shader-db + Some TF2 and Portal-shaders).
No reduction in instruction count, and no
significant increase in compilation time.
I decided to put them up here anyway, as
with your collection of shaders maybe YMMV.
These are mostly RFC-quality, and not all are
as complete and nicely formatted as they could be.
Possibly some are also implemented incorrectly.
(I'm still trying to get a good understanding of
the buildup of the ir, the visitors, etc)
Feel free to do with these patches as you please;
Ignore, test, review, flame, make cookies...
Thomas Helland (10):
glsl: Optimize X - X -> 0
glsl: Optimize !A || A == 1
glsl: Optimize !A && A == 0
glsl: Optimize (A || B) && A == A
glsl: Optimize min(-8, sin(x)) == -8 and similar
glsl: Optimize max(8, sin(x)) == 8 and similar
glsl: Optimize log(x) + log(y) == log(x*y)
glsl: Optimize exp(x)*exp(y) == exp(x+y)
glsl: Optimize A - neg(B) == A + B and neg(A) - B == neg(A + B)
glsl: Optimize some more pow() special cases
src/glsl/opt_algebraic.cpp | 152
+++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 152 insertions(+)
--
2.0.0
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=lGQMzzTgII0I7jefp2FHq7WtZ%2BTLs8wadB%2BiIj9xpBY%3D%0A&m=AYR8hWikWHJNvkG02hozH%2BwkDnyXmqwN9EKzxX2zk2E%3D%0A&s=7fc598ca37f58cc3cc06507056ce8a3d0c0b87e7e32bc6b65ec2a192c2261265
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev