1 2/* 3 * Mesa 3-D graphics library 4 * 5 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * and/or sell copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included 15 * in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 * OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 26#ifdef USE_SSE_ASM 27#include "assyntax.h" 28#define MATH_ASM_PTR_SIZE 4 29#include "math/m_vector_asm.h" 30#include "xform_args.h" 31 32 SEG_TEXT 33 34#define FRAME_OFFSET 8 35 36#define SRC(i) REGOFF(i * 4, ESI) 37#define DST(i) REGOFF(i * 4, EDI) 38#define MAT(i) REGOFF(i * 4, EDX) 39 40#define SELECT(r0, r1, r2, r3) CONST( r0 * 64 + r1 * 16 + r2 * 4 + r3 ) 41 42 43ALIGNTEXT16 44GLOBL GLNAME( _mesa_sse_transform_points4_general ) 45HIDDEN(_mesa_sse_transform_points4_general) 46GLNAME( _mesa_sse_transform_points4_general ): 47 _CET_ENDBR 48 PUSH_L( ESI ) 49 PUSH_L( EDI ) 50 51 MOV_L( ARG_SOURCE, ESI ) 52 MOV_L( ARG_DEST, EDI ) 53 54 MOV_L( ARG_MATRIX, EDX ) 55 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) 56 57 TEST_L( ECX, ECX ) /* verify non-zero count */ 58 JE( LLBL( sse_general_done ) ) 59 60 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ 61 OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ 62 63 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ 64 MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )/* set dest size */ 65 66 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ 67 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ 68 69 PREFETCHT0( REGIND(ESI) ) 70 71 MOVAPS( MAT(0), XMM4 ) /* m3 | m2 | m1 | m0 */ 72 MOVAPS( MAT(4), XMM5 ) /* m7 | m6 | m5 | m4 */ 73 MOVAPS( MAT(8), XMM6 ) /* m11 | m10 | m9 | m8 */ 74 MOVAPS( MAT(12), XMM7 ) /* m15 | m14 | m13 | m12 */ 75 76ALIGNTEXT16 77LLBL( sse_general_loop ): 78 79 MOVSS( SRC(0), XMM0 ) /* ox */ 80 SHUFPS( CONST(0x0), XMM0, XMM0 ) /* ox | ox | ox | ox */ 81 MULPS( XMM4, XMM0 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */ 82 83 MOVSS( SRC(1), XMM1 ) /* oy */ 84 SHUFPS( CONST(0x0), XMM1, XMM1 ) /* oy | oy | oy | oy */ 85 MULPS( XMM5, XMM1 ) /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */ 86 87 MOVSS( SRC(2), XMM2 ) /* oz */ 88 SHUFPS( CONST(0x0), XMM2, XMM2 ) /* oz | oz | oz | oz */ 89 MULPS( XMM6, XMM2 ) /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */ 90 91 MOVSS( SRC(3), XMM3 ) /* ow */ 92 SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ow | ow | ow | ow */ 93 MULPS( XMM7, XMM3 ) /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */ 94 95 ADDPS( XMM1, XMM0 ) /* ox*m3+oy*m7 | ... */ 96 ADDPS( XMM2, XMM0 ) /* ox*m3+oy*m7+oz*m11 | ... */ 97 ADDPS( XMM3, XMM0 ) /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */ 98 MOVAPS( XMM0, DST(0) ) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */ 99 100 ADD_L( CONST(16), EDI ) 101 ADD_L( EAX, ESI ) 102 103 DEC_L( ECX ) 104 JNZ( LLBL( sse_general_loop ) ) 105 106LLBL( sse_general_done ): 107 108 POP_L( EDI ) 109 POP_L( ESI ) 110 RET 111 112 113 114 115ALIGNTEXT4 116GLOBL GLNAME( _mesa_sse_transform_points4_3d ) 117HIDDEN(_mesa_sse_transform_points4_3d) 118GLNAME( _mesa_sse_transform_points4_3d ): 119 _CET_ENDBR 120 PUSH_L( ESI ) 121 PUSH_L( EDI ) 122 123 MOV_L( ARG_SOURCE, ESI ) /* ptr to source GLvector4f */ 124 MOV_L( ARG_DEST, EDI ) /* ptr to dest GLvector4f */ 125 126 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */ 127 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */ 128 129 TEST_L( ECX, ECX) 130 JZ( LLBL(K_GTP43P3DR_finish) ) /* count was zero; go to finish */ 131 132 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ 133 OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ 134 135 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ 136 MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )/* set dest size */ 137 138 SHL_L( CONST(4), ECX ) /* count *= 16 */ 139 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ 140 141 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ 142 ADD_L( EDI, ECX ) /* count += dest ptr */ 143 144 MOVAPS( MAT(0), XMM0 ) /* m3 | m2 | m1 | m0 */ 145 MOVAPS( MAT(4), XMM1 ) /* m7 | m6 | m5 | m4 */ 146 MOVAPS( MAT(8), XMM2 ) /* m11 | m10 | m9 | m8 */ 147 MOVAPS( MAT(12), XMM3 ) /* m15 | m14 | m13 | m12 */ 148 149ALIGNTEXT32 150LLBL( K_GTP43P3DR_top ): 151 MOVSS( SRC(0), XMM4 ) /* ox */ 152 SHUFPS( CONST(0x0), XMM4, XMM4 ) /* ox | ox | ox | ox */ 153 MULPS( XMM0, XMM4 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */ 154 155 MOVSS( SRC(1), XMM5 ) /* oy */ 156 SHUFPS( CONST(0x0), XMM5, XMM5 ) /* oy | oy | oy | oy */ 157 MULPS( XMM1, XMM5 ) /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */ 158 159 MOVSS( SRC(2), XMM6 ) /* oz */ 160 SHUFPS( CONST(0x0), XMM6, XMM6 ) /* oz | oz | oz | oz */ 161 MULPS( XMM2, XMM6 ) /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */ 162 163 MOVSS( SRC(3), XMM7 ) /* ow */ 164 SHUFPS( CONST(0x0), XMM7, XMM7 ) /* ow | ow | ow | ow */ 165 MULPS( XMM3, XMM7 ) /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */ 166 167 ADDPS( XMM5, XMM4 ) /* ox*m3+oy*m7 | ... */ 168 ADDPS( XMM6, XMM4 ) /* ox*m3+oy*m7+oz*m11 | ... */ 169 ADDPS( XMM7, XMM4 ) /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */ 170 MOVAPS( XMM4, DST(0) ) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */ 171 172 MOVSS( SRC(3), XMM4 ) /* ow */ 173 MOVSS( XMM4, DST(3) ) /* ->D(3) */ 174 175LLBL( K_GTP43P3DR_skip ): 176 ADD_L( CONST(16), EDI ) 177 ADD_L( EAX, ESI ) 178 CMP_L( ECX, EDI ) 179 JNE( LLBL(K_GTP43P3DR_top) ) 180 181LLBL( K_GTP43P3DR_finish ): 182 POP_L( EDI ) 183 POP_L( ESI ) 184 RET 185 186 187ALIGNTEXT16 188GLOBL GLNAME( _mesa_sse_transform_points4_identity ) 189HIDDEN(_mesa_sse_transform_points4_identity) 190GLNAME( _mesa_sse_transform_points4_identity ): 191 _CET_ENDBR 192 PUSH_L( ESI ) 193 PUSH_L( EDI ) 194 195 MOV_L( ARG_SOURCE, ESI ) 196 MOV_L( ARG_DEST, EDI ) 197 198 MOV_L( ARG_MATRIX, EDX ) 199 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) 200 201 TEST_L( ECX, ECX ) /* verify non-zero count */ 202 JE( LLBL( sse_identity_done ) ) 203 204 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */ 205 OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */ 206 207 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */ 208 MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )/* set dest size */ 209 210 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */ 211 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */ 212 213ALIGNTEXT16 214LLBL( sse_identity_loop ): 215 216 PREFETCHNTA( REGOFF(32, ESI) ) 217 218 MOVAPS( REGIND(ESI), XMM0 ) 219 ADD_L( EAX, ESI ) 220 221 MOVAPS( XMM0, REGIND(EDI) ) 222 ADD_L( CONST(16), EDI ) 223 224 DEC_L( ECX ) 225 JNZ( LLBL( sse_identity_loop ) ) 226 227LLBL( sse_identity_done ): 228 229 POP_L( EDI ) 230 POP_L( ESI ) 231 RET 232#endif 233 234#if defined (__ELF__) && defined (__linux__) 235 .section .note.GNU-stack,"",%progbits 236#endif 237