gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz gfx/demo/mipzip.py gfx/jni/GzzGL-jni.cxx gz...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz gfx/demo/mipzip.py gfx/jni/GzzGL-jni.cxx gz...
Date: Sat, 18 Jan 2003 15:24:26 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        03/01/18 15:24:26

Modified files:
        gfx/demo       : mipzip.py 
        gfx/jni        : GzzGL-jni.cxx 
        gzz/gfx/gl     : MipzipLoader.java MipzipMemoryConsumer.java 
        gzz/mem        : MemoryConsumer.java MemoryPartitioner.java 

Log message:
        Somewhat working, but something really weird is going on: sometimes 
textures flash with other textures' images\!

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/mipzip.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.78&tr2=1.79&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/MipzipLoader.java.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/MipzipMemoryConsumer.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/mem/MemoryConsumer.java.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/mem/MemoryPartitioner.java.diff?tr1=1.10&tr2=1.11&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/mipzip.py
diff -u gzz/gfx/demo/mipzip.py:1.5 gzz/gfx/demo/mipzip.py:1.6
--- gzz/gfx/demo/mipzip.py:1.5  Sat Jan 18 10:18:21 2003
+++ gzz/gfx/demo/mipzip.py      Sat Jan 18 15:24:25 2003
@@ -15,10 +15,10 @@
 
 class Scene:
     def __init__(self):
-       self.mem = MemoryPartitioner(32 * 1024 * 1024)
+       self.mem = MemoryPartitioner(80 * 1024 * 1024)
        self.files = []
        self.tex = []
-       for f in glob.glob("../mstmpimg/*.mipzip"):
+       for f in glob.glob("../mstmpimg/*.mipzip")[0:50]:
            ml = MipzipLoader(File(f))
            # ml.loadToBaseLevelSynch(0)
            mc = MipzipMemoryConsumer(self.mem, ml)
@@ -44,13 +44,13 @@
            TexCoord %(x1)s %(y0)s
            Vertex 1 0
            End
-       """ % { "x0" : .25, "y0" : .25, "x1": .3, "y1":.3 })
+       """ % { "x0" : .25, "y0" : .25, "x1": .4, "y1":.4 })
     def scene(self, vs):
        vs.map.put(background((.3,.7,.8)))
        AbstractUpdateManager.setNoAnimation()
        h = vs.size.height / self.nrows
        w = h
-       print "S"
+       # print "S"
        # print "Sc:",len(self.files)
        for x in range(0, self.nrows):
            for y in range(0, self.nrows):
@@ -60,7 +60,8 @@
                xc = x * w
                yc = y * h
                
-               imp = 1 / (.1 + math.hypot(self.x - xc, self.y - yc))
+               imp = 1 / (1 + .01 * math.hypot(self.x - xc-w/2, self.y - 
yc-h/2))
+               # print "Imp:",imp
                self.files[i].getTexture(imp, 4000)
 
                cs = vs.orthoCS(0, str((x,y)), 0, xc, yc, w, h)
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -u gzz/gfx/jni/GzzGL-jni.cxx:1.78 gzz/gfx/jni/GzzGL-jni.cxx:1.79
--- gzz/gfx/jni/GzzGL-jni.cxx:1.78      Sat Jan 18 09:53:08 2003
+++ gzz/gfx/jni/GzzGL-jni.cxx   Sat Jan 18 15:24:25 2003
@@ -537,6 +537,7 @@
 
      glCompressedTexImage2DARB(GL_TEXTURE_2D, level, internalFormat,
                    width, height, border, size, data);
+     glFinish(); // Appears that NV 4191 drivers need this.
      glBindTexture(GL_TEXTURE_2D, 0);
      env->ReleaseByteArrayElements(jdata, data, 0);
      GLERR;
Index: gzz/gzz/gfx/gl/MipzipLoader.java
diff -u gzz/gzz/gfx/gl/MipzipLoader.java:1.10 
gzz/gzz/gfx/gl/MipzipLoader.java:1.11
--- gzz/gzz/gfx/gl/MipzipLoader.java:1.10       Sat Jan 18 10:18:21 2003
+++ gzz/gzz/gfx/gl/MipzipLoader.java    Sat Jan 18 15:24:26 2003
@@ -20,8 +20,8 @@
     public static boolean dbg = false;
     final static void pa(String s) { System.out.println(s); }
 
