17117f1b4Smrg/*
27ec681f3Smrg * Written by José Fonseca <j_r_fonseca@yahoo.co.uk>
37117f1b4Smrg */
47117f1b4Smrg
57117f1b4Smrg
67117f1b4Smrg/*
73464ebd5Sriastradh * void _mesa_mmx_blend( struct gl_context *ctx,
87117f1b4Smrg *                       GLuint n,
97117f1b4Smrg *                       const GLubyte mask[],
107117f1b4Smrg *                       GLchan rgba[][4],
117117f1b4Smrg *                       CONST GLchan dest[][4] )
127117f1b4Smrg *
137117f1b4Smrg */
147117f1b4SmrgALIGNTEXT16
157117f1b4SmrgGLOBL GLNAME( TAG(_mesa_mmx_blend) )
167117f1b4SmrgHIDDEN( TAG(_mesa_mmx_blend) )
177117f1b4SmrgGLNAME( TAG(_mesa_mmx_blend) ):
187ec681f3Smrg    _CET_ENDBR
197117f1b4Smrg    PUSH_L     ( EBP )
207117f1b4Smrg    MOV_L      ( ESP, EBP )
217117f1b4Smrg    PUSH_L     ( ESI )
227117f1b4Smrg    PUSH_L     ( EDI )
237117f1b4Smrg    PUSH_L     ( EBX )
247117f1b4Smrg
257117f1b4Smrg    MOV_L      ( REGOFF(12, EBP), ECX )		/* n */
267117f1b4Smrg    CMP_L      ( CONST(0), ECX)
277117f1b4Smrg    JE         ( LLTAG(GMB_return) )
287117f1b4Smrg
297117f1b4Smrg    MOV_L      ( REGOFF(16, EBP), EBX )		/* mask */
307117f1b4Smrg    MOV_L      ( REGOFF(20, EBP), EDI )         /* rgba */
317117f1b4Smrg    MOV_L      ( REGOFF(24, EBP), ESI )         /* dest */
327117f1b4Smrg
337117f1b4Smrg    INIT
347117f1b4Smrg
357117f1b4Smrg    TEST_L     ( CONST(4), EDI )		/* align rgba on an 8-byte boundary */
367117f1b4Smrg    JZ         ( LLTAG(GMB_align_end) )
377117f1b4Smrg
387117f1b4Smrg    CMP_B      ( CONST(0), REGIND(EBX) )	/* *mask == 0 */
397117f1b4Smrg    JE         ( LLTAG(GMB_align_continue) )
407117f1b4Smrg
417117f1b4Smrg    /* runin */
427117f1b4Smrg#define ONE(x)	x
437117f1b4Smrg#define TWO(x)
447117f1b4Smrg    MAIN       ( EDI, ESI )
457117f1b4Smrg#undef ONE
467117f1b4Smrg#undef TWO
477117f1b4Smrg
487117f1b4SmrgLLTAG(GMB_align_continue):
497117f1b4Smrg
507117f1b4Smrg    DEC_L      ( ECX )				/* n -= 1 */
517117f1b4Smrg    INC_L      ( EBX )		                /* mask += 1 */
527117f1b4Smrg    ADD_L      ( CONST(4), EDI )		/* rgba += 1 */
537117f1b4Smrg    ADD_L      ( CONST(4), ESI )		/* dest += 1 */
547117f1b4Smrg
557117f1b4SmrgLLTAG(GMB_align_end):
567117f1b4Smrg
577117f1b4Smrg    CMP_L      ( CONST(2), ECX)
587117f1b4Smrg    JB         ( LLTAG(GMB_loop_end) )
597117f1b4Smrg
607117f1b4SmrgALIGNTEXT16
617117f1b4SmrgLLTAG(GMB_loop_begin):
627117f1b4Smrg
637117f1b4Smrg    CMP_W      ( CONST(0), REGIND(EBX) )	/* *mask == 0 && *(mask + 1) == 0 */
647117f1b4Smrg    JE         ( LLTAG(GMB_loop_continue) )
657117f1b4Smrg
667117f1b4Smrg    /* main loop */
677117f1b4Smrg#define ONE(x)
687117f1b4Smrg#define TWO(x)	x
697117f1b4Smrg    MAIN       ( EDI, ESI )
707117f1b4Smrg#undef ONE
717117f1b4Smrg#undef TWO
727117f1b4Smrg
737117f1b4SmrgLLTAG(GMB_loop_continue):
747117f1b4Smrg
757117f1b4Smrg    DEC_L      ( ECX )
767117f1b4Smrg    DEC_L      ( ECX )				/* n -= 2 */
777117f1b4Smrg    ADD_L      ( CONST(2), EBX )		/* mask += 2 */
787117f1b4Smrg    ADD_L      ( CONST(8), EDI )		/* rgba += 2 */
797117f1b4Smrg    ADD_L      ( CONST(8), ESI )		/* dest += 2 */
807117f1b4Smrg    CMP_L      ( CONST(2), ECX )
817117f1b4Smrg    JAE        ( LLTAG(GMB_loop_begin) )
827117f1b4Smrg
837117f1b4SmrgLLTAG(GMB_loop_end):
847117f1b4Smrg
857117f1b4Smrg    CMP_L      ( CONST(1), ECX )
867117f1b4Smrg    JB         ( LLTAG(GMB_done) )
877117f1b4Smrg
887117f1b4Smrg    CMP_B      ( CONST(0), REGIND(EBX) )	/* *mask == 0 */
897117f1b4Smrg    JE         ( LLTAG(GMB_done) )
907117f1b4Smrg
917117f1b4Smrg    /* runout */
927117f1b4Smrg#define ONE(x)	x
937117f1b4Smrg#define TWO(x)
947117f1b4Smrg    MAIN       ( EDI, ESI )
957117f1b4Smrg#undef ONE
967117f1b4Smrg#undef TWO
977117f1b4Smrg
987117f1b4SmrgLLTAG(GMB_done):
997117f1b4Smrg
1007117f1b4Smrg    EMMS
1017117f1b4Smrg
1027117f1b4SmrgLLTAG(GMB_return):
1037117f1b4Smrg
1047117f1b4Smrg    POP_L      ( EBX )
1057117f1b4Smrg    POP_L      ( EDI )
1067117f1b4Smrg    POP_L      ( ESI )
1077117f1b4Smrg    MOV_L      ( EBP, ESP )
1087117f1b4Smrg    POP_L      ( EBP )
1097117f1b4Smrg    RET
1107117f1b4Smrg
1117117f1b4Smrg#undef TAG
1127117f1b4Smrg#undef LLTAG
1137117f1b4Smrg#undef INIT
1147117f1b4Smrg#undef MAIN
115