Wednesday, August 30, 2006

Display List Debugger

I've been working on a few new features which I'm eager to talk about, but I thought it would be interesting to give some details about some of the tools I use to help me debug various problems with the emulator.

Some of the hardest problems to identify and fix are various graphical issues that crop up when running certain roms. Sometimes it's unhandled combiner modes (this is what results in the purple-and-black textures seen in so many screenshots). Other times there are black or white polygons, or scrambled textures and so on. Sometimes the screen is just totally black :)

When I'm trying to figure out what's causing a particular problem my first step is to recompile Daedalus with the Display List Debugger enabled. If you've been playing with the source, this is done by setting CFLAGS = $(DEBUG_DLIST_CFLAGS) in the Makefile, and linking in Source/PSPGraphics/DisplayListDebugger.o.

The debugger is accessed by pausing emulation and hitting the right trigger button. You need to have PSPLink set up in order to use it, as I didn't want to clutter up the display with various debbuging output. When the debugger is activated, it keeps the emulator paused and replays the current display list over and over. The first thing is does is dump out a list of all the commands in the display list to a logfile which looks something like this (I've edited it somewhat to create a simple example):


[00066] 0x00214290: 01060040 802143b0 G_GBI1_MTX
Command: ModelView Load Push Length 64 Address 0x002143b0
+1.00000 +0.00000 +0.00000 +0.00000
+0.00000 +1.00000 +0.00000 +0.00000
+0.00000 +0.00000 +1.00000 +0.00000
+0.00000 +160.00000 +0.00000 +1.00000

[00067] 0x001c1118: bb000001 ffffffff G_GBI1_TEXTURE
Level: 0 Tile: 0 enabled
ScaleS: 0.999985, ScaleT: 0.999985
[00068] 0x001c1120: 04f00100 0a000000 G_GBI0_VTX
Address 0x001c1000, v0: 0, Num: 16, Length: 0x0100
#00 Flags: 0x0000 Pos: { 0.000000, 60.000000,-1.000000}
#01 Flags: 0x0000 Pos: { 80.000000, 60.000000,-1.000000}
#02 Flags: 0x0000 Pos: { 80.000000, 80.000000,-1.000000}
[00069] 0x001c1130: bf000000 00000a14 G_GBI1_TRI1
Tri: 0,1,2


