static void import_float_spec_colors( GLcontext *ctx ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct gl_client_array *to = &SWSETUP_CONTEXT(ctx)->ChanSecondaryColor; do_import( VB, to, VB->SecondaryColorPtr[0] ); VB->SecondaryColorPtr[0] = to; }
/** * Prepare to render a vertex buffer. * Called via tnl->Driver.Render.Start. */ static void _swsetup_RenderStart( struct gl_context *ctx ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; if (swsetup->NewState & _SWSETUP_NEW_RENDERINDEX) { _swsetup_choose_trifuncs(ctx); } if (swsetup->NewState & _NEW_PROGRAM) { swsetup->last_index_bitset = 0; } swsetup->NewState = 0; /* This will change if drawing unfilled tris */ _swrast_SetFacing(ctx, 0); _swrast_render_start(ctx); /* Important */ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; setup_vertex_format(ctx); }
static void interp_extras( GLcontext *ctx, GLfloat t, GLuint dst, GLuint out, GLuint in, GLboolean force_boundary ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; if (VB->ColorPtr[1]) { INTERP_4CHAN( t, GET_COLOR(VB->ColorPtr[1], dst), GET_COLOR(VB->ColorPtr[1], out), GET_COLOR(VB->ColorPtr[1], in) ); if (VB->SecondaryColorPtr[1]) { INTERP_3CHAN( t, GET_COLOR(VB->SecondaryColorPtr[1], dst), GET_COLOR(VB->SecondaryColorPtr[1], out), GET_COLOR(VB->SecondaryColorPtr[1], in) ); } } else if (VB->IndexPtr[1]) { VB->IndexPtr[1]->data[dst] = (GLuint) (GLint) LINTERP( t, (GLfloat) VB->IndexPtr[1]->data[out], (GLfloat) VB->IndexPtr[1]->data[in] ); } if (VB->EdgeFlag) { VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary; } interp_tab[SWSETUP_CONTEXT(ctx)->SetupIndex](ctx, t, dst, out, in, force_boundary); }
void _swsetup_InvalidateState( struct gl_context *ctx, GLuint new_state ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); swsetup->NewState |= new_state; _tnl_invalidate_vertex_state( ctx, new_state ); }
void _swsetup_Wakeup( struct gl_context *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); SScontext *swsetup = SWSETUP_CONTEXT(ctx); tnl->Driver.Render.Start = _swsetup_RenderStart; tnl->Driver.Render.Finish = _swsetup_RenderFinish; tnl->Driver.Render.PrimitiveNotify = _swsetup_RenderPrimitive; tnl->Driver.Render.Interp = _tnl_interp; tnl->Driver.Render.CopyPV = _tnl_copy_pv; tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; /* new */ tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; /* new */ /* points */ /* line */ /* triangle */ /* quad */ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; tnl->Driver.Render.BuildVertices = _tnl_build_vertices; tnl->Driver.Render.Multipass = 0; _tnl_invalidate_vertices( ctx, ~0 ); _tnl_need_projected_coords( ctx, GL_TRUE ); _swsetup_InvalidateState( ctx, ~0 ); swsetup->verts = (SWvertex *)tnl->clipspace.vertex_buf; swsetup->last_index_bitset = 0; }
/* * We patch this function into tnl->Driver.Render.Start. * It's called when we start rendering a vertex buffer. */ static void _swsetup_RenderStart( GLcontext *ctx ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; GLuint new_state = swsetup->NewState; if (new_state & _SWSETUP_NEW_RENDERINDEX) { _swsetup_choose_trifuncs( ctx ); } swsetup->NewState = 0; _swrast_render_start( ctx ); /* Important: */ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; if (tnl->render_inputs != swsetup->last_index) { GLuint index = tnl->render_inputs; struct tnl_attr_map map[_TNL_ATTRIB_MAX]; int i, e = 0; EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, win ); if (index & _TNL_BIT_COLOR0) EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color ); if (index & _TNL_BIT_COLOR1) EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4CHAN_4F_RGBA, specular); if (index & _TNL_BIT_FOG) EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F, fog); if (index & _TNL_BITS_TEX_ANY) { for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { if (index & _TNL_BIT_TEX(i)) { EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F, texcoord[i] ); } } } if (index & _TNL_BIT_INDEX) EMIT_ATTR( _TNL_ATTRIB_INDEX, EMIT_1F, index ); if (index & _TNL_BIT_POINTSIZE) EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize ); _tnl_install_attrs( ctx, map, e, ctx->Viewport._WindowMap.m, sizeof(SWvertex) ); swsetup->last_index = index; } }
void _swsetup_DestroyContext( struct gl_context *ctx ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); if (swsetup) { free(swsetup); ctx->swsetup_context = 0; } _tnl_free_vertices( ctx ); }
void _swsetup_choose_rastersetup_func(GLcontext *ctx) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); int funcindex = 0; if (ctx->RenderMode == GL_RENDER) { if (ctx->Visual.rgbMode) { funcindex = COLOR; if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) funcindex |= MULTITEX; else if (ctx->Texture._ReallyEnabled & TEXTURE0_ANY) funcindex |= TEX0; if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) funcindex |= SPEC; } else { funcindex = INDEX; } if (ctx->Point._Attenuated) funcindex |= POINT; if (ctx->Fog.Enabled) funcindex |= FOG; } else if (ctx->RenderMode == GL_FEEDBACK) { if (ctx->Visual.rgbMode) funcindex = (COLOR | TEX0); /* is feedback color subject to fogging? */ else funcindex = INDEX; } else funcindex = 0; swsetup->SetupIndex = funcindex; tnl->Driver.Render.BuildVertices = setup_tab[funcindex]; if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { tnl->Driver.Render.Interp = interp_extras; tnl->Driver.Render.CopyPV = copy_pv_extras; } else { tnl->Driver.Render.Interp = interp_tab[funcindex]; tnl->Driver.Render.CopyPV = copy_pv_tab[funcindex]; } ASSERT(tnl->Driver.Render.BuildVertices); ASSERT(tnl->Driver.Render.BuildVertices != emit_invalid); }
/* * Render a triangle respecting cull and shade model. */ static void _swsetup_render_tri(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e2, GLuint facing, swsetup_edge_render_prim_tri render) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLubyte *ef = VB->EdgeFlag; SWvertex *verts = swsetup->verts; SWvertex *v0 = &verts[e0]; SWvertex *v1 = &verts[e1]; SWvertex *v2 = &verts[e2]; /* cull testing */ if (ctx->Polygon.CullFlag) { if (facing == 1 && ctx->Polygon.CullFaceMode != GL_FRONT) return; if (facing == 0 && ctx->Polygon.CullFaceMode != GL_BACK) return; } _swrast_SetFacing(ctx, facing); if (ctx->Light.ShadeModel == GL_FLAT) { GLchan c[2][4]; GLfloat s[2][4]; /* save colors/indexes for v0, v1 vertices */ COPY_CHAN4(c[0], v0->color); COPY_CHAN4(c[1], v1->color); COPY_4V(s[0], v0->attrib[FRAG_ATTRIB_COL1]); COPY_4V(s[1], v1->attrib[FRAG_ATTRIB_COL1]); /* copy v2 color/indexes to v0, v1 indexes */ COPY_CHAN4(v0->color, v2->color); COPY_CHAN4(v1->color, v2->color); COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]); COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]); render(ctx, ef, e0, e1, e2, v0, v1, v2); COPY_CHAN4(v0->color, c[0]); COPY_CHAN4(v1->color, c[1]); COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], s[0]); COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], s[1]); } else { render(ctx, ef, e0, e1, e2, v0, v1, v2); } }
static void _swsetup_render_line_tri( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLubyte *ef = VB->EdgeFlag; SWvertex *verts = swsetup->verts; SWvertex *v0 = &verts[e0]; SWvertex *v1 = &verts[e1]; SWvertex *v2 = &verts[e2]; GLchan c[2][4]; GLchan s[2][4]; GLuint i[2]; if (ctx->_TriangleCaps & DD_FLATSHADE) { COPY_CHAN4(c[0], v0->color); COPY_CHAN4(c[1], v1->color); COPY_CHAN4(s[0], v0->specular); COPY_CHAN4(s[1], v1->specular); i[0] = v0->index; i[1] = v1->index; COPY_CHAN4(v0->color, v2->color); COPY_CHAN4(v1->color, v2->color); COPY_CHAN4(v0->specular, v2->specular); COPY_CHAN4(v1->specular, v2->specular); v0->index = v2->index; v1->index = v2->index; } if (swsetup->render_prim == GL_POLYGON) { if (ef[e2]) _swrast_Line( ctx, v2, v0 ); if (ef[e0]) _swrast_Line( ctx, v0, v1 ); if (ef[e1]) _swrast_Line( ctx, v1, v2 ); } else { if (ef[e0]) _swrast_Line( ctx, v0, v1 ); if (ef[e1]) _swrast_Line( ctx, v1, v2 ); if (ef[e2]) _swrast_Line( ctx, v2, v0 ); } if (ctx->_TriangleCaps & DD_FLATSHADE) { COPY_CHAN4(v0->color, c[0]); COPY_CHAN4(v1->color, c[1]); COPY_CHAN4(v0->specular, s[0]); COPY_CHAN4(v1->specular, s[1]); v0->index = i[0]; v1->index = i[1]; } }
static void swsetup_points( struct gl_context *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; GLuint i; if (VB->Elts) { for (i = first; i < last; i++) if (VB->ClipMask[VB->Elts[i]] == 0) _swrast_Point( ctx, &verts[VB->Elts[i]] ); } else { for (i = first; i < last; i++) if (VB->ClipMask[i] == 0) _swrast_Point( ctx, &verts[i] ); } }
/* * We patch this function into tnl->Driver.Render.Start. * It's called when we start rendering a vertex buffer. */ static void _swsetup_RenderStart( GLcontext *ctx ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); GLuint new_state = swsetup->NewState; if (new_state & _SWSETUP_NEW_RENDERINDEX) { _swsetup_choose_trifuncs( ctx ); } if (new_state & _SWSETUP_NEW_VERTS) { _swsetup_choose_rastersetup_func( ctx ); } swsetup->NewState = 0; _swrast_render_start( ctx ); }
/** * Tell the tnl module how to build SWvertex objects for swrast. * We'll build the map[] array with that info and pass it to * _tnl_install_attrs(). */ static void setup_vertex_format(struct gl_context *ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); SScontext *swsetup = SWSETUP_CONTEXT(ctx); GLboolean intColors = ctx->RenderMode == GL_RENDER && CHAN_TYPE != GL_FLOAT; if (intColors != swsetup->intColors || tnl->render_inputs_bitset != swsetup->last_index_bitset) { GLbitfield64 index_bitset = tnl->render_inputs_bitset; struct tnl_attr_map map[_TNL_ATTRIB_MAX]; unsigned e = 0; swsetup->intColors = intColors; EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, attrib[FRAG_ATTRIB_WPOS] ); if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR)) { if (swsetup->intColors) EMIT_ATTR( _TNL_ATTRIB_COLOR, EMIT_4CHAN_4F_RGBA, color ); else EMIT_ATTR( _TNL_ATTRIB_COLOR, EMIT_4F, attrib[FRAG_ATTRIB_COL]); } if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_FOG)) { EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F, attrib[FRAG_ATTRIB_FOGC]); } if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_TEX)) { EMIT_ATTR( _TNL_ATTRIB_TEX, EMIT_4F, attrib[FRAG_ATTRIB_TEX] ); } if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE)) EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize ); _tnl_install_attrs( ctx, map, e, ctx->Viewport._WindowMap.m, sizeof(SWvertex) ); swsetup->last_index_bitset = index_bitset; } }
void _swsetup_DestroyContext( GLcontext *ctx ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); if (swsetup) { if (swsetup->verts) ALIGN_FREE(swsetup->verts); if (swsetup->ChanSecondaryColor.Ptr) ALIGN_FREE(swsetup->ChanSecondaryColor.Ptr); if (swsetup->ChanColor.Ptr) ALIGN_FREE(swsetup->ChanColor.Ptr); FREE(swsetup); ctx->swsetup_context = 0; } }
static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; if (VB->ColorPtr[1]) { COPY_CHAN4( GET_COLOR(VB->ColorPtr[1], dst), GET_COLOR(VB->ColorPtr[1], src) ); if (VB->SecondaryColorPtr[1]) { COPY_3V( GET_COLOR(VB->SecondaryColorPtr[1], dst), GET_COLOR(VB->SecondaryColorPtr[1], src) ); } } else if (VB->IndexPtr[1]) { VB->IndexPtr[1]->data[dst] = VB->IndexPtr[1]->data[src]; } copy_pv_tab[SWSETUP_CONTEXT(ctx)->SetupIndex](ctx, dst, src); }
/** * Prepare to render a vertex buffer. * Called via tnl->Driver.Render.Start. */ static void _swsetup_RenderStart( struct gl_context *ctx ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; if (swsetup->NewState & _SWSETUP_NEW_RENDERINDEX) { _swsetup_choose_trifuncs(ctx); } swsetup->NewState = 0; _swrast_render_start(ctx); /* Important */ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; setup_vertex_format(ctx); }
/* * Render a triangle using lines and respecting edge flags. */ static void _swsetup_edge_render_line_tri(struct gl_context *ctx, const GLubyte *ef, GLuint e0, GLuint e1, GLuint e2, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); if (swsetup->render_prim == GL_POLYGON) { if (ef[e2]) _swrast_Line( ctx, v2, v0 ); if (ef[e0]) _swrast_Line( ctx, v0, v1 ); if (ef[e1]) _swrast_Line( ctx, v1, v2 ); } else { if (ef[e0]) _swrast_Line( ctx, v0, v1 ); if (ef[e1]) _swrast_Line( ctx, v1, v2 ); if (ef[e2]) _swrast_Line( ctx, v2, v0 ); } }
/** * Tell the tnl module how to build SWvertex objects for swrast. * We'll build the map[] array with that info and pass it to * _tnl_install_attrs(). */ static void setup_vertex_format(struct gl_context *ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); SScontext *swsetup = SWSETUP_CONTEXT(ctx); GLboolean intColors = !ctx->FragmentProgram._Current && !ctx->ATIFragmentShader._Enabled && ctx->RenderMode == GL_RENDER && CHAN_TYPE != GL_FLOAT; if (intColors != swsetup->intColors || tnl->render_inputs_bitset != swsetup->last_index_bitset) { GLbitfield64 index_bitset = tnl->render_inputs_bitset; struct tnl_attr_map map[_TNL_ATTRIB_MAX]; unsigned int i, e = 0; swsetup->intColors = intColors; EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, attrib[VARYING_SLOT_POS] ); if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR0)) { if (swsetup->intColors) EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color ); else EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F, attrib[VARYING_SLOT_COL0]); } if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR1)) { EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F, attrib[VARYING_SLOT_COL1]); } if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_FOG)) { const GLint emit = ctx->FragmentProgram._Current ? EMIT_4F : EMIT_1F; EMIT_ATTR( _TNL_ATTRIB_FOG, emit, attrib[VARYING_SLOT_FOGC]); } if (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX)) { for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_TEX(i))) { EMIT_ATTR( _TNL_ATTRIB_TEX(i), EMIT_4F, attrib[VARYING_SLOT_TEX0 + i] ); } } } /* shader varying vars */ if (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_GENERIC0, _TNL_NUM_GENERIC)) { for (i = 0; i < ctx->Const.MaxVarying; i++) { if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_GENERIC(i))) { EMIT_ATTR( _TNL_ATTRIB_GENERIC(i), VARYING_EMIT_STYLE, attrib[VARYING_SLOT_VAR0 + i] ); } } } if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE)) EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize ); _tnl_install_attrs( ctx, map, e, ctx->Viewport._WindowMap.m, sizeof(SWvertex) ); swsetup->last_index_bitset = index_bitset; } }
static void swsetup_line( struct gl_context *ctx, GLuint v0, GLuint v1 ) { SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; _swrast_Line( ctx, &verts[v0], &verts[v1] ); }
void _swsetup_InvalidateState( GLcontext *ctx, GLuint new_state ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); swsetup->NewState |= new_state; }
static void _swsetup_RenderPrimitive( struct gl_context *ctx, GLenum mode ) { SWSETUP_CONTEXT(ctx)->render_prim = mode; _swrast_render_primitive( ctx, mode ); }
static void _swsetup_RenderPrimitive( GLcontext *ctx, GLenum mode ) { SWSETUP_CONTEXT(ctx)->render_prim = mode; }