PDA

View Full Version : UPDATED! - Further Daedalus R7 WIP Update from Strmnnrmn



tsurumaru
August 7th, 2006, 00:22
From strmnnrmn's blog:

http://strmnnrmn.blogspot.com/

LOL I just realised I should have summarised the post for the tldr crowd.

Basically R7 looks like having greater compatibility, more speed increases, and if all goes well the new release will be out by next weekend. ;)

For those of you who like the juicy details:




More R7 Optimisations

It's been a while since my last post, but I've still been hard at work with various optimisations for Daedalus R7.

Although my main focus is on improving the dynamic recompiler, I've been looking at optimising a couple of other areas that I noticed were fairly expensive. The texture cache is one of the areas that I spent time tuning this week. This cache is used to avoid converting textures from the native n64 formats to psp formats every frame. I made a couple of fixes to improve the hashing function which gives much faster lookups in certain situations (such as tiled backdrops). I also provided an option to change the frequency at which the texture cache checks for updates to the textures. Many roms look fine when this check is entirely disabled, and this can give quite a nice speed boost.

My main focus has continued to be on the dynamic recompiler. I've made a couple more bugfixes in this area. One bugfix involved detecting when roms were using self-modifying code. The fix involved dumping the contents of the dynarec cache so that the code is correctly regenerated for the updated instructions. This fix solves a couple of issues I was seeing with Quest64, and I'm sure it will help improve compatibility with a number of other roms too.

The other dynarec issue I fixed was related to the way I was handling certain types of branch instructions. The MIPS processor has a set of 'branch likely' instructions which work slightly differently to regular branches and so I handle them separately in the dynamic recompiler. It turned out that I had forgotten to link together code fragments when they exited through a branch likely instruction. This fix gives a nice little speedup.

The biggest bit of new development I've been doing on the dynarec is on optimising for various situations where I can determine the contents of a given register at the time I'm compiling the code. As an example, many roms use the following sequence to load an integer value from memory at a specific address:

LUI $t0, 0x8033 // Load Upper Immediate - i.e. load t0 with 0x80330000
LW $t0, 0x1234($t0) // Load Word - i.e. load t0 with the value at 0x80331234

Previously I'd generate code for both of these instructions on the PSP. The LUI instruction is easy (if t0 is cached on the PSP then this is just one instruction). The LW is a lot more tricky. I have to call a function to convert the address on the n64 (0x80331234 in this case) to the address in the emulated memory on the PSP. Then I have to read from that address, or trigger an exception in the emulator if the memory address is invalid.

With the changes I've just made, when I encounter the LUI instruction (or other instructions involving loading constant values into registers) I keep track of the fact that I've loaded t0 with 0x80330000. When I come to process the LW instruction, I can now determine that the desired address is 0x80331234. I can then map that address directly to the required location on the PSP, avoiding a function call in the generated code. By avoiding the function call I no longer need to flush cached registers back out to memory. Also, because I can tell in advance that the address lies in RAM (and isn't referencing a hardware register for instance) then I can also omit the code testing for an exception. Finally, in situations like the example above, I can don't need to generate any code for the initial LUI (as the register is immediately overwritten with the loaded value.)

In summary this is a very nice optimisation - it generates fewer instructions (reducing the size of the dynarec code), it avoids unnecessarily flushing out cached registers, it avoids generating exception handling code, and it can eliminate redundant instructions (the initial LUI). In the best case, for 2 source instructions it will generate just 3 output instructions, compared to 12-13 for the unoptimised case.

Unfortunately this approach only works with load and store instructions where the address can be determined in advance, but from the roms I've examined so far around 10-15% of the load/store instructions can be optimised in this way, which is enough to give a measurable benefit.

I'm going to spend the rest of this week seeing which other parts of the dynarec engine can benefit from similar approaches. I have a couple of other features to implement (configurable controllers etc), if that all goes to plan I'll try and prepare R7 for a release next weekend.
-StrmnNrmn

Please see page 4 for the update. Thanks - Tsu

NoQuarter
August 7th, 2006, 00:33
Man,you rock.I just wish I understood the programming involved.Are you planning to implement wireless 2player once you hit full speed?

xiringu
August 7th, 2006, 00:33
wow, sounds great

and I'm really happy you share all this information with us. it's useless to me :P, but I'm pretty sure somebody else will learn something from it, and maybe try to follow your steps in the future.

thnx again, for everything. :)

