Game Development Community

My game crashes when playing any particle on Xbox 360

by Diego Santos Leao - GameBlox Studio · in Torque X 2D · 01/08/2009 (7:29 pm) · 23 replies

This problem is easy to explain: I have a particle on my game (marked as template), that appears when I kill an enemy ship. The exact moment the particle appears on screen, the game crashes!

I tried four different games I've made with TX2D, all of them freezes when displaying particles, some are able to display 2 or 3 instances of the particles, but then the game freezes. So, I guess it is a common problem... although I can't find any related topics here...

Bellow I'm sending you the code that freezes:

T2DSceneObject explosionTemplate = (T2DSceneObject)TorqueObjectDatabase.Instance.FindObject("Explosion");
T2DSceneObject explosion = (T2DSceneObject)explosionTemplate.Clone();
explosion.Position = this.Position;
TorqueObjectDatabase.Instance.Register(explosion);

I'm just cloning templates here, and then registering them on torqueobjectdatabase, nothing fancy...
Page «Previous 1 2
#1
01/10/2009 (5:39 pm)
No one here ever had this problem? :P

Can someone post a correct use of particle instantiation here (as a zipped project) so I can open it and test on my xbox?

I tryied the search, but searching here is **very** difficult.. some topics never appears even if you use the right search criteria.
#2
01/10/2009 (7:36 pm)
Hi Diego:

I don't have a direct answer to your question (because I've never tried it). However, John Kanalakis recently released a game for review for CC testing and it successfully uses particle effects on the Xbox 360 (the timer bar to the left has a star-like particle effect). You might be able to ask your question to him directly, the blog post about his game is here: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=15809.
#3
01/10/2009 (9:15 pm)
Thanks for the tip Lucas, I just emailed him on the subject :) If anyone have any other tip that might help please post, I really need it... I intend to post the source code of a remake of Drone Swarm I'm coding, but can't do it until I figure this out...

Thanks!
#4
01/11/2009 (1:15 am)
Message received - in the interest of community, I've copied my email reply to Diego below.

Diego,

Sorry to hear about your trouble with particles. Can you please pull down Solicheck from here: www.envygames.com/tx3/Solicheck_Xbox360.ccgame ? This game uses 3 particle effects - one that moves with the countdown timer - anoter when a plain game piece is jumped - and the last when you land on a bonus piece. Do any of these work for you on Xbox 360 or do they freeze too? The code that powers them is a little different and I can pull together the relevant pieces of code. The main difference is that these three paticle effects are not templates, but rather created at design time (and therefore appear automatically at load time) off screen. Then, when the event happens, I move them to the desired position in code and play the effect (the effect set to play once). That being said, I believe the code fragment you posted in the forum looks fine and I'm not sure why that is not working. So please try this...

1. Let me know if solicheck works on your Xbox 360 - that's going to tell a lot.

2. Tell me about your particle materials - are they HUGE 1024x1024 PNG files or something?

3. Try creating an offline instance of the particle (not a template) for your scene - do they render on screen at the start of the game?

4. I'll pull together some material, but it will take a couple days (Monday) is the soonest I can get to it - and I'll need a reminder email

5. Add more description about the crash - is there a message? exception thrown? Do you have a pro license that can set low-level break points?

John K.
#5
01/11/2009 (1:41 am)
Quick update - I took a few minutes to create from scratch a very basic example. It runs on Windows and Xbox (at least for me). The game is simple, move your round GGLogo image (player) into the streched GGLogo image (wall) and see GGLogo particle explosion. You can get the .zip file with game code and compiled binaries here.... www.envygames.com/share/ParticleCloneTest.zip

The XML defines the particle effect as a template. In the MovementComponent, I added a custom collision delegate (ApplyDamage of type T2DOnCollisionDelegate) that is set on the T2DCollisionComponent attached to the player. When the OnCollision delegate hits, all it does clone the effect, set the position to the player, set to play the effect, and then register the object.

Pretty simple. If this example doesn't work for you, then we need to keep digging. Good Luck!

John K.
#6
01/11/2009 (7:18 am)
Hi John, thanks for your time! Let's go:

Because I didn't have xna 3.0 installed, I had to copy your source code to a XNA 2.0 project. Unfortunatelly the game still crashes. The project I used can be downloaded here:
http://www.megaupload.com/pt/?d=C0HEIFRH

