gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/gldemo.py demo/opengl/texperf.py l...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/gfx demo/gldemo.py demo/opengl/texperf.py l...
Date: Mon, 23 Sep 2002 03:43:43 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/09/23 03:43:42

Modified files:
        gfx/demo       : gldemo.py 
        gfx/demo/opengl: texperf.py 
        gfx/libcallgl  : callgl.cxx 

Log message:
        Texture performance investigation

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/gldemo.py.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/opengl/texperf.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.cxx.diff?tr1=1.16&tr2=1.17&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/gldemo.py
diff -c gzz/gfx/demo/gldemo.py:1.19 gzz/gfx/demo/gldemo.py:1.20
*** gzz/gfx/demo/gldemo.py:1.19 Thu Sep 19 03:15:20 2002
--- gzz/gfx/demo/gldemo.py      Mon Sep 23 03:43:42 2002
***************
*** 30,38 ****
  def background(rgb):
      return gzz.vob.SolidBgVob(java.awt.Color(float(rgb[0]), float(rgb[1]), 
float(rgb[2])))
  
  
! def coloredQuad(rgb):
      return getDList("""
        Color %s %s %s
        Begin QUADS
        TexCoord 0 0
--- 30,45 ----
  def background(rgb):
      return gzz.vob.SolidBgVob(java.awt.Color(float(rgb[0]), float(rgb[1]), 
float(rgb[2])))
  
+ def texbindcode(texid):
+     if texid:
+       return "BindTexture TEXTURE_2D %s"%texid
+     return ""
  
! def coloredQuad(rgb, texid=None):
!     texcode = texbindcode(texid)
      return getDList("""
+       PushAttrib TEXTURE_BIT
+       """+texcode+"""
        Color %s %s %s
        Begin QUADS
        TexCoord 0 0
***************
*** 44,53 ****
        TexCoord 1 0
        Vertex 1 -1
        End
      """%(rgb))
  
! def quad():
      return getDList("""
        Begin QUADS
        TexCoord 0 0
        Vertex -1 -1
--- 51,64 ----
        TexCoord 1 0
        Vertex 1 -1
        End
+       PopAttrib
      """%(rgb))
  
! def quad(texid=None):
!     texcode = texbindcode(texid)
      return getDList("""
+       PushAttrib TEXTURE_BIT
+       """+texcode+"""
        Begin QUADS
        TexCoord 0 0
        Vertex -1 -1
***************
*** 58,69 ****
        TexCoord 1 0
        Vertex 1 -1
        End
      """)
  
  def partialquad(x0, y0, x1, y1, texid = None):
!     texcode = ""
!     if texid:
!       texcode = "BindTexture TEXTURE_2D %s"%texid
      return getDList("""
        PushAttrib TEXTURE_BIT
        """+texcode+"""
--- 69,79 ----
        TexCoord 1 0
        Vertex 1 -1
        End
+       PopAttrib
      """)
  
  def partialquad(x0, y0, x1, y1, texid = None):
!     texcode = texbindcode(texid)
      return getDList("""
        PushAttrib TEXTURE_BIT
        """+texcode+"""
Index: gzz/gfx/demo/opengl/texperf.py
diff -c gzz/gfx/demo/opengl/texperf.py:1.1 gzz/gfx/demo/opengl/texperf.py:1.2
*** gzz/gfx/demo/opengl/texperf.py:1.1  Sat Sep 21 03:35:17 2002
--- gzz/gfx/demo/opengl/texperf.py      Mon Sep 23 03:43:42 2002
***************
*** 1,35 ****
  # Test texture performance: at what point does texture memory start trashing.
  # Also, test texture prioritization and the effect of BASE_LEVEL.
  
  
! if not locals().has_key("tex"):
      tex = GZZGL.createTexture()
!     tex.shade(1024, 1024, 0, 3, "R3_G3_B2", "RGB", "waves", [])
  
- texes = [ GZZGL.createTexture() for i in range(0, 40) ]
- for t in texes:
-     tex.downsampleInto(t, "TEXTURE_2D", 0, "R3_G3_B2", "RGBA")
  
  class TPScene:
      def __init__(self):
!       self.ntex = 40
      def time(self):
!       vs = w.createVobScene()
!       putnoc(vs, background((0.1, 0.2, 0.5)))
!       putnoc(vs, getDListNocoords("""
!           Enable TEXTURE_2D
!       """))
!       for i in range(0, self.ntex):
!           print "Id ",texes[i].getTexId()
!           print "Resid", GZZGL.getGLTexParameterFloat("TEXTURE_2D", 
texes[i].getTexId(), "TEXTURE_RESIDENT")
!           print "Prio", GZZGL.getGLTexParameterFloat("TEXTURE_2D", 
texes[i].getTexId(), "TEXTURE_PRIORITY")
!           vs.put(partialquad(0, 0, 1, 1, texid=texes[i].getTexId()), 10, 100, 
100, 500, 500)
!       niters = 10
!       print "Time: ", w.timeRender(vs, niters) / niters
  
      def key(self, key):
        if key == 't':
            self.time()
      def scene(self, vs):
        putnoc(vs, background((0.8, 0.2, 0.5)))
  currentScene = TPScene()
--- 1,104 ----
  # Test texture performance: at what point does texture memory start trashing.
  # Also, test texture prioritization and the effect of BASE_LEVEL.
  
+ # A really bizarre behaviour from NVIDIA drivers:
+ # If the first texture loaded and used is large (e.g. 1024x1024 RGB 24-bit),
+ # then the driver switches to software rendering on my GF4Go. 
+ # But if the first texture drawn is small enough, things are ok.
+ #
+ # The stencil stuff was my screwup but this seems not so.
  
! # Observations so far:
! #  - there's a clear threshold when texture fetching starts trashing
! #  - 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...
! 
! form = "R3_G3_B2"
! size = 1024
! baselevel=0
! 
! img = GZZGL.createImage("doc/gl/irreg0.png")
! 
! tex0 = GZZGL.createTexture()
! tex0.loadNull2D(0, "R3_G3_B2", 64, 64, 0, "RGB", "UNSIGNED_BYTE")
! 
! 
! def maketex():
!     global tex, texes
      tex = GZZGL.createTexture()
!     tex.loadNull2D(0, form, size, size, 0, "RGB", "UNSIGNED_BYTE")
!     tex.loadSubImage(0, img, 50, 50)
!     # tex.shade(size, size, 0, 4, form, "RGBA", "waves", [])
!     # tex.shade(size, size, 0, 4, form, "RGBA", "waves", [])
! 
!     texes = [ GZZGL.createTexture() for i in range(0, 50) ]
!     for t in texes:
!       tex.downsampleInto(t, "TEXTURE_2D", 0, form, "RGB")
! 
! 
! def printTex(id):
!     for i in range(0,1):
!       for p in (
!           "TEXTURE_WIDTH", 
!           "TEXTURE_HEIGHT",
!           "TEXTURE_RED_SIZE",
!           "TEXTURE_GREEN_SIZE",
!           "TEXTURE_BLUE_SIZE",
!           "TEXTURE_ALPHA_SIZE",
!           "TEXTURE_LUMINANCE_SIZE",
!           "TEXTURE_INTENSITY_SIZE",
!                       ):
!           print "p:\t",p,"\t", 
GZZGL.getGLTexLevelParameterFloat("TEXTURE_2D", id, i, p)
!       print "if:\t",GZZGL.getGLTokenString(
!           int(GZZGL.getGLTexLevelParameterFloat("TEXTURE_2D", id, i, 
!                           "TEXTURE_INTERNAL_FORMAT")[0]))
  
  
  class TPScene:
      def __init__(self):
!       self.ntex = 2
      def time(self):
!       if not globals().has_key("tex"):
!           maketex()
!       times = []
!       for nt in range(0,len(texes)):
!           vs = w.createVobScene()
!           putnoc(vs, background((0.1, 0.2, 0.5)))
!           putnoc(vs, getDListNocoords("""
!               Enable TEXTURE_2D
!           """))
!           for i in range(0, nt):
!               texid = texes[i].getTexId()
!               if 0:
!                   print "Id ",texid
!                   print "Resid", GZZGL.getGLTexParameterFloat("TEXTURE_2D", 
texes[i].getTexId(), "TEXTURE_RESIDENT")
!                   print "Prio", GZZGL.getGLTexParameterFloat("TEXTURE_2D", 
texes[i].getTexId(), "TEXTURE_PRIORITY")
!                   printTex(texid)
!               putnoc(vs, getDListNocoords("""
!                   BindTexture TEXTURE_2D %s
!                   TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
!                   TexParameter TEXTURE_2D TEXTURE_MIN_FILTER 
LINEAR_MIPMAP_LINEAR
!                   TexParameter TEXTURE_2D TEXTURE_BASE_LEVEL 2
!               """ % texes[i].getTexId()))
!               vs.put(quad(), "T"+str(i), 50-i, 100+20*i, 100+20*i, 100, 100)
!           niters = 10
!           t = w.timeRender(vs, niters) / niters
!           print "Time: ", nt, t
!           times.append(t)
!           if t > 0.3:
!               break
!       print times
  
      def key(self, key):
        if key == 't':
            self.time()
+       if key == '+':
+           self.ntex += 1
+       if key == '-':
+           self.ntex -= 1
+       if key == 'p':
+           maketex()
      def scene(self, vs):
        putnoc(vs, background((0.8, 0.2, 0.5)))
+       vs.put(quad(tex0.getTexId()), "Q", 20, 10, 10, 100, 100)
  currentScene = TPScene()
Index: gzz/gfx/libcallgl/callgl.cxx
diff -c gzz/gfx/libcallgl/callgl.cxx:1.16 gzz/gfx/libcallgl/callgl.cxx:1.17
*** gzz/gfx/libcallgl/callgl.cxx:1.16   Sat Sep 21 03:35:17 2002
--- gzz/gfx/libcallgl/callgl.cxx        Mon Sep 23 03:43:42 2002
***************
*** 137,142 ****
--- 137,146 ----
          glEnable(getToken(v[1]));
        } else if (checkfunc(v, "Disable", 1)) {
          glDisable(getToken(v[1]));
+       } else if (checkfunc(v, "ReadBuffer", 1)) {
+         glReadBuffer(getToken(v[1]));
+       } else if (checkfunc(v, "DrawBuffer", 1)) {
+         glDrawBuffer(getToken(v[1]));
        } else if (checkfunc(v, "PushMatrix", 0)) {
          glPushMatrix();
        } else if (checkfunc(v, "PopMatrix", 0)) {




reply via email to

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