Go Back   Project64 Forums > General Discussion > Open Discussion

Reply
 
Thread Tools Display Modes
  #1  
Old 27th December 2012, 11:25 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 14,578
Lightbulb I'm bored, so I wanted to put this together.

About 11 months ago I wrote a rudimentary RSP disassembler.
Well it wasn't until recently that I wrote an op-codes counter.

It extracts all the necessary info one could need, but, I'd have a lot more use talking to myself on empty space summarizing what it means.

So here is some example output from my executable:

-- Resident Evil 2 -- GBI command lists spanning (MPEG compression ucodes in video intro):
Code:
RSP Iterations Log:  primary R4000 operation codes
--------------------------------------------------
SPECIAL 746448
REGIMM  86375
J       824
JAL     824
BEQ     618
BNE     218543
BGTZ    3374841
ADDI    15040158
ANDI    1236
ORI     411
COP0    598916
        1 # ignore that <-- probably some stupid-ass bug in my use of CRT fread()
COP2    39964773
LW      5356
LWC2    12584320
SWC2    17813018

RSP Iterations Log:  SPECIAL operation codes
--------------------------------------------------
SLL     287965
SRL     12360
JR      87611
BREAK   411
ADD     345789
OR      12312

RSP Iterations Log:  REGIMM operation codes
--------------------------------------------------
BGEZAL  86375

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
MFC0    211951
MTC0    386965

RSP Iterations Log:  COP2 operation codes
--------------------------------------------------
VECTOP  39964773

RSP Iterations Log:  vector operation codes
--------------------------------------------------
VMUDL   2954651
VMUDM   2966400
VMADM   2954650
VMADN   2954650
VADD    9617302
VSUB    3708618
VADDC   5909302
VLT     4449600
VGE     4449600