What this is showing is a matrix being loaded (command 0066), texturing being enabled (0067), a bunch of vertices being loaded (0068) and then a triangle being rendered (0069). (That's quite a lot of work to display a single trinangle! In reality the n64 would load up batches of vertices and render multiple triangles at a time.)

The display list debugger also provides a number of other useful features. The first is the Combiner Explorer. This is how it looks in PSPLink:



This displays all the different combiners used in a scene, and allows them to be enabled or disabled individually. When they're disabled, it replaces the triangle with a big green and black texture, like so:





In each of these cases a single combiner was disabled, showing how different combiners are used to achieve different effects in the scene.

This tool is invaluable in debugging combiners as I add them, to ensure that they're doing what I think they're doing.

The Texture Explorer displays all the textures used in the scene. It looks like this in PSPLink:



It allows individual textures to be displayed on the PSP so I can ensure that they're being decoded correctly:




The final function I want to demonstrate is the ability to terminate the display list at a given point. That is, if a display list has 1000 commands, I can stop it after at any point during rendering to see what the scene looks like. The example pasted above shows a snippet of 4 commands from 66-69, typically there may be 3000-5000 commands in a display list - the Mario scene above is composed of 3614 commands.

Being able to stop the display list like this is really useful, because it allows me to see the exact command at which a given triangle in the scene is drawn. Let's say that we're trying to figure out why the triangles making up Mario's feet are coming out in the wrong colour. What we'd do is render the display list command by command until the specific triangle we were interested in appeared on-screen. At this point we'd be able to determine the command number, and cross-reference this with the display list log which was dumped at the beginning. Usually looking a few lines before this point in the log will reveal the source of the problem.

I hope this has provided a little insight into how I go about debugging some of Daedalus' graphical problems. I'll leave you with a sequence of shots showing how Mario 64 looks as it's rendered from start to finish:











-StrmnNrmn

44 comments:

Paulnpoosy said...

So what doez this mean?
( O ) ( O )

Morgan said...

Skater I use the regular 1.5 firmware, not any custom one. Also just so we're clear the eboot you made I put that one in the place of the eboot in my __SCE__Daedalus folder correct? Because for some reason when I do this Daedalus looks like it's going to launch but then it returns with the error.

Morgan said...

Okay I deleted Daedalus off my psp and then redownloaded R8 and put it on my psp. Then I downloaded your eboot and swapped them. Now the emulator boots only problem is now the textures were still messed up in DKR. But there is good news, this time after selecting my save spot it let me choose my initals now. I'm not sure what's going on because it works on yours you say but I'm not getting the results. Has anyone else tried it?

Morgan said...

Does the rom name matter because mine is Diddy Kong Racing (v1.0)

skater9269 said...

try wallys

Urkel said...

Love hearing about your updates strmnnrmn, they keep getting better and better. cant wait for R9

JOshISPoser said...

nice update and thx for keeping us up w/ info

Morgan said...

Skater thanks for trying and I don't know why it's not working for me but where is Wally's link to his eboot. I'll be happy to try his but where's the link?

Morgan said...

No if you read the article he says where he can look at the objects individually to see how the textures and everything is working. He's just got a single shot of door to the castle in Super Mario 64. It's similar looking to when you enter doors in RE2 but no RE2 pics in there, sorry. Someone please tell me where Wally's eboot is so I can try it, Wally help me out!

skater9269 said...

morgan check the dcemu forums I believe he posted there and also wally lives in australia so i dont think he will be on soon but maybe wrong.

skater9269 said...

johnny wally and I have been trying to use this and we have been unsucessful sadly.I am going to try some more today. When I use putty it gives me a connection refused warning If we figure it out it should help tremendously.

JOshISPoser said...

off topic
ive got a mario save with all boxes if anyone wants it.
btw my aim sn is joshisposer, just make sure it is not going to my cell.
should i have said that? idk

Morgan said...

I must have the worst luck, I just tried Wally's eboot. I have tried and tried after time and again, and I can't get the emulator to start? I tryed re downloading the entire emulator before many times. I guess it's my only hope that StrmnNrmn can fix these DKR changes (for me). I know I'm putting the eboot in right I just don't know why it won't start the mu up. Any tips Wally?

Morgan said...

Wally I'll try going to dcemu and downloading it from there but the link "johnybon" put up your eboot file, Wally? I tried that one and the emulator wouldn't start.

Morgan said...

Okay I got good news I went to Wally's thread and got his file. It works and everything is good but then I noticed DKR isn't in the changelist you made Wally. Wally obviously I have been talking about DKR for the past couple days and I wanted the textures/ texture fonts in that to be corrected. Wally could you possibly do an update WHENEVER you have some free time to add DKR.

Morgan said...

Oops I forgot you posted that you'll look into it tonight. Please Wally though make the 1.5 version and release it if you get anything going tonight. Because switching eboots for some reason is working/not working at random times for me. But adding the two Daedalus folders seems to work flawlessly.

skater9269 said...

morgan use pspbrew to convert it to a 1.5 kxploited eboot.

Morgan said...

I did but DKR isn't included in Wally's build.

Morgan said...

"This is Big Brother. Morgan it is ... That is all"

Wally I'm 100% confused on what your talking about in this post. Are you trying to say DKR is included in your fix? If so it's not in the list of games you said in your thread, also when I tested your build the texture problems in DKR are still present. I know a very good amount of homebrew and I use programs such as PSPBrew to customize my homebrew and do minor editing. There is only certain areas that I'm unsure of. Anyway can someone please fix the purple/black textures in Diddy Kong Racing please! Every single time someone here says that they fixed it, I try it and I get nothing. I appreciate the work your doing guys but I mean I'm not getting the results you say your getting so I'm feeling cheated.

Paulnpoosy said...

OKAYP MORGAN! We have nothing against you okayp bro!
Would you stop bugging?
Wally iz using his (very little and limited) time to help further this project!
Show some respect!
I honestly wouldnt be surprised I Norm quit because of all your Bugging, and its not just u too, I admit I can be stuped at times but atlest I dont ask stuff all the time kk!
Your a cool guy Captian theres no doubt about tit with your "compat list" (teehee) Now Id sugest ( as beeing popular guy and a good friend) taht you go out with sum friends befor school stars ( if it hasent started yet)
So im not tgrying to be a pain in the azz okayp bro!
Just go out for a couple of days and there will be an update before you know tit! No hard feelings!

( O ) ( O )

Morgan said...

Sroon I'm not here alot, I maybe spend an hour a day on the computer. I have friends and I have a job, I come here when I'm bored and have spare time. I'm not bugging about anything I'm just trying to find out why when two people say they fixed a texture bug and then when I test out the eboot the bug is still there. I'm not getting straight answers so yeah I am going to continue to ask. I'm not bugging StrmnNrmn and the texture thing I'm talking about is towards Wally & Skater not StrmnNrmn, so why would StrmnNrmn quit when what I'm talking about isn't directed towards him. Anyway I gotta go to work in a little so I hope whenever I get back on there will be something going on here. Sroon if your saying your a popular guy on some internet comments thing I think it's you that needs to get out, because my life is fine and I don't need people telling me how to live it.

Morgan said...

I swear it's like you guys don't even read all of my posts and just read parts of it and then just respond. You said show some respect, " appreciate the work your doing guys but I mean I'm not getting the results you say your getting so I'm feeling cheated." I just said I appreciate his work and I really do it's just that I'm not getting the results they say I should be getting, so I'm trying to find out why.

Morgan said...

Here's Wally's eboot ryan.

http://rapidshare.de/files/31724445/EBOOT.PBP.html

skater9269 said...

morgan I did have it fixed at one time but it had a dragging problem in parts and still did not work in game Wallys has more added textures than I do and so I have been looking at other parts we have not merged our combiner modes I know that I did have dkr fixed to a point but am unsure if either I uploaded the wrong eboot or what but as the ingames is still not fixed it is not incredibly urgent. Also I have not had time to work on anything this weekend as I have not been at my house but all in good time. Thanks

Morgan said...

Then don't read it. Thanks Skater for straightening it out, I know that DKR seems useless to you guys since you can't play ingame. But see the thing is after you select what memory slot and everything you start the Adenture mode with a short video of the Wizpig mountain and the Genie (elephant) flying around. The reason I want the textures fixed is because I would like to see the actual words on the menus (they're purple/black) because the short video doesn't play on Daedalus like it's supposed too. I just want to find out why this problem is happening. So I'm saying Skater if you could try to find that eboot or just whatever someone if they could try to fix the textures if possible. Wally's build didn't fix the textures for me like you say Skater, could you tell me what fonts you see, maybe take some screenshots? Alright I'm going to go roll up a dutch, so I'm out!

skater9269 said...

johnny every release is realeased with source therfor we can simply overwrite the blendmodes file that is in each source realease therfore even if strmnnrmn choses not to use our blendmodes then we can still release an alternate R9 within 5 mins most likley.

JOshISPoser said...

megaman 64 har great speed improvements. the game is playable now but the textures are bad even with wallys eboot

Morgan said...

Hopefully StrmnNrmn will update us on some progress here shortly. Until then I'm going to go watch the race at 7pm EST.

Morgan said...

Yeah people frameskip is gay, it's like fake speed trust me just let's keep the frameskip thing on the back burner. And congrats to StrmnNrmn you are officially the only active N64 coder for PSP, now that PSMonkey has left the scene for a dev job. Make us proud StrmnNrmn, you already have blown me away! Question Wally in the settings what do you like to run with the graphics update thing (disable, every frame, every 2, every 5....) I usually run every 5 but if I use every frame it will only slwo it down fractions right?

Morgan said...

Full speed Mario might be like R10 man, it's already like full speed now.

Morgan said...

Well I never have it disabled because the graphics are bad then, like for example in Mario Kart 64 the cloud guys that gives you the green light flickers if it's disabled. I tested it today and update every frame IS NOT slower FPS wise than every 5 frames update. Well it might be mayeb fractions of fps but nothing noticeable.

Morgan said...

On Daedalus I've played over 50 games obviously when I made my compat list. But yes full speed mario 64 could be in R10. It's only like 5-7fps (depends where you are)away from full speed. Yes it doesn't have sound yet but still, Mario 64 is almost full speed go play it and look at the FPS. I'm just saying Mario is close to full speed, there are others though. I hope StrmnNrmn gives us an update soon, I bet he's got alot to talk about and some exciting changes for us!

skater9269 said...

ryanwolfe do you atleast have basic programing skills atleast the abillity to read source code and cygwin or a simillar compiler?

Morgan said...

No offense to ryan but I don't think he does, but maybe you could get into making icons/wallpapers for Daedalus. I mean I currently use the green deadalus icons/wallpapers that pochi makes. I think you took your time you could make some sick icons.

skater9269 said...

wally have you got it yet I cant get nethost to recognize

Morgan said...

Make icons/backgrounds for Daedalus Ryan, I'm sure if you put some effort into it you could make some hot icons. And think if they look really good then people all over the world would be using your icons on their psp.

Morgan said...

Well you can make them with almost any program you just have to make sure the icons are 134 x 74 and the backgrounds are 480 x 272.

Morgan said...

I'm sure there is a program that makes the pics those sizes, but for reference those are the sizes.

Disturbd1 said...

for pics use The GIMP or Photoshop....

Morgan said...

www.rapidshare.de

Go there click Browse and select the pics then hit upload. Then when it's done scroll down and hit forget the whatever just give me the links. Then copy and paste the links here.

Morgan said...

Not to bad for your first try, but here go here for inspiration.

http://www.riotsgraph.jp/pochistyle/


Check out the Daedalus ones under the N64 section, it has a matching green background if you scroll down AFT YOU CLICK THE LINK I GAVE YOU.

Morgan said...

Links worked for me, the background looked okay but the icon wasn't your best work. It was just a pic of the N64 system.

Morgan said...

The background was better than the icon, just the plain old system as the icon can be boring.

Morgan said...

Like I said go to Pochi for inspiration. Look how he made the Daedalus icon.