Crash when using DirectX when playing a Particle Effect

Hello,

When I play the following particle effect using DirectX, Panda3D crashes. I can successfully reproduce it on the Roaming Ralph example. This issue does not happen when using OpenGL.

effect = ParticleEffect()
effect.reset()
effect.setPos(0.000, 0.000, 6.000)
effect.setHpr(0.000, 0.000, 0.000)
effect.setScale(2.000, 2.000, 2.000)
p0 = Particles.Particles('particles-1')
# Particles parameters
p0.setFactory("PointParticleFactory")
p0.setRenderer("SparkleParticleRenderer")
p0.setEmitter("DiscEmitter")
p0.setPoolSize(150)
p0.setBirthRate(0.1000)
p0.setLitterSize(7)
p0.setLitterSpread(0)
p0.setSystemLifespan(0.0000)
p0.setLocalVelocityFlag(1)
p0.setSystemGrowsOlderFlag(0)
# Factory parameters
p0.factory.setLifespanBase(2.2000)
p0.factory.setLifespanSpread(0.2000)
p0.factory.setMassBase(1.0000)
p0.factory.setMassSpread(0.0000)
p0.factory.setTerminalVelocityBase(400.0000)
p0.factory.setTerminalVelocitySpread(0.0000)
# Point factory parameters
# Renderer parameters
p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
p0.renderer.setUserAlpha(1.00)
# Sparkle parameters
p0.renderer.setCenterColor(Vec4(1.00, 1.00, 1.00, 1.00))
p0.renderer.setEdgeColor(Vec4(0.00, 0.00, 1.00, 1.00))
p0.renderer.setBirthRadius(0.0400)
p0.renderer.setDeathRadius(0.0000)
p0.renderer.setLifeScale(SparkleParticleRenderer.SPNOSCALE)
# Emitter parameters
p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
p0.emitter.setAmplitude(1.0000)
p0.emitter.setAmplitudeSpread(0.0000)
p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 0.0000))
p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 4.0000))
# Disc parameters
p0.emitter.setRadius(0.3000)
effect.addParticles(p0)
f0 = ForceGroup.ForceGroup('forces')
# Force parameters
force0 = LinearJitterForce(3.6003, 0)
force0.setActive(1)
f0.addForce(force0)
effect.addForceGroup(f0)

This is the specific error message:

P.S. There are no errors in the output.

Probably because DirectX is abandoned and not fully supported. I still do not understand why it was not removed from Panda3D.

Hi @Maxwell175! Could you file this as an issue on the issue tracker, and post all the code needed to reproduce it? Then we can look into fixing this issue.

Thanks for responding, @rdb. I filed a bug report with the complete code I used. Let me know if you need anything else.

Thanks for filing the bug. It’s fixed now. The fix will be in the upcoming 1.10.5 release, but if you can’t wait, you can try this build:
https://buildbot.panda3d.org/downloads/5eb40b90619060ee62ab43288646d4b4bb243c52/

I can confirm the fix works perfectly! Thanks a bunch!

However, I have gotten a report from one of the testers of the following error:

:display:gsg:dxgsg9(error): CreateVertexBuffer failed at (panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx:503), hr=D3DERR_INVALIDCALL: Invalid call
:display:gsg:dxgsg9(error): CreateVertexBuffer failed at (panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx:503), hr=D3DERR_INVALIDCALL: Invalid call
:display:gsg:dxgsg9(error): CreateVertexBuffer failed at (panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx:503), hr=D3DERR_INVALIDCALL: Invalid call
Assertion failed: _contexts == nullptr at line 299 of panda/src/gobj/geomVertexArrayData.cxx

Nobody else had this error, and even this person only had this crash once after a while of testing and could not reproduce it. Is it possible this error could be caused by low graphics memory? On the surface it doesn’t seem so.

Hmm, a little troubling. It’s not clear to me why this error would occur. I think it would fail with a different error if it were a memory allocation error. Is this happening with particle effects again?

No. The tester was changing zones. So I suppose a bunch of objects are getting removed and new ones added.

Before I start, let me note that I don’t know enough about DirectX or that specific error to be confident in the following; thus take this with much salt.

That said, the fact that the issue happened intermittently, and after some time had passed with the game running, and seemed related to changing zones, suggests to me the possibility that it might be a cleanup issue: either a memory leak, or loading resources before cleaning up the old ones.