PDA

View Full Version : simpe 2D triangle fill vs. built in 3D graphics



conner
03-04-2011, 09:31 AM
I have an application that needs to fill lots of simple 2D triangles.

I have a matrix of cells (pixels), and I need to increment the 16-bit cell value by a given amount for lots of triangles.

This can be done with OpenGL or other 3D graphics primitives, but the overhead of dealing with 3D seems excessive.

There are a number of triangle fill algorithms available, and it seems straight forward to code them into OpenCL.

My question is, are there hardware optimizations that will make populating 3D graphics structures and rendering using standard tools faster than anything that can be coded by hand for simple 2D?

Can someone point me to existing 2D libraries for OpenCL code?

chai
03-04-2011, 12:20 PM
From what I understand (and this should be verified), the graphics pipeline has fixed functions for rasterization, which includes triangle filling. So it might actually be faster to do simple 2d drawing with OpenGL than implement an OpenCL filling algorithm. Unless, of course, there is an algorithmic improvement upon the existing fixed-function methods.

If you use gl sharing, you could render white 2d triangles with gl on a black background, then open the texture in OpenCL and use that to query whether points are in or outside of a triangle based on their color.

As far as existing libraries, I can't help you though, sorry...