ss_tritmp.h revision a562313f378a056c8d886e418b518063ab077c39
17c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell/* 27c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * Mesa 3-D graphics library 322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 4a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 67c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 77c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * copy of this software and associated documentation files (the "Software"), 87c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * to deal in the Software without restriction, including without limitation 97c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense, 107c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * and/or sell copies of the Software, and to permit persons to whom the 117c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * Software is furnished to do so, subject to the following conditions: 1222144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 137c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * The above copyright notice and this permission notice shall be included 147c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * in all copies or substantial portions of the Software. 1522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 167c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 177c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 187c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 193d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 203d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 213d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 223d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * OTHER DEALINGS IN THE SOFTWARE. 237c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * 247c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell * Authors: 25877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca * Keith Whitwell <keithw@vmware.com> 267c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell */ 277c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 287c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 29a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul/** 30a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul * This is where we handle assigning vertex colors based on front/back 31a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul * facing, compute polygon offset and handle glPolygonMode(). 32a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul */ 33f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergstatic void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e2 ) 347c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell{ 35cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 36a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul SScontext *swsetup = SWSETUP_CONTEXT(ctx); 37cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; 387c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell SWvertex *v[3]; 397c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell GLfloat z[3]; 40b755a2d9de5b7977c410a904a8adb7c07c88f82aBrian Paul GLfloat offset, oz0, oz1, oz2; 417c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell GLenum mode = GL_FILL; 4221709b354b45ad6aa4669d9ef028df9c902d3552Brian Paul GLuint facing = 0; 4319045d3749827caf176ae5cfc00c81e4fd486d74Vinson Lee GLchan saved_color[3][4] = { { 0 } }; 440aef54ba627c748a43f601228c725f5ba79be002Vinson Lee GLfloat saved_col0[3][4] = { { 0 } }; 450aef54ba627c748a43f601228c725f5ba79be002Vinson Lee GLfloat saved_spec[3][4] = { { 0 } }; 467c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 477c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell v[0] = &verts[e0]; 487c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell v[1] = &verts[e1]; 497c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell v[2] = &verts[e2]; 507c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 517c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT)) 527c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell { 53eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry GLfloat ex = v[0]->attrib[VARYING_SLOT_POS][0] - v[2]->attrib[VARYING_SLOT_POS][0]; 54eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry GLfloat ey = v[0]->attrib[VARYING_SLOT_POS][1] - v[2]->attrib[VARYING_SLOT_POS][1]; 55eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry GLfloat fx = v[1]->attrib[VARYING_SLOT_POS][0] - v[2]->attrib[VARYING_SLOT_POS][0]; 56eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry GLfloat fy = v[1]->attrib[VARYING_SLOT_POS][1] - v[2]->attrib[VARYING_SLOT_POS][1]; 577c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell GLfloat cc = ex*fy - ey*fx; 587c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 597c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT)) 607c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell { 61a562313f378a056c8d886e418b518063ab077c39Matt Turner facing = (cc < 0.0F) ^ ctx->Polygon._FrontBit; 6222144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes 637c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell if (IND & SS_UNFILLED_BIT) 647c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode; 6522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes 6658e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell if (facing == 1) { 6758e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell if (IND & SS_TWOSIDE_BIT) { 68e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick if (VB->BackfaceColorPtr) { 69e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->data; 70565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao 71e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick if (swsetup->intColors) { 72e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick COPY_CHAN4(saved_color[0], v[0]->color); 73e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick COPY_CHAN4(saved_color[1], v[1]->color); 74e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick COPY_CHAN4(saved_color[2], v[2]->color); 75e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick } 76e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick else { 77eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(saved_col0[0], v[0]->attrib[VARYING_SLOT_COL0]); 78eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(saved_col0[1], v[1]->attrib[VARYING_SLOT_COL0]); 79eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(saved_col0[2], v[2]->attrib[VARYING_SLOT_COL0]); 80e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick } 81e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick 82e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick if (VB->BackfaceColorPtr->stride) { 83a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul if (swsetup->intColors) { 84e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick SS_COLOR(v[0]->color, vbcolor[e0]); 85e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick SS_COLOR(v[1]->color, vbcolor[e1]); 86e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick SS_COLOR(v[2]->color, vbcolor[e2]); 87a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul } 88a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul else { 89eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[0]->attrib[VARYING_SLOT_COL0], vbcolor[e0]); 90eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[1]->attrib[VARYING_SLOT_COL0], vbcolor[e1]); 91eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[2]->attrib[VARYING_SLOT_COL0], vbcolor[e2]); 92a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul } 93e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick } 94e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick else { 95e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick /* flat shade */ 96e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick if (swsetup->intColors) { 97e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick SS_COLOR(v[0]->color, vbcolor[0]); 98e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick SS_COLOR(v[1]->color, vbcolor[0]); 99e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick SS_COLOR(v[2]->color, vbcolor[0]); 100565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao } 101565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao else { 102eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[0]->attrib[VARYING_SLOT_COL0], vbcolor[0]); 103eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[1]->attrib[VARYING_SLOT_COL0], vbcolor[0]); 104eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[2]->attrib[VARYING_SLOT_COL0], vbcolor[0]); 105565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao } 106565cd49b5fc7a5bd1e533542888bf322b83b8e56Xiang, Haihao } 107e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick } 108326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell 109e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick if (VB->BackfaceSecondaryColorPtr) { 110e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->data; 111326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell 112eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(saved_spec[0], v[0]->attrib[VARYING_SLOT_COL1]); 113eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(saved_spec[1], v[1]->attrib[VARYING_SLOT_COL1]); 114eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(saved_spec[2], v[2]->attrib[VARYING_SLOT_COL1]); 115326bc7150d31e052f018bb40f23cf9f60cb9c35dKeith Whitwell 116e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick if (VB->BackfaceSecondaryColorPtr->stride) { 117eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry SS_SPEC(v[0]->attrib[VARYING_SLOT_COL1], vbspec[e0]); 118eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry SS_SPEC(v[1]->attrib[VARYING_SLOT_COL1], vbspec[e1]); 119eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry SS_SPEC(v[2]->attrib[VARYING_SLOT_COL1], vbspec[e2]); 120e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick } 121e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick else { 122eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry SS_SPEC(v[0]->attrib[VARYING_SLOT_COL1], vbspec[0]); 123eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry SS_SPEC(v[1]->attrib[VARYING_SLOT_COL1], vbspec[0]); 124eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry SS_SPEC(v[2]->attrib[VARYING_SLOT_COL1], vbspec[0]); 1251182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell } 1261e1aac034c986a08248861363c0baa27dc2ae2d5Keith Whitwell } 1277c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 12822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes } 1297c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 1307c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 131b755a2d9de5b7977c410a904a8adb7c07c88f82aBrian Paul if (IND & SS_OFFSET_BIT) { 132b755a2d9de5b7977c410a904a8adb7c07c88f82aBrian Paul const GLfloat max = ctx->DrawBuffer->_DepthMaxF; 133b755a2d9de5b7977c410a904a8adb7c07c88f82aBrian Paul /* save original Z values (restored later) */ 134eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry z[0] = v[0]->attrib[VARYING_SLOT_POS][2]; 135eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry z[1] = v[1]->attrib[VARYING_SLOT_POS][2]; 136eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry z[2] = v[2]->attrib[VARYING_SLOT_POS][2]; 137b755a2d9de5b7977c410a904a8adb7c07c88f82aBrian Paul /* Note that Z values are already scaled to [0,65535] (for example) 138b755a2d9de5b7977c410a904a8adb7c07c88f82aBrian Paul * so no MRD value is used here. 139b755a2d9de5b7977c410a904a8adb7c07c88f82aBrian Paul */ 140b755a2d9de5b7977c410a904a8adb7c07c88f82aBrian Paul offset = ctx->Polygon.OffsetUnits; 141a562313f378a056c8d886e418b518063ab077c39Matt Turner if (cc * cc > 1e-16F) { 1427c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul const GLfloat ez = z[0] - z[2]; 1437c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul const GLfloat fz = z[1] - z[2]; 1447c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul const GLfloat oneOverArea = 1.0F / cc; 145bd7f7aac56d3703f3d0fd55cd20f86f6c431b030Brian Paul const GLfloat dzdx = fabsf((ey * fz - ez * fy) * oneOverArea); 146bd7f7aac56d3703f3d0fd55cd20f86f6c431b030Brian Paul const GLfloat dzdy = fabsf((ez * fx - ex * fz) * oneOverArea); 1477c6a04f6d8ef3c8a47a708a76bb4f4ac65c6b20fBrian Paul offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor; 1487c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 149b755a2d9de5b7977c410a904a8adb7c07c88f82aBrian Paul /* new Z values */ 150eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry oz0 = CLAMP(v[0]->attrib[VARYING_SLOT_POS][2] + offset, 0.0F, max); 151eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry oz1 = CLAMP(v[1]->attrib[VARYING_SLOT_POS][2] + offset, 0.0F, max); 152eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry oz2 = CLAMP(v[2]->attrib[VARYING_SLOT_POS][2] + offset, 0.0F, max); 1537c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 1547c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 1557c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 1567c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell if (mode == GL_POINT) { 1577c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) { 158eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[0]->attrib[VARYING_SLOT_POS][2] = oz0; 159eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[1]->attrib[VARYING_SLOT_POS][2] = oz1; 160eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[2]->attrib[VARYING_SLOT_POS][2] = oz2; 1617c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 162355e9bb45c4f56f228c73e2886d907a75968209bMichal Krol _swsetup_render_tri(ctx, e0, e1, e2, facing, _swsetup_edge_render_point_tri); 1637c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } else if (mode == GL_LINE) { 1647c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) { 165eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[0]->attrib[VARYING_SLOT_POS][2] = oz0; 166eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[1]->attrib[VARYING_SLOT_POS][2] = oz1; 167eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[2]->attrib[VARYING_SLOT_POS][2] = oz2; 1687c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 169355e9bb45c4f56f228c73e2886d907a75968209bMichal Krol _swsetup_render_tri(ctx, e0, e1, e2, facing, _swsetup_edge_render_line_tri); 1707c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } else { 1717c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) { 172eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[0]->attrib[VARYING_SLOT_POS][2] = oz0; 173eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[1]->attrib[VARYING_SLOT_POS][2] = oz1; 174eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[2]->attrib[VARYING_SLOT_POS][2] = oz2; 1757c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 17622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes _swrast_Triangle( ctx, v[0], v[1], v[2] ); 1777c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 1787c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 179a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul /* 180a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul * Restore original vertex colors, etc. 181a7008322146f589ed5cb7a563365ff5e31844c62Brian Paul */ 1827c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell if (IND & SS_OFFSET_BIT) { 183eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[0]->attrib[VARYING_SLOT_POS][2] = z[0]; 184eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[1]->attrib[VARYING_SLOT_POS][2] = z[1]; 185eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry v[2]->attrib[VARYING_SLOT_POS][2] = z[2]; 1867c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell } 1877c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 18822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes if (IND & SS_TWOSIDE_BIT) { 18958e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell if (facing == 1) { 190e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick if (VB->BackfaceColorPtr) { 191e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick if (swsetup->intColors) { 192e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick COPY_CHAN4(v[0]->color, saved_color[0]); 193e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick COPY_CHAN4(v[1]->color, saved_color[1]); 194e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick COPY_CHAN4(v[2]->color, saved_color[2]); 195e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick } 196e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick else { 197eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[0]->attrib[VARYING_SLOT_COL0], saved_col0[0]); 198eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[1]->attrib[VARYING_SLOT_COL0], saved_col0[1]); 199eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[2]->attrib[VARYING_SLOT_COL0], saved_col0[2]); 200e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick } 201e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick } 202e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick 203e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick if (VB->BackfaceSecondaryColorPtr) { 204eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[0]->attrib[VARYING_SLOT_COL1], saved_spec[0]); 205eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[1]->attrib[VARYING_SLOT_COL1], saved_spec[1]); 206eed6baf7621fa94e7888f8079b155fc67a08540cPaul Berry COPY_4V(v[2]->attrib[VARYING_SLOT_COL1], saved_spec[2]); 207e650c07f47ac6f49a4dfcb58290fd049092fb768Ian Romanick } 2081e1aac034c986a08248861363c0baa27dc2ae2d5Keith Whitwell } 20922144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes } 2107c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell} 2117c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 2127c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 2137c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 214709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell/* Need to fixup edgeflags when decomposing to triangles: 2157c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell */ 216f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergstatic void TAG(quadfunc)( struct gl_context *ctx, GLuint v0, 21758e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell GLuint v1, GLuint v2, GLuint v3 ) 2187c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell{ 219cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell if (IND & SS_UNFILLED_BIT) { 220cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 221c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul if (VB->EdgeFlag) { /* XXX this test shouldn't be needed (bug 12614) */ 222c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul GLubyte ef1 = VB->EdgeFlag[v1]; 223c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul GLubyte ef3 = VB->EdgeFlag[v3]; 224c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul VB->EdgeFlag[v1] = 0; 225c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul TAG(triangle)( ctx, v0, v1, v3 ); 226c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul VB->EdgeFlag[v1] = ef1; 227c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul VB->EdgeFlag[v3] = 0; 228c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul TAG(triangle)( ctx, v1, v2, v3 ); 229c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul VB->EdgeFlag[v3] = ef3; 230c9ce3e8fd2a8db93c833bfd9a06d31843145657bBrian Paul } 231cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell } else { 23258e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell TAG(triangle)( ctx, v0, v1, v3 ); 23358e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell TAG(triangle)( ctx, v1, v2, v3 ); 234cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell } 2357c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell} 2367c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 2377c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 2387c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 2397c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 2407c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwellstatic void TAG(init)( void ) 2417c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell{ 2427c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell tri_tab[IND] = TAG(triangle); 2436f3178a3bed43b49407f0bde92c2e6d85c40d190Sven M. Hallberg quad_tab[IND] = TAG(quadfunc); 2447c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell} 2457c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 2467c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell 2477c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell#undef IND 2487c20642b1091df1aab7d9076a3fe2fb11c6f011cKeith Whitwell#undef TAG 249