[Shootout-list] Graphics algorithms

Jon Harrop jon@ffconsultancy.com
Fri, 6 May 2005 01:26:59 +0100


On Friday 06 May 2005 00:37, Isaac Gouy wrote:
> --- Jon Harrop <jon@ffconsultancy.com> wrote:
> > What about a Bresenham-based triangle or circle renderer as a
> > benchmark for
> > the shootout? Or something slightly more sophisticated (free form
> > texture
> > mapper)?
> >
> > Just an idea.
>
> Is it an idea that fills some specific gap in the benchmarks etc etc?

No, it would have to be the converse. What gaps are there in the current set 
of benchmarks? From that information maybe we can come up with some 
algorithms from graphics which fill those holes.

I like the idea of heavy duty factoring, to make the code as small as 
possible. I don't know of any current shootout benchmarks which cover this 
(and the performance trade-off, of course) so this may be a gap.

A free-form texture mapper might be a good test of this. In this algorithm, 
there are several similar copies of Bresenham's line algorithm all at work at 
the same time. It would be interesting to see how this commonality can be 
factored out in different languages in order to minimise the amount of code 
required whilst not impacting performance adversely.

In functional languages, like OCaml, this should be much easier because you 
can factor out higher-order functions. However, in OCaml you'll suffer a 
significant performance hit if any of them turn out to be polymorphic, for 
example.

In C++, you can do similar factoring by passing functions around as template 
arguments. In Java, you could probably use inheritance to try to regain the 
functionality of higher-order functions. In C, you can only factor out 
functions easily but, in theory, you could pass function pointers (this could 
get ugly though).

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists