/[fenfire]/fenfire/org/fenfire/spanimages/gl/PoolManager.java
ViewVC logotype

Diff of /fenfire/org/fenfire/spanimages/gl/PoolManager.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by tjl, Thu Sep 11 17:26:08 2003 UTC revision 1.13 by tjl, Fri Oct 17 09:25:34 2003 UTC
# Line 28  package org.fenfire.spanimages.gl; Line 28  package org.fenfire.spanimages.gl;
28  import org.fenfire.spanimages.*;  import org.fenfire.spanimages.*;
29  import org.nongnu.libvob.*;  import org.nongnu.libvob.*;
30  import org.nongnu.libvob.gl.*;  import org.nongnu.libvob.gl.*;
31    import org.nongnu.libvob.gl.virtualtexture.*;
32  import org.nongnu.libvob.memory.*;  import org.nongnu.libvob.memory.*;
33  import org.nongnu.libvob.util.ThreadBackground;  import org.nongnu.libvob.util.ThreadBackground;
34  import java.util.*;  import java.util.*;
# Line 37  public class PoolManager implements GL.S Line 38  public class PoolManager implements GL.S
38      private static void p(String s) {      private static void p(String s) {
39          System.out.println("PoolManager: "+s); }          System.out.println("PoolManager: "+s); }
40    
41      public int POOLSIZE = 64 * 1024 * 1024;      // public int POOLSIZE = 64 * 1024 * 1024;
42    
43      public float DICELENGTH = 1;      public float DICELENGTH = 1;
44      public float DICELENGTH2 = 1;      public float DICELENGTH2 = 1;
# Line 47  public class PoolManager implements GL.S Line 48  public class PoolManager implements GL.S
48    
49      Set activeSet = Collections.synchronizedSet(new HashSet());      Set activeSet = Collections.synchronizedSet(new HashSet());
50    
51    
52      class MySIV extends AbstractVob implements SpanImageVob {      class MySIV extends AbstractVob implements SpanImageVob {
53          float w, h;          float w, h;
54          float sx0, sx1;          float sx0, sx1;
# Line 77  public class PoolManager implements GL.S Line 79  public class PoolManager implements GL.S
79          }          }
80      }      }
81    
82        IndirectMipzipManager indirectMipzipManager;
83        int[] allocations = new int[] {
84            /*
85            2, 2, 0, 0, 0, 0,
86            0, 0, 0, 0, 0, 0
87            */
88    
89            2, 8, 15, 20, 40, 80,
90            200, 0, 0, 0, 0, 0
91        };
92        VirtualTexture[][] slotContents;
93    
94        public PoolManager() {
95            indirectMipzipManager = new NonDeletingIndirectMipzipManager();
96            indirectMipzipManager.init("COMPRESSED_RGB_S3TC_DXT1_EXT",
97                            2048, 2048);
98            indirectMipzipManager.setDefaultTexParameters(new String[] {
99                "TEXTURE_MIN_FILTER", "LINEAR_MIPMAP_LINEAR",
100                "TEXTURE_MAG_FILTER", "LINEAR",
101                "TEXTURE_MAX_ANISOTROPY_EXT", "10"
102            });
103            indirectMipzipManager.setAllocations(allocations);
104            slotContents = new VirtualTexture[allocations.length][];
105            for(int i=0; i<allocations.length; i++)
106                slotContents[i] = new VirtualTexture[allocations[i]];
107        }
108    
109      /** Make a SpanImageVob whose SingleImage's texture allocation will      /** Make a SpanImageVob whose SingleImage's texture allocation will
110       * be tracked by this object.       * be tracked by this object.
111       * @param i The image       * @param i The image
# Line 170  public class PoolManager implements GL.S Line 199  public class PoolManager implements GL.S
199          SingleImage[] actives = (SingleImage[])activeSet.toArray(templ);          SingleImage[] actives = (SingleImage[])activeSet.toArray(templ);
200          if(dbg) p("UpdateAllocs start "+actives.length);          if(dbg) p("UpdateAllocs start "+actives.length);
201          Arrays.sort(actives, sortPriority);          Arrays.sort(actives, sortPriority);
202            int level=0; int ind = 0;
203            for(int i=0; level < slotContents.length &&
204                         i<actives.length; i++) {
205                // if(dbg) p("Level 1 "+i+" "+level);
206                slotContents[level][ind] = actives[i].virtualTexture;
207                ind++;
208                while(level < slotContents.length &&
209                      ind >= slotContents[level].length) {
210                    // if(dbg) p("LevelIn1 "+level);
211                    ind = 0;
212                    level++;
213                }
214            }
215    
216            while(level < slotContents.length) {
217                slotContents[level][ind] = null;
218                ind++;
219                while(level < slotContents.length &&
220                      ind >= slotContents[level].length) {
221                    ind = 0;
222                    level++;
223                }
224            }
225            if(dbg) p("UpdateAllocs finish ");
226            indirectMipzipManager.setSlotContents(slotContents);
227    
228            /*
229          int left = POOLSIZE;          int left = POOLSIZE;
230          long time = System.currentTimeMillis();          long time = System.currentTimeMillis();
231          for(int i=0; i<actives.length; i++) {          for(int i=0; i<actives.length; i++) {
# Line 206  public class PoolManager implements GL.S Line 262  public class PoolManager implements GL.S
262                  activeSet.remove(actives[i]);                  activeSet.remove(actives[i]);
263          }          }
264          if(dbg) p("Memory left: "+left);          if(dbg) p("Memory left: "+left);
265            */
266      }      }
267    
268  }  }

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26