Exception in T3DParticleEmitter when Engine.Settings.EnableBackBufferEffects is set to false [with workaround]
by Trent · in Torque X 3D · 12/10/2009 (2:27 am) · 5 replies
Exception was on line 772: _vb.Instance.SetData<GFXVertexFormat.PCTTBN>(v, 0, _vbSize);
in method: private void _CopyToVB(GraphicsDevice d3d, Matrix camToWorld, out VertexBuffer vb, out IndexBuffer ib, out int numVerts, out int numPrimitives)
System.InvalidOperationException was unhandled
Message="The operation was aborted. You may not modify a resource that has been set on a device, or after it has been used within a tiling bracket."
Source="Microsoft.Xna.Framework"
StackTrace:
at Microsoft.Xna.Framework.Helpers.GetExceptionFromResult(UInt32 result)
at Microsoft.Xna.Framework.Graphics.VertexBuffer.CopyData[T](Int32 offsetInBytes, T[] data, Int32 startIndex, Int32 elementCount, Int32 vertexStride, UInt32 options, Boolean isSetting)
at Microsoft.Xna.Framework.Graphics.VertexBuffer.SetData[T](Int32 offsetInBytes, T[] data, Int32 startIndex, Int32 elementCount, Int32 vertexStride)
at Microsoft.Xna.Framework.Graphics.VertexBuffer.SetData[T](T[] data, Int32 startIndex, Int32 elementCount)
at GarageGames.Torque.T3D.T3DParticleEmitter._CopyToVB(GraphicsDevice d3d, Matrix camToWorld, VertexBuffer& vb, IndexBuffer& ib, Int32& numVerts, Int32& numPrimitives) in C:TrentProjectsXNATXTXTorque3DT3DT3DParticleEmitter.cs:line 772
at GarageGames.Torque.T3D.T3DParticleEmitter.Render(SceneRenderState srs) in C:TrentProjectsXNATXTXTorque3DT3DT3DParticleEmitter.cs:line 336
at GarageGames.Torque.T3D.T3DParticleEffectComponent.Render(SceneRenderState sceneRenderState) in C:TrentProjectsXNATXTXTorque3DT3DComponentsT3DParticleEffectComponent.cs:line 181
at GarageGames.Torque.T3D.T3DSceneComponent.Render(SceneRenderState sceneRenderState) in C:TrentProjectsXNATXTXTorque3DT3DComponentsT3DSceneComponent.cs:line 498
at GarageGames.Torque.T3D.T3DSceneGraph._RenderObjects(TorqueObjectType renderMask, Single aspectRatio) in C:TrentProjectsXNATXTXTorque3DT3DT3DSceneGraph.cs:line 194
at GarageGames.Torque.SceneGraph.BaseSceneGraph.PreRender(GFXDevice gfx, TorqueObjectType renderMask, TorqueObjectType noRenderMask, Single aspectRatio) in C:TrentProjectsXNATXTXTorqueCoreSceneGraphSceneGraph.cs:line 585
at GarageGames.Torque.GUI.GUISceneview.OnRender(Vector2 offset, RectangleF updateRect) in C:TrentProjectsXNATXTXTorqueCoreGUIGUISceneview.cs:line 121
at GarageGames.Torque.GUI.GUICanvas.OnRender(Vector2 offset, RectangleF updateRect) in C:TrentProjectsXNATXTXTorqueCoreGUIGUICanvas.cs:line 253
at GarageGames.Torque.GUI.GUICanvas.RenderFrame() in C:TrentProjectsXNATXTXTorqueCoreGUIGUICanvas.cs:line 162
at GarageGames.Torque.XNA.TorqueEngineComponent.Draw(GameTime gameTime) in C:TrentProjectsXNATXTXTorqueCoreXNATorqueEngineComponent.cs:line 564
at Microsoft.Xna.Framework.Game.Draw(GameTime gameTime)
at GarageGames.Torque.GameUtil.TorqueGame.Draw(GameTime gameTime) in C:TrentProjectsXNATXTXTorqueCoreGameUtilTorqueGame.cs:line 413
at Microsoft.Xna.Framework.Game.DrawFrame()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.Run()
at StarterGame3D.Game.Main() in C:TrentProjectsXNATXTXGameGame.cs:line 52
InnerException:
in method: private void _CopyToVB(GraphicsDevice d3d, Matrix camToWorld, out VertexBuffer vb, out IndexBuffer ib, out int numVerts, out int numPrimitives)
System.InvalidOperationException was unhandled
Message="The operation was aborted. You may not modify a resource that has been set on a device, or after it has been used within a tiling bracket."
Source="Microsoft.Xna.Framework"
StackTrace:
at Microsoft.Xna.Framework.Helpers.GetExceptionFromResult(UInt32 result)
at Microsoft.Xna.Framework.Graphics.VertexBuffer.CopyData[T](Int32 offsetInBytes, T[] data, Int32 startIndex, Int32 elementCount, Int32 vertexStride, UInt32 options, Boolean isSetting)
at Microsoft.Xna.Framework.Graphics.VertexBuffer.SetData[T](Int32 offsetInBytes, T[] data, Int32 startIndex, Int32 elementCount, Int32 vertexStride)
at Microsoft.Xna.Framework.Graphics.VertexBuffer.SetData[T](T[] data, Int32 startIndex, Int32 elementCount)
at GarageGames.Torque.T3D.T3DParticleEmitter._CopyToVB(GraphicsDevice d3d, Matrix camToWorld, VertexBuffer& vb, IndexBuffer& ib, Int32& numVerts, Int32& numPrimitives) in C:TrentProjectsXNATXTXTorque3DT3DT3DParticleEmitter.cs:line 772
at GarageGames.Torque.T3D.T3DParticleEmitter.Render(SceneRenderState srs) in C:TrentProjectsXNATXTXTorque3DT3DT3DParticleEmitter.cs:line 336
at GarageGames.Torque.T3D.T3DParticleEffectComponent.Render(SceneRenderState sceneRenderState) in C:TrentProjectsXNATXTXTorque3DT3DComponentsT3DParticleEffectComponent.cs:line 181
at GarageGames.Torque.T3D.T3DSceneComponent.Render(SceneRenderState sceneRenderState) in C:TrentProjectsXNATXTXTorque3DT3DComponentsT3DSceneComponent.cs:line 498
at GarageGames.Torque.T3D.T3DSceneGraph._RenderObjects(TorqueObjectType renderMask, Single aspectRatio) in C:TrentProjectsXNATXTXTorque3DT3DT3DSceneGraph.cs:line 194
at GarageGames.Torque.SceneGraph.BaseSceneGraph.PreRender(GFXDevice gfx, TorqueObjectType renderMask, TorqueObjectType noRenderMask, Single aspectRatio) in C:TrentProjectsXNATXTXTorqueCoreSceneGraphSceneGraph.cs:line 585
at GarageGames.Torque.GUI.GUISceneview.OnRender(Vector2 offset, RectangleF updateRect) in C:TrentProjectsXNATXTXTorqueCoreGUIGUISceneview.cs:line 121
at GarageGames.Torque.GUI.GUICanvas.OnRender(Vector2 offset, RectangleF updateRect) in C:TrentProjectsXNATXTXTorqueCoreGUIGUICanvas.cs:line 253
at GarageGames.Torque.GUI.GUICanvas.RenderFrame() in C:TrentProjectsXNATXTXTorqueCoreGUIGUICanvas.cs:line 162
at GarageGames.Torque.XNA.TorqueEngineComponent.Draw(GameTime gameTime) in C:TrentProjectsXNATXTXTorqueCoreXNATorqueEngineComponent.cs:line 564
at Microsoft.Xna.Framework.Game.Draw(GameTime gameTime)
at GarageGames.Torque.GameUtil.TorqueGame.Draw(GameTime gameTime) in C:TrentProjectsXNATXTXTorqueCoreGameUtilTorqueGame.cs:line 413
at Microsoft.Xna.Framework.Game.DrawFrame()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.Run()
at StarterGame3D.Game.Main() in C:TrentProjectsXNATXTXGameGame.cs:line 52
InnerException:
About the author
#2
12/10/2009 (2:41 am)
Something a bit wierd going on with the forums at the moment... I wont try posting it in bug submissions again...
#3
Oh the VertexBuffer says it's size is 384 bytes.
It doesn't seem to matter whether I have 1 or 10 particle emitters going, the values are the same. The values are the same with or without EnableBackBufferEffects, so I'm guessing that there is something being done in the post processor that is not getting done when you set EBBE to false?
12/10/2009 (2:42 am)
Ok, _vbSize == 6, but the array passed in via parameter v (of type PCTTBN in this case) is 8190 elements long. is this normal?Oh the VertexBuffer says it's size is 384 bytes.
It doesn't seem to matter whether I have 1 or 10 particle emitters going, the values are the same. The values are the same with or without EnableBackBufferEffects, so I'm guessing that there is something being done in the post processor that is not getting done when you set EBBE to false?
#4
12/10/2009 (8:31 am)
Doing some debugging of this, it appears that SetData<>() is called on the same vertex buffer more than once in the same frame, but only if EBBE is true.
#5
Got the idea from this thread: http://forums.xna.com/forums/p/6723/35536.aspx#35536
12/10/2009 (9:42 am)
Ok I have a work around that goes in your Game.cs:protected override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
GarageGames.Torque.GFX.GFXDevice.Instance.Device.Vertices[0].SetSource(null, 0, 0);
}Got the idea from this thread: http://forums.xna.com/forums/p/6723/35536.aspx#35536
Torque Owner Trent