>>I have posted at the futurebasic.org dropbox a small case study in >>optimising for speed. >> >><ftp://ftp.futurebasic.org/FutureBasic/dropbox/Optimisation_Study_v1.0.sit> >> >>(22K download) >> >>The test problem is Gouraud rendering of triangles, inspired by Robert >>Covington's recent posting to this list >> >>>' Gouraud Shading FB3 Demo, Robert Covington >>>' artlythere@... > >>The study shows a series of coding changes that increase the speed of >>drawing by a large factor (tens or hundreds of times). Some of the >>techniques illustrated are specific to this example; others are more widely >>applicable. >>I should appreciate feedback on any mistakes, bugs, incompatibilities, etc >>that you may find. >> >>Robert P. FB.org is back up. (1:46am) Raves and rejoinders... Next time I am going to post some treatise on a gravity vortex and let you come up with anti-gravity. :) You appear to be a rocket scientist. Please, go into Physics, and take care of the anti-gravity thing for us in a more electrical way. Works here in principal for most levels, but the red channel for levels 7-8 appears to have a problem in vertex 2. (might not be exact problem, limited testing) I did away with the RND's and set the vertex colors to be 0 or 65535 for R G or B, and levels 1-6 display these fine, but above that, the Red (v2) goes to black. Probably some assembly call and my PPC (603) or some weird thing. In the Gouraud Main: vert.rgb.red(0) = 0 vert.rgb.green(0) = 0 vert.rgb.blue(0) = 65535 vert.rgb.red(1) = 0 vert.rgb.green(1) = 65535 vert.rgb.blue(1) = 0 vert.rgb.red(2) = 65535 vert.rgb.green(2) = 0 vert.rgb.blue(2) = 0 One Big Triangle is 400+ ticks at level one. One Big Triangle is 2 ticks at level 8 on my machine. >Pardons if I am being paranoidly oversensitive (can't get to the archive, >FB.org server is croaking), but I hope that my original posting wasn't used >an an example how not to do it. :) Other than it is built on the one that was that, all cool : ( Oh the humanity. Be aware that I am going to tackle Phong shading sometime soon, you will have your optimization work cut out for you then. :) You will rue the Day of Phong. You will speak it softly, with dread. Dream of it. Interpolate Vertex Normals with it. You will surely rue the Day. (you scared yet? :) ) >I have some assembly loop source that cuts the Gouraud thing to a minimum. I see where you have assembled a plenty in Level 7-8. You know what I think would be cool? If you applied this to Grappling Calculator. You can Gouraud shade a Quad too, but I don't know if it would be faster over a pair of triangles for which you already have an algorithm going. Might be faster to use OpenGL or QuickDraw3D though still. But the ability to render in software alone is something that I like, because your software still works with extensions off, and you can tailor it to the precise job at hand. >I hope you used more globals in this demo. You need to use more globals. >It's a Global Village, you know. :) (picking at a prior pick ;)) > >Clear Glocal Mode > >(new syntax) Let's you use local vars as Globals. :) > >Robert Other Robert Joking aside, you not only demo'ed the demo , but you also demo the idea of thinking globally and acting Local-ly. About the fewest Globals I have ever seen in a major network demo. This brings up maybe a useless or impractical idea, but since you have 0-8 levels here, might it be possible to add a multi-paged Profiler feature eventually where you can set some flag (beginProPage/.../End ProPage) and then you could run your demo sequentially the one time, and get a readout as to how it all worked for each rendition/level? That way you save 7 global _flag sets and re-runs. Would be a cool thing for optimizers, because then you can set your code to show all differences in only one run. Like So: Local FN GoToIt(level) FN Render(level)// Pass it onward now. End FN For i = 0 to 8 Begin ProPage FN GoToIt(i) End ProPage Next i When all done, profiler has a scrollable or indexed readout for the FN's called in each "i" loop, instead of totaling the times for all in a final display. Then you can have an option where you can show identical FN data side by side or in a nice Gouraud Shaded Pie Chart. Hey Dude, there's a cool feature to add... The Gouraud Shaded Pie chart display for the FN's and times. :) Robert Covington Author, "Gouraud Tell It On The Mountain"