[Glamor] [PATCH] Optimize gradient_fs_template shader

Tom Stellard tom at stellard.net
Mon Jun 10 19:11:23 PDT 2013


From: Tom Stellard <thomas.stellard at amd.com>

Replace:

while(t > 1.0)
   t = t - 1.0;
while(t < 0.0)
   t = t + 1.0;

With:

t = fract(t);
---

This code is untested since I'm not usre which test suite to use
for glamor.  Any suggestions?

This should improve the performance of any app that uses this shader via glamor.
I think the cairo perf test firefox-canvas uses this, but the patch didn't
improve perfomance.  I may try looking through the cairo micro benchmarks
to see if I can find a more specific performance test.


 src/glamor_gradient.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/glamor_gradient.c b/src/glamor_gradient.c
index 4abc82d..b01fd57 100644
--- a/src/glamor_gradient.c
+++ b/src/glamor_gradient.c
@@ -305,10 +305,7 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, int dy
 	    "    }\n"\
 	    "    \n"\
 	    "    if(repeat_type == %d){\n" /* repeat normal*/\
-	    "        while(t > 1.0) \n"\
-	    "            t = t - 1.0; \n"\
-	    "        while(t < 0.0) \n"\
-	    "            t = t + 1.0; \n"\
+            "        t = fract(t);\n"\
 	    "    }\n"\
 	    "    \n"\
 	    "    if(repeat_type == %d) {\n" /* repeat reflect*/\
-- 
1.7.11.4



More information about the Glamor mailing list