[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: optimization question: a faster way to PIXMAP?



Thanks to both Randall and Bill for the tips...

I've found a temporary workaround which is only enabled by the fact that 
my polygons are much smaller than the summation grid ... I allocate much 
smaller drawing windows, which tremendously speeds up TVRD(), and 
accumulate them into the appropriate summation grid subarrays.  However, 
this is obviously case-specific, and doesn't solve the general problem 
of full-image accumulation.  (Indeed, once this kludge is implemented, 
the initial PLOT used to set up each temporary frame's coordinate bounds 
becomes the bottleneck... it seems the graphics functions are just 
[relatively] slow).

Non-graphics and POLYFILLV sounds promising... will check that shortly.

Bill:  I've benched your suggested code using both PIXMAP and the 
Z-buffer.  The Z-buffer (at least on a Mac) seems to win out 
significantly:

                    Z_buf      PIXMAP
                    -----      ------
main                95.72      151.45
tvrd                17.04       38.45
plots               14.07       49.95
randomu              1.38        1.34
sin                  1.35        1.37
findgen              0.38        0.59

Surprising ... I'm curious how the guts of drawing to the Z-buf are 
different from the guts of drawing to a PIXMAP...

- Dennis

Test code below:

pro testzbuf

   intensity_array = uintarr(540, 459)  ; image array
   current_clip = !P.CLIP  ; Copy current clipping boundaries
   
   set_plot, 'z'
   DEVICE, Z_BUFFERING = 0
   device, set_resolution = [540,459]
   !P.CLIP = current_clip  ; Make Z-buffer clip same boundaries
   
   ; Setup new color table for Z-buffer image
   table = intarr(256)
   table[1] = 255
   tvlct, table, table, table
   
   plot,1*!pi*findgen(1000)/1000,sin(4*!pi*findgen(1000)/1000) + $
        randomu(seed,1000),color=1,/nodata
   
   FOR i = 0, 4000, 1 DO BEGIN
      plots,1*!pi*findgen(1000)/1000,sin(4*!pi*findgen(1000)/1000) + $
            randomu(seed,1000),color=1
     intensity_array = temporary(intensity_array) + tvrd()
   ENDFOR
 
   device, /close
   set_plot, 'mac'

end

pro testpixmap

   set_plot,'mac'
   intensity_array = uintarr(540, 459)  ; image array
   window,0,xsize=540,ysize=459,/pixmap
   plot,1*!pi*findgen(1000)/1000,sin(4*!pi*findgen(1000)/1000) + $
        randomu(seed,1000),color=1,/nodata
   table = intarr(256)
   table[1] = 255
   tvlct, table, table, table
   
   FOR i = 0, 4000, 1 DO BEGIN
     plots,1*!pi*findgen(1000)/1000,sin(4*!pi*findgen(1000)/1000) + $
           randomu(seed,1000),color=1
     intensity_array = temporary(intensity_array) + tvrd()
   ENDFOR
   
   set_plot, 'mac'

end