-    private int goalBaseLevel = 0;
-    private int currentBaseLevel = 0;
+    private int goalBaseLevel = -15;
+    private int currentBaseLevel = 1000;
 
     private Background bg = null;
     private float priority = 0;
@@ -110,8 +110,8 @@
                pa("LoadData "+MipzipLoader.this+" "+level+
                        " "+state);
            if(state != STATE_NONE) return;
-           // Not sure if required, but safer
-           loadedData = readEntry(""+level);
+           if(loadedData == null) 
+               loadedData = readEntry(""+level);
            state = STATE_DATALOADED;
        }
 
@@ -144,7 +144,7 @@
            switch(state) {
            case STATE_INTEXTURE:
                tex.loadNull2D(level, texFormat, 
-                       1, 1, 0, "RGB", "FLOAT");
+                       0, 0, 0, "RGB", "FLOAT");
            case STATE_DATALOADED:
                loadedData = null;
            }
@@ -170,6 +170,7 @@
      */
     synchronized private void setBaseLevel(int level) {
        tex.setTexParameter("TEXTURE_2D", "TEXTURE_BASE_LEVEL", level);
+       tex.setTexParameter("TEXTURE_2D", "TEXTURE_MIN_LOD", level);
        currentBaseLevel = level;
     }
 
@@ -199,9 +200,9 @@
      */
     synchronized public void setGoalBaseLevel(int level,
                                Background bg, float priority) {
-       if(dbg) pa("MipzipLoader "+this+" goal "+level+
-                       " now at "+currentBaseLevel);
        if(level != goalBaseLevel || level != currentBaseLevel) {
+           if(dbg) pa("MipzipLoader "+this+" goal "+level+
+                           " now at "+currentBaseLevel);
            this.goalBaseLevel = level;
            this.bg = bg;
            this.priority = priority;
@@ -231,8 +232,9 @@
                try {
                    levels[i].loadData();
                    AbstractUpdateManager.doWhenIdle( 
-                           levels[i], priority - .1f * i);
+                           levels[i], priority - 10 - .1f * i);
                    AbstractUpdateManager.chg();
+                   priority += .05;
                    bg.addTask(r_runBg, priority);
                } catch(IOException e) {
                    pa("Exception while loading mipzip data "+e);
@@ -242,7 +244,7 @@
            }
        }
        // Schedule runGL always
-       AbstractUpdateManager.doWhenIdle( r_runGL, priority);
+       AbstractUpdateManager.doWhenIdle( r_runGL, priority - 5);
     }
 
     // See if any too large mipmaps still here
Index: gzz/gzz/gfx/gl/MipzipMemoryConsumer.java
diff -u gzz/gzz/gfx/gl/MipzipMemoryConsumer.java:1.2 
gzz/gzz/gfx/gl/MipzipMemoryConsumer.java:1.3
--- gzz/gzz/gfx/gl/MipzipMemoryConsumer.java:1.2        Fri Jan 17 10:06:37 2003
+++ gzz/gzz/gfx/gl/MipzipMemoryConsumer.java    Sat Jan 18 15:24:26 2003
@@ -19,11 +19,9 @@
     public int getMaxBytes(float quality) {
        int mb = mipzip.getMemory(
                    mipzip.getLevelForQuality(quality));
-       if(dbg) 
-           pa("MipzipMemcons maxbytes "+quality+" = "+mb);
        return mb;
     }
-    public int setReservation(int bytes, float quality, Obs o) {
+    public int setReservation(float priority, int bytes, float quality, Obs o) 
{
        if(dbg) pa("MipzipMemcons setres "+mipzip+" "+
                bytes+" "+quality);
        int lq = mipzip.getLevelForQuality(quality);
@@ -32,7 +30,7 @@
 
        mipzip.setGoalBaseLevel(level, 
                            Background.getDefaultInstance(),
-                           0);
+                           priority);
 
        return mipzip.getMemory(level);
     }
Index: gzz/gzz/mem/MemoryConsumer.java
diff -u gzz/gzz/mem/MemoryConsumer.java:1.6 gzz/gzz/mem/MemoryConsumer.java:1.7
--- gzz/gzz/mem/MemoryConsumer.java:1.6 Mon Jan 13 01:48:50 2003
+++ gzz/gzz/mem/MemoryConsumer.java     Sat Jan 18 15:24:26 2003
@@ -57,6 +57,8 @@
      * is called, is the new one.
      * <p>
      * <b>This method may only be called by address@hidden 