D Maurice
August 7th, 2006, 00:51
august is getting better first the CPS2 emu, now R7. but I have a ? will wrestling games be compatible(just wondering?) but still great news

SSaxdude
August 7th, 2006, 01:30
strmnnrmn is the best coder out there.

pkmaximum
August 7th, 2006, 02:12
Its great to see we have such a deticated worker working on a N64 emu for us ^_^

Zion
August 7th, 2006, 02:16
I can't wait! :D by the sounds of it....this will at least be 30 to 40 FPS :p

Keep up the stunning work Strmnrmn :D :D :D

shenske37
August 7th, 2006, 02:26
i appreciate all of the updates, it really builds up the hype! its amaizing that you have gained so much speed in this next release.

i'm very glad to here that you are implementing configurable controls.

i can't wait untill this next release, thanks strmnnrmn for your constant hard work!

sroon
August 7th, 2006, 03:01
:D There's only one thing I can say. . . .TITS!!!:rolleyes:
Dude Zelda will be awsome to play!!
I honestly cannot wait!!
Keep it up Norm!!!(O)(O)

felonyr301
August 7th, 2006, 03:04
love the work man and cant wait for this release but to zion i dont think mario is gonna be running at 30 to 40 fps just yet he did said % speed increase not fps increase but i wont be surprised if mario runs at 20 fps crossing fingers that zelda also gets a big increase too.

psiko_scweek
August 7th, 2006, 03:17
lol im not trying to be a pessimest, but im not setting my hopes high (like 30fps, considering most N64 games AFAIK run at max 30fps) or anything, so I wont get disappointed. The only game i care about though is Zelda...that is of course unless there is wireless mulitplayer...SuperSmashBros baby!

skater9269
August 7th, 2006, 03:47
the n64 native frame rate is 50-60 fps so 30 fps would be half speed if i am correct.

skater9269
August 7th, 2006, 03:47
btw i cannot wait for r7 strmnnrmn you rule keep it up

SnoopKatt
August 7th, 2006, 03:56
I can't understand coding for crap, but I can tell that it sounds good.

brainpan
August 7th, 2006, 04:15
I'd be amazed to see Mario 64 run @ 10fps with the R7 release.

No offense StormnNormn. Afterall, it took Micheangelo 4 years to paint the Sistine Chapel.

idapimp
August 7th, 2006, 04:32
ummmmmm. mario64 already practicall runs @ 10 fps, plus i also think that the native frame rate varies, because i got mario 64 up to 22 frames per second on R5 and it was really fast.

ACID
August 7th, 2006, 04:58
Great work cant wait for the release.

shiftybill
August 7th, 2006, 04:58
yea i had it around 22fps in the room before world 1

and i cant wait for next weekend, R7 baby!

Strmnnrnm is LORD!

SpacemanSpiff
August 7th, 2006, 05:23
Can't wait for this release. I've noticed that StrmnNrmn isn't that good at meeting his deadlines, so I'm not expecting him to release it for a couple of weeks at least. That way I won't be disappointed if he doesn't release it next week.

felonyr301
August 7th, 2006, 05:28
but still it would be worth it and that just shows to me that he keeps finding little extra stuff to work on kinda like the finishing touches before he releases it. now come on ZELDA hoping zelda gets a bigger boost in speed and obviously more stable ohh please.

LAMPRO
August 7th, 2006, 05:41
rumblin bumblin brewin and screwin its strmnnnrmmmnnnn.. r7 what. im hipe. keep it up, great work, this makes it all worth while.

Emeriastone
August 7th, 2006, 06:02
Exciting!

xlokichaosx
August 7th, 2006, 06:43
Hey dude, you totally rock. Stuff like this makes people wanna buy a psp. LoL.

Btw, could you PLEASE try to make it so that R7 can run Resident Evil 2? :D You've done so much work, but this would totally rock... then we dont have to wait til the PSOne Emu from Sony to play RE on the go. Hah. PeAcE


