Beispiel #1
0
/* TCL render.
 */
static GLboolean radeon_run_tcl_render( struct gl_context *ctx,
                                        struct tnl_pipeline_stage *stage )
{
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
    GLuint inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
    GLuint i;

    /* TODO: separate this from the swtnl pipeline
     */
    if (rmesa->radeon.TclFallback)
        return GL_TRUE;	/* fallback to software t&l */

    if (VB->Count == 0)
        return GL_FALSE;

    /* NOTE: inputs != tnl->render_inputs - these are the untransformed
     * inputs.
     */
    if (ctx->Light.Enabled) {
        inputs |= VERT_BIT_NORMAL;
    }

    if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
        inputs |= VERT_BIT_COLOR1;
    }

    if ( (ctx->Fog.FogCoordinateSource == GL_FOG_COORD) && ctx->Fog.Enabled ) {
        inputs |= VERT_BIT_FOG;
    }

    for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
        if (ctx->Texture.Unit[i]._ReallyEnabled) {
            /* TODO: probably should not emit texture coords when texgen is enabled */
            if (rmesa->TexGenNeedNormals[i]) {
                inputs |= VERT_BIT_NORMAL;
            }
            inputs |= VERT_BIT_TEX(i);
        }
    }

    radeonReleaseArrays( ctx, ~0 );
    GLuint emit_end = radeonEnsureEmitSize( ctx, inputs )
                      + rmesa->radeon.cmdbuf.cs->cdw;
    radeonEmitArrays( ctx, inputs );

    rmesa->tcl.Elts = VB->Elts;

    for (i = 0 ; i < VB->PrimitiveCount ; i++)
    {
        GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
        GLuint start = VB->Primitive[i].start;
        GLuint length = VB->Primitive[i].count;

        if (!length)
            continue;

        if (rmesa->tcl.Elts)
            radeonEmitEltPrimitive( ctx, start, start+length, prim );
        else
            radeonEmitPrimitive( ctx, start, start+length, prim );
    }

    if (emit_end < rmesa->radeon.cmdbuf.cs->cdw)
        WARN_ONCE("Rendering was %d commands larger than predicted size."
                  " We might overflow  command buffer.\n", rmesa->radeon.cmdbuf.cs->cdw - emit_end);

    return GL_FALSE;		/* finished the pipe */
}
Beispiel #2
0
/* TCL render.
 */
static GLboolean radeon_run_tcl_render( GLcontext *ctx,
					struct tnl_pipeline_stage *stage )
{
   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
   TNLcontext *tnl = TNL_CONTEXT(ctx);
   struct vertex_buffer *VB = &tnl->vb;
   GLuint inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
   GLuint i;

   /* TODO: separate this from the swtnl pipeline 
    */
   if (rmesa->TclFallback)
      return GL_TRUE;	/* fallback to software t&l */

   if (VB->Count == 0)
      return GL_FALSE;

   /* NOTE: inputs != tnl->render_inputs - these are the untransformed
    * inputs.
    */
   if (ctx->Light.Enabled) {
      inputs |= VERT_BIT_NORMAL;
   }

   if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
      inputs |= VERT_BIT_COLOR1;
   }

   if ( (ctx->Fog.FogCoordinateSource == GL_FOG_COORD) && ctx->Fog.Enabled ) {
      inputs |= VERT_BIT_FOG;
   }

   for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
      if (ctx->Texture.Unit[i]._ReallyEnabled) {
      /* TODO: probably should not emit texture coords when texgen is enabled */
	 if (rmesa->TexGenNeedNormals[i]) {
	    inputs |= VERT_BIT_NORMAL;
	 }
	 inputs |= VERT_BIT_TEX(i);
      }
   }

   radeonReleaseArrays( ctx, ~0 );
   radeonEmitArrays( ctx, inputs );

   rmesa->tcl.Elts = VB->Elts;

   for (i = 0 ; i < VB->PrimitiveCount ; i++)
   {
      GLuint prim = VB->Primitive[i].mode;
      GLuint start = VB->Primitive[i].start;
      GLuint length = VB->Primitive[i].count;

      if (!length)
	 continue;

      if (rmesa->tcl.Elts)
	 radeonEmitEltPrimitive( ctx, start, start+length, prim );
      else
	 radeonEmitPrimitive( ctx, start, start+length, prim );
   }

   return GL_FALSE;		/* finished the pipe */
}