Monday, April 30, 2007

R11 almost ready

Following on from last week's work, I've been busy fixing a few more issues relating to the way Daedalus handles textures.

To start with, I refactored the way that n64-format textures are converted to psp-format textures. Previously, I was converting the textures at the point at which they were loaded into texture memory on the n64. A result of this was that in order to support mirroring, I needed to keep a copy of the converted pixels in RAM. By moving the conversion process closer to the point that the textures are actually used on the psp, I've been able to remove this buffer and perform conversion and mirroring in the same step. This has approximately halved the memory needed for each texture, and is slightly faster than the previous approach.

The most significant change I've made is to fix a memory leak in the texture cache. I mentioned last week that I'd discovered that the texture cache was the biggest culprit for soaking up memory. It turned out that despite my fixes and support for 4-bit and 8-bit palettised textures, I was still running out of memory in certain situations. I did a bit more investigating, and discovered a resource leak that had been in the texture cache since it was first written (probably 7 or 8 years ago now!)

It turned out that in certain situations, several textures would hash to the same bucket in the hash table that I was using. This wasn't normally a problem, but occasionally the process which purges old textures from the cache was accidentally leaking textures. This was wasting video memory and causing the leaked textures to be re-converted on next frame.

The fix ended up being a very simple one-line change, and as a result the texture cache is now 100% leak-free. As an added bonus, it seems that the change has resulted in a nice 4-5% speedup - I suspect this is because the leaked textures are now no-longer being unnecessarily reconverted.

The final bit of work I've been doing is setting up a fixed-size pool for allocating textures from (well, there are actually two pools - one for fast VRAM and another of standard RAM for when this runs out). Despite the various improvements and fixes I've made to reduce the amount of memory being consumed by the texture cache, I wanted to put a hard limit on how much memory can ever be used. This change means that if the limit is ever reached, I just display white textures until some texture memory is freed up a little later. Previously Daedalus would just keep allocating RAM until it ran out of memory and crashed, so the new solution is much nicer :)

All in all I'm very happy with the state of R11. The changes I've made mean that I can permanently allocate 8MB for the Expansion Pak, and not worry about running out of memory. A welcome side-effect to all the texture changes I've made is an approximate 5-10% speedup over R11. On top of this Daedalus now remembers your preferences for each rom, so it's a little nicer to use.

I've still got a few small things to polish, but I'm hoping to release R11 by the weekend.



Childress said...

Sounds good. Just keep on chugging.

Do you feel you've hit anything of a wall, or do you feel that there will always be something to polish?

wally said...

Wow this sounds great :)

It keeps those speed / compatibility freaks happy :)

One game still renders upside down, I mentioned it to you in MSN ages ago (I'll double check it in R11)


Josh said...

nice, can't wait. keep up the awesome work.

mbeck said...

Thanks for keeping us updated! I always enjoy hearing how great these releases are going to be. You never disappoint. Keep up the good work!

disturbed19 said...

this is great news man!! i honestly think your the best coders out there! you committed to your project and you make sure its as perfect and neat as possible. thats one of your great features, and your very knowledgable about the psp. you know wat your doind so theres no worries here what so ever. keep of the great work. oh and i have a few questions.

1. D you think its possible that daedalus will run a few games full speed with great sound? long do u plan on working daedalus for? (estimate) does it get boring sometimes?

3. when do you think you will acheive your full goals for daedalus on the psp?

i have alot more to ask but these are good for now. so if you can answer them it wold greatly be appreicated! thanks guy. you have alot of fans!

Turok said...

Wow...very nice. Give us one new version every month and we'll b happy :). I cant wait til the day that I'll be able to play the Turok games. Keep up the excellent work. This is by far(to me) the best emulator for the psp to have. PSX is nice but when this one is as compatible, ill bet my money on this one

Joe said...

sounds awesome StrmnNrmn!
cant wait to see it
i love that you are getting more speedchanges without even needing to directly focus on them!

i look forward to a real-time speed running emulator

thanks again and keep up the good work!

Jaren said...

Nice job =)

LollypopMan said...

Nice work man!

nice to see a real emu coder producing quality code for the psp.

(not that i'm knocking zx81's work porting other emus)

Frack said...

