rspfuncs.c 13.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
#include <ultra64.h>

#include <ramrom.h>

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "perf.h"
#include "static.h"
#include "rspfuncs.h"
#include "controller.h"

TestStruct RSPTestStruct[NUMRSPFUNCS] = 
{
/*0 */ RSPDummy,   RSPDummyP,   RSPController, DEFAULTCLEARMODE, 0,
/*1 */ RSPVTrans,  RSPVTransP,  RSPController, DEFAULTCLEARMODE, 0,
/*2 */ RSPMatM,    RSPMatMP,    RSPController, DEFAULTCLEARMODE, 0,
/*3 */ RSPMatL,    RSPMatLP,    RSPController, DEFAULTCLEARMODE, 0,
/*4 */ RSPVLTrans, RSPVLTransP, RSPController, DEFAULTCLEARMODE, G_SHADE|G_LIGHTING|G_SHADING_SMOOTH,
/*5 */ RSPTTrans,  RSPTTransP,  RSPController, DEFAULTCLEARMODE, G_SHADE|G_SHADING_SMOOTH,
/*6 */ RSPTex,     RSPTexP,     RSPController, DEFAULTCLEARMODE, G_SHADE|G_SHADING_SMOOTH, 
/*7 */ RSPZB,	   RSPZBP,      RSPController, DEFAULTCLEARMODE, G_SHADE|G_SHADING_SMOOTH|G_ZBUFFER,
/*8 */ RSPTexZB,   RSPTexZBP,   RSPController, DEFAULTCLEARMODE, G_SHADE|G_SHADING_SMOOTH|G_ZBUFFER,
/*9 */ RSPRDP,	   RSPRDPP,     RSPController, DEFAULTCLEARMODE, 0,
/*10*/ RSPNOOP,    RSPNOOPP,    RSPController, DEFAULTCLEARMODE, 0,
/*11*/ RSPVARDL,   RSPVARDLP,   RSPController, DEFAULTCLEARMODE, 0,
/*11*/ RSPClip1,   RSPClip1P,   RSPController, DEFAULTCLEARMODE, G_SHADE|G_SHADING_SMOOTH,
/*11*/ RSPClip2,   RSPClip2P,   RSPController, DEFAULTCLEARMODE, G_SHADE|G_SHADING_SMOOTH,
/*12*/ RSPRDPT,    RSPRDPTP,    RSPController, DEFAULTCLEARMODE, G_SHADE|G_SHADING_SMOOTH|G_ZBUFFER,
};

int VAROPS   = 2;
int MAXVARDL = MAXGLIST/2 - 100;

void RSPDummy (Dynamic	*dynamicp)
{
    int i;

    /* Dummy procedure to see what VI interrupt timings are */
}

void RSPDummyP (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tIn dummy print routine \n", framecount, TestFuncNum);
}

void RSPVTrans (Dynamic	*dynamicp)
{
    int i;

    /* Sees how many vertex transforms we can do in the rsp per frame */

    for (i=0; i< MAXVTRANS; i++)
	{
	    gSPVertex (glistp++, v, 16, 0);
	}
}

void RSPVTransP(OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d vertex transforms in %.3f secs, %llu trans/sec \n",
	       framecount, TestFuncNum, 
	       16 * (MAXVTRANS), (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXVTRANS) * (OSTime) 16 * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPMatM (Dynamic	*dynamicp)
{
    int i;
                            
    /* Sees how many matrix multiplies we can do in the rsp per frame */

    for (i=0; i< MAXMATMS; i++)
	{
	    gSPMatrix(glistp++, K0_TO_PHYS((u32) &(dynamicp->modeling)),
		      G_MTX_MODELVIEW|G_MTX_MUL|G_MTX_NOPUSH);

	}
}

void RSPMatMP(OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d matrix mults in %.3f secs, %llu mat-mults/sec \n",
	       framecount, TestFuncNum, 
	       MAXMATMS, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXMATMS) * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPMatL (Dynamic	*dynamicp)
{
    int i;
                            
    /* Sees how many matrix loads we can do in the rsp per frame */

    for (i=0; i< MAXMATLS; i++)
	{
	    gSPMatrix(glistp++, K0_TO_PHYS((u32) &(dynamicp->modeling)),
		      G_MTX_MODELVIEW|G_MTX_LOAD|G_MTX_NOPUSH);

	}
}

void RSPMatLP(OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d matrix loads in %.3f secs, %llu mat-loads/sec \n",
	       framecount, TestFuncNum, 
	       MAXMATLS, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXMATLS) * (OSTime) TICKSPERSEC / NumTicks);
}

