GeomPoints used as point sprites restricted to 16-bits indices

Bug #936913 reported by MJ-meo-dmt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Panda3D
Fix Released
Undecided
rdb

Bug Description

* Here is the console error output
* 32bit natty (ubuntu) + Nothing else really running only firefox, IM and few open folders :P even closed same error...
* panda3d1.8_1.8.0+cvs20120219~natty256_i386.deb with python (Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24))
* Note I got this error with the builds before this aswell.
* Also this error started to popup when I started to use an image to add to the points.
* I hope thats all the info you need... Can find me in irc

Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
:display:glxdisplay(warning): No suitable FBConfig contexts available; using XVisual only.
depth_bits=24 color_bits=24 alpha_bits=8 back_buffers=1 force_hardware=1
LVector3f(-6.07107, -4.07107, 12.9289)
25919
The number of bytes being used:192Bytes
Assertion failed: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx
Assertion failed: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx
Assertion failed: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx
Assertion failed: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx
Assertion failed: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx

--- THESE GO ON FOR SOME TIME...

Assertion failed: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx
Assertion failed: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx
Assertion failed: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx
:display:x11display(error): BadMatch (invalid parameter attributes)
Traceback (most recent call last):
  File "/usr/share/panda3d/direct/showbase/ShowBase.py", line 1844, in __igLoop
    self.graphicsEngine.renderFrame()
AssertionError: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx
:task(error): Exception occurred in PythonTask igLoop
Traceback (most recent call last):
  File "another.py", line 133, in <module>
    run()
  File "/usr/share/panda3d/direct/showbase/ShowBase.py", line 2910, in run
    self.taskMgr.run()
  File "/usr/share/panda3d/direct/task/Task.py", line 502, in run
    self.step()
  File "/usr/share/panda3d/direct/task/Task.py", line 460, in step
    self.mgr.poll()
  File "/usr/share/panda3d/direct/showbase/ShowBase.py", line 1844, in __igLoop
    self.graphicsEngine.renderFrame()
AssertionError: *(PN_uint16 *)pointer == a at line 1838 of panda/src/gobj/geomVertexColumn.cxx
>Exit code: 1

-------------------------------------------------------------------------------------------------------------------------------------------------------

# A PIECE OF CODE : Note that it will miss some needed resources... ofc

from pandac.PandaModules import loadPrcFileData
loadPrcFileData("",
"""
 window-title 3D Space
 fullscreen 0
 win-size 1024 768
 cursor-hidden 0
 sync-video 1
 show-frame-rate-meter 1
"""
)

from direct.showbase.ShowBase import ShowBase
from direct.gui.OnscreenText import OnscreenText
from direct.filter.CommonFilters import CommonFilters
from pandac.PandaModules import *
from random import random
import sys, array

