[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz ./TODO gfx/demo/opengl/texperf.py gfx/libco...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz ./TODO gfx/demo/opengl/texperf.py gfx/libco... |
Date: |
Wed, 15 Jan 2003 09:14:46 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 03/01/15 09:14:45
Modified files:
. : TODO
gfx/demo/opengl: texperf.py
gfx/libcoords : Coords.cxx
gzz/gfx/gl : FileSetTextureMemoryConsumer.java GL.java
test/gzz/vob : vobcoorder.test
Log message:
Some more texcache, ...
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.513&tr2=1.514&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/opengl/texperf.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.60&tr2=1.61&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/FileSetTextureMemoryConsumer.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GL.java.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/vob/vobcoorder.test.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
Patches:
Index: gzz/TODO
diff -u gzz/TODO:1.513 gzz/TODO:1.514
--- gzz/TODO:1.513 Wed Jan 15 05:52:32 2003
+++ gzz/TODO Wed Jan 15 09:14:44 2003
@@ -234,7 +234,12 @@
colors (not "not" tests but test that the
color really is right)
tjl:
+ - matrix inv!
- faster (asynch) loading of (pagespan) images
+ - move Image class (imageraster &c) out from Os-GLX.
+ Os-GLX should only contain methods to directly
+ load images into given memory buffers in given
+ formats.
- load in separate thread
- discard high-rez images when not in use
- use lower resolution first, lazily load better
Index: gzz/gfx/demo/opengl/texperf.py
diff -u gzz/gfx/demo/opengl/texperf.py:1.7 gzz/gfx/demo/opengl/texperf.py:1.8
--- gzz/gfx/demo/opengl/texperf.py:1.7 Sat Nov 23 14:03:35 2002
+++ gzz/gfx/demo/opengl/texperf.py Wed Jan 15 09:14:44 2003
@@ -13,13 +13,13 @@
# - BASE_LEVEL *does* have an effect - I falsely concluded earlier that it
didn't.
# Therefore, we'll be using that for quite a lot of things...
-# forms = ("R3_G3_B2",)
-forms = ("COMPRESSED_RGB_S3TC_DXT1_EXT",)
+forms = ("R3_G3_B2",)
+# forms = ("COMPRESSED_RGB_S3TC_DXT1_EXT",)
# sizes = (512,1024,)
baselevels =(0,1,2,3,4,5)
downsamples = (0,1,2,3)
-ntex = 25
+ntex = 10
sizes = (2048,)
size = sizes[0]
@@ -36,7 +36,10 @@
global tex, texes
tex = GL.createTexture()
tex.loadNull2D(0, form, size, size, 0, "RGB", "UNSIGNED_BYTE")
- tex.loadSubImage(0, img, 0, 0)
+ # Round size to 4
+ w = (img.getSize(0) / 4) * 4
+ h = (img.getSize(1) / 4) * 4
+ tex.loadSubImage(0, img, 0, 0, 0, 0, w, h)
# tex.shade(size, size, 0, 4, form, "RGBA", "waves", [])
# tex.shade(size, size, 0, 4, form, "RGBA", "waves", [])
Index: gzz/gfx/libcoords/Coords.cxx
diff -u gzz/gfx/libcoords/Coords.cxx:1.60 gzz/gfx/libcoords/Coords.cxx:1.61
--- gzz/gfx/libcoords/Coords.cxx:1.60 Tue Jan 14 08:36:06 2003
+++ gzz/gfx/libcoords/Coords.cxx Wed Jan 15 09:14:44 2003
@@ -1,9 +1,13 @@
+#include <GL/gl.h>
+#include <math.h>
+
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
#include "libutil/Debug.hxx"
#include "libfisheye/Fisheye.hxx"
#include "Coords.hxx"
#include "libutil/VecGL.hxx"
-#include <GL/gl.h>
-#include <math.h>
using namespace VecGL;
@@ -169,12 +173,76 @@
}
};
+using boost::numeric::ublas::bounded_array;
+using boost::numeric::ublas::matrix;
+using boost::numeric::ublas::column_major;
+using boost::numeric::ublas::identity_matrix;
+typedef bounded_array<float, 4> boostVecArray;
+typedef bounded_array<float, 16> boostMatArray;
+
+typedef boost::numeric::ublas::vector<float, boostVecArray> boostVec;
+typedef matrix<float, column_major, boostMatArray> boostMat;
+
+/** Really stupid approximation...
+ * 1/(1-t) = 1 + t + t**2 + t**3 + ..
+ * Therefore, just set t = 1-m.
+ */
+boostMat invertMat(const boostMat &m) {
+ DBG(dbg) << "Invert\n" << m << "\n\n";
+ // Really stupid routine
+ float scale = norm_inf(m);
+ scale = 2 * scale;
+ identity_matrix<float> id(4);
+ boostMat t(4,4);
+ t = id-(1/scale)*m;
+ DBG(dbg) << "t = \n" << t << "\n\n";
+ boostMat res(4,4);
+ res = scale * (id + prod(t , (id + prod(t , (id + t)))));
+ DBG(dbg) << "res = \n" << res << "\n\n" << prod(res,m) << "\n\n" <<
prod(m, res)<<"\n\n";
+ return res;
+}
+
+/** A coordinate system defined by a 4x4 modelview matrix.
+ * Used for PointInterpCoordSys inverse.
+ * Note: this is not a transform, it is a full root-level cs.
+ */
+struct MatrixCoordSys : public CoordSys {
+ boostMat mat;
+ MatrixCoordSys(const boostMat &mat) : mat(mat) { }
+ virtual CoordSys *createInverse() {
+ return new MatrixCoordSys(invertMat(mat));
+ }
+ virtual void setParams(float *params) {
+ }
+ virtual void vertex(const ZPt &p) const {
+ glVertex(transform(p));
+ }
+ virtual ZPt transform(const ZPt &p) const {
+ boostVec v(4);
+ v[0] = p.x;
+ v[1] = p.y;
+ v[2] = p.z;
+ v[3] = 1;
+ boostVec r(4);
+ r = prod(mat, v);
+ return ZPt(r[0], r[1], r[2]);
+
+ }
+ virtual bool canPerformGL() { return true; }
+ virtual bool performGL() {
+ glMultMatrixf(mat.data().begin());
+ return true;
+ }
+};
struct PointInterpCoordSys : public CoordSys {
CoordSys *cs1, *cs2;
float fract;
+ bool didGetMat;;
+ boostMat mat;
+
PointInterpCoordSys(CoordSys *cs1, CoordSys *cs2, float fract)
- : cs1(cs1), cs2(cs2), fract(fract) { }
+ : cs1(cs1), cs2(cs2), fract(fract), mat(4,4) { }
virtual void setSuper(CoordSys **super) {
}
virtual void setParams(float *params) {
@@ -206,9 +274,10 @@
bool canPerformGL() {
return cs1->canPerformGL() && cs2->canPerformGL();
}
- bool performGL() {
- // XXX Allow using of vertex weighting or something
- if(!canPerformGL()) return false;
+
+ void getMat() {
+ if(didGetMat) return;
+
GLfloat mat1[16], mat2[16];
glPushAttrib(GL_TRANSFORM_BIT);
glMatrixMode(GL_MODELVIEW);
@@ -229,26 +298,35 @@
for(int i=0; i<16; i++) DBG(dbg) << mat2[i] << " ";
DBG(dbg) << "\n";
}
- for(int i=0; i<16; i++) mat1[i] = lerp(mat1[i], mat2[i], fract);
- if(dbg) {
- for(int i=0; i<16; i++) DBG(dbg) << mat1[i] << " ";
- DBG(dbg) << "\n";
- }
+ for(int i=0; i<16; i++) mat.data()[i] = lerp(mat1[i], mat2[i], fract);
+ DBG(dbg) << mat;
glPopMatrix();
glPopAttrib();
- glMultMatrixf(mat1);
+
+ }
+
+
+ bool performGL() {
+ // XXX Allow using of vertex weighting or something
+ if(!canPerformGL()) return false;
+ getMat();
+ glMultMatrixf(mat.data().begin());
return true;
}
CoordSys *createInverse() {
- // Badly wrong
ownInverse = true;
- return new PointInterpCoordSys(cs1->getInverse(), cs2->getInverse(),
fract);
- // if(canPerformGL()) {
- // } else {
- // }
+ /*
+ if(canPerformGL()) {
+ getMat();
+ return new MatrixCoordSys(invertMat(mat));
+ } else {
+ */
+ // Badly wrong
+ return new PointInterpCoordSys(cs1->getInverse(),
cs2->getInverse(), fract);
+ /* } */
}
};
Index: gzz/gzz/gfx/gl/FileSetTextureMemoryConsumer.java
diff -u gzz/gzz/gfx/gl/FileSetTextureMemoryConsumer.java:1.2
gzz/gzz/gfx/gl/FileSetTextureMemoryConsumer.java:1.3
--- gzz/gzz/gfx/gl/FileSetTextureMemoryConsumer.java:1.2 Tue Jan 14
03:58:17 2003
+++ gzz/gzz/gfx/gl/FileSetTextureMemoryConsumer.java Wed Jan 15 09:14:45 2003
@@ -1,6 +1,7 @@
// (c): Tuomas J. Lukka
package gzz.gfx.gl;
+import gzz.*;
import gzz.mem.*;
import gzz.client.*;
@@ -9,8 +10,8 @@
*/
public abstract class FileSetTextureMemoryConsumer extends
TextureMemoryConsumer {
- Runnable r_runTexImage = new Runnable() {
- public void run() { runTexImage(); }
+ Runnable r_runGLThread = new Runnable() {
+ public void run() { runGLThread(); }
};
Runnable r_runRequest = new Runnable() {
public void run() { runRequest(); }
@@ -18,22 +19,81 @@
static final int STATE_IDLE = 0,
STATE_REQUESTED = 1,
- STATE_TEXIMAGING = 2;
+ STATE_TEXIMAGING = 2,
+ STATE_DOWNSAMPLING = 3
+ ;
+
+ GL.Texture currentTexture;
+ int curTexW, curTexH;
+ int curW, curH;
+
+ int goalTexW, goalTexH;
+
+ String filename;
+ int fullW, fullH;
+ int fullTexW, fullTexH;
- public class File {
- int w, h;
- String name;
+ int state;
+
+ GL.Image img;
+ private void clearImg() {
+ if(img != null)
+ img.deleteObject();
+ img = null;
+ }
+ private void clearTexture() {
+ if(currentTexture != null)
+ currentTexture.deleteObject();
+ currentTexture = null;
}
- int state;
+ synchronized public int setReservation(int bytes, float quality, Obs o) {
+ // Only care about bytes.
+ int w = fullTexW, h = fullTexH;
+ int e = 0;
+ int b;
+ while(w >= 1) {
+ b = getBytes(w, h);
+ if(b <= bytes) break;
+ }
+ if(w == 0) {
+ clearImg();
+ clearTexture();
+ return 0;
+ }
+ if(w <= curTexW) {
+ state = STATE_DOWNSAMPLING;
+ } else { // Need to load a larger version.
+ }
+ return b;
+ }
+
+ synchronized private void runRequest() {
+ // The only GL function callable outside GL thread ;)
+ // This may take quite some time.
+ this.img = GL.createImage(filename);
- private void runRequest() {
state = STATE_TEXIMAGING;
// High priority, we're using a lot of memory
- AbstractUpdateManager.doWhenIdle(r_runRequest, -10);
+ AbstractUpdateManager.doWhenIdle(r_runGLThread, -10);
}
- private void runTexImage() {
+ synchronized private void runGLThread() {
+ // Now we are in the GL thread.
+ //
+ // Check that we still actually *want* this image
+ if(state == STATE_TEXIMAGING) {
+
+ GL.Texture newTexture = GL.createTexture();
+
+ // Make sure the data is freed NOW.
+ clearImg();
+ state = STATE_IDLE;
+ } else if(state == STATE_DOWNSAMPLING) {
+ } else {
+ clearImg();
+ return;
+ }
}
Index: gzz/gzz/gfx/gl/GL.java
diff -u gzz/gzz/gfx/gl/GL.java:1.36 gzz/gzz/gfx/gl/GL.java:1.37
--- gzz/gzz/gfx/gl/GL.java:1.36 Mon Jan 13 01:48:49 2003
+++ gzz/gzz/gfx/gl/GL.java Wed Jan 15 09:14:45 2003
@@ -322,6 +322,10 @@
* TO USE A SECURITY MANAGER OR SO.
* Exploit: load something that the image loader library doesn't like...
* Need to work out how this should properly interact with mediaserver.
+ * <p>
+ * This method is VERY special: it is NOT necessary to have
+ * an OpenGL context for the thread it uses since
+ * it is <b>guaranteed</b> not to use OpenGL.
*/
static public Image createImage(String filename) {
return new Image(createImageImpl(filename));
Index: gzz/test/gzz/vob/vobcoorder.test
diff -u gzz/test/gzz/vob/vobcoorder.test:1.13
gzz/test/gzz/vob/vobcoorder.test:1.14
--- gzz/test/gzz/vob/vobcoorder.test:1.13 Mon Jan 6 06:51:59 2003
+++ gzz/test/gzz/vob/vobcoorder.test Wed Jan 15 09:14:45 2003
@@ -151,6 +151,37 @@
failUnlessEqual(interp[cs1_1], cs2)
checkInterp(vs, vs2, interp , .5, cs1_1, [0, 0, 0], [175, 125, 0])
+def testInterpolateInverseOutsideHierarchy():
+ """Test that inverse coordsys of pointwise interpolating coordsys work
+ at least for affines.
+
+ !!!
+
+ fail: *
+ """
+
+ cs1 = c.translate(0, 100, 100, 0)
+ cs1_1 = c.translate(cs1, 0, 0, 0)
+ vs.matcher.add(cs1_1, "FOO")
+ cs1_2 = c.invert(cs1_1)
+ vs.matcher.add(cs1_1, cs1_2, "BAR")
+
+ vs2 = getvs()
+ c2 = vs2.coords
+ cs2_1 = c2.rotate(0, 90)
+ vs2.matcher.add(cs2_1, "FOO")
+ cs2_2 = c2.invert(cs2_1)
+ vs2.matcher.add(cs2_1, cs2_2, "BAR")
+
+ interp = vs.matcher.interpList(vs2.matcher, 0)
+ interp[0] = len(interp)
+ failUnlessEqual(interp[cs1_1], cs2_1)
+ failUnlessEqual(interp[cs1_2], cs2_2)
+
+ checkInterp(vs, vs2, interp , .5, cs1_1, [0, 0, 0, 100, 0, 0], [50, 50, 0,
75, 100, 0])
+ checkInterp(vs, vs2, interp , .5, cs1_2, [50, 50, 0, 75, 100, 0], [0, 0,
0, 100, 0, 0])
+
+
def testInterpolateKeymap():
"""Test that vobs get according to keymap.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz ./TODO gfx/demo/opengl/texperf.py gfx/libco...,
Tuomas J. Lukka <=