tbl.s 11.8 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
 # Test cases for blender unit

 # regs $10 .. $15 are available for use

#if 1
 ######################################################################
 ###### RMW TEMPLATE ##################################################
 ######################################################################
 #
 # Test the left blender multiply:
 # Use force_blend=1 and color_on_cov=0 to select pixel color out.
 # Use b=0 and memcol=0 to zero right mul input.
 # Use every combo of pix col and alpha for every multiplier possibility.
 # Pix col and alpha both come from shadecol except in alpha=1.0 case where 
 # alpha must come from coverage.


.name pixcol,	$10
.name alpha1,	$11

	ori	numtst, zero, TEST_RMW
rmw:
	ori	pixcol, zero, 0			# pixcol=0..ff   by 1
	ori	alpha1, zero, 0			# alpha = 0..f8  by 8
	ori	shadecov, zero, 0x8		# shadecov = full

rmw_loop:
	jal	clobberNextTri			# clear mem to black
	ori	shadecol, zero, 0		#

	jal     sendDL				# set modes for this test
        ori     parm1, zero, RMW_DL		# 

	jal	sendTri				# do the test
	or	shadecol, pixcol, alpha1	#

	addi	alpha1, alpha1, 0x8		# next alpha
	andi	alpha1, alpha1, 0xff		#
	bne	alpha1, zero, rmw_loop		#
	nop

	lui	parm1, 0x0101			# next pixcol
	ori	parm1, parm1, 0x0100		#
	add	pixcol, pixcol, parm1		#
	lui	parm1, 0x0101			#
	ori	parm1, 0x0000			#
 	bne	parm1, pixcol, rmw_loop	#
	nop
	
.unname pixcol
.unname alpha1
 #
 #
 ############## END OF RMW TEMPLATE ###################################
#endif

#if 1
 ######################################################################
 ###### LEFT LERP MULTIPLYER TEST #####################################
 ######################################################################
 #
 # Test the left blender multiply:
 # Use force_blend=1 and color_on_cov=0 to select pixel color out.
 # Use blendcolor=0 to zero right mul input.
 # use p=pixcol, a=pixa, m=blendcol, b=0
 # Use every combo of pix col and alpha for every multiplier possibility.
 # Pix col and alpha both come from shadecol except in alpha=1.0 case where 
 # alpha must come from coverage. Alpha steps by 0x08.


.name pixcol,	$10
.name alpha1,	$11
.name alphacvg,	$12

	ori	numtst, zero, TEST_BL_LLMT
llmt:
	lui	pixcol, 0xff00			# pixcol=0..ff   by 1
	ori	pixcol, pixcol, 0xff00		# pixcol=0..ff   by 1
	ori	shadecov, zero, 0x8		# shadecov = full

llmt_loop_pix:
	ori	alpha1, zero, 0			# alpha = 0..f8  by 8
	ori	alphacvg, zero, 0		# alpha from alpha
	jal     sendDL				# set modes for this test
        ori     parm1, zero, LLMT_DL		# 

llmt_loop_alpha:
	jal	sendNextTri			# do the test
	or	shadecol, pixcol, alpha1	#

	addi	alpha1, alpha1, 0x8		# next alpha
	andi	alpha1, alpha1, 0xff		#
	bne	alpha1, zero, llmt_loop_alpha	#
	nop

	bne	alphacvg, zero, llmt_nextpixcol	# do alpha=1.0 (alpha=cvg)
	ori	alpha1, zero, 0xf8		# do 1 extra pixel

	ori	alphacvg, zero, 1			# alpha from coverage
	jal     sendDL				# set modes for this test
        ori     parm1, zero, LLMT2_DL		# turn on alpha_cvg_sel

 # jal	sendNextTri			# Make a blue mark
 # ori	shadecol, zero, 0xffff		#

	j	llmt_loop_alpha
	nop

llmt_nextpixcol:
	lui	parm1, 0xff00			# next pixcol
	ori	parm1, parm1, 0xff00		#
	add	pixcol, pixcol, parm1		#
	lui	parm1, 0xffff			#
	ori	parm1, 0xff00			#
 	bne	parm1, pixcol, llmt_loop_pix	#
	nop
	
