PageRenderTime 78ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/pkgs/libs/mesa/src/src/mesa/tnl_dd/imm/t_dd_imm_vapi.h

https://bitbucket.org/mminutoli/benchmarks-parsec
C++ Header | 159 lines | 108 code | 16 blank | 35 comment | 26 complexity | 21382c754f54dc3080a88cdadcb0ab55 MD5 | raw file
Possible License(s): Apache-2.0, GPL-3.0, CC0-1.0, LGPL-2.1, BSD-2-Clause, BSD-3-Clause, LGPL-2.0, GPL-2.0, AGPL-3.0, MPL-2.0-no-copyleft-exception
  1. /*
  2. * Mesa 3-D graphics library
  3. * Version: 3.5
  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. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  21. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors:
  25. * Gareth Hughes <gareth@valinux.com>
  26. * Keith Whitwell <keithw@valinux.com>
  27. */
  28. /* Template for immediate mode vertex functions.
  29. */
  30. #define DBG 0
  31. #define VERTEX( ox, oy, oz, ow )
  32. do {
  33. GET_CURRENT_VERTEX;
  34. GLfloat w;
  35. GLuint mask;
  36. const GLfloat * const m = ctx->_ModelProjectMatrix.m;
  37. if (DO_FULL_MATRIX) {
  38. VERTEX_CLIP(0) = m[0] * ox + m[4] * oy + m[8] * oz + m[12] * ow;
  39. VERTEX_CLIP(1) = m[1] * ox + m[5] * oy + m[9] * oz + m[13] * ow;
  40. VERTEX_CLIP(2) = m[2] * ox + m[6] * oy + m[10] * oz + m[14] * ow;
  41. VERTEX_CLIP(3) = m[3] * ox + m[7] * oy + m[11] * oz + m[15] * ow;
  42. w = VERTEX_CLIP(3);
  43. }
  44. else if (DO_NOROT_MATRIX) {
  45. VERTEX_CLIP(0) = m[0] * ox + m[12] * ow;
  46. VERTEX_CLIP(1) = m[5] * oy + m[13] * ow;
  47. VERTEX_CLIP(2) = m[10] * oz + m[14] * ow;
  48. VERTEX_CLIP(3) = ow;
  49. w = ow;
  50. }
  51. else {
  52. ASSERT (DO_IDENTITY_MATRIX);
  53. VERTEX_CLIP(0) = ox;
  54. VERTEX_CLIP(1) = oy;
  55. VERTEX_CLIP(2) = oz;
  56. VERTEX_CLIP(3) = ow;
  57. w = ow;
  58. }
  59. mask = 0;
  60. if (DO_CLIP_TEST) {
  61. if ( VERTEX_CLIP(0) > w ) mask |= CLIP_RIGHT_BIT;
  62. if ( VERTEX_CLIP(0) < -w ) mask |= CLIP_LEFT_BIT;
  63. if ( VERTEX_CLIP(1) > w ) mask |= CLIP_TOP_BIT;
  64. if ( VERTEX_CLIP(1) < -w ) mask |= CLIP_BOTTOM_BIT;
  65. if ( VERTEX_CLIP(2) > w ) mask |= CLIP_FAR_BIT;
  66. if ( VERTEX_CLIP(2) < -w ) mask |= CLIP_NEAR_BIT;
  67. VERTEX_MASK(v) = mask;
  68. }
  69. if (!mask) {
  70. if (HAVE_VERTEX_WIN) {
  71. if (!HAVE_HW_VIEWPORT) {
  72. const GLfloat *s = GET_VIEWPORT_MATRIX();
  73. if (HAVE_W && HAVE_HW_DIVIDE) {
  74. VERTEX_WIN( 0 ) = s[0] * VERTEX_CLIP( 0 ) + s[12];
  75. VERTEX_WIN( 1 ) = s[5] * VERTEX_CLIP( 1 ) + s[13];
  76. VERTEX_WIN( 2 ) = s[10] * VERTEX_CLIP( 2 ) + s[14];
  77. VERTEX_WIN( 3 ) = w;
  78. }
  79. else {
  80. const GLfloat oow = 1.0/w; /* possibly opt away */
  81. VERTEX_WIN( 0 ) = s[0] * VERTEX_CLIP( 0 ) * oow + s[12];
  82. VERTEX_WIN( 1 ) = s[5] * VERTEX_CLIP( 1 ) * oow + s[13];
  83. VERTEX_WIN( 2 ) = s[10] * VERTEX_CLIP( 2 ) * oow + s[14];
  84. if (HAVE_W)
  85. VERTEX_WIN( 3 ) = oow;
  86. }
  87. }
  88. else if (HAVE_W && HAVE_HW_DIVIDE) {
  89. if (!VERTEX_WIN_IS_VERTEX_CLIP) {
  90. VERTEX_WIN( 0 ) = VERTEX_CLIP( 0 );
  91. VERTEX_WIN( 1 ) = VERTEX_CLIP( 1 );
  92. VERTEX_WIN( 2 ) = VERTEX_CLIP( 2 );
  93. VERTEX_WIN( 3 ) = w;
  94. }
  95. }
  96. else {
  97. const GLfloat oow = 1.0/w; /* possibly opt away */
  98. VERTEX_WIN( 0 ) = VERTEX_CLIP( 0 ) * oow;
  99. VERTEX_WIN( 1 ) = VERTEX_CLIP( 1 ) * oow;
  100. VERTEX_WIN( 2 ) = VERTEX_CLIP( 2 ) * oow;
  101. if (HAVE_W)
  102. VERTEX_WIN( 3 ) = oow;
  103. }
  104. }
  105. } else if (!FALLBACK_OR_CLIPPING) {
  106. SET_CLIPPING(); /* transition to clipping */
  107. }
  108. COPY_VERTEX_FROM_CURRENT;
  109. BUILD_PRIM_FROM_VERTEX;
  110. }
  111. /* Let the compiler optimize away the constant operations:
  112. */
  113. static void VTAG(Vertex2f)( GLfloat ox, GLfloat oy )
  114. {
  115. /* Cliptest on clip[2] could also be eliminated...
  116. */
  117. VERTEX( ox, oy, 0, 1 );
  118. }
  119. static void VTAG(Vertex2fv)( const GLfloat *obj )
  120. {
  121. /* Cliptest on clip[2] could also be eliminated...
  122. */
  123. VERTEX( obj[0], obj[1], 0, 1 );
  124. }
  125. static void VTAG(Vertex3f)( GLfloat ox, GLfloat oy, GLfloat oz )
  126. {
  127. VERTEX( ox, oy, oz, 1 );
  128. }
  129. static void VTAG(Vertex3fv)( const GLfloat *obj )
  130. {
  131. VERTEX( obj[0], obj[1], obj[2], 1 );
  132. }
  133. static void VTAG(Vertex4f)( GLfloat ox, GLfloat oy, GLfloat oz, GLfloat ow )
  134. {
  135. VERTEX( ox, oy, oz, ow );
  136. }
  137. static void VTAG(Vertex4fv)( const GLfloat *obj )
  138. {
  139. VERTEX( obj[0], obj[1], obj[2], obj[3] );
  140. }
  141. #undef DO_FULL_MATRIX
  142. #undef VTAG
  143. #undef VERTEX