rspverif.c 6.58 KB

/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1994, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *                                                                        *
 *************************************************************************/

/*
 * File:	rspverif.c
 * Creator:	hsa@sgi.com
 * Create Date:	Tue Apr 11 17:47:03 PDT 1995
 *
 *
 * This application is a test-bed of single frame tests for RSP
 * verification. The idea is that each frame possibly uses a different
 * dataset (see static.c) to render a particular test.
 *
 * This is the TEST-SPECIFIC file, see comment in main.c for more
 * information.
 *
 * TO ADD A TEST CASE:
 * New test cases require that you define the display list and add
 * a few simple things in the files rspverif.h, rspverif.c, static.c.
 * All locations are marked with comments that say "ADD TEST CASE"
 * and give some hints what you need to do there. See main.c for
 * detailed instructions.
 *
 *
 */

#include <ultra64.h>
#include <gu.h>
#include <em.h>

#include "rspverif.h"

u32   addrProjection, addrViewing, addrModeling;
u32   addrModel[20], addrModelPop[20], addrVP[17];

/* procedure to do the work for placebo case: */
void
testCasePlacebo(Dynamic *dynamicp, int caseno)
{
    static float	theta = 0.0;
    u16   		perspNorm;

    guPerspective(&dynamicp->projection,&perspNorm,
		  33, 320.0/240.0, 1, 500, 1.0);
    guLookAt(&dynamicp->viewing, 
	     0, 0, 200, 0, 0, 0, 0, 1, 0);

    guRotate(&dynamicp->modeling, theta, 0.0, 0.0, 1.0);

    /* fix dynamic seg addresses: */
    addrProjection = K0_TO_PHYS((u32) &(dynamicp->projection));
    addrViewing =    K0_TO_PHYS((u32) &(dynamicp->viewing));
    addrModeling =    K0_TO_PHYS((u32) &(dynamicp->modeling));

    gSPMatrix(glistp++, addrProjection,
	      G_MTX_PROJECTION|G_MTX_LOAD|G_MTX_NOPUSH);

    gSPMatrix(glistp++, addrViewing,
	      G_MTX_MODELVIEW|G_MTX_LOAD|G_MTX_NOPUSH);

    gSPMatrix(glistp++, addrModeling,
	      G_MTX_MODELVIEW|G_MTX_MUL|G_MTX_NOPUSH);

    gSPPerspNormalize(glistp++, perspNorm);

    gSPDisplayList(glistp++, testList[caseno]);

    gDPFullSync(glistp++);
}

/* procedure to do the work for test 0: */
void
testCaseProc0(Dynamic *dynamicp, int caseno)
{
    static float	theta = 0.0;
    u16   		perspNorm;

    guPerspective(&dynamicp->projection,&perspNorm,
		  33, 320.0/240.0, 1, 500, 1.0);
    guLookAt(&dynamicp->viewing, 
	     0, 0, 200, 0, 0, 0, 0, 1, 0);

    guRotate(&dynamicp->modeling, theta, 0.0, 0.0, 1.0);

    /* fix dynamic seg addresses: */
    addrProjection = K0_TO_PHYS((u32) &(dynamicp->projection));
    addrViewing =    K0_TO_PHYS((u32) &(dynamicp->viewing));
    addrModeling =    K0_TO_PHYS((u32) &(dynamicp->modeling));

    gSPMatrix(glistp++, addrProjection,
	      G_MTX_PROJECTION|G_MTX_LOAD|G_MTX_NOPUSH);

    gSPMatrix(glistp++, addrViewing,
	      G_MTX_MODELVIEW|G_MTX_LOAD|G_MTX_NOPUSH);

    gSPMatrix(glistp++, addrModeling,
	      G_MTX_MODELVIEW|G_MTX_MUL|G_MTX_NOPUSH);

    gSPPerspNormalize(glistp++, perspNorm);

    gSPDisplayList(glistp++, testList[caseno]);

    gDPFullSync(glistp++);
}

/* procedure to do the work for test 1: */
/* test of hw1 load tile problem */
void
testCaseProc1(Dynamic *dynamicp, int caseno)
{
    u16			perspNorm;

    guPerspective(&dynamicp->projection,&perspNorm,
		  33, 320.0/240.0, 10, 500, 1.0);
    guLookAt(&dynamicp->viewing, 
	     0, 0, 200, 0, 0, 0, 0, 1, 0);

    gSPPerspNormalize(glistp++, perspNorm);

    /* fix dynamic seg addresses: */
    addrProjection = K0_TO_PHYS((u32) &(dynamicp->projection));
    addrViewing =    K0_TO_PHYS((u32) &(dynamicp->viewing));

    gSPMatrix(glistp++, addrProjection,
	      G_MTX_PROJECTION|G_MTX_LOAD|G_MTX_NOPUSH);
    gSPMatrix(glistp++, addrViewing,
	      G_MTX_MODELVIEW|G_MTX_LOAD|G_MTX_NOPUSH);
    gSPDisplayList(glistp++, &(bg_dl[0]));

    gSPDisplayList(glistp++, &(diag_dl[0]));

    gDPFullSync(glistp++);

}

/* procedure to do the work for test 2: */
/* test of hw1 load tlut problem */
void
testCaseProc2(Dynamic *dynamicp, int caseno)
{
    static	float	scale = 0.0625;

    guOrtho(&dynamicp->projection,
		  -(float)SCREEN_WD/2.0F, (float)SCREEN_WD/2.0F,
		  -(float)SCREEN_HT/2.0F, (float)SCREEN_HT/2.0F,
		  1.0F, 10.0F, 1.0F);

    guLookAt(&dynamicp->viewing, 
	     128*scale, 512*scale, 5, 128*scale, 512*scale, 0, -1, 0, 0);

    guScale(&dynamicp->modeling, scale, scale, 1.0);

    /* fix dynamic seg addresses: */
    addrProjection = K0_TO_PHYS((u32) &(dynamicp->projection));
    addrViewing =    K0_TO_PHYS((u32) &(dynamicp->viewing));
    addrModeling =    K0_TO_PHYS((u32) &(dynamicp->modeling));

    gSPMatrix(glistp++, addrProjection,
	      G_MTX_PROJECTION|G_MTX_LOAD|G_MTX_NOPUSH);
    gSPMatrix(glistp++, addrViewing,
	      G_MTX_MODELVIEW|G_MTX_LOAD|G_MTX_NOPUSH);
    gSPMatrix(glistp++, addrModeling,
	      G_MTX_MODELVIEW|G_MTX_MUL|G_MTX_NOPUSH);

    /*
    gSPDisplayList(glistp++, &(bg_dl[0]));
    */

    gSPDisplayList(glistp++, &(ci_test_dl[0]));

    gDPFullSync(glistp++);

}

/* ADD TEST CASE: test frames: */
/* add procedure to do the work above here. */


/* 
 * ADD TEST CASE: test frames:
 *
 * Static display lists from static.c must be inserted in this
 * table, in the same position as the test's frame number.
 * 
 * NOTE: a test doesn't need to have a static display list, if
 * the corresponding testCaseProc doesn't use. But you still
 * need to put a NULL entry here in the table.
 *
 * It is a good idea to put your name beside the test, so others
 * can track you down with questions.
 *
 */
Gfx *testList[] = {	/* list of specific test Gfx display lists: */
    &(square0[0]),			/* hsa */
    &(placebo_dl[0]),			/* lipes */
    &(placebo_dl[0]),			/* lipes */
    &(placebo_dl[0]),

    /* add cases above here: */
    (Gfx *) NULL,	/* last one, to count them... */
};

/* 
 * ADD TEST CASE: test frames:
 * Above procedures to do the work for each test, must be
 * entered in the table here, in the same position as their
 * frame number.
 *
 */
CaseProc_t testCaseProcs[] =
{
    testCaseProc0,
    testCaseProc1,
    testCaseProc2,
    testCasePlacebo,

    testCasePlacebo,
};