.unname pixcol
.unname alpha1
.unname alphacvg
 #
 #
 ############## END OF LEFT LERP MULTIPLYER TEST ######################
#endif /* 0 */

#if 1
 ######################################################################
 ###### RIGHT LERP MULTIPLYER TEST ####################################
 ######################################################################
 #
 # Test the right blender multiply:
 # Use force_blend=1 and color_on_cov=0 to select pixel color out.
 # Use blendcolor=0 to zero left mul input.
 # use p=blendcol, a=pixa, m=pixcol, b=ff-A
 # Use every combo of pix col and alpha for every multiplier possibility.
 # Pix col and alpha both come from shadecol. Alpha steps by 0x08.


.name pixcol,	$10
.name alpha1,	$11

	ori	numtst, zero, TEST_BL_RLMT
rlmt:
	lui	pixcol, 0x00ff			# pixcol=0..ff   by 1
	ori	alpha1, zero, 0			# alpha = 0..f8  by 8
	ori	shadecov, zero, 0x8		# shadecov = full

	jal     sendDL				# set modes for this test
        ori     parm1, zero, RLMT_DL		# 

rlmt_loop:
	jal	sendNextTri			# do the test
	or	shadecol, pixcol, alpha1	#

	addi	alpha1, alpha1, 0x8		# next alpha
	andi	alpha1, alpha1, 0xf8		#
	bne	alpha1, zero, rlmt_loop		#
	nop

	lui	parm1, 0x00ff			# next pixcol
	ori	parm1, parm1, 0x0100		#
	add	pixcol, pixcol, parm1		#
	lui	parm1, 0x0000			#
	ori	parm1, 0x0000			#
 	bne	parm1, pixcol, rlmt_loop	#
	nop
	
.unname pixcol
.unname alpha1
 #
 #
 ############## END OF RIGHT LERP MULTIPLYER TEST #####################
#endif /* 0 */

#if 1
 ######################################################################
 ###### MAIN ADDER TEST ###############################################
 ######################################################################
 #
 # Test the main color adder:
 # Use force_blend=1 and color_on_cov=0 to select pixel color out.
 # Use memcol = blendcolor =  pow's of 2 & +1, -1 & negatives
 # Use pixcolor = pow's of 2 & +1, -1 & negatives
 # Use a=alpha = 0...0xff by 8
 # Use b= 0, ff, and 1-A
 # use p=pixcolor, a=pixa, m=blendcolor, b=ff, 0, and ff-A

#define PIXIN	SC0
#define MEMIN	SC1

.name	alpha,	$10

	ori	numtst, zero, TEST_BL_MAINADD
mad:  
	sw	zero, PIXIN(zero)
	sw	zero, MEMIN(zero)
	ori	alpha, zero, 0x00

mad_loop:
	jal     sendDL				# b = 0
	ori     parm1, zero, MAD1_DL		# 

	lw	parm1, MEMIN(zero)		# blendcolor = MEMIN
	andi	parm1, parm1, 0xff		#
	sll	parm2, parm1, 24		#
	xori	parm1, parm1, 0xff		# make colorful
	sll	parm1, parm1, 8			#
	or	parm2, parm2, parm1		#
	sll	parm1, parm1, 8			#
	or	parm2, parm2, parm1		#

	jal	sendCmd				#
	lui	parm1, 0xf900			#

	lw	parm1, PIXIN(zero)		# shadecolor = PIXIN, alpha
	andi	parm1, parm1, 0xff		#
	sll	shadecol, parm1, 8		#
	xori	parm1, parm1, 0xff		# make colorful
	sll	parm1, parm1, 24		#
	or	shadecol, shadecol, parm1	#
	srl	parm1, parm1, 8			#
	or	shadecol, shadecol, parm1	#

	jal	sendNextTri			# DO A PIXEL
	or	shadecol, shadecol, alpha	#


	jal     sendDL				# b = ff
	ori     parm1, zero, MAD2_DL		# 
	
	jal	sendNextTri			# DO A PIXEL
	nop					#
	

	jal     sendDL				# b = 1-A
	ori     parm1, zero, MAD3_DL		# 
	
	jal	sendNextTri			# DO A PIXEL
	nop					#


	jal	nxtnum				# next pixel color
	lw	parm1, PIXIN(zero)		#
	andi	parm2, parm1, 0xff		#
	bne	parm2, zero, mad_loop		#
	sw	parm1, PIXIN(zero)		#


	addi	alpha, alpha, 8			# next alpha
	andi	alpha, alpha, 0xff		#
	bne	alpha, zero, mad_loop		# 
	nop					#


	jal	nxtnum				# next mem color
	lw	parm1, MEMIN(zero)		#
	andi	parm2, parm1, 0xff		#
	bne	parm2, zero, mad_loop		#
	sw	parm1, MEMIN(zero)		#

