gtstate.s 5.21 KB

/*
 * Copyright 1995, Silicon Graphics, Inc.
 * ALL RIGHTS RESERVED
 *
 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
 * States.   Use of a copyright notice is precautionary only and does not
 * imply publication or disclosure.
 *
 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:	
 * Use, duplication or disclosure by the Government is subject to restrictions
 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
 * Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
 *
 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
 * GRAPHICS, INC.
 *
 */
	
/*
 * File:		gtstate.s
 * Creator:		hsa@sgi.com
 * Create Date:		Thu Oct 12 11:04:55 PDT 1995
 *
 * This file processes the 'state' structures of the TURBO 3D
 * ucode.
 *
 */

.name	dpp,	$1
.name	w0,	$2
.name	w1,	$3
.name	mask,	$4
.name	retsave,	$5
.name   inputp,	$6
.name   tmp,	$7
.name	outsz,	$18	# used in OutputOpen
.name	addr,	$19

	################################################################
	#
	# global state processing
	#
GlobStateProc:

	# save return, call open, get DP block pointer
		add	retsave, zero, return
#if !(defined(OUTPUT_DRAM)||defined(OUTPUT_FIFO))
		jal	OutputOpen
		addi	outsz, zero, RSP_SETUP_TMP_SIZE8 + 8
#endif /* !(OUTPUT_DRAM || OUTPUT_FIFO) */
 		lw	addr, RSP_GLOB_DP_LISTP(zero)
	
	# send othermode word first:
		ldv	$v0[0], RSP_GLOB_STATE_OTHERMODE(rsp_state)
		sdv	$v0[0], 0(outp)
 		addi	outp, outp, 8

	# check for DP block==NULL
		beq	addr, zero, GlobDBBlockDone
		nop
	
		jal	AddrFixup
		nop

		addi	inputp, addr, 0
	
	# load DP block into setup tmp area
    ReadGlobDPBlock:
		addi	addr, inputp, 0
		addi	dpp, zero, RSP_SETUP_TMP_OFFSET + RSP_SETUP_TMP_SIZE8
		addi	$20, zero, RSP_SETUP_TMP_OFFSET
	# we always fetch one more command than we process, in
	# case the last command is a textured rectangle and we
	# need the extra 64 bits...
 		addi	$18, zero, RSP_SETUP_TMP_SIZE8 + 8 - 1
		jal	DMAproc
		addi	$17, zero, 0

	# wait for DP block to load:
		jal	DMAwait
		nop
	
	# process DP block
        NextGlobDPCmd:	
		lw	w0, 0($20)
		lw	w1, 4($20)
		beq	w0, zero, GlobDBBlockDone
		addi	$20, $20, 8
		addi	inputp, inputp, 8
	
	# identify RDP command as having an address or not...
		sra	mask, w0, 24
		addi	mask, mask, G_RDP_ADDR_FIXUP
		bltz	mask, doGRDPSend
		nop
	# RDP command has an address to patch...
		jal	AddrFixup
		add	addr, w1, zero		# delay slot
		add	w1, addr, zero
	# if RDP command doesn't have an addr, copy it verbatim.
    doGRDPSend:

	# check for TEXRECT command (ugh!):
		srl	mask, w0, 24
		andi	mask, mask, 0xfe	# handle rectflip, too
		addi	tmp, mask, -G_TEXRECT
		bne	tmp, zero, NotTEXRECT
		nop
		sw	w0, 0(outp)
		sw	w1, 4(outp)
 		addi	outp, outp, 8
	# grab the next 64 bits and pass it on to the RDP also.
	# it's guarenteed to be there, since we always page in 8
	# more bytes than we need...
		lw	w0,  0($20)
		lw	w1,  4($20)
		addi	$20, $20, 8
		addi	inputp, inputp, 8

    NotTEXRECT:
		sw	w0,  0(outp)
		sw	w1,  4(outp)
 		addi	outp, outp, 8

	# check for need to page in more cmds
		bne	$20, dpp, NextGlobDPCmd
		nop	
	
	# process next chunk of DP block
	GetMoreGlobDBCmds:
		jal	OutputClose
		nop			# close-open sequence for xbus wrap

#if !(defined(OUTPUT_DRAM)||defined(OUTPUT_FIFO))
		jal	OutputOpen
		addi	outsz, zero, RSP_SETUP_TMP_SIZE8
#endif /* !(OUTPUT_DRAM || OUTPUT_FIFO) */

		j	ReadGlobDPBlock
		nop
		
    GlobDBBlockDone:	
		jal	OutputClose
		nop

		jr	retsave
		nop
	#
	#
	################################################################
	

	################################################################
	#
	# object state processing
	#
	# so far, the only real work to the state is to dump
	# the DP data.
	#
ObjStateProc:

		add	retsave, zero, return

	# check flag, see if we can avoid loading the matrix:
		lb	tmp, RSP_STATE_FLAG(rsp_state)
		andi	tmp, tmp, 0x01
		bgtz	tmp, DontLoadMtx		

	# load the matrix:
 		add	$19, zero, gfx0
		jal	AddrFixup
		addi	$19, $19,  RSP_OBJ_STATE_SIZE8 - 64
		addi	$20, zero, RSP_CURR_MPMTX_OFFSET
 		addi	$18, zero, 64 - 1
		jal	DMAproc
		addi	$17, zero, 0
	# wait for matrix to load. Can't do anything while we wait
		jal	DMAwait
		nop
    DontLoadMtx:


#if !(defined(OUTPUT_DRAM)||defined(OUTPUT_FIFO))
		jal	OutputOpen
		addi	outsz, zero, 8 + RSP_SETUP_TMP_SIZE8 # worst case
#endif /* !(OUTPUT_DRAM || OUTPUT_FIFO) */

	# send othermode word first:
		ldv	$v0[0], RSP_STATE_OTHERMODE(rsp_state)
		sdv	$v0[0], 0(outp)
 		addi	outp, outp, 8
	
	# check for rdp block:
 		lw	addr, RSP_STATE_RDP(rsp_state)
	
	# check for DP block==NULL
		beq	addr, zero, GlobDBBlockDone
		nop
	
		jal	AddrFixup
		nop
	
		addi	inputp, addr, 0
	
		j	ReadGlobDPBlock
		nop
	#
	#
	################################################################
	
.unname dpp
.unname w0
.unname w1
.unname	mask
.unname	retsave
.unname inputp
.unname tmp
.unname	outsz
.unname	addr