Commit Graph

40 Commits

Author SHA1 Message Date
wagic.the.homebrew@gmail.com
66a505969e Erwan
- fix issue 215
- added test for purple screen (this is the small white square on top of the loading screen)
2009-11-23 08:25:27 +00:00
wagic.the.homebrew@gmail.com
e059890446 Erwan
-reduced SFX Quality. This seems to fix the Bug with samples getting silent on the PSP (issue 112), and improves loading times. If you think this is unacceptable, let's discuss it
- AI now should play fetchlands' ability, although still not "efficiently"
- Fix a bug where the game would crash if a card has a valid alias to a hardcoded card that is in no _cards.dat (starwars mod cards aliasing a MTG card)
2009-11-12 11:39:47 +00:00
wagic.the.homebrew@gmail.com
f33d37d9f2 Erwan
-attempt at fixing shop crash introduced in r1231 (size needed in ram divided by 4)
2009-11-04 13:33:21 +00:00
wagic.jeck
3347fd020b Jeck - Removed some unused bits of code, added zip support to themes' card overrides. @Jean, please check WResourceManager::dirOK() on Linux.
This needs some impact testing, to be certain it doesn't noticeably slow anything down. In a future version I'd like to memoize checking for zip file existence in each "Res/sets/XXX/" directory once during boot, and in the themed directory whenever switching themes.
2009-10-28 04:06:45 +00:00
wagic.jeck
fb7f48f26b Jeck - Please review: this makes minor changes to a lot of files, and major changes to the WCache flatten() function.
* Removed all calls to Release(JQuad*).
* Updated flatten(). Prior flatten was buggy beyond belief.
* Done some extensive testing, but if this causes more trouble than it fixes, we'll have to revert. It's too close to release time.
2009-10-27 02:46:39 +00:00
wagic.jeck
8e0bcef6e9 Jeck - Removed a ton of unreached or unused code from the cache, to make debugging easier. None of this actually effects execution at all. Some of these functions (though not many) are potentially useful, but as they aren't actually used there's no reason to have them cluttering up the files. 2009-10-26 05:55:52 +00:00
wagic.jeck
7f7320f904 Jeck - Some basic options handling rewrites, main menu update, example alternate theme (for testing). I'm closing issues 44 and 45, as hopefully this resolves them satisfactorily.
* The alternate theme is just useful for testing themes, but please comment on the changes to the main theme.
 * Options reading and initializing separated from UI.
 * Options UI abstracted a bit, made more easily extensible.
 * With some extension, the options UI could be used as the basis for more complicated themes, if we load a file and use it to do stuff like GameStateOptions::Start()
2009-10-20 03:46:18 +00:00
wagic.the.homebrew@gmail.com
273b0672e4 Erwan
- various optimization fixes
2009-10-19 11:37:47 +00:00
wagic.the.homebrew@gmail.com
97a0732682 Erwan
- Fix issue 97. Please review. How about performance ?
2009-10-15 13:58:35 +00:00
wagic.the.homebrew@gmail.com
6f159fb39c Erwan - cache fixes - Code review highly appreciated, please criticize my code!
- fix issue 65 (quads when no image  load slowly in shop/deck editor)
- Possibly fix issue 92, please let me know if it reproduces
- Fix issue 97 (Deck editor: weird behavior of deck display)
- Fix issue 39 - please verify
- Issue 56 can probably be closed as well
- Fix issue 86
2009-10-13 14:16:30 +00:00
wagic.jeck
d9786dfdc2 Jeck - (Probable) fix for issue 41. Turns out AttachZipFile is very robust, and already handles all the unattach / reattach optimizing & checking for us. 2009-09-22 05:33:01 +00:00
wagic.jeck
6de4f5612e Jeck - Resource manager zipfile fix.
* Only attaches when necessary.
2009-09-21 06:59:28 +00:00
wagic.jeck
20b41ab569 Jeck - Larger small cache size, to reduce likelihood of issue 39. 2009-09-21 00:02:10 +00:00
wagic.jeck
8c9374fe1f Jeck - GameStateMenu releases background image from cache, minor cache fixes. 2009-09-20 23:56:08 +00:00
wagic.jeck
e0b225bad9 Jeck - TEMPORARY enabling of exceptions. (~6hrs) Sorry, I've been an idiot lately and coded myself into a corner with stuff that "should only take a minute" to fine tune. I honestly shouldn't have committed r871+, but I'd sworn to high heaven that the damn thing was fixed. In reality getting the cache 100% needs a bit more time, so I'm committing this in the hopes that it'll prevent sloppy cache work from interrupting other people's coding.
Exception handling in the cache means that Wagic runs slightly, but noticeably slower. However, it also means that the cache works the way it was intended to, and should prevent all sorts of awkward errors I introduced because things were half-allocated or worse. 

I've learned my lesson from tonight, and once I get this stuff put back together without exception handling I think I'll self-impose a manditory 24 hours debugging time before any commits. Sorry for the inconvenience. 