Keep up the good work

dagger89
August 7th, 2006, 07:19
i doubt it...most n64 emus have problems w/ that game, even pj64

SnoopKatt
August 7th, 2006, 07:25
Running Star Wars: Rogue Squadron would be awesome lol.

Mr. Shizzy
August 7th, 2006, 08:37
Can't wait. Keep up the hard work StrmNrmn. If I ever get to play GoldenEye 007 on a PSP, it will mean I've died and gone to Heaven!!!

Baboon
August 7th, 2006, 08:46
I cant wait for this update, sounds like its gonna be great!

Good luck StrmNrmn. :)

BL4Z3D247
August 7th, 2006, 09:17
great news, can't wait for next weekend :D

tophead420
August 7th, 2006, 10:27
cant wait man this sounds like you've been on the ball lol keep it up dood

shiftybill
August 7th, 2006, 11:27
on the ball? he is the ball!

Voltron
August 7th, 2006, 17:27
This news creates lots of mouth-watering anticipation. This is really getting exciting. Excellent news!

tsurumaru
August 7th, 2006, 22:50
I'll post this here rather than start a new news thread.

Here a few more bits of info gleaned from some Q&A on StrmnNrmn's blog.

I've edited out the various usernames that fielded each question just so that its easier to follow each question and its answer. The originals can be found on strmnnrmn's blog.

http://www.blogger.com/comment.g?blogID=13094505&postID=115490392201480461

Q (In response to the update) sounds great StrmnNrmn cant wait for next weekend
hopefully the comments section doesnt get spammed up again.

A - I think I'll try and post brief updates a couple of times through the week. I can appreciate that people get a bit frustrated when they don't hear anything for a few days, and new posts help to keep everything a bit fresher.

Q - well i have news for everyone,

Im going to wait until R7 before continuing my compat list..(wally*won_kenobie's) (probably need to start from scratch)
Its shocking
Strmnnmrn please fix the missing_mux and screenshot problem :P Its getting a bit overboard!

A - The compatibility does seem to have improved somewhat so it may well be worth waiting until R7 (not least because the mux/screenshot situation will be a bit less painfile for you :)

Q - About how much faster have you gotten it since last time? Percentage wise.

A - I've lost track where I'm at now. The problem is some roms are seeing much bigger speedups than others. For instance bits of Super Mario are running at 20fps now (in the castle for instance) whereas the opening sequence of Zelda is still stubbornly running at 4fps. I think you'll be quite pleased anyway :) MarioKart is around 12fps now - I'm not sure what it was before, but it's starting to feel quite playable.

Q - yes, you forgot to tell us the zelda speed and you must tell us how much faster it is now.

A - As I mention above the opening sequence in Zelda is still just 4fps. In game is a little faster now (5-6fps rather than 4), but it's still not running as quickly as I'd like.

Q - I've got a question about all that dynarec stuff.

what's the ratio, between difficulty and the bennefits we could achieve in other emulators, like gameboy advance.

for example, too difficult/too much developing time for the speed gained?

does dynarec adapt better to one kind of emulation (machine), or is it the same for all, say Commodore 64?

any comments on this? thanx :)

A - Good question :) Dynarec should benefit all emulators. Obviously if the emulator runs at full speed through an interpretor then there's no point in going for the added complexity of implementing a dynarec engine too.
The principles of the dynarec are pretty similar for all machines, but some are easier to handle than others (the N64 is fairly easy because it's based on a RISC chip - I imagine writing a dynarec engine for an x86 emulator would be a lot more difficult for instance).

Q - Congratulations on your accomplishments Strmnnrmn! If you reach full speed, may I request that you work on sound input? That is, if it's what you want to do...

A - It's definitely looking a lot better, but I think sound is still a handful of releases away (maybe R10 or R11??)

playamp3
August 8th, 2006, 05:03
Sounds like you got a good plan on what's important to do first. sound is the last thing you need to worry about. Just keep up the hard work and take it one step at a time, sooner or later it will come together with good enough or full speed, majority of games will play, and graphics will be good and then you can work on sound after everything else. :cool: