Welcome, Guest. Please login or register.

What openbor you prefer: Double dragon,battletoads or final fight !? by lirexpatrio
[December 07, 2012, 07:15:27 pm]


what are your favorite games OpenBOR?! by lirexpatrio
[December 07, 2012, 07:09:46 pm]


Post Some Awesome Videos by maxman
[December 07, 2012, 05:51:39 pm]


Can @cmd playmusic "aaaa" 1 also increse music sound ? by BeasTie
[December 07, 2012, 05:24:38 pm]


Streets of Rage: Silent Storm by mtrain
[December 07, 2012, 03:45:05 pm]


Site will be down for maintenance on 12/8/2012 thru 12/10/2012 by Damon Caskey
[December 07, 2012, 07:42:42 am]


Cancelled SOR 3d Remake by riccochet
[December 07, 2012, 03:58:33 am]


Dungeon Fighter: B.O.R. by msmalik681
[December 07, 2012, 03:24:27 am]


[TUTORIAL] How to create 4 Games of OpenBOR in 1 CD (650 MB) by magggas
[December 06, 2012, 09:46:25 pm]


custknife by Bloodbane
[December 06, 2012, 09:34:09 pm]


blockfx help by B.Kardi
[December 06, 2012, 04:09:14 pm]


street of age 4 hd by corradlo
[December 06, 2012, 01:41:36 pm]


ClaFan - Classic Fantasy ver 1.17 by soniczxblade
[December 06, 2012, 05:01:20 am]


Bug Archive by Bloodbane
[December 06, 2012, 02:00:44 am]


"Bio-Doom" and "Gears of Doom" by BulletBob
[December 05, 2012, 10:07:21 pm]


Contra Locked 'N' Loaded v2 by Bloodbane
[December 05, 2012, 09:39:43 pm]


Downloadable OpenBoR Manual by BeasTie
[December 05, 2012, 08:31:24 pm]


Having trouble testing changes by B.Kardi
[December 05, 2012, 03:05:53 pm]


DragonBall Absalon by msmalik681
[December 05, 2012, 02:52:13 pm]


[Hi-Res] Swamp by Vibrant
[December 05, 2012, 10:47:14 am]


  • Dot Guests: 160
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.



Author Topic: Uncache and Recache  (Read 600 times)

0 Members and 1 Guest are viewing this topic.

Offline utunnels

  • Developer
  • Hero Member
  • *****
  • Posts: 2713
Uncache and Recache
« on: November 29, 2011, 10:55:31 pm »
Well it is an old subject.

I just got an idea. Leave the cache entries (sound or sprites) empty if the user forces a model to be uncached (either via script or a command), leaving only the file pathes.

Since strings are relatively smaller than sprites or samples, this may save lots of resources.

When the engine requests a sprite from an invalid handle, it can reload it according to the path, or you can use a recache command to reload resources from a model.

Thoughts?

Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: Uncache and Recache
« Reply #1 on: November 30, 2011, 11:07:34 am »
Quote
I just got an idea. Leave the cache entries (sound or sprites) empty if the user forces a model to be uncached (either via script or a command), leaving only the file pathes.
I would imagine that this would be the easiest solution to this feature with out the need to re-writing things and I can't imagine it ever being a problem for mods that have no inclination to use this feature at all.

Quote
When the engine requests a sprite from an invalid handle, it can reload it according to the path, or you can use a recache command to reload resources from a model.
I would imagine it reloading it on error by itself would be best but a option to disable it could be added and having a log entry would be very usefull as well.

Can't really add more as I don't know the back end of openBor.

Another thought, would it be possible to add entity loading via a thread using this solution?

Offline utunnels

  • Developer
  • Hero Member
  • *****
  • Posts: 2713
Re: Uncache and Recache
« Reply #2 on: November 30, 2011, 07:22:51 pm »
Threading is another story. If a program uses thread, it is likely many things need to be reworked,  like locking certain resources until a thread is done using them.
 And I don't know how portable it is, at least SDL has threading support, not sure about other platforms (it doesn't really matter if they don't, since there are already several features that can only be used on PC).