If for some reason you can't compile with exceptions, r862 should be completely without them. Again, wow, this was stupid-- I hadn't even realized exceptions were off for like 24 hours, as the compiler wasn't producing warnings. 

Apologies,
—Jeck
2009-09-20 03:10:34 +00:00
wagic.jeck
1ba7f108b0 Jeck - Cache is using map<> again. The implementation is cleaner and seems a little faster. 2009-09-19 23:20:43 +00:00
wagic.jeck
8cc9bff484 Jeck - Stricter cache limits. 2009-09-19 22:34:48 +00:00
wagic.jeck
0d3686e65a Jeck - Cache fix, booster duplicate fix.
* Restored OptionItem saving fix.
 * Booster duplicate replacement was picking random cards from the wrong set. My fault, but I've fixed it :)
 * The problem with cache had nothing to do with memory fragmentation, but I've switched to an array rather than map<> just in case. The actual issue was that in GameStateDeckViewer, I'd given the cache unlimited space, thinking that AttemptNew would recover from any bad_allocs. Unfortunately, the image loading routines and similar stuff called by various implementations of WResource::Attempt() could fail halfway through, leaking memory. 

The temporary solution is to set a proper limit (8000000 px, more or less) and (in case we still run out of memory) test to make certain CACHE_SPACE_RESERVED can be malloc'd/free'd. The proper solution would be to keep byte-perfect records of memory used (right now we're kinda fuzzy-- we track pixels per image and bytes per sound, but not the space for jquads or other incidentals) instead of testing a malloc, and potentially cleaning up all calls inside of Attempt() so they fail without leaks. That's what I'm working on now.

Still, it's nice to have identified the problem. This version of the cache should be fully functional, it's just a bit inelegant.
2009-09-19 21:11:35 +00:00
wagic.jeck
4b8d344bcd Jeck - Card ID collisions, cache fixes, cache deleted pooling.
* mtgid now defaults to 0.
 * TextScroller will not update when empty.
 * Cache now moves WCachedResources we're finished with to a garbage pool for later use (to reduce memory fragmentation). 
 * Demo still crashes... but I'm thinking that has to do with fragmentation, not a leak?
2009-09-19 01:48:42 +00:00
wagic.jeck
8ba34dafca Jeck - WResourceManager / Cache should now be leak free. Demo mode still crashes around EnstackBlocker. 2009-09-18 01:20:46 +00:00
wagic.jeck
505ee8d1eb Jeck - I somehow managed to break the test suite. Rolled back my changes to r843, won't commit until they're properly debugged. 2009-09-15 01:53:02 +00:00
wagic.jeck
a84ed94954 Jeck - Cache Leakfix. Quads now individually lock/unlock. Demo still crashes PSP. 2009-09-14 20:54:49 +00:00
wagic.jeck
5467fd379f Jeck - Signed/unsigned fix in resource manager, options save fix. 2009-09-14 18:30:47 +00:00
wagic.jeck
d55fc91112 Jeck - [Requires JGE rebuild] Extensive cache improvements.
* Numerous cache fixes, reduced filesystem access.
 * Cache fails very gracefully. 
 * Cache is now a templated class, with individual caches per data-type.
 * Much easier to extend.
 * Extensively debugged. Try compiling with -DDEBUG_CACHE.
 * Caches limits can be set on a per-item basis.
 * hgeParticleSystemInfo are now cached, mana particles now fall back to defaults.
 * Samples are not cached, but track filesystem misses using the cache backbone. 
 * Avatars are cached. Default baka avatar is now baka.jpg, to prevent collision with player.

A note on the retrieval types: 
  RETRIEVE_MANAGE puts a resource into a seperate, managed resource list.
    Managed resources are guarenteed valid for the lifetime of the program. 
    Retrieving a managed quad promotes the associated texture to managed. Don't do that by mistake.
    Calls to Resources.Refresh() will attempt to reload managed resources in place.

  RETRIVE_LOCK (and by extension, RETRIEVE_VRAM), returns a resource after locking it.
    A resource may have many locks, and remains in cache until they are all released. 
    If the resource is managed, it returns it unmodified.

A note on quads:
Unlike all other RetrieveWhatever() functions, the default behavior for RetrieveQuad is RETRIEVE_LOCK. Worse, Release(JQuad*) is slow, and will /always/ release one lock from the associated texture.   

There's a long and complicated explanation for this, involving support for live relinking of textures to existing quads, but basically what it means is that we only use RetrieveQuad for quads we intend to store and later Release(). If a temporary quad is needed, the preferred method is to use NEW JQuad* and SAFE_DELETE with RetrieveTexture(). RetrieveTempQuad is also provided, but is only guaranteed until the next call to the cache.

Note that RetrieveCard has none of these problems.
2009-09-14 08:28:49 +00:00
wagic.jeck
9d203619aa Jeck - Extremely minor speedup for cache access in GameStateDeckViewer, minor fix to WResourceManager::cleanup(). 2009-09-11 08:17:05 +00:00
wagic.the.homebrew@gmail.com
c0be024093 Erwan
- Put back delayed loading functionality for the Deck editor
2009-09-09 13:51:29 +00:00
wagic.jeck
4993cc5dea Jeck - Cache now pretty damn near guarantees successful retrieval.
* The only fail condition is if all resources are locked, or the file doesn't exist at all.
2009-09-09 05:02:08 +00:00
wagic.jeck
e3d86f0824 Jeck - Improved cache size tracking. 2009-09-09 00:15:33 +00:00
wagic.jeck
ad7006e2de Jeck - Profile and cache improvements, booster duplicate likelihood reduced.
* Cache now tracks missing textures for RetrieveQuad, not just RetrieveCard/RetrieveTexture.
* Profile options are no longer overwritten when switching profiles.
* Main menu notifies of alternate profile- "Database: X" becomes "Profile: Y of X cards."
* Boosters iterates through cards, replacing duplicates. Stops after 15 tries to prevent infinite loops on small sets.
* Very simplistic theme switcher, only displays when alternate themes are present.
2009-09-08 03:23:19 +00:00
wagic.jeck
62be1e1c72 Jeck — Cache refresh functionality, forcing in situ reload of textures.
* Changing profiles will now reload graphics, in case the profile has a different theme/mode/whatever.
2009-09-04 22:33:39 +00:00
wagic.jeck
78b9d61baf Jeck - Crashfix for cache, proposed replacement for icon.png
* Please comment on new icon.png with any suggestions.
* Prevents RemoveOldestTexture from deleting things it shouldn't
2009-09-04 20:41:31 +00:00
wagic.jeck
0689b01536 Jeck - WResourceManager now tracks filesystem misses for cards (up to MAX_CACHE_OBJECTS) and sfx, so disk use is much reduced. 2009-09-03 21:52:41 +00:00
wagic.jeck
8340fdbd5b Jeck - It wasn't emptying the cache properly, so this is a step in the right direction. I'll keep looking for more issues, though. 2009-09-03 18:21:57 +00:00
wagic.jeck
f220d2e9b9 Jeck - Cache and resource manager merged, streamlined.
This is pretty major, so there'll probably be something wrong with it... even though I did spend a few hours looking.
NOTES:
 * If you've Retrieved it, don't delete it--- Use resources.Release(Whatever). 
    Textures automatically release subordinate quads.
 * Most of the time, use resources.RetrieveQuad to grab a quad. Should handle everything for you.
    RetrieveQuad will load the required texture, if needed.
    Only managed resources have a resource name ("back", "simon", etc). 
    Managed resources can be retrieved with GetTexture/GetQuad/GetWhatever.
    Non managed quads lookup by position/dimensions, defaulting to the whole texture.
 * Use resources.RetrieveTexture only when you need to do something special to it. 
    Calling retrieve texture with RETRIEVE_MANAGE will permanently add a texture to the manager
    RETRIEVE_LOCK and RETRIEVE_VRAM will lock a texture. It will not leave the cache until
    Release(JTexture*) is called, or as a last resort during cache overflow.
 * Try to only store (as a class member) pointers to textures retrieved with RETRIEVE_MANAGE. 
    All others may become invalid, although locked textures do have a high degree of stability. It's
    pretty safe to store a locked texture if you're not going to load much between uses.

There's a lot going on here, so I might have missed something... but it runs through the test suite alright.

TODO: 
 * When called without any arguments, RetrieveQuad sometimes leaves a thin border around the image. 
    This can be bypassed by specifying a quad one or two pixels less than the image size. Why?
 * I've had a crash while runing the Demo mode, something to do with receiveEventMinus? 
    This hasn't exactly reproduced on a clean SVN copy, (being a hang, rather than a crash) so 
    I've probably done something to worsen the problem somehow? I'll look into it tomorrow.
 * Clean up lock/unlock system, memory usage. Streamline interface, consider phasing out calls using GetWhatever() format.
2009-09-03 09:28:16 +00:00
wagic.the.homebrew@gmail.com
0454fb20ec Erwan
- fixed textures cache bug
- fixed one card in TMP
2009-08-31 12:22:43 +00:00
wagic.jeck
62e12380a4 Jeck - Stopgap update fixing WResourceManager slowdown until complete rewrite. 2009-08-27 23:24:55 +00:00
wagic.jeck
c5b530bd3b Jeck - Forgot to commit headers. Ooops. 2009-08-27 14:13:39 +00:00
wagic.the.homebrew@gmail.com
99aa284431 Erwan
-code cleanup
-memory leaks fixes
2009-08-27 13:32:12 +00:00
wagic.jeck
807eea7ddb Jeck - As prior, but for sounds and music as well. Use CommonRes->ssLoadMusic / CommonRes->ssLoadSample. 2009-08-27 06:31:38 +00:00
wagic.jeck
5e14efed3c Jeck - CommonRes transparently finds themed versions of files. Use JRenderer::LoadTexture for unthemed files, and CommonRes::LoadTexture for themed files. Res/graphics/back.jpg renamed to Res/graphics/backdrop.jpg due to collision with sets/back.jpg. 2009-08-27 05:58:26 +00:00