davem69 | 775355a | 2001-06-05 23:54:00 +0000 | [diff] [blame^] | 1 | /* $Id: sparc.c,v 1.3 2001/06/05 23:54:01 davem69 Exp $ */ |
Brian Paul | 7943b34 | 2001-05-23 14:27:03 +0000 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * Mesa 3-D graphics library |
Brian Paul | 04a6c35 | 2001-05-23 14:42:47 +0000 | [diff] [blame] | 5 | * Version: 3.5 |
Brian Paul | 7943b34 | 2001-05-23 14:27:03 +0000 | [diff] [blame] | 6 | * |
Brian Paul | 04a6c35 | 2001-05-23 14:42:47 +0000 | [diff] [blame] | 7 | * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. |
Brian Paul | 7943b34 | 2001-05-23 14:27:03 +0000 | [diff] [blame] | 8 | * |
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 10 | * copy of this software and associated documentation files (the "Software"), |
| 11 | * to deal in the Software without restriction, including without limitation |
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 13 | * and/or sell copies of the Software, and to permit persons to whom the |
| 14 | * Software is furnished to do so, subject to the following conditions: |
| 15 | * |
| 16 | * The above copyright notice and this permission notice shall be included |
| 17 | * in all copies or substantial portions of the Software. |
| 18 | * |
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | */ |
| 26 | |
| 27 | /* |
| 28 | * Sparc assembly code by David S. Miller |
| 29 | */ |
| 30 | |
| 31 | |
Brian Paul | 7943b34 | 2001-05-23 14:27:03 +0000 | [diff] [blame] | 32 | #include "context.h" |
| 33 | #include "math/m_vertices.h" |
| 34 | #include "math/m_xform.h" |
| 35 | #include "tnl/t_context.h" |
| 36 | #include "sparc.h" |
| 37 | |
| 38 | #ifdef DEBUG |
| 39 | #include "math/m_debug.h" |
| 40 | #endif |
| 41 | |
| 42 | #define XFORM_ARGS GLvector4f *to_vec, \ |
| 43 | const GLfloat m[16], \ |
| 44 | const GLvector4f *from_vec |
| 45 | |
| 46 | #define DECLARE_XFORM_GROUP(pfx, sz) \ |
| 47 | extern void _mesa_##pfx##_transform_points##sz##_general(XFORM_ARGS); \ |
| 48 | extern void _mesa_##pfx##_transform_points##sz##_identity(XFORM_ARGS); \ |
| 49 | extern void _mesa_##pfx##_transform_points##sz##_3d_no_rot(XFORM_ARGS); \ |
| 50 | extern void _mesa_##pfx##_transform_points##sz##_perspective(XFORM_ARGS); \ |
| 51 | extern void _mesa_##pfx##_transform_points##sz##_2d(XFORM_ARGS); \ |
| 52 | extern void _mesa_##pfx##_transform_points##sz##_2d_no_rot(XFORM_ARGS); \ |
| 53 | extern void _mesa_##pfx##_transform_points##sz##_3d(XFORM_ARGS); |
| 54 | |
| 55 | #define ASSIGN_XFORM_GROUP(pfx, sz) \ |
| 56 | _mesa_transform_tab[sz][MATRIX_GENERAL] = \ |
| 57 | _mesa_##pfx##_transform_points##sz##_general; \ |
| 58 | _mesa_transform_tab[sz][MATRIX_IDENTITY] = \ |
| 59 | _mesa_##pfx##_transform_points##sz##_identity; \ |
| 60 | _mesa_transform_tab[sz][MATRIX_3D_NO_ROT] = \ |
| 61 | _mesa_##pfx##_transform_points##sz##_3d_no_rot; \ |
| 62 | _mesa_transform_tab[sz][MATRIX_PERSPECTIVE] = \ |
| 63 | _mesa_##pfx##_transform_points##sz##_perspective; \ |
| 64 | _mesa_transform_tab[sz][MATRIX_2D] = \ |
| 65 | _mesa_##pfx##_transform_points##sz##_2d; \ |
| 66 | _mesa_transform_tab[sz][MATRIX_2D_NO_ROT] = \ |
| 67 | _mesa_##pfx##_transform_points##sz##_2d_no_rot; \ |
| 68 | _mesa_transform_tab[sz][MATRIX_3D] = \ |
| 69 | _mesa_##pfx##_transform_points##sz##_3d; |
| 70 | |
| 71 | |
| 72 | #ifdef USE_SPARC_ASM |
| 73 | DECLARE_XFORM_GROUP(sparc, 1) |
| 74 | DECLARE_XFORM_GROUP(sparc, 2) |
| 75 | DECLARE_XFORM_GROUP(sparc, 3) |
| 76 | DECLARE_XFORM_GROUP(sparc, 4) |
| 77 | |
| 78 | extern GLvector4f *_mesa_sparc_cliptest_points4(GLvector4f *clip_vec, |
| 79 | GLvector4f *proj_vec, |
| 80 | GLubyte clipMask[], |
| 81 | GLubyte *orMask, |
| 82 | GLubyte *andMask); |
| 83 | |
| 84 | extern GLvector4f *_mesa_sparc_cliptest_points4_np(GLvector4f *clip_vec, |
| 85 | GLvector4f *proj_vec, |
| 86 | GLubyte clipMask[], |
| 87 | GLubyte *orMask, |
| 88 | GLubyte *andMask); |
| 89 | #endif |
| 90 | |
| 91 | void _mesa_init_all_sparc_transform_asm(void) |
| 92 | { |
| 93 | #ifdef USE_SPARC_ASM |
| 94 | ASSIGN_XFORM_GROUP(sparc, 1) |
| 95 | ASSIGN_XFORM_GROUP(sparc, 2) |
| 96 | ASSIGN_XFORM_GROUP(sparc, 3) |
| 97 | ASSIGN_XFORM_GROUP(sparc, 4) |
| 98 | |
| 99 | _mesa_clip_tab[4] = _mesa_sparc_cliptest_points4; |
| 100 | _mesa_clip_np_tab[4] = _mesa_sparc_cliptest_points4_np; |
| 101 | |
| 102 | #ifdef DEBUG |
| 103 | _math_test_all_transform_functions("sparc"); |
| 104 | _math_test_all_cliptest_functions("sparc"); |
| 105 | #endif |
| 106 | |
| 107 | #endif |
| 108 | } |
davem69 | 775355a | 2001-06-05 23:54:00 +0000 | [diff] [blame^] | 109 | |
| 110 | extern unsigned int _mesa_sparc_glapi_begin; |
| 111 | extern unsigned int _mesa_sparc_glapi_end; |
| 112 | |
| 113 | void _mesa_init_sparc_glapi_relocs(void) |
| 114 | { |
| 115 | unsigned int *insn_ptr, *end_ptr; |
| 116 | unsigned long disp_addr; |
| 117 | |
| 118 | insn_ptr = &_mesa_sparc_glapi_begin; |
| 119 | end_ptr = &_mesa_sparc_glapi_end; |
| 120 | disp_addr = (unsigned long) &_glapi_Dispatch; |
| 121 | |
| 122 | while (insn_ptr < end_ptr) { |
| 123 | #ifdef __sparc_v9__ |
| 124 | insn_ptr[0] |= (disp_addr >> (32 + 10)); |
| 125 | insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10); |
| 126 | _mesa_sparc_icache_flush(&insn_ptr[0]); |
| 127 | insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1)); |
| 128 | insn_ptr[3] |= (disp_addr & ((1 << 10) - 1)); |
| 129 | _mesa_sparc_icache_flush(&insn_ptr[2]); |
| 130 | insn_ptr += 10; |
| 131 | #else |
| 132 | insn_ptr[0] |= (disp_addr >> 10); |
| 133 | insn_ptr[1] |= (disp_addr & ((1 << 10) - 1)); |
| 134 | _mesa_sparc_icache_flush(&insn_ptr[0]); |
| 135 | insn_ptr += 4; |
| 136 | #endif |
| 137 | } |
| 138 | } |