Hi,Thanks For The Great Work You Did With This Emulator,Nice Improvements At Each Realeases.(Please Don't Forget To Enable 333Mhz ~ + 20 FPS!)

Sir Ify said...

Hey Strmn,

You had said you wanted to increase compatibility so here is one of the problems I noticed. In Paper Mario, when you attempt to put in your name (I think when you hit end it saves here) The game crashes. Would it be an easy fix to make it either not allow saving or to save properly?


phantom xXx said...

great to see a speedup at the effect of recoding texture things

to frack I think its already 333mhz!

Trexx said...

Good luck with the release of R11. Sounds like alot of effort was put in to it.

Luís said...

Cant wait for the R11 but i prefer to wait more if that eases your take your time.
PSP-owners-N64-fans rely their hopes of seeing a psp N64 emulator on you.
Keep up if you can!

iamagamesadict said...

nice job.
btw, does this mean that more roms that just crashed when starting up will now run?

Cody said...

I swear, I can hear my PSP repeatedly whispering the words "R-11.... R-11...."

Oh yeh baby, Can I get a heyheyhey for Super Smash Bros compatibility??! w00t!


Thanks StrmnNrmn, I look forward to your release!sxpidlz

roelandb said...

all i want now is that these games run on this:
-indiana jones

and it would be perfect

any idea if these might work on your new release?

PSdonkey said...

[quote=strmnnrmn]I wanted to put a hard limit on how much memory can ever be used. This change means that if the limit is ever reached, I just display white textures until some texture memory is freed up a little later. Previously Daedalus would just keep allocating RAM until it ran out of memory and crashed, so the new solution is much nicer :)[/quote]

Wow,that is a brilliant idea. That is something I would never had thought about. Great work on this release

Duffman said...

I have one suggestion for daedalus.
As far as I have seen you cant switch CPU speed. I dont know what the speed is on R10 but you must get a lot more FPS if you have it on 333 mhz, if the current speed is 222 mhz.

BTW luuuv the homebrew <3 Mario is portable (pluss DS and SNES emulatore of course)

GoGo Yubari said...

Whoa, this was going to be a compatibility release and yet there will be a 4-5% speedup, amazing!

Looing forward to this release and can't wait for the speedup release!

Jody said...

Haha. A speed-up and you didn't even focus on it. That's kool. N64 is one the greatest consols out there, and you're making it that way. 'D

awesome job.

you play guitar?

Ice said...

"Hi,Thanks For The Great Work You Did With This Emulator,Nice Improvements At Each Realeases.(Please Don't Forget To Enable 333Mhz ~ + 20 FPS!)"

What? Daedalus is running at 222mhz??

raddog said...

Awesome, looking forward to it. I'd love to be able to play some portable banjo and kazooie in the near future.

mkbin said...

So before awhile back you talked about that you had ideas on fixing z-fighting and on most roms it doesnt make a real difference but LOZ ooT the paths and stuff dont display right anyway thanks for the great emulator its the best

Morgan said...

Great work StrmnNrmn this emulator is really comming along. You know how much I love reading your blog updates, I can't wait till R11. Since R11 is a compatability (and now a small speed increase!) release could you maybe list some titles that will work in R11 that didn't work in previous versions before you release R11 this weekend?

El Xando said...

Any chance for support for Super Smash Bros?

power_trancer said...

you the man!

alucart13 said...

Good Job Man. I wanted to personally thank you for all the hard work. also, if you need someone to help you with the coding, i'll be glad to help with what i can. I am not an advanced coder, but i will help as much as possible

pliskin said...

Grazie per il lavoro che stai facendo,DAVVERO GRAZIE!

Mattias said...

WOW!! i wonder how much speedup u can get when the ME is included :D

u have truly become the mastercoder together with NJ and Exophase! thanx so very much for your fantastic work..

im not doubting anymore (like i did before) that we will be able to play N64 games at fullspeed on the psp, perhaps without FS too ;)


Eneko said...

Nice work!
One question: Would performance improve if textures were processed before loading in the emulator? I mean, coding a program for computer which converts textures to PSP format and then use that new rom to run on the PSP. It remembers me something to NJ's CPS1, CPS2 and Neogeo emulators...
Thanks for the updates!

taco said...

Is it coming soon?
I thought it would be released yesterday...

taco said...

Strmn Nrmn,
If you aren't ready to release it yet, just tell us so that I won't have to keep reloading your blog every minute lol