RSP Iterations Log:  LWC2 operation codes
--------------------------------------------------
LQV     618
LUV     11100502
LHV     1483200

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
SQV     1509568
SUV     2954650
SHV     4449600
SFV     8899200
-- Castlevania: Legacy of Darkness -- GBI command lists spanning (resurrection of Count Dracula in Cornell's intro, shit load of triangles slowing the game down here)

Code:
RSP Iterations Log:  primary R4000 operation codes
--------------------------------------------------
SPECIAL 65570082
REGIMM  3945476
J       6289367
JAL     3253744
BEQ     10807773
BNE     15390579
BLEZ    3379149
BGTZ    1887799
ADDI    20758404
ADDIU   6321565
ANDI    13637095
ORI     5971356
XORI    429898
LUI     381700
COP0    20781982
        1
COP2    278518561
LH      705476
LW      27165926
LBU     11756439
LHU     13190711
SB      1767548
SH      7763417
SW      11236192
LWC2    62708738
SWC2    67084498

RSP Iterations Log:  SPECIAL operation codes
--------------------------------------------------
SLL     12845730
SRL     2276901
SRA     7783739
SRLV    381700
SRAV    381700
JR      11620643
BREAK   609
ADD     5746813
SUB     11248438
AND     8251846
OR      4650263
NOR     381700

RSP Iterations Log:  REGIMM operation codes
--------------------------------------------------
BLTZ    1509548
BGEZ    2435319
BGEZAL  609

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
MFC0    17059593
MTC0    3722389

RSP Iterations Log:  COP2 operation codes
--------------------------------------------------
MFC2    4184830
CFC2    3774378
MTC2    2887464
VECTOP  267671889

RSP Iterations Log:  vector operation codes
--------------------------------------------------
VMULF   2739810
VMULU   3012320
VMUDL   16552584
VMUDM   5416108
VMUDN   13182847
VMUDH   6744291
VMACF   3050012
VMACU   6024640
VMADL   6543211
VMADM   16459860
VMADN   35368347
VMADH   42224277
VADD    6939173
VSUB    13062421
VABS    23668
VADDC   658058
VSUBC   2140097
VSAW    4920326
VLT     3999616
VEQ     185526
VNE     1146439
VGE     9533150
VCL     3774378
VCH     3774378
VCR     705476
VMRG    18312706
VAND    3012320
VOR     3804364
VXOR    6892
VNXOR   7153494
VRCP    2116431
VRCPL   5225290
VRCPH   9974345
VMOV    9039955
VRSQL   281693
VRSQH   563386

RSP Iterations Log:  LWC2 operation codes
--------------------------------------------------
LSV     12528018
LLV     16844389
LDV     12950023
LQV     2315644
LPV     12718130
LUV     5352534

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
SBV     4223484
SSV     27090434
SLV     11823290
SDV     22119761
SQV     313688
SPV     343734
SUV     1170107
-- Star Wars: Rogue Squadron -- ABI command lists spanning (full intro scene before START screen)
Code:
RSP Iterations Log:  primary R4000 operation codes
--------------------------------------------------
SPECIAL 3190270
REGIMM  189487
J       114275
JAL     548386
BEQ     292304
BNE     2011177
ADDI    3660
ADDIU   7840219
ANDI    577967
ORI     1084452
XORI    219364
COP0    854269
COP2    53999422
LW      443783
LBU     548514
LHU     13243226
SB      67332
SH      32403
SW      2526
LWC2    19632777
SWC2    6835930

RSP Iterations Log:  SPECIAL operation codes
--------------------------------------------------
SLL     1025929
SRL     97243
SRA     453642
SRLV    189487
JR      550911
BREAK   915
ADDU    159938
SUBU    32403
AND     80832
OR      578762
SLT     20208

RSP Iterations Log:  REGIMM operation codes
--------------------------------------------------
BLTZ    189487

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
MFC0    388655
MTC0    465614

RSP Iterations Log:  COP2 operation codes
--------------------------------------------------
MFC2    32403
MTC2    1770159
VECTOP  52196860

RSP Iterations Log:  vector operation codes
--------------------------------------------------
VMULF   6221376
VMUDL   812601
VMUDM   752944
VMUDN   4078259
VMUDH   1000444
VMADM   2923
VMADN   3903565
VMADH   10718231
VADD    11762289
VSUB    810075
VADDC   4060479
VSAW    1520948
VLT     810075
VMRG    810075
VAND    1515896
VXOR    1900784
VMOV    1515896

RSP Iterations Log:  LWC2 operation codes
--------------------------------------------------
LLV     189487
LDV     12956923
LQV     3833549
LRV     2652818

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
SSV     1099596
SDV     5052
SQV     5731282
-- Super Mario 64 -- ABI command lists spanning (File Select screen)
Code:
RSP Iterations Log:  primary R4000 operation codes
--------------------------------------------------
SPECIAL 7235499
J       1625295
JAL     264105
BEQ     311855
BNE     761010
BLEZ    1236278
BGTZ    2239800
ADDI    10638246
ANDI    1142846
ORI     87606
LUI     85302
COP0    1780682
COP2    34759954
LH      9076299
LW      959433
LBU     255652
LHU     203820
SH      610376
SW      48055
LWC2    14729933
SWC2    7559964

RSP Iterations Log:  SPECIAL operation codes
--------------------------------------------------
SLL     2741526
SRL     1395704
SRLV    255652
JR      646060
BREAK   1152
ADD     1776351
SUB     333752
AND     85302

RSP Iterations Log:  REGIMM operation codes
--------------------------------------------------

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
MFC0    762162
MTC0    1018520

RSP Iterations Log:  COP2 operation codes
--------------------------------------------------
MFC2    56834
MTC2    373923
VECTOP  34329197

RSP Iterations Log:  vector operation codes
--------------------------------------------------
VMULF   6151864
VMUDL   1548729
VMUDM   990822
VMUDN   2457464
VMUDH   454378
VMACF   2173488
VMADM   1559945
VMADN   5580636
VMADH   6075309
VADD    3978336
VSUB    68048
VSUBC   11216
VSAW    908756
VGE     267303
VCL     727301
VAND    1022608
VXOR    352994

RSP Iterations Log:  LWC2 operation codes
--------------------------------------------------
LSV     39632
LDV     8809653
LQV     4091084
LRV     1789564

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
SSV     1347073
SDV     1336701
SQV     4876190
Reply With Quote
  #2  
Old 27th December 2012, 11:25 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 14,578
Default

-- Pokémon Puzzle League -- MBI command lists spanning (SP task type == M_HVQMTASK)
Code:
RSP Iterations Log:  primary R4000 operation codes
--------------------------------------------------
SPECIAL 2812005
REGIMM  53828
J       250716
JAL     575906
BEQ     546036
BNE     1223955
BLEZ    104197
BGTZ    251602
ADDI    2817803
ADDIU   30
ANDI    603329
ORI     390896
LUI     5804
COP0    594586
COP2    14266622
LB      3094
LH      744477
LW      185441
LBU     452986
LHU     258721
SB      3052
SH      60488
SW      66880
LWC2    4015783
SWC2    1160733

RSP Iterations Log:  SPECIAL operation codes
--------------------------------------------------
SLL     877130
SRL     169799
SRA     13459
SLLV    3054
SRLV    17768
JR      622660
BREAK   132
ADD     588010
ADDU    60
SUB     58750
AND     198541
OR      255255
NOR     3067
SLT     4320

RSP Iterations Log:  REGIMM operation codes
--------------------------------------------------
BLTZ    16467
BGEZ    37361

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
MFC0    293850
MTC0    300736

RSP Iterations Log:  COP2 operation codes
--------------------------------------------------
MFC2    6712
CFC2    2880
MTC2    145666
VECTOP  14111364

RSP Iterations Log:  vector operation codes
--------------------------------------------------
VMULF   409782
VMUDL   577980
VMUDM   785254
VMUDN   517216
VMUDH   814000
VMACF   169302
VMADL   2280
VMADM   364314
VMADN   409420
VMADH   1812720
VADD    2289052
VSUB    1082585
VABS    238452
VSUBC   18050
VSAW    80168
VLT     677712
VGE     1178264
VCL     27832
VCH     2880
VCR     1440
VMRG    11520
VAND    744464
VOR     895936
VXOR    29423
VRCP    4320
VRCPL   122826
VRCPH   247092
VMOV    597080

RSP Iterations Log:  LWC2 operation codes
--------------------------------------------------
LBV     1275855
LSV     932462
LLV     20160
LDV     1013647
LQV     346924
LRV     125762
LPV     273
LUV     300700

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
SBV     75
SSV     97336
SLV     5958
SDV     162612
SQV     894752
Reply With Quote
  #3  
Old 27th December 2012, 11:54 PM
squall_leonhart's Avatar
squall_leonhart squall_leonhart is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Mar 2007
Location: Sydney, Australia
Posts: 2,665
Default

nice work
__________________
Xfire Profile | VBA-M | XBCD 0.2.7

CPU:Intel i7 920 @ 3.8(D0), Mainboard:Asus Rampage II Gene, Memory:12GB Corsair Vengeance 1600
Video:EVGA Geforce GTX 680+ 4GB, Sound:Creative XFI Titanium Fatal1ty Pro, Monitor:BenQ G2400WD
HDD:500GB Spinpoint F3, 1TB WD Black, 2TB WD Red, 1TB WD Black
Case:NZXT Guardian 921RB, PSU:Corsair 620HX, OS:Windows 7 SP1
Reply With Quote
  #4  
Old 28th December 2012, 12:13 AM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 14,578
Default

So naturally it's best if we figure our own way what the numbers mean, but personally I'd like to reflect to myself the following generalizations per each of those results.

  1. In 4/5 of those games, the most frequently executed primary R4000 operation on the RSP is Add Immediate `ADDI`, by far. The exception of course is the audio ucodes run on Star Wars RS, where a very, very poor amount of `ADDI` ops are encountered. But of the tens of logs or so I have generated ADDI is the most-used CPU inst on the RCP. The runner-up varies greatly across games however it seems, for CV LoD e.g. it is Load Word `LW`.
  2. Frequency of encountered LWC2 opcodes seem to average out to this approximate order:
    1. LDV
    2. LQV
    3. LSV
    4. LLV
    5. LUV
    6. LPV
    7. LTV // lots for those lightning & transformation games
    8. LRV
    9. LBV // little for games using presets and templates
    10. LHV (very high of course for Resident Evil 2 but never any other games?)
    11. LFV
    12. LTWV // opcode does not exist on RCP
  3. Frequency of encountered SWC2 opcodes seem to average out to this approximate order:
    1. SSV // for dlists and hence overall this is extremely often used
    2. SQV // way, WAY more often than SSV iff. audio list task types
    3. SDV
    4. SLV
    5. SUV
    6. SPV
    7. SBV
    8. STV // never in alists I believe, only T&L for dlists
    9. SFV // pretty common and intense for custom ucodes using it, just rarely existent
    10. SHV (very high of course for Resident Evil 2 but never any other games?)
    11. SRV // You would think per many iterations of SQV this gets used a lot, but actually I have never seen this one get encountered.
    12. SWV // honestly ain't never seen this one get used
  4. Frequency of encountered vector operations can be broken down for these top five:
    1. VMADH // Of any opcode *total* on the RSP this gets executed the most billions of times in complex RDP lists used by games, followed up closely by:
    2. VMADN
    3. VMULF // Every single game I have checked so far this seems to be the most frequently executed if not by far for audio tasks on the RSP. If using audio LLE it is important to optimize this.
    4. VADD // ranked up there for major heavy gfx tasks? moderately so, but custom / special task types or ucodes? Probably the most-ever used.
The ones I have never seen or even heard of getting used are VNOP, VMACQ, and VRSQ, although MAME devs probably found one or two ROMs using VRSQ so they added back in after the backport ziggy did to implement the MAME RSP using zilmar's plugin system. Either way it ain't important to optimize those.
Reply With Quote
  #5  
Old 28th December 2012, 12:15 AM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 14,578
Default

lmao, major ninja

well thx guys XD

I was initially too lazy to write the opcodes counter program to spits out the frequencies, but zilmar said he wanted to make one or hear the results.
Reply With Quote
  #6  
Old 28th December 2012, 12:18 AM
haxatax's Avatar
haxatax haxatax is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Dec 2012
Posts: 363
Default

I guess you havent heard of the undocumented VDCT opcode....
Reply With Quote
  #7  
Old 28th December 2012, 12:23 AM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 14,578
Default

haha nope, but I read in external VU patents non-specific to SGI's implementation that "DCT" means "Discrete Cosine Transform", a chain of algorithms used in those tasks a lot.

I usually read that term as an algorithm comprised of vector operations, rather than VDCT in itself being a valid opcode. But who knows, somebody might try it.
Reply With Quote
  #8  
Old 28th December 2012, 12:25 AM
haxatax's Avatar
haxatax haxatax is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Dec 2012
Posts: 363
Default

yes, DCT: used in hardware MPEG decoding. Methinks Nintendo omitted it to save on patent fees.
Reply With Quote
  #9  
Old 28th December 2012, 12:36 AM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 14,578
Default

Hmmm I haven't seen this `VDCT`, explicitly in of its self used in the VICE MSP implementation of SGI O2 either, as temporarily supported by GNU assembler:
http://www.linux-mips.org/~glaurung/...-2.13-msp.diff

If you scroll down you will see that the GNU compiler collection supported the SGI vectops at one time ...

But, in lots of other vector stuffs done by Samsung and other individual documentations I see talk about DCT a lot, just not of that opcode.

Some other got omitted too by Nintendo,

LTWV (abbreviated by Michael Tedder was "LWV") was a standard SGI CP2 memory-register transactions opcode just like SWV under SWC2, but it was completely omitted from the ultra64 dev library and had no symbol references to it. LTV of course still exists, also VRNDN or whatever it was some of those other ops got omitted?
I don't know why, you would know more about patent responsbilities and financial concerns than I would so other than that I have no clue

I don't have a problem with it though the more omitted vector ops the more I can concentrate on what's there
Reply With Quote
  #10  
Old 15th February 2013, 04:32 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 14,578
Default

Updates -- regarding Rareware games.

I have tested all of the Rare games I have ever owned carts for, but mudlord was definitely right about Conker's Bad Fur Day.
This game is extremely RSP-heavy. No other game I have encountered has been so slow with LLE gfx as Conker's, so it makes for an interesting test.

I figured as such that it would be appropriate to update this thread with two more logs, centralized with the graphics tasks employed by Conker's.

Here is a log of the intro logo/disclaimer warning parental advisory.

Code:
RSP Iterations Log:  primary R4000 operation codes
--------------------------------------------------
SPECIAL 3541616
REGIMM  311632
J       663766
JAL     94896
BEQ     582100
BNE     901475
BLEZ    480522
BGTZ    7740
ADDI    1389225
ADDIU   697792
ANDI    660688
ORI     82023
XORI    130683
LUI     3
COP0    2487108
COP2    862751
LH      1032
LW      1498915
LBU     25280
LHU     590370
SB      14190
SH      54954
        1
SW      981755
LWC2    275454
SWC2    263071

RSP Iterations Log:  SPECIAL operation codes
--------------------------------------------------
SLL     615825
SRL     180403
SRA     519170
JR      1035538
BREAK   258
ADD     371672
ADDU    516
SUB     758124
AND     43084
OR      17026

RSP Iterations Log:  REGIMM operation codes
--------------------------------------------------
BLTZ    182509
BGEZ    128608
BGEZAL  515

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
MFC0    1846047
MTC0    641061

RSP Iterations Log:  COP2 operation codes
--------------------------------------------------
MFC2    5934
CFC2    14964
MTC2    4644
VECTOP  837209

RSP Iterations Log:  vector operation codes
--------------------------------------------------
VMUDL   71466
VMUDM   16770
VMUDN   34572
VMUDH   28638
VMADL   17544
VMADM   84882
VMADN   122808
VMADH   134418
VADD    22704
VSUB    23995
VABS    4128
VADDC   16768
VSUBC   7224
VSAW    6192
VLT     13158
VEQ     4128
VGE     31734
VCL     14964
VCH     14964
VCR     1032
VMRG    48246
VAND    1032
VOR     9804
VXOR    258
VNXOR   10836
VRCP    3096
VRCPL   25284
VRCPH   45150
VMOV    21414

RSP Iterations Log:  LWC2 operation codes
--------------------------------------------------
LSV     40506
LLV     50568
LDV     145423
LQV     18833
LPV     8514
LUV     11610

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
SBV     14964
SSV     75852
SLV     53664
SDV     111367
SQV     3096
SUV     4128
Not very important or slow.
This suggests that MFC0 (which is way faster than MTC0 in almost all cases), SDV, and LDV are all used at least as much as basically any of the vector operation codes. MFC0 is easily emulated on the scalar pipeline, so nothing much to optimize there. We could speed up MFC0 significantly by voiding the switch table into an instant assignment of pointers, using a table of pointers to the CP0 registers laid out in zilmar's Rsp #1.1.

When we get to Conker cutting the N logo with his chainsaw, LLE gfx (I am not logging audio tasks to my EXE.) expands the results to contradict this pattern. Also included is a log of the extremely slow scene (Conker entering the **censored**-and-Pluckers' or whatever it's called) that's like 9-12 VI/s last time I checked on my older RSP. (I left the logger on overnight because it was taking too damn long to log RSP iterations for one single frame, hence the results below are so big.)

Code:
RSP Iterations Log:  primary R4000 operation codes
--------------------------------------------------
SPECIAL 81103002
REGIMM  8171938
J       6578938
JAL     3840834
BEQ     12870990
BNE     17582831
BLEZ    2971913
BGTZ    1522832
ADDI    26130691
ADDIU   5118644
ANDI    21082823
ORI     5684714
XORI    1207040
LUI     3208
COP0    22319455
COP2    414003283
LB      4684002
LH      3062472
LW      25016388
LBU     11570643
LHU     12177662
SB      9967767
SH      8703988
SW      8031850
LWC2    92643838
SWC2    73080927

RSP Iterations Log:  SPECIAL operation codes
--------------------------------------------------
SLL     18728838
SRL     12814698
SRA     5884879
SRLV    3208
SRAV    3208
JR      8944261
BREAK   665
ADD     7650532
ADDU    472779
SUB     12108282
SUBU    1126582
AND     8215387
OR      5146475
NOR     3208

RSP Iterations Log:  REGIMM operation codes
--------------------------------------------------
BLTZ    2321847
BGEZ    5848760
BGEZAL  1331

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
MFC0    15404844
MTC0    6914611

RSP Iterations Log:  COP2 operation codes
--------------------------------------------------
MFC2    4722881
CFC2    3044332
MTC2    10627693
VECTOP  395608377

RSP Iterations Log:  vector operation codes
--------------------------------------------------
VMULF   4490444
VMULU   4520728
VMUDL   23255297
VMUDM   10870526
VMUDN   14371435
VMUDH   12044655
VMACF   4212179
VMACU   5861306
VMADL   7821654
VMADM   23812761
VMADN   43179939
VMADH   56243596
VADD    23508240
VSUB    19298132
VABS    25156
VADDC   12284098
VSUBC   2453086
VSAW    17524196
VLT     9422197
VEQ     25156
VNE     1215419
VGE     8876574
VCL     3044332
VCH     3044332
VCR     809310
VMRG    17190246
VAND    2613382
VOR     3997827
VXOR    31655
VNXOR   7078881
VRCP    2427930
VRCPL   15280512
VRCPH   22729951
VMOV    9623088
VRSQL   806719
VRSQH   1613438

RSP Iterations Log:  LWC2 operation codes
--------------------------------------------------
LSV     12452998
LLV     16898940
LDV     16837809
LQV     18179574
LPV     16982721
LUV     11291796

RSP Iterations Log:  COP0 operation codes
--------------------------------------------------
SBV     3044332
SSV     26735294
SLV     9710384
SDV     27037606
SQV     3137004
SPV     960312
SUV     2455995
WOOOOOOOOOOOOOOOOO! (sorry probably should keep that to the other thread) some big number-crunching there for stats on why games are so effing slow.

I'm surprised I didn't get any negative numbers from overflow of the opcode counts; I just used sign int type. Even though I left it on overnight while I was asleep, the RSP counter seems to go hand-in-hand that none of the opcodes went over 4 billion (or, if they did...they did so twice, and the overflow is invisible lolXD).
__________________
Showbiz ain't easy biz for us misperceived cats. ^.^

Last edited by HatCat; 15th February 2013 at 04:43 PM. Reason: 4 billion*, not million >.<
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 01:45 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.