.unname	alpha
	
 #
 #
 ############## END OF MAIN ADDER TEST ################################
#endif /* 0 */

#if 1
 ######################################################################
 ###### ALPHA ADDER TEST ##############################################
 ######################################################################
 #
 # Test the main color adder:
 # Use force_blend=1 and color_on_cov=0 to select pixel color out.
 # Use memcol = blendcolor =  pow's of 2 & +1, -1 & negatives
 # Use pixcolor = pow's of 2 & +1, -1 & negatives
 # Use a=alpha = 0...0xff by 8
 # Use b= 0, ff, and 1-A
 # use p=pixcolor, a=pixa, m=blendcolor, b=ff, 0, and ff-A

.name aval,	$10			# 1.5 format
.name bval,	$11			# 1.5 format

	ori	numtst, zero, TEST_BL_ALPHADD
aad:  
	addi	shadecol, zero, -1		#
	ori	aval, zero, 0			#
	ori	bval, zero, 0			#

	jal     sendDL				# Modes...
 #	ori     parm1, zero, aad_DL		# 

aad_loop:
	# STORE DZ AND A(CVG) IN SPANBUF HERE
 #
 # clear spanbuf
 #
	srl	shadecov, bval, 2		# bval (mema) is coverage
	jal	clobberNextTri			# clear cvg to bval
	ori	shadecol, zero, 0		#

	ori	shadecov, zero, 0x8		# coverage returns to full
 #
 # end clear spanbuf
 #

	ori	parm2, zero, 0			# find pixcol value
	ori	parm1, zero, 0x07ff		# what we want the numerator to be
aad_pc_loop:					#
	addi	parm3, parm2, -255		#
	beq	parm3, zero, aad_pc_found	#
	sub	parm1, parm1, aval		#
	bgez	parm1, aad_pc_loop		#
	addi	parm2, parm2, 1			#

	addi	parm2, parm2, -1		# parm2 = shadecol val
aad_pc_found:					#
	add	parm1, parm1, aval		# parm1 = what to get from mem

	sll	shadecol, parm2, 16		# use green only
	sll	parm2, aval, 3			# convert from 1.5 to 1.8 format
	or	shadecol, shadecol, parm2	#
	
	
	ori	parm2, zero, 0			# find pixcol value
aad_mc_loop:					#
	addi	parm3, parm2, -255		#
	beq	parm3, zero, aad_mc_found	#
	sub	parm1, parm1, aval		#
	bgez	parm1, aad_mc_loop		#
	addi	parm2, parm2, 1			#

	addi	parm2, parm2, -1		# parm2 = shadecol val
aad_mc_found:					#
	sll	parm2, parm2, 16		# use green only
	jal	sendCmd				# put in blend color
	lui	parm1, 0xf900			#


	jal	sendNextTri			# DO A PIXEL
	nop					#
	
	
	addi	aval, aval, 0x4			# next aval
	add	parm1, aval, bval		#
	addi	parm1, parm1, (-1*0x20)	# aval + bval <= 1.0
	blez	parm1, aad_loop			#
	nop					#

	addi	bval, bval, 0x4			# next bval
	addi	parm1, bval, (-1*0x20)	#
	bltz	parm1, aad_loop			# range up to 0x1c (in 0.5 format)
	nop
	
	
