Go Back   Project64 Forums > General Discussion > Open Discussion

Reply
 
Thread Tools Display Modes
  #1  
Old 12th 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: 16,236
Default multiply-and-add (high)

Code:
void VMADH(int vd, int vs, int vt, int element)
{
    switch (element)
    {
        case 0x0: /* none:  { 00, 01, 02, 03, 04, 05, 06, 07 } */
        case 0x1:
            VACC[00].l[01] += VR[vs].s[00] * VR[vt].s[00];
            VACC[01].l[01] += VR[vs].s[01] * VR[vt].s[01];
            VACC[02].l[01] += VR[vs].s[02] * VR[vt].s[02];
            VACC[03].l[01] += VR[vs].s[03] * VR[vt].s[03];
            VACC[04].l[01] += VR[vs].s[04] * VR[vt].s[04];
            VACC[05].l[01] += VR[vs].s[05] * VR[vt].s[05];
            VACC[06].l[01] += VR[vs].s[06] * VR[vt].s[06];
            VACC[07].l[01] += VR[vs].s[07] * VR[vt].s[07];
            goto CLAMP_TO_VR_FILE;
/* [...] etc., for different elements */
Accidentally added like 8 VI/s speed to games just by using an element switch table. According to external VU vendor patents outside of SGI's VU, the saturated arithmetic originally described in the 1.4 Project64 RSP interpreter source using an extended chain of individual byte checks, is really simplified to a "signed clamp" conditional chain of 2 or 3 checks. Once the vector accumulators have buffered the most significant bits of the multiplicative result, they are clamped using this "signed clamp" to the destination primary vector register file.
Reply With Quote
  #2  
Old 12th December 2012, 11:51 PM
ExtremeDude2's Avatar
ExtremeDude2 ExtremeDude2 is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Apr 2010
Location: USA
Posts: 3,101
Default

cool story bro
__________________
Quote:
Originally Posted by dsx! View Post
are you american or something
Reply With Quote
  #3  
Old 13th December 2012, 08:26 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,236
Default

LOL!
It's my story; I invented it; boy I'll copy-pasta it until it's so cool yo momma can't touch it.


Also, edited for clarity:
Code:
CLAMP_TO_VR_FILE:
    VR[vd].s[00] = SIGNED_CLAMP(VACC[00].l[01]);
    VR[vd].s[01] = SIGNED_CLAMP(VACC[01].l[01]);
    VR[vd].s[02] = SIGNED_CLAMP(VACC[02].l[01]);
    VR[vd].s[03] = SIGNED_CLAMP(VACC[03].l[01]);
    VR[vd].s[04] = SIGNED_CLAMP(VACC[04].l[01]);
    VR[vd].s[05] = SIGNED_CLAMP(VACC[05].l[01]);
    VR[vd].s[06] = SIGNED_CLAMP(VACC[06].l[01]);
    VR[vd].s[07] = SIGNED_CLAMP(VACC[07].l[01]);
    return;
Conceptually speaking, this is a function of one of two 32-bit words, of which the virtual 64-bit vector accumulator register (which on the physical hardware is really only 48 bits, thanks to Mr. zilmar for telling me that cause I wasn't sure), so in this case this takes the middle- and high- segments of the specified accumulator register `VACC[i]` and clamps it using "saturated arithmetic".

The documented algorithm for this arithmetic is as follows:
*dammit, can't find the HTML version of the vector unit patent*

oh well, in short,
for any quantity wider than 16-bits,
signed clamping down to a 16-bit signed short for any such number (n) is:
if (n < -32768) return 0x8000; // clamp to -32768
if (n > +32767) return 0x7FFF; // clamp to +32767
return ((short)n);

Last edited by HatCat; 13th December 2012 at 08:40 PM.
Reply With Quote
  #4  
Old 13th December 2012, 10:59 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,236
Default

Stupid recursive patent chains.

Code:
The following is one example of a computer source code implementation for a pixel post-processing filter:

 
cfb_PixelProc_1:    
 add sys0, cptr, cbuf_width 
 sub sys1, sys0, cbuf_size 
 lqv depth00[0], 0 (sys0) 
 lsv depth10[0], 32+14 (zero) 
 lqv depth10[2], 0 (sys0) 
 lqv depth01[0], 0 (sys1) 
 lqv color00[0], 0 (cptr) 
 sqv depth00[0], 0 (sys1) 
 sqv depth00[0], 32 (zero) 
 vnxor depth00, depth00, _0x7fff 
 vnxor depth10, depth10, _0x7fff 
 vnxor depth01, depth01, _0x7fff 
 vsub depthDX, depth00, depth10 # X 
 vsub depthDY, depth00, depth01 # Y 
 vabs depthDX, depthDX, depthDX 
 vabs depthDY, depthDY, depthDY 
#if def FILTER_2 
 vor color00, vzero, _0xffff 
#endif 
 vadd depthDX, depthDX, depthDY 
 vadd depthDX, depthDX, Coeff_A 
 vmudh depthDX, depthDX, Coeff_B 
 vge depthDX, depthDX, _0x0000 
 vmud1 color0r, color00, _0x0020 
 vand color0g, color00, v0x07c0 
 vand color0b, color00, v0x003e 
 vmulf color0r, color0r, depthDX 
 vmulf color0g, color0g, depthDX 
 vmulf color0b, color0b, depthDX 
 vand color00, color0g, v0x07c0 
 vmadn color00, color0b, _0x0001 
 vmadn color00, color0r, v0x0800 
 vor color00, color00, _0x0001 
 addi cptr, cptr, 16 
 bne cptr, cptr_end, cfb_PixelProc_1 
 sqv color00[0], −16(cptr) 
 jr return_sv 
 nop
where the hell do they keep pulling those mnemonics from
Reply With Quote
  #5  
Old 14th December 2012, 05:30 PM
ExtremeDude2's Avatar
ExtremeDude2 ExtremeDude2 is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Apr 2010
Location: USA
Posts: 3,101
Default

Your moms ass ofc
__________________
Quote:
Originally Posted by dsx! View Post
are you american or something
Reply With Quote
  #6  
Old 14th December 2012, 09:54 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,236
Default

Quote:
Originally Posted by ExtremeDude2 View Post
Your moms ass ofc
Well, that just put a fat grin on my face.


And here I thought you didn't have the intelligence to use them words!!


(I just didn't think you'd actually say something like that XD, but good job!! You made it!! )

still trying to figure out VMACU mostly
Reply With Quote
  #7  
Old 21st December 2012, 06:44 AM
Endafy Endafy is offline
Junior Member
 
Join Date: Dec 2012
Posts: 12
Default

lolXD I love your gif
Reply With Quote
  #8  
Old 21st December 2012, 09:36 AM
mudlord_ mudlord_ is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Dec 2012
Posts: 381
Default

If you know of the "oman" archive, acquire it. You will like the verilog implementation of the RSP.

Yay for Iconoclast learning vector math. Maybe he should learn 3D coding now.

Last edited by mudlord_; 21st December 2012 at 10:13 AM.
Reply With Quote
  #9  
Old 21st December 2012, 09:48 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,236
Default

Quote:
Originally Posted by Endafy View Post
lolXD I love your gif
lmao, it's not mine honestly

I stole it off of some fatass who used to annoy the crap out of me.
Had good tastes though.

IDK how he made it, but anyone who listens to that Caramelldansen song will probably know "why".

Quote:
Originally Posted by haxatax View Post
If you know of the "oman" archive, acquire it. You will like the verilog implementation of the RSP.

Yay for Iconoclast learning vector math. Maybe he should learn 3D coding now.
Well there's UMAN, PMAN, and OMFGMAN!!!, but idk if I ever saw an OMAN.
But I think I know what you mean, I recalled some documents that zilmar used in place of the specifics to brief the headings of the RCP, I even saw some devkit libraries that contained the official RSP opcode mnemonic names in them but nothing else very readable and extractable at first glance.

But I know basically nothing about gfx or 3-D game stuff lmao. I'm good at trigonometry and college algebra but like, never programmed a game before lmao. I like the CPU stuff a lot more.
So I figure the RCP is as terrible as it gets, before I practice on something like the core.

Last edited by HatCat; 21st December 2012 at 09:50 PM.
Reply With Quote
  #10  
Old 21st December 2012, 10:05 PM
mudlord_ mudlord_ is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Dec 2012
Posts: 381
Default

So you didnt see the official SGI RSP emulator?
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 02:21 PM.


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