Lights1 diffuseL1 =  gdSPDefLights1(
    0x00, 0x00, 0x00,
    0x1f, 0x7f, 0x1f,	 90, 90, 0);

Lights2 diffuseL2 =  gdSPDefLights2(
    0x00, 0x00, 0x00,
    0x00, 0x7f, 0x00,	 -90,  -90,   0,
    0x00, 0x7f, 0x00,	  90,   90,   0
    );

Lights3 diffuseL3 =  gdSPDefLights3(
    0x00, 0x00, 0x00,
    0x00, 0x7f, 0x00,	 -90,  -90,   0,
    0x00, 0x7f, 0x00,	 -90,  -90,   0,
    0x00, 0x7f, 0x00,	  90,   90,   0
    );

void RSPVLTrans (Dynamic	*dynamicp)
{
    int i;

    /* Sees how many vertex transforms we can do in the rsp per frame */
    /* Two diffuse lights are defined                                 */

    /* gSPSetLights1(glistp++, diffuseL1); */
    gSPSetLights2(glistp++, diffuseL2);
    /* gSPSetLights3(glistp++, diffuseL3); */


    for (i=0; i< MAXVLTRANS; i++)
	{
	    gSPVertex (glistp++, v, 16, 0);
	}
}

void RSPVLTransP (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d vertex shadings in %.3f secs, %llu shades/sec \n",
	       framecount, TestFuncNum, 
	       (MAXVLTRANS) * 16, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXVLTRANS) * (OSTime) 16 * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPTTrans (Dynamic	*dynamicp)
{
    int i;

    /* See how many triangles we can send down, use the same
       vertex list over and over again */

    clearFrameBuffer();
    gDPSetCycleType(glistp++, G_CYC_1CYCLE);    
    gDPSetRenderMode(glistp++, G_RM_OPA_SURF, G_RM_OPA_SURF2);

    if (UseSmallTri)
	gSPVertex (glistp++, smalltri, 3, 0)
    else
	gSPVertex (glistp++, w, 3, 0);
    

    for (i=0; i< MAXTTRANS; i++) 
	{	    
	    gSP1Triangle (glistp++, 0, 1, 2, 0);
	}
}

void RSPTTransP (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d triangles in %.3f secs, %llu tris/sec \n",
	       framecount, TestFuncNum, 
	       MAXTTRANS, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXTTRANS) * (OSTime) TICKSPERSEC / NumTicks);
}


void RSPTex (Dynamic	*dynamicp)
{
    int i;

    /* See how many textured triangles we can send down, 
       use the same vertex list over and over again */

    clearFrameBuffer();
    gDPSetCycleType(glistp++, G_CYC_1CYCLE);    
    gDPSetRenderMode(glistp++, G_RM_OPA_SURF, G_RM_OPA_SURF2);

    gSPTexture(glistp++, 0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON);
    
    /* gDPSetCombineMode(glistp++, G_CC_DECALRGB, G_CC_DECALRGB); */
    gDPSetCombineMode(glistp++, 
		      G_CC_MODULATERGBDECALA, 
		      G_CC_MODULATERGBDECALA); 

    gDPSetTextureLOD(glistp++, G_TL_TILE);
    gDPSetTextureLUT(glistp++, G_TT_NONE);
    gDPSetTextureDetail(glistp++, G_TD_CLAMP);
    gDPSetTexturePersp(glistp++, G_TP_PERSP);
    gDPSetTextureFilter(glistp++, G_TF_BILERP);
    gDPSetTextureConvert(glistp++, G_TC_FILT);

    gDPLoadTextureBlock(glistp++, RGBA16cbar, 
			G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0,
			G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP|G_TX_NOMIRROR ,
			5, 5, G_TX_NOLOD, G_TX_NOLOD);
   
    if (UseSmallTri)
	gSPVertex (glistp++, smalltri, 3, 0)
    else
	gSPVertex (glistp++, w, 3, 0);

    for (i=0; i< MAXTEXS; i++)
	{
	    gSP1Triangle (glistp++, 0, 1, 2, 0);
	}
}