Now, the answers:
1. I can't download the ccgame from the link you provided ("The page cannot be found"). I tryied to play the one from your blog post: http://www.envygames.com/public/Solicheck_Xbox360.zip, but the playtest time was expired.
2. No, only small png images.
3. Yes they do. But when I try to move them the position I want them to be (as you said you did), the game freezes. I also can't make copies of non template particles, because it gives me an error saying that I should implement "particle.Age = this.Age" in the CopyTo method of the particle.
4. Ok, I'll send the reminder ;)
5. Yes an exception occurs, and no, I don't have a pro license yet... The exception doesn't give much detail about the problem, it's details are not accessible, only the following message can be read:

"
An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.Xna.Framework.dll

Additional information: 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.
"
#7
01/11/2009 (11:39 am)
BIG EDIT: I posted a few hours ago that the problem was solved. It wasn't.

I managed to solve it for a simple example, by putting the particle on a different layer then my sceneobjects.
But, to make things worse, I noticed that the problem reappears in at least three cases:
* If I put other particles on the same layer as the old one
* If I put particles on the first layer (zero)
* If I set the particles in particular orders: for example, there is a particle in my game that I'm putting on layer 10, and another on layer 11. If I switch them (from 10 to 11, and 11 to 10), the exception is shown.

As I have more or less 10 particles on my game, it is not pratical to try all the combinations of layers just to make it work.

I just wasted two whole days trying to fix this... even postponed a date with my girlfriend... :(
You don't want to be me :(
#8
02/20/2009 (7:52 am)
CAN A GARAGE GAMES EMPLOYEE >>>>>>>PLEASE<<<<<<< ANSWER THIS?????????????
WE ABOSOLUTELLY NEED THIS WORKING!!!

Other people including me are having the same BLOCKING ISSUE (sorry):
http://www.garagegames.com/community/forums/viewthread/77304
http://www.garagegames.com/community/forums/viewthread/77962
http://www.garagegames.com/community/forums/viewthread/82275
http://www.garagegames.com/community/forums/viewthread/77315

It is very frustrating to see this kind of BLOCKING issue being COMPLETELLY IGNORED by garage games! I have this problem for more than six months already!

PS: I'm going to post this same text on every quoted forum thread that complained about this problem as a way to draw atention to this pressing matter. Sorry, I'm forced to do so, can't wait another six months.
#9
03/10/2009 (5:20 pm)
Hey Diego, I have the same problem. However, if John's is working in XNA 3.0, then perhaps it's been fixed in Torque X 2D. I assume John's got some inside super cool edition of TX2D since he wrote the book on it. :)

So maybe you're not getting a response because the bug has been fixed in the next release, whenever that may be (fingers crossed for GDC).

At least, I hope that's why. I put some particles in and I am feeling your pain :(

#10
03/10/2009 (7:05 pm)
I discovered you can test your game without problems if you set up your xbox' video configuration to 720p. You can use this "temporary solution" to test your game while the fix is being done (if there is someone working on it... I never received an answer for my bug report).
#11
05/10/2009 (9:29 am)
hey ya it's crashing on me too
I haven't tried the 720p workaround yet
#12
07/21/2009 (8:34 pm)
Me too.. anyone know of a fix yet?
#13
07/22/2009 (12:46 am)
I remember getting that message about "You may not modify a resource that has been set on a device..." before when I was coloring a material in code. The error came because the texture was sometimes still locked for the GraphicsDevice, which prevented GetData() from working. SetData() will also not work, because either way it is trying to access a "locked" resource.

Looking in the source for the TX2D Particle effect files, I found only one place where either of those methods are used: in T2DParticleEffect.cs, in the Render() method. In there, it uses SetData() to put data into the vertex and index buffer. It is possible one or both of those resources are locked at some point causing the crash.

But I don't have an XBOX and so can't confirm this. Maybe someone who has the TX source and an XBOX can recreate this crash and see if this is indeed the place where it crashes. We could then possibly see a way to unlock the locked resource and fix the crash.
#14
07/22/2009 (6:27 am)
Scott is correct about the specific code where the error is occuring, this is how I resolved it:

If you have UseDisplaySizeforBackbuffer set to true then TX uses a backbuffer at the resolution of the players tv screen, which means you are responsible for drawing everything the correct size in your draw methods.
I set UseDisplaySizeForBackbuffer to false then set preferred back buffer width and height to 1280x720. This lets me have a set format I design and draw everything at, allows the xbox to auto-resize (or letterbox) the screen for the players screen size on the backend, stopped all the crashes, and the GUI's now work as I designed them.
#15
07/22/2009 (8:06 am)
Excellent, Tom. Thanks!
#16
07/22/2009 (4:21 pm)
Does anyone else think this might be a predicate tiling problem?

Every solution I've seen posted to this problem has something to do with reducing the size of the backbuffer:

- switch from 1080 to 720 (two of those solutions in here)
- turning off multisampling / UseDisplaySizeForBackbuffer(TileLayer issue with this problem, also fix proposed here by Tom)

With these facts, it seems like anything above 720 for most people is kicking in predicate tiling on the Xbox, and there are some special considerations to take into account about predicate tiling when it kicks in mainly this (from the MSDN predicate tiling documentation):

Specifically, in the Draw method of an Xbox 360 game, vertex buffers, index buffers, and textures should not be written to using SetData during the Draw method. This condition may lead to graphics corruption or crashes. For vertex buffers, this issue can be avoided by using DrawUserPrimitives or DrawUserIndexedPrimitives as the preferred alternative to VertexBuffer.SetData for dynamic vertex generation.

It would be nice to find this out, because there hasn't been a solution I've seen yet allows a fix for 1080 resolutions, which I would like to do at some point :)