MemoryPartitioner}.</b>
+     * @param priority The priority to use for scheduling
+     *                         this operation.
      * @param bytes The maximum amount of bytes this object should reserve.
      * @param quality Maximum quality that should be loaded (if quality is
      *                 adjusted in discrete steps, the class may round 
upwards). 
@@ -65,7 +67,8 @@
      *                 sizes come in certain increments, less memory will be 
used
      *                 than needed..
      */
-    int setReservation(int bytes, float quality, Obs o);
+    int setReservation(float priority,
+                       int bytes, float quality, Obs o);
     /** Get the number of bytes currently used.
      */
     int getReservation();
Index: gzz/gzz/mem/MemoryPartitioner.java
diff -u gzz/gzz/mem/MemoryPartitioner.java:1.10 
gzz/gzz/mem/MemoryPartitioner.java:1.11
--- gzz/gzz/mem/MemoryPartitioner.java:1.10     Sat Jan 18 08:30:58 2003
+++ gzz/gzz/mem/MemoryPartitioner.java  Sat Jan 18 15:24:26 2003
@@ -114,17 +114,17 @@
            this.o = o;
        }
 
-       void fit(MemoryConsumer cons, int bytes) {
+       void fit(MemoryConsumer cons, float priority, int bytes) {
            if(dbg) pa("Reserving "+bytes+" for "+cons);
-           cons.setReservation(bytes, curQuality, o);
+           cons.setReservation(priority, bytes, curQuality, o);
            if(dbg) pa("Reserved");
            setBytes = bytes;
            setQuality = curQuality;
        }
 
-       int maximum(MemoryConsumer cons, int left) {
+       int maximum(MemoryConsumer cons, float priority, int left) {
            int m = cons.getMaxBytes(curQuality);
-           cons.setReservation(m, curQuality, o);
+           cons.setReservation(priority, m, curQuality, o);
            setBytes = m;
            setQuality = curQuality;
            return left-m;
@@ -172,7 +172,7 @@
                    rerate();
                    // AbstractUpdateManager.chg();
                    if(dbg) pa("rerated, sleeping");
-                   Thread.sleep(50);
+                   Thread.sleep(250);
                } catch(Exception e) { 
                    ZZLogger.exc(e, "gzz.mem.MemoryPartitioner thread!");
                }
@@ -203,9 +203,9 @@
                MemoryConsumer cons = (MemoryConsumer)i.next();
                ConsumerRecord rec = (ConsumerRecord)consumer2record.get(cons);
                if(rec.curImportance == 1) 
-                   left = rec.maximum(cons, left);
+                   left = rec.maximum(cons, 0, left);
                else 
-                   rec.fit(cons, 0);
+                   rec.fit(cons, 0, 0);
            }
            return;
        }
@@ -220,7 +220,7 @@
                ConsumerRecord rec = (ConsumerRecord)consumer2record.get(cons);
                float imp = 0;
                if(rec.curImportance > 0)
-                   imp = (float)Math.pow(rec.curImportance/maximportance, 
round);
+                   imp = (float)Math.pow(.99 * 
rec.curImportance/maximportance, round);
                else if(round == 0)
                    imp = 1;
                int byt = cons.getMaxBytes(rec.curQuality);
@@ -235,11 +235,18 @@
                    ConsumerRecord rec = 
(ConsumerRecord)consumer2record.get(cons);
                    float imp = 0;
                    if(rec.curImportance > 0)
-                       imp = (float)Math.pow(rec.curImportance/maximportance, 
round);
+                       imp = (float)Math.pow(.99 * 
rec.curImportance/maximportance, round);
                    else if(round == 0)
                        imp = 1;
                    int byt = cons.getMaxBytes(rec.curQuality);
-                   rec.fit(cons, (int)(imp * byt));
+
+                   float priority = 1-rec.curImportance;
+                   byt = (int) (imp * byt);
+
+                   if(byt < cons.getReservation())
+                       priority -= 1; // First free
+
+                   rec.fit(cons, priority, (int)(imp * byt));
                }
                return;
            }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]