class Space(ShowBase):

 def __init__(self):
  ShowBase.__init__(self)
  base.setBackgroundColor(0,0,0)

  #self.filters = CommonFilters(base.win, base.cam)
  #self.filters.setBloom(blend=(0.33, 0.33, 0.33,0), desat=0.0, intensity=1, size="large")
  self.createDots()

 def genLabelText(self, text, i):
  return OnscreenText(text = text, pos = (-1.3, .95-.05*i), fg=(1,1,1,1),
    align = TextNode.ALeft, scale = .05, mayChange = 1)

 def createDots(self):
  format = GeomVertexFormat.getV3()
  vdata = GeomVertexData('points', format, Geom.UHStatic)

  vertex = GeomVertexWriter(vdata, 'vertex')
  image= PNMImage()
  image.read(Filename("editD.png"))
  image2=PNMImage()
  image2.read(Filename("edit3.png"))
  counter = 0
  pos_list = []
  for i in xrange(800000*10):
   x = random() * 255
   y = random() * 255
   z = random() * 63
   if random() < image.getBright(int(x), int(y)):
    if random() < image2.getBright(int(x), int(z)):
     if random() < image2.getBright(int(y), int(z)):

      vertex.addData3f(x, y, z - 32)
      #pos_list.append(point_pos)
      counter+=1

  # X, Y, Z

  grid_x = 10
  grid_y = 10
  grid_z = 10

  #for count_x in range(grid_x):
  # count_x=random.randint(0, 150)
  # for count_y in range(grid_y):
  # count_y=random.randint(0,50)
  # for count_z in range(grid_z):
  # count_z=random.randint(0,100)
  # vertex.addData3f(count_x,count_y,count_z)

  prim = GeomPoints(Geom.UHStatic)
  prim.setIndexType(Geom.NTUint32)
  prim.addNextVertices(counter)
  prim.closePrimitive()

  x = ((Point3(1,3,20))-(Point3(5,3,4)).length())
  print x
  geom = Geom(vdata)
  geom.addPrimitive(prim)

  node = GeomNode('gnode')

  node.addGeom(geom)

  nodePath = render.attachNewNode(node)
  nodePath.setRenderModeThickness(2)
  nodePath.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
  #nodePath.setAlphaScale(0.1)
  #nodePath.setTransparency(TransparencyAttrib.MAlpha)
  nodePath.setColorScale((0.2,0.15,0.1,1))
  #nodePath.setColorScale((0.8,0.6,0.4,1))
  nodePath.setRenderModePerspective(True)
  nodePath.setDepthTest(False)
  nodePath.setDepthWrite(False)
  nodePath.setAntialias(AntialiasAttrib.MAuto)

  #flippedNode = GeomNode('flipped_gnode')
  #flippedNode.addGeom(geom)
  #flippedNP = nodePath.attachNewNode(flippedNode)
  #flippedNP.setSz(-1)

  ### INFO ###
  self.info = self.genLabelText("Info: ",1)
  self.pointinfo = self.genLabelText("Points: "+str(counter), 2)
  print counter
  print "The number of bytes being used:" +str(prim.getNumBytes())+"Bytes"

  ###INFO DONE ####
  tex = loader.loadTexture('textures/sun.png')
  tex.setWrapU(Texture.WMClamp)
  tex.setWrapV(Texture.WMClamp)
  nodePath.setTexGen(TextureStage.getDefault(), TexGenAttrib.MPointSprite)
  nodePath.setTexture(tex)

  nodePath2 = nodePath.copyTo(render)
  nodePath2.setColorScale((1.6,1.2,0.8,1))
  nodePath2.setRenderModeThickness(0.02)
  nodePath2.setDepthOffset(1)

  #dotsNode = GeomNode('gnode-dots')
  #dotsNode.addGeom(geom)
  #dotsNP = render.attachNewNode(dotsNode)
  #dotsNP.setDepthOffset(-1)
  #dotsNP.setAntialias(AntialiasAttrib.MAuto)
  #dotsNP.setRenderModePerspective(True)
  #dotsNP.setRenderModeThickness(0.04)
  #dotsNP.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
  #dotsNP.setDepthTest(False)
  #dotsNP.setDepthWrite(False)
  #dotsNP.setColorScale((0.8, 0.8, 0.8, 1.0))

Main = Space()
run()

Revision history for this message
David Rose (droklaunchpad) wrote :

Panda3D could do a better job of giving a more meaningful error message here, but this is technically not a bug. You have only exceeded an internal limit: you have called setRenderModePerspective() on a GeomPrimitive that contains too many vertices. (The limit is 16384 vertices, but you will probably have performance issues with that many anyway.)

Note that the limit is imposed only when Panda transforms these particles on the CPU, instead of handing them to the GPU. Therefore, you also may be able to avoid the limit by putting "hardware-points 1" and "hardware-point-sprites 1" in your Config.prc file, but I think these are the defaults anyway in 1.8.0. Even with these variables set, Panda may still be forced to transform them on the CPU anyway, depending on the OpenGL extensions provided by your graphics card, and/or by the render state you apply.

David

Changed in panda3d:
assignee: nobody → David Rose (droklaunchpad)
status: New → Won't Fix
Revision history for this message
rdb (rdb) wrote :

I don't quite understand where the limit is coming from. The assert seems to originate from the fact that munge_points_into_quads (or whatever it was called) seems to write the new index array as uint16 and not uint32, regardless of what the original index array type was - which seems like a bug to me.

If this was changed to set the new numeric type to uint32 if the vertex count exceeds 16384, would there be problems elsewhere? It does seem that OpenGL and many GPUs support 32-bits indices.

Revision history for this message
David Rose (droklaunchpad) wrote :

That would be a worthy experiment; but I haven't pursued it because I think the performance wouldn't be acceptable with this number of vertices anyway. munge_points_into_quads() gets kind of expensive with a lot of vertices.

Revision history for this message
rdb (rdb) wrote :

Checked in a flurry of fixes. There's actually a range of things that went wrong here:
* TransformState::make_identity()->has_identity_scale() returned *false*, causing Panda to think there was a scale applied
* OpenGL GSG didn't support scaled points (even though that is trivial) causing hardware support to be disabled
* The munge function didn't pick a new index type to fit the actual number of vertices
* GeomPrimitive::set_vertices didn't account for index type, causing garbled indices

I've checked in fixes for all of these things. Now I'm happily rendering hundreds of thousands of points at full frame rate. :-)

Changed in panda3d:
assignee: David Rose (droklaunchpad) → rdb (rdb)
milestone: none → 1.9.0
status: Won't Fix → Fix Committed
rdb (rdb)
Changed in panda3d:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.