void RSPTexP (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d textured tris in %.3f secs, %llu tex-tris/sec \n",
	       framecount, TestFuncNum, 
	       MAXTEXS, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXTEXS) * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPZB (Dynamic	*dynamicp)
{
    int i;

    /* See how many zbuffered triangles we can send down, 
       use the same vertex list over and over again */

    clearFrameBuffer();
    gDPSetCycleType(glistp++, G_CYC_1CYCLE);    
    gDPSetRenderMode(glistp++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);

    if (UseSmallTri)
	gSPVertex (glistp++, smalltri, 3, 0)
    else
	gSPVertex (glistp++, w, 3, 0);

    for (i=0; i< MAXZBS; i++)
	{
	    gSP1Triangle (glistp++, 0, 1, 2, 0);
	}
}

void RSPZBP (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d zbuffered tris in %.3f secs, %llu z-tris/sec \n",
	       framecount, TestFuncNum, 
	       MAXZBS, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXZBS) * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPTexZB (Dynamic	*dynamicp)
{
    int i;
    
    /* See how many textured zbuffered triangles we can send
       down, use the same vertex list over and over again */
    
    clearFrameBuffer();
    gDPSetCycleType(glistp++, G_CYC_1CYCLE);    
    gDPSetRenderMode(glistp++, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2);

    gSPTexture(glistp++, 0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON);
    
    /* gDPSetCombineMode(glistp++, G_CC_DECALRGB, G_CC_DECALRGB);  */
    gDPSetCombineMode(glistp++, 
		      G_CC_MODULATERGBDECALA, 
		      G_CC_MODULATERGBDECALA); 
    
    gDPSetTextureLOD(glistp++, G_TL_TILE);
    gDPSetTextureLUT(glistp++, G_TT_NONE);
    gDPSetTextureDetail(glistp++, G_TD_CLAMP);
    gDPSetTexturePersp(glistp++, G_TP_PERSP);
    gDPSetTextureFilter(glistp++, G_TF_BILERP);
    gDPSetTextureConvert(glistp++, G_TC_FILT);
		
    gDPLoadTextureBlock(glistp++, RGBA16cbar, 
			G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0,
			G_TX_CLAMP , G_TX_WRAP|G_TX_CLAMP ,
			G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
    
    if (UseSmallTri)
	gSPVertex (glistp++, smalltri, 3, 0)
    else
	gSPVertex (glistp++, w, 3, 0);
    
    for (i=0; i< MAXTEXZBS; i++)
	{
	    gSP1Triangle (glistp++, 0, 1, 2, 0);
	}
}

void RSPTexZBP (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d tex zbuf tris in %.3f secs, %llu tex-z-tris/sec \n",
	       framecount, TestFuncNum, 
	       MAXTEXZBS, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXTEXZBS) * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPRDPP (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d dummy RDP ops in %.3f secs, %llu rdps/sec \n",
	       framecount, TestFuncNum, 
	       MAXRDP, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXRDP) * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPRDP (Dynamic	*dynamicp)
{
    int i;

    /* See how many rdp commands we can send through the rsp
       This computes what the overhead for command parsing is
       in the rsp, thus letting us see how much overhead there
       is for real rsp operations */

    for (i=0; i< MAXRDP; i++)
	{
	    gDPNoOp(glistp++);
	}
}

void RSPNOOPP (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d RSP NOOPs in %.3f secs, %llu NOOPs/sec \n",
	       framecount, TestFuncNum, 
	       MAXNOOP, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXNOOP) * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPNOOP (Dynamic	*dynamicp)
{
    int i;

    /* See how many rsp noops we can send through the rsp
       This computes what the overhead for command parsing is
       in the rsp, thus letting us see how much overhead there
       is for real rsp operations. We are using line commands
       because in the poly microcode, these are noops */

    for (i=0; i< MAXNOOP; i++)
	{
	    gSPLine3D(glistp++, 0, 1, 0);
	}
}


void RSPVARDLP (OSTime NumTicks)
{
  rmonPrintf("%d:\t(%.2d)\tDid %6d %3d-OP VAR lists in %.3f secs, %7llu OPs/sec \n",
	       framecount, TestFuncNum, 
	       MAXVARDL, VAROPS, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) VAROPS * (OSTime) (MAXVARDL) * (OSTime) TICKSPERSEC / NumTicks);


  /* rmonPrintf("{%d, %lf}, \n", VAROPS, 
	     ((OSTime) VAROPS * (OSTime) (MAXVARDL) * 
	      (OSTime) TICKSPERSEC / NumTicks) / 10000.0);  */

}

void ConstructVarDL(Gfx *varp)
{
    int i;

    for (i=0; i < VAROPS - 1; i++)
	{
	    gSPLine3D(varp++, 0, 1, 0);
	}
    gSPEndDisplayList(varp++);
}