.unname aval
.unname bval


 #
 #
 ############## END OF ALPHA ADDER TEST ###############################
#endif /* 0 */

#if 0
 jal	sendDL
 ori	parm1, zero, RECT_DL

 ori shadecov, zero, 50
 jal sendRect
#endif

#if 1
 ######################################################################
 ###### LEFT LERP MULTIPLYER TEST RECT ################################
 ######################################################################
 #
 # Test the left blender multiply:
 # Use force_blend=1 and color_on_cov=0 to select pixel color out.
 # Use blendcolor=0 to zero right mul input.
 # use p=pixcol, a=pixa, m=blendcol, b=0
 # Use every combo of pix col and alpha for every multiplier possibility.
 # Pix col and alpha both come from shadecol except in alpha=1.0 case where 
 # alpha must come from coverage. Alpha steps by 0x08.

 # pixcol=tex alpha=tex memcol=blendcol=0 b=0


.name pixcol,	$10
.name alpha1,	$11
.name alphacvg,	$12

	ori	numtst, zero, TEST_BL_LLMT_R
llmtr:

	jal     sendDL				# set modes for this test
        ori     parm1, zero, LLMTR_DL		# 

	ori	tloc_x, zero, START_X
	ori	tloc_y, zero, (START_Y+0)
	ori	shadecol, zero, 0
	jal	sendRect
	ori	shadecov, zero, 250

 #	jal     sendDL				# set modes for this test
 #	ori     parm1, zero, LLMTR2_DL		# 

	ori	tloc_x, zero, START_X
	ori	tloc_y, zero, (START_Y+20)
	ori	shadecol, zero, 250
	jal	sendRect
	ori	shadecov, zero, 250
	
 #	jal     sendDL				# set modes for this test
 #	ori     parm1, zero, LLMTR3_DL		# 

	ori	tloc_x, zero, START_X
	ori	tloc_y, zero, (START_Y+40)
	ori	shadecol, zero, 500
	jal	sendRect
	ori	shadecov, zero, 180
	
	


#if 0



	lui	pixcol, 0xff00			# pixcol=0..ff   by 1
	ori	pixcol, pixcol, 0xff00		# pixcol=0..ff   by 1
	ori	shadecov, zero, 0x8		# shadecov = full

llmt_loop_pix_r:
	ori	alpha1, zero, 0			# alpha = 0..f8  by 8
	ori	alphacvg, zero, 0		# alpha from alpha
	jal     sendDL				# set modes for this test
        ori     parm1, zero, LLMT_DL		# 

llmt_loop_alpha_r:
	jal	sendNextTri			# do the test
	or	shadecol, pixcol, alpha1	#

	addi	alpha1, alpha1, 0x8		# next alpha
	andi	alpha1, alpha1, 0xff		#
	bne	alpha1, zero, llmt_loop_alpha_r	#
	nop

	bne	alphacvg, zero, llmt_nextpixcol_r	# do alpha=1.0 (alpha=cvg)
	ori	alpha1, zero, 0xf8		# do 1 extra pixel

	ori	alphacvg, zero, 1			# alpha from coverage
	jal     sendDL				# set modes for this test
        ori     parm1, zero, LLMT2_DL_R		# turn on alpha_cvg_sel

 # jal	sendNextTri			# Make a blue mark
 # ori	shadecol, zero, 0xffff		#

	j	llmt_loop_alpha_r
	nop

llmt_nextpixcol_r:
	lui	parm1, 0xff00			# next pixcol
	ori	parm1, parm1, 0xff00		#
	add	pixcol, pixcol, parm1		#
	lui	parm1, 0xffff			#
	ori	parm1, 0xff00			#
 	bne	parm1, pixcol, llmt_loop_pix_r	#
	nop
#endif
	
.unname pixcol
.unname alpha1
.unname alphacvg
 #
 #
 ############## END OF LEFT LERP MULTIPLYER RECT ######################
#endif /* 0 */


	nop
stop_bl:
	nop