« Last Edit: November 30, 2011, 07:28:24 pm by utunnels »

Offline volcanic

  • Hero Member
  • *****
  • Posts: 706
  • Nobody
Re: Uncache and Recache
« Reply #3 on: November 30, 2011, 08:38:35 pm »
I totally agree with you, UT.
This reminds me the hard time when I optimized and shrike ATOV just to make it run on my Dingoo. I unloaded everything that uses only once but no luck lol.

To be a mature engine, it’s quite necessary to release resources as need.
Perhaps this is not that necessary for PC, but for most platforms especially consoles and heldhands which don’t have as much RAM as PC has, this is definitely essential.
But I don’t think you should leave the samples and scripts which might also occupy a lot of resources especially as the Mods go heavier and heavier with scripts nowadays. And the samples , needless to say, might be a better consumption of RAM.

Offline Plombo

  • Hero Member
  • *****
  • Posts: 1724
  • Your source for useful modding tools!
Re: Uncache and Recache
« Reply #4 on: November 30, 2011, 08:39:26 pm »
Threading is another story. If a program uses thread, it is likely many things need to be reworked,  like locking certain resources until a thread is done using them.
 And I don't know how portable it is, at least SDL has threading support, not sure about other platforms (it doesn't really matter if they don't, since there are already several features that can only be used on PC).

I think all the platforms have support for threads.  But they all have different threading systems, of course.

It might be possible to implement a common interface on top of the different threading systems for each platform like we do for sound, video, timer, etc.  But I don't know how well that would work since threading systems work in different ways.

Offline utunnels

  • Developer
  • Hero Member
  • *****
  • Posts: 2713
Re: Uncache and Recache
« Reply #5 on: November 30, 2011, 09:46:15 pm »
I've made the changes.

In next build you should be able to change the second parameter of the load command to 2 or 3 (in level txt or model txt, I don't recall other places).

While 1 unloads the model it self, 2 unloads sprites and 3 unloads both. Those level decorations (animated backgrounds) should be safe to use 3 and unused characters can use 2 to cut the reload speed (recaching animation sprites is much faster than loading the entire model).

I haven't considered mask sprites, but guess they are rare enough to be ignored for now.
And subclassed models are not taken care of either. (or should they?)


No script support yet, so if you want to unload a model, you have to wait until current level ends.



Edit*

This should work for script users to change the unload flag.

Code: [Select]
loadmodel("data/chars/someone.txt", 2);
« Last Edit: November 30, 2011, 10:06:39 pm by utunnels »

Offline volcanic

  • Hero Member
  • *****
  • Posts: 706
  • Nobody
Re: Uncache and Recache
« Reply #6 on: November 30, 2011, 10:42:29 pm »
Really appreciate that UT.

Offline Bloodbane

  • Hero Member
  • *****
  • Posts: 7113
  • Dark Dragon
Re: Uncache and Recache
« Reply #7 on: November 30, 2011, 10:55:59 pm »
 What's the difference between unloading model and unloading sprites?

 Anyways, thanks ! :)
OpenBoR Manual

Basic OpenBoR Tutorials

OpenBoR Tricks & Tutorials

"The more often enemies attack, the more open they are to counter attacks"

Offline utunnels

  • Developer
  • Hero Member
  • *****
  • Posts: 2713
Re: Uncache and Recache
« Reply #8 on: November 30, 2011, 11:01:02 pm »
Unloading model will keep the sprites.
When you reload the model later, the sprites are taken from previously loaded ones.

Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: Uncache and Recache
« Reply #9 on: December 01, 2011, 01:56:01 pm »
Thanx uT. Will put this to the test ASAP!

 



 0%




mighty
SimplePortal 2.3.3 © 2008-2010, SimplePortal