void RSPVARDL (Dynamic	*dynamicp)
{
    int i;
    Gfx varp[100];

    ConstructVarDL(varp);

    MAXVARDL = MAXGLIST/VAROPS - 100;

    for (i=0; i< MAXVARDL; i++)
	{
	    /* Put in calls to display list lenVAR */
	    gSPDisplayList(glistp++, varp);
	}
}

void RSPClip1 (Dynamic	*dynamicp)
{
    int i;

    /* See how many 1 vertex clipped triangles we can send down, 
       use the same vertex list over and over again */

    guOrtho(&dynamicp->projection,
	    0.00, SCREEN_WD-1,
	    0.00, SCREEN_HT-1, 
	    -0.01, 1.00, 
	    1.0);

    gSPMatrix(glistp++, K0_TO_PHYS(&(dynamicp->projection)),
	      G_MTX_PROJECTION|G_MTX_LOAD|G_MTX_NOPUSH); 
    
    gSPViewport(glistp++, &clipvp);
    
    gSPVertex (glistp++, clip1, 3, 0);
    

    for (i=0; i< MAXCLIP1; i++) 
	{	    
	    gSP1Triangle (glistp++, 0, 1, 2, 0);
	}
}

void RSPClip1P (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d clip1 tris in %.3f secs, %llu tris/sec \n",
	       framecount, TestFuncNum, 
	       MAXCLIP1, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXCLIP1) * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPClip2 (Dynamic	*dynamicp)
{
    int i;

    /* See how many 2 vertex clipped triangles we can send down, 
       use the same vertex list over and over again */

    guOrtho(&dynamicp->projection,
	    0.00, SCREEN_WD-1,
	    0.00, SCREEN_HT-1, 
	    -0.01, 1.00, 
	    1.0);

    gSPMatrix(glistp++, K0_TO_PHYS(&(dynamicp->projection)),
	      G_MTX_PROJECTION|G_MTX_LOAD|G_MTX_NOPUSH); 
    
    gSPViewport(glistp++, &clipvp);
    
    gSPVertex (glistp++, clip2, 3, 0);
    

    for (i=0; i< MAXCLIP2; i++) 
	{	    
	    gSP1Triangle (glistp++, 0, 1, 2, 0);
	}
}

void RSPClip2P (OSTime NumTicks)
{
    rmonPrintf("%d:\t(%d)\tDid %d clip2 tris in %.3f secs, %llu tris/sec \n",
	       framecount, TestFuncNum, 
	       MAXCLIP2, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	       (OSTime) (MAXCLIP2) * (OSTime) TICKSPERSEC / NumTicks);
}

void RSPRDPT (Dynamic *dynamicp)
{
    int i;

    clearFrameBuffer();
    clearZBuffer(G_MAXFBZ);

    gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b,
		     SCREEN_WD, OS_K0_TO_PHYSICAL(cfb_ptrs[0]));    

    gDPSetCycleType(glistp++, G_CYC_1CYCLE);    

    gDPSetCombineMode(glistp++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
    gDPSetPrimColor(glistp++, 0, 0,   0, 255, 0,   255);

    /* First render an opaque polygon to initialize the frame and Z buffers */

    gDPSetRenderMode(glistp++, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2);
    gDPSetPrimDepth(glistp++, 0x10d, 0);
    gDPSetDepthSource(glistp++, G_ZS_PRIM); 

    gDPFillRectangle(glistp++, 1, 1, SCREEN_WD-1, SCREEN_HT-1); 

    gDPPipeSync(glistp++);

    gDPSetRenderMode(glistp++, 
		     G_RM_AA_ZB_OPA_DECAL  | Z_UPD , 
		     G_RM_AA_ZB_OPA_DECAL2 | Z_UPD);      

    for (i=0; i<MAXRSPRDPT-1; i++)
      {
	gDPFillRectangle(glistp++, 1, 1, SCREEN_WD-1, SCREEN_HT-1); 
      }
}

void RSPRDPTP (OSTime NumTicks)
{
  rmonPrintf("%d:\t(%d) Did %5d RSPRDP Tris in %.3f secs, %9llu Pixls/sec \n",
	     framecount, TestFuncNum, 
	     MAXRSPRDPT, (float) NumTicks / ((OSTime) (TICKSPERSEC)), 
	     (OSTime) (MAXRSPRDPT * 320 * 240) * (OSTime) TICKSPERSEC / NumTicks);  
}