Loading libpixelflinger/Android.mk +9 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,14 @@ PIXELFLINGER_SRC_FILES_mips := \ arch-mips/t32cb16blend.S \ endif PIXELFLINGER_SRC_FILES_mips64 := \ codeflinger/MIPSAssembler.cpp \ codeflinger/MIPS64Assembler.cpp \ codeflinger/mips64_disassem.c \ arch-mips64/col32cb16blend.S \ arch-mips64/t32cb16blend.S \ # # Shared library # Loading @@ -59,6 +67,7 @@ LOCAL_SRC_FILES := $(PIXELFLINGER_SRC_FILES) LOCAL_SRC_FILES_arm := $(PIXELFLINGER_SRC_FILES_arm) LOCAL_SRC_FILES_arm64 := $(PIXELFLINGER_SRC_FILES_arm64) LOCAL_SRC_FILES_mips := $(PIXELFLINGER_SRC_FILES_mips) LOCAL_SRC_FILES_mips64 := $(PIXELFLINGER_SRC_FILES_mips64) LOCAL_CFLAGS := $(PIXELFLINGER_CFLAGS) LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_C_INCLUDES += $(LOCAL_EXPORT_C_INCLUDE_DIRS) \ Loading libpixelflinger/arch-mips/col32cb16blend.S 0 → 100644 +134 −0 Original line number Diff line number Diff line /* ** Copyright 2015, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ .macro pixel dreg src f sR sG sB shift #if __mips==32 && __mips_isa_rev>=2 /* extract red */ ext $t4,\src,\shift+11,5 mul $t4,$t4,\f /* extract green */ ext $t5,\src,\shift+5,6 mul $t5,$t5,\f /* extract blue */ ext $t6,\src,\shift,5 mul $t6,$t6,\f #else /* extract red */ srl $t4,\src,\shift+11 andi $t4, 0x1f mul $t4,$t4,\f /* extract green */ srl $t5,\src,\shift+5 andi $t5, 0x3f mul $t5,$t5,\f /* extract blue */ srl $t6,\src,\shift andi $t6, 0x1f mul $t6,$t6,\f #endif srl $t4,$t4,8 srl $t5,$t5,8 srl $t6,$t6,8 addu $t4,$t4,\sR addu $t5,$t5,\sG addu \dreg,$t6,\sB sll $t4,$t4,11 sll $t5,$t5,5 or \dreg,\dreg,$t4 or \dreg,\dreg,$t5 andi \dreg, 0xffff .endm .text .align .global scanline_col32cb16blend_mips .ent scanline_col32cb16blend_mips scanline_col32cb16blend_mips: /* check if count is zero */ srl $v0,$a1,24 /* sA */ beqz $a2,done li $t4, 0x100 srl $v1,$v0,7 addu $v0,$v1,$v0 subu $v0,$t4,$v0 /* f */ #if __mips==32 && __mips_isa_rev>=2 ext $a3,$a1,3,5 /* sR */ ext $t0,$a1,10,6 /* sG */ ext $t1,$a1,19,5 /* sB */ #else srl $a3, $a1, 3 andi $a3, 0x1f /* sR */ srl $t0, $a1, 10 andi $t0, 0x3f /* sG */ srl $t1, $a1, 19 andi $t1, 0x1f /* sB */ #endif /* check if cnt is at least 4 */ addiu $a2,$a2,-4 bltz $a2,tail loop_4pixels: lw $t7,0($a0) lw $t8,4($a0) addiu $a0,$a0,8 addiu $a2,$a2,-4 pixel $t2 $t7 $v0 $a3 $t0 $t1 0 pixel $t3 $t7 $v0 $a3 $t0 $t1 16 #if __mips==32 && __mips_isa_rev>=2 ins $t2,$t3,16,16 #else sll $t3, 16 or $t2, $t2, $t3 #endif pixel $t7 $t8 $v0 $a3 $t0 $t1 0 pixel $t3 $t8 $v0 $a3 $t0 $t1 16 #if __mips==32 && __mips_isa_rev>=2 ins $t7,$t3,16,16 #else sll $t3, 16 or $t7, $t7, $t3 #endif sw $t2,-8($a0) sw $t7,-4($a0) bgez $a2, loop_4pixels tail: /* the pixel count underran, restore it now */ addiu $a2,$a2,4 /* handle the last 0..3 pixels */ beqz $a2,done loop_1pixel: lhu $t7,0($a0) addiu $a0,$a0,2 addiu $a2,$a2,-1 pixel $t2 $t7 $v0 $a3 $t0 $t1 0 sh $t2, -2($a0) bnez $a2,loop_1pixel done: j $ra .end scanline_col32cb16blend_mips libpixelflinger/arch-mips/t32cb16blend.S +191 −182 Original line number Diff line number Diff line Loading @@ -55,7 +55,12 @@ DBG .set at ext $t8,\src,3,5 # src[7..3] srl $t6,8 addu $t8,$t6 ins \fb,$t8,\shift+6+5,5 # dst[\shift:15..11] .if \shift!=0 sll $t8,\shift+11 or \fb,$t8 .else sll \fb,$t8,11 .endif /* green */ mul $t8,$t0,$t7 Loading @@ -66,11 +71,13 @@ DBG .set at /* blue */ mul $t0,$t0,$t7 ins \fb,$t8,\shift+5,6 # finish green insertion dst[\shift:10..5] sll $t8, $t8, \shift+5 or \fb, \fb, $t8 ext $t6,\src,(3+8+8),5 srl $t8,$t0,8 addu $t8,$t6 ins \fb,$t8,\shift,5 sll $t8, $t8, \shift or \fb, \fb, $t8 DBG .set noat DBG rdhwr $t8,$2 Loading Loading @@ -215,6 +222,7 @@ fourpixels: lw $t3,-8($a0) pixel $t3,$t4,$t1,0 andi $t1, 0xFFFF pixel $t3,$t5,$t1,16 sw $t1,-8($a0) Loading @@ -231,6 +239,7 @@ fourpixels: lw $t3,-4($a0) pixel $t3,$t4,$t1,0 andi $t1, 0xFFFF pixel $t3,$t5,$t1,16 sw $t1,-4($a0) Loading libpixelflinger/arch-mips64/col32cb16blend.S 0 → 100644 +108 −0 Original line number Diff line number Diff line /* ** Copyright 2015, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ .macro pixel dreg src f sR sG sB shift /* extract red */ .if \shift < 32 dext $t0,\src,\shift+11,5 .else dextu $t0,\src,\shift+11,5 .endif mul $t0,$t0,\f /* extract green */ .if \shift < 32 dext $t1,\src,\shift+5,6 .else dextu $t1,\src,\shift+5,6 .endif mul $t1,$t1,\f /* extract blue */ .if \shift < 32 dext $t2,\src,\shift,5 .else dextu $t2,\src,\shift,5 .endif mul $t2,$t2,\f srl $t0,$t0,8 srl $t1,$t1,8 srl $t2,$t2,8 addu $t0,$t0,\sR addu $t1,$t1,\sG addu \dreg,$t2,\sB sll $t0,$t0,11 sll $t1,$t1,5 or \dreg,\dreg,$t0 or \dreg,\dreg,$t1 .endm .text .align .global scanline_col32cb16blend_mips64 .ent scanline_col32cb16blend_mips64 scanline_col32cb16blend_mips64: /* check if count is zero */ srl $v0,$a1,24 /* sA */ beqz $a2,done li $t0, 0x100 srl $v1,$v0,7 addu $v0,$v1,$v0 subu $v0,$t0,$v0 /* f */ ext $a3,$a1,3,5 /* sR */ ext $a4,$a1,10,6 /* sG */ ext $a5,$a1,19,5 /* sB */ /* check if cnt is at least 4 */ addiu $a2,$a2,-4 bltz $a2,tail loop_4pixels: ld $t3,0($a0) daddiu $a0,$a0,8 addiu $a2,$a2,-4 pixel $a6 $t3 $v0 $a3 $a4 $a5 0 pixel $a7 $t3 $v0 $a3 $a4 $a5 16 pixel $t8 $t3 $v0 $a3 $a4 $a5 32 pixel $t9 $t3 $v0 $a3 $a4 $a5 48 dins $a6,$a7,16,16 dinsu $a6,$t8,32,16 dinsu $a6,$t9,48,16 sd $a6,-8($a0) bgez $a2, loop_4pixels tail: /* the pixel count underran, restore it now */ addiu $a2,$a2,4 /* handle the last 0..3 pixels */ beqz $a2,done loop_1pixel: lhu $t3,0($a0) daddiu $a0,$a0,2 addiu $a2,$a2,-1 pixel $a6 $t3 $v0 $a3 $a4 $a5 0 sh $a6, -2($a0) bnez $a2,loop_1pixel done: j $ra .end scanline_col32cb16blend_mips64 libpixelflinger/arch-mips64/t32cb16blend.S 0 → 100644 +172 −0 Original line number Diff line number Diff line /* ** Copyright 2015, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ #ifdef DEBUG #define DBG #else #define DBG # #endif /* * blend one of 2 16bpp RGB pixels held in dreg selected by shift * with the 32bpp ABGR pixel held in src and store the result in fb * * Assumes that the dreg data is little endian and that * the the second pixel (shift==16) will be merged into * the fb result * * Uses $a4,$t2,$t3,$t8 */ .macro pixel dreg src fb shift /* * sA = s >> 24 * f = 0x100 - (sA + (sA>>7)) */ srl $t3,\src,24 srl $t2,$t3,7 addu $t3,$t2 li $t2,0x100 subu $t3,$t2,$t3 /* red */ ext $t8,\dreg,\shift+6+5,5 # dst[\shift:15..11] mul $t2,$t8,$t3 ext $a4,\dreg,\shift+5,6 # start green extraction dst[\shift:10..5] ext $t8,\src,3,5 # src[7..3] srl $t2,8 addu $t8,$t2 .if \shift!=0 sll $t8,\shift+11 # dst[\shift:15..11] or \fb,$t8 .else sll \fb,$t8,11 .endif /* green */ mul $t8,$a4,$t3 ext $a4,\dreg,\shift,5 # start blue extraction dst[\shift:4..0] ext $t2,\src,2+8,6 # src[15..10] srl $t8,8 addu $t8,$t2 /* blue */ mul $a4,$a4,$t3 sll $t8, $t8, \shift+5 # finish green insertion dst[\shift:10..5] or \fb, \fb, $t8 ext $t2,\src,(3+8+8),5 srl $t8,$a4,8 addu $t8,$t2 sll $t8, $t8, \shift or \fb, \fb, $t8 .endm .text .align .global scanline_t32cb16blend_mips64 .ent scanline_t32cb16blend_mips64 scanline_t32cb16blend_mips64: daddiu $sp, $sp, -40 DBG li $v0,0xffffffff DBG li $v1,0 /* Align the destination if necessary */ and $a4,$a0,3 beqz $a4,aligned /* as long as there is at least one pixel */ beqz $a2,done lw $t0,($a1) daddu $a0,2 daddu $a1,4 beqz $t0,1f lhu $a7,-2($a0) pixel $a7,$t0,$a5,0 sh $a5,-2($a0) 1: subu $a2,1 aligned: /* Check to see if its worth unrolling the loop */ subu $a2,4 bltz $a2,tail /* Process 4 pixels at a time */ fourpixels: /* 1st pair of pixels */ lw $t0,0($a1) lw $t1,4($a1) daddu $a0,8 daddu $a1,16 /* both are zero, skip this pair */ or $a7,$t0,$t1 beqz $a7,1f /* load the destination */ lw $a7,-8($a0) pixel $a7,$t0,$a5,0 andi $a5, 0xFFFF pixel $a7,$t1,$a5,16 sw $a5,-8($a0) 1: /* 2nd pair of pixels */ lw $t0,-8($a1) lw $t1,-4($a1) /* both are zero, skip this pair */ or $a7,$t0,$t1 beqz $a7,1f /* load the destination */ lw $a7,-4($a0) pixel $a7,$t0,$a5,0 andi $a5, 0xFFFF pixel $a7,$t1,$a5,16 sw $a5,-4($a0) 1: subu $a2,4 bgtz $a2,fourpixels tail: /* the pixel count underran, restore it now */ addu $a2,4 /* handle the last 0..3 pixels */ beqz $a2,done onepixel: lw $t0,($a1) daddu $a0,2 daddu $a1,4 beqz $t0,1f lhu $a7,-2($a0) pixel $a7,$t0,$a5,0 sh $a5,-2($a0) 1: subu $a2,1 bnez $a2,onepixel done: DBG .set push DBG .set mips32r2 DBG rdhwr $a0,$3 DBG mul $v0,$a0 DBG mul $v1,$a0 DBG .set pop daddiu $sp, $sp, 40 j $ra .end scanline_t32cb16blend_mips64 Loading
libpixelflinger/Android.mk +9 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,14 @@ PIXELFLINGER_SRC_FILES_mips := \ arch-mips/t32cb16blend.S \ endif PIXELFLINGER_SRC_FILES_mips64 := \ codeflinger/MIPSAssembler.cpp \ codeflinger/MIPS64Assembler.cpp \ codeflinger/mips64_disassem.c \ arch-mips64/col32cb16blend.S \ arch-mips64/t32cb16blend.S \ # # Shared library # Loading @@ -59,6 +67,7 @@ LOCAL_SRC_FILES := $(PIXELFLINGER_SRC_FILES) LOCAL_SRC_FILES_arm := $(PIXELFLINGER_SRC_FILES_arm) LOCAL_SRC_FILES_arm64 := $(PIXELFLINGER_SRC_FILES_arm64) LOCAL_SRC_FILES_mips := $(PIXELFLINGER_SRC_FILES_mips) LOCAL_SRC_FILES_mips64 := $(PIXELFLINGER_SRC_FILES_mips64) LOCAL_CFLAGS := $(PIXELFLINGER_CFLAGS) LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_C_INCLUDES += $(LOCAL_EXPORT_C_INCLUDE_DIRS) \ Loading
libpixelflinger/arch-mips/col32cb16blend.S 0 → 100644 +134 −0 Original line number Diff line number Diff line /* ** Copyright 2015, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ .macro pixel dreg src f sR sG sB shift #if __mips==32 && __mips_isa_rev>=2 /* extract red */ ext $t4,\src,\shift+11,5 mul $t4,$t4,\f /* extract green */ ext $t5,\src,\shift+5,6 mul $t5,$t5,\f /* extract blue */ ext $t6,\src,\shift,5 mul $t6,$t6,\f #else /* extract red */ srl $t4,\src,\shift+11 andi $t4, 0x1f mul $t4,$t4,\f /* extract green */ srl $t5,\src,\shift+5 andi $t5, 0x3f mul $t5,$t5,\f /* extract blue */ srl $t6,\src,\shift andi $t6, 0x1f mul $t6,$t6,\f #endif srl $t4,$t4,8 srl $t5,$t5,8 srl $t6,$t6,8 addu $t4,$t4,\sR addu $t5,$t5,\sG addu \dreg,$t6,\sB sll $t4,$t4,11 sll $t5,$t5,5 or \dreg,\dreg,$t4 or \dreg,\dreg,$t5 andi \dreg, 0xffff .endm .text .align .global scanline_col32cb16blend_mips .ent scanline_col32cb16blend_mips scanline_col32cb16blend_mips: /* check if count is zero */ srl $v0,$a1,24 /* sA */ beqz $a2,done li $t4, 0x100 srl $v1,$v0,7 addu $v0,$v1,$v0 subu $v0,$t4,$v0 /* f */ #if __mips==32 && __mips_isa_rev>=2 ext $a3,$a1,3,5 /* sR */ ext $t0,$a1,10,6 /* sG */ ext $t1,$a1,19,5 /* sB */ #else srl $a3, $a1, 3 andi $a3, 0x1f /* sR */ srl $t0, $a1, 10 andi $t0, 0x3f /* sG */ srl $t1, $a1, 19 andi $t1, 0x1f /* sB */ #endif /* check if cnt is at least 4 */ addiu $a2,$a2,-4 bltz $a2,tail loop_4pixels: lw $t7,0($a0) lw $t8,4($a0) addiu $a0,$a0,8 addiu $a2,$a2,-4 pixel $t2 $t7 $v0 $a3 $t0 $t1 0 pixel $t3 $t7 $v0 $a3 $t0 $t1 16 #if __mips==32 && __mips_isa_rev>=2 ins $t2,$t3,16,16 #else sll $t3, 16 or $t2, $t2, $t3 #endif pixel $t7 $t8 $v0 $a3 $t0 $t1 0 pixel $t3 $t8 $v0 $a3 $t0 $t1 16 #if __mips==32 && __mips_isa_rev>=2 ins $t7,$t3,16,16 #else sll $t3, 16 or $t7, $t7, $t3 #endif sw $t2,-8($a0) sw $t7,-4($a0) bgez $a2, loop_4pixels tail: /* the pixel count underran, restore it now */ addiu $a2,$a2,4 /* handle the last 0..3 pixels */ beqz $a2,done loop_1pixel: lhu $t7,0($a0) addiu $a0,$a0,2 addiu $a2,$a2,-1 pixel $t2 $t7 $v0 $a3 $t0 $t1 0 sh $t2, -2($a0) bnez $a2,loop_1pixel done: j $ra .end scanline_col32cb16blend_mips
libpixelflinger/arch-mips/t32cb16blend.S +191 −182 Original line number Diff line number Diff line Loading @@ -55,7 +55,12 @@ DBG .set at ext $t8,\src,3,5 # src[7..3] srl $t6,8 addu $t8,$t6 ins \fb,$t8,\shift+6+5,5 # dst[\shift:15..11] .if \shift!=0 sll $t8,\shift+11 or \fb,$t8 .else sll \fb,$t8,11 .endif /* green */ mul $t8,$t0,$t7 Loading @@ -66,11 +71,13 @@ DBG .set at /* blue */ mul $t0,$t0,$t7 ins \fb,$t8,\shift+5,6 # finish green insertion dst[\shift:10..5] sll $t8, $t8, \shift+5 or \fb, \fb, $t8 ext $t6,\src,(3+8+8),5 srl $t8,$t0,8 addu $t8,$t6 ins \fb,$t8,\shift,5 sll $t8, $t8, \shift or \fb, \fb, $t8 DBG .set noat DBG rdhwr $t8,$2 Loading Loading @@ -215,6 +222,7 @@ fourpixels: lw $t3,-8($a0) pixel $t3,$t4,$t1,0 andi $t1, 0xFFFF pixel $t3,$t5,$t1,16 sw $t1,-8($a0) Loading @@ -231,6 +239,7 @@ fourpixels: lw $t3,-4($a0) pixel $t3,$t4,$t1,0 andi $t1, 0xFFFF pixel $t3,$t5,$t1,16 sw $t1,-4($a0) Loading
libpixelflinger/arch-mips64/col32cb16blend.S 0 → 100644 +108 −0 Original line number Diff line number Diff line /* ** Copyright 2015, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ .macro pixel dreg src f sR sG sB shift /* extract red */ .if \shift < 32 dext $t0,\src,\shift+11,5 .else dextu $t0,\src,\shift+11,5 .endif mul $t0,$t0,\f /* extract green */ .if \shift < 32 dext $t1,\src,\shift+5,6 .else dextu $t1,\src,\shift+5,6 .endif mul $t1,$t1,\f /* extract blue */ .if \shift < 32 dext $t2,\src,\shift,5 .else dextu $t2,\src,\shift,5 .endif mul $t2,$t2,\f srl $t0,$t0,8 srl $t1,$t1,8 srl $t2,$t2,8 addu $t0,$t0,\sR addu $t1,$t1,\sG addu \dreg,$t2,\sB sll $t0,$t0,11 sll $t1,$t1,5 or \dreg,\dreg,$t0 or \dreg,\dreg,$t1 .endm .text .align .global scanline_col32cb16blend_mips64 .ent scanline_col32cb16blend_mips64 scanline_col32cb16blend_mips64: /* check if count is zero */ srl $v0,$a1,24 /* sA */ beqz $a2,done li $t0, 0x100 srl $v1,$v0,7 addu $v0,$v1,$v0 subu $v0,$t0,$v0 /* f */ ext $a3,$a1,3,5 /* sR */ ext $a4,$a1,10,6 /* sG */ ext $a5,$a1,19,5 /* sB */ /* check if cnt is at least 4 */ addiu $a2,$a2,-4 bltz $a2,tail loop_4pixels: ld $t3,0($a0) daddiu $a0,$a0,8 addiu $a2,$a2,-4 pixel $a6 $t3 $v0 $a3 $a4 $a5 0 pixel $a7 $t3 $v0 $a3 $a4 $a5 16 pixel $t8 $t3 $v0 $a3 $a4 $a5 32 pixel $t9 $t3 $v0 $a3 $a4 $a5 48 dins $a6,$a7,16,16 dinsu $a6,$t8,32,16 dinsu $a6,$t9,48,16 sd $a6,-8($a0) bgez $a2, loop_4pixels tail: /* the pixel count underran, restore it now */ addiu $a2,$a2,4 /* handle the last 0..3 pixels */ beqz $a2,done loop_1pixel: lhu $t3,0($a0) daddiu $a0,$a0,2 addiu $a2,$a2,-1 pixel $a6 $t3 $v0 $a3 $a4 $a5 0 sh $a6, -2($a0) bnez $a2,loop_1pixel done: j $ra .end scanline_col32cb16blend_mips64
libpixelflinger/arch-mips64/t32cb16blend.S 0 → 100644 +172 −0 Original line number Diff line number Diff line /* ** Copyright 2015, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ #ifdef DEBUG #define DBG #else #define DBG # #endif /* * blend one of 2 16bpp RGB pixels held in dreg selected by shift * with the 32bpp ABGR pixel held in src and store the result in fb * * Assumes that the dreg data is little endian and that * the the second pixel (shift==16) will be merged into * the fb result * * Uses $a4,$t2,$t3,$t8 */ .macro pixel dreg src fb shift /* * sA = s >> 24 * f = 0x100 - (sA + (sA>>7)) */ srl $t3,\src,24 srl $t2,$t3,7 addu $t3,$t2 li $t2,0x100 subu $t3,$t2,$t3 /* red */ ext $t8,\dreg,\shift+6+5,5 # dst[\shift:15..11] mul $t2,$t8,$t3 ext $a4,\dreg,\shift+5,6 # start green extraction dst[\shift:10..5] ext $t8,\src,3,5 # src[7..3] srl $t2,8 addu $t8,$t2 .if \shift!=0 sll $t8,\shift+11 # dst[\shift:15..11] or \fb,$t8 .else sll \fb,$t8,11 .endif /* green */ mul $t8,$a4,$t3 ext $a4,\dreg,\shift,5 # start blue extraction dst[\shift:4..0] ext $t2,\src,2+8,6 # src[15..10] srl $t8,8 addu $t8,$t2 /* blue */ mul $a4,$a4,$t3 sll $t8, $t8, \shift+5 # finish green insertion dst[\shift:10..5] or \fb, \fb, $t8 ext $t2,\src,(3+8+8),5 srl $t8,$a4,8 addu $t8,$t2 sll $t8, $t8, \shift or \fb, \fb, $t8 .endm .text .align .global scanline_t32cb16blend_mips64 .ent scanline_t32cb16blend_mips64 scanline_t32cb16blend_mips64: daddiu $sp, $sp, -40 DBG li $v0,0xffffffff DBG li $v1,0 /* Align the destination if necessary */ and $a4,$a0,3 beqz $a4,aligned /* as long as there is at least one pixel */ beqz $a2,done lw $t0,($a1) daddu $a0,2 daddu $a1,4 beqz $t0,1f lhu $a7,-2($a0) pixel $a7,$t0,$a5,0 sh $a5,-2($a0) 1: subu $a2,1 aligned: /* Check to see if its worth unrolling the loop */ subu $a2,4 bltz $a2,tail /* Process 4 pixels at a time */ fourpixels: /* 1st pair of pixels */ lw $t0,0($a1) lw $t1,4($a1) daddu $a0,8 daddu $a1,16 /* both are zero, skip this pair */ or $a7,$t0,$t1 beqz $a7,1f /* load the destination */ lw $a7,-8($a0) pixel $a7,$t0,$a5,0 andi $a5, 0xFFFF pixel $a7,$t1,$a5,16 sw $a5,-8($a0) 1: /* 2nd pair of pixels */ lw $t0,-8($a1) lw $t1,-4($a1) /* both are zero, skip this pair */ or $a7,$t0,$t1 beqz $a7,1f /* load the destination */ lw $a7,-4($a0) pixel $a7,$t0,$a5,0 andi $a5, 0xFFFF pixel $a7,$t1,$a5,16 sw $a5,-4($a0) 1: subu $a2,4 bgtz $a2,fourpixels tail: /* the pixel count underran, restore it now */ addu $a2,4 /* handle the last 0..3 pixels */ beqz $a2,done onepixel: lw $t0,($a1) daddu $a0,2 daddu $a1,4 beqz $t0,1f lhu $a7,-2($a0) pixel $a7,$t0,$a5,0 sh $a5,-2($a0) 1: subu $a2,1 bnez $a2,onepixel done: DBG .set push DBG .set mips32r2 DBG rdhwr $a0,$3 DBG mul $v0,$a0 DBG mul $v1,$a0 DBG .set pop daddiu $sp, $sp, 40 j $ra .end scanline_t32cb16blend_mips64