If I have some time I'll run some tests on this with my Xbox and perhaps have some more information.
#17
07/22/2009 (10:23 pm)
Wow, nice find, Lucas. In reading that MS article, that does sound like what's going on, particularly about not using SetData. If you can get it to work using the suggested DrawUserPrimitives or DrawUserIndexedPrimitives please fill us in.
#18
07/23/2009 (7:19 am)
Ok, so this indeed seems more like a predicate tiling issue after testing.

I made an example project of the tile layer issue I posted above. I forced a backbuffer use of 1920x1080 and also enabled multi sampling. I filled the whole scene with a single tile layer. Running this scenario had no problems on PC, however running this on the Xbox causes the exception Scott mentions.

Running the tile layer at 1920x1080 without multisampling works, I'm guessing that the render target hasn't exceeded the Xbox's limitation of 10MB so predicate tiling hasn't kicked in yet.

As for a solution, I'm not sure how to go about this. It looks like according to Torque X's architecture there is a SceneManager that manages a collection of RenderInstances. For the T2DTileLayer, these RenderInstances are created in the Render() function and are queued onto the SceneManager via the SceneRenderer.RenderManager.AddInstance() method. In the T2DTileLayer there is both a VertexBuffer and IndexBuffer that are allocated and set every frame. References to these buffers are maintained in the RenderInstance which the SceneManager then uses later on to render using DrawUserPrimitives / DrawUserIndexedPrimitives.

The solution proposed in the MSDN article seems to state to not allocate memory on the GPU via Index/Vertex Buffers but to instead send the data allocated on the CPU directly to the GPU.

In short, there are a few issues:
- Torque X's architecture relies on the use of Vertex/Index buffers within RenderInstances, which are later rendered by the SceneManager. A lot of refacting will need to be done to break this dependency.

- If the architecture was refactored to fix this problem, there are limitations that will come from not using the buffers such as data limitations, as Sean Greaves describes here.

- There are also performance considerations, from using buffers vs not using buffers (i.e., use of DrawUserPrimitives vs DrawPrimitives) which Sean Greaves describes in the same post linked above.

Ok, I better stop here before I go over the character limit :)
#19
11/18/2009 (1:29 am)
The XML defines the particle effect as a template. In the MovementComponent, I added a custom collision delegate (ApplyDamage of type T2DOnCollisionDelegate) that is set on the T2DCollisionComponent attached to the player. When the OnCollision delegate hits, all it does clone the effect, set the position to the player, set to play the effect, and then register the object.
regards,
girlie

_______________
Simulation pret
#20
06/25/2010 (4:39 pm)
Can someone please let me know if this issue still exists in the current Beta of TX 2D
Page «Previous 1 2