PDA

View Full Version : Old code...large raster = slow



cru
05-06-2002, 06:45 PM
Got a small problem. I inherited some code where I work that has run into some speed problems. Basically the problem is this: using code that was designed to draw small rectangular rasters is now being used to draw LARGE rectangular rasters. The data is broken up into triangle strips and glDrawArrays(…) is being used to actually draw the data. How can I speed this up? If the entire raster is being shown, fine, it’s going to be somewhat slow. I can accept that. If only a small portion of the data is being shown, well, it’s still slow, the code is still drawing the WHOLE raster. This brute force approach worked well when the images were tiny, but now that the rasters have grown there is no need to draw the whole thing when only a small portion is used. What can I do? I thought about throwing the data into some sort of gridded data structure and only draw the grids that are on the screen. Anyway, I welcome some comments.

jwatte
05-06-2002, 06:48 PM
I suggest you profile your app and figure out what actually is slow.

For example, if your screen has limited resolution, and your "rasters" are substantially bigger than the screen, you can upload only the part that will be drawn to a texture using PixelStore() and TexSubImage().

Also, if the entire "raster" is one big texture, you only need to draw one quad for the part that's actually visible on screen, and adjust texture coordinates appropriately.

This is assuming you're fill rate bound. If you're transform bound, try using DrawRangeElements() instead of DrawArrays(), and try putting fewer, larger primitives in your array.