Exemple #1
0
static void r300_predict_emit_size( r300ContextPtr rmesa )
{
	if (!rmesa->radeon.swtcl.emit_prediction) {
		const int vertex_size = 7;
		const int prim_size = 3;
		const int cache_flush_size = 4;
		const int pre_emit_state = 4;
		const int scissor_size = 3;
		const int state_size = radeonCountStateEmitSize(&rmesa->radeon);

		if (rcommonEnsureCmdBufSpace(&rmesa->radeon,
					state_size + pre_emit_state + scissor_size
					+ vertex_size + prim_size + cache_flush_size * 2,
					__FUNCTION__))
			rmesa->radeon.swtcl.emit_prediction = radeonCountStateEmitSize(&rmesa->radeon);
		else
			rmesa->radeon.swtcl.emit_prediction = state_size;

		rmesa->radeon.swtcl.emit_prediction += rmesa->radeon.cmdbuf.cs->cdw
			+ vertex_size + scissor_size + prim_size + cache_flush_size * 2 + pre_emit_state;
		radeon_print(RADEON_SWRENDER, RADEON_VERBOSE,
				"%s, size %d\n",
				__func__, rmesa->radeon.cmdbuf.cs->cdw
				+ vertex_size + scissor_size + prim_size + cache_flush_size * 2 + pre_emit_state);
	}
}
Exemple #2
0
/**
 * Predict total emit size for next rendering operation so there is no flush in middle of rendering
 * Prediction has to aim towards the best possible value that is worse than worst case scenario
 */
static GLuint r200EnsureEmitSize( struct gl_context * ctx , GLubyte* vimap_rev )
{
  r200ContextPtr rmesa = R200_CONTEXT(ctx);
  TNLcontext *tnl = TNL_CONTEXT(ctx);
  struct vertex_buffer *VB = &tnl->vb;
  GLuint space_required;
  GLuint state_size;
  GLuint nr_aos = 0;
  int i;
  /* predict number of aos to emit */
  for (i = 0; i < 15; ++i)
  {
    if (vimap_rev[i] != 255)
    {
      ++nr_aos;
    }
  }

  {
    /* count the prediction for state size */
    space_required = 0;
    state_size = radeonCountStateEmitSize( &rmesa->radeon );
    /* vtx may be changed in r200EmitArrays so account for it if not dirty */
    if (!rmesa->hw.vtx.dirty)
      state_size += rmesa->hw.vtx.check(&rmesa->radeon.glCtx, &rmesa->hw.vtx);
    /* predict size for elements */
    for (i = 0; i < VB->PrimitiveCount; ++i)
    {
      if (!VB->Primitive[i].count)
	continue;
      /* If primitive.count is less than MAX_CONVERSION_SIZE
         rendering code may decide convert to elts.
	 In that case we have to make pessimistic prediction.
	 and use larger of 2 paths. */
      const GLuint elt_count =(VB->Primitive[i].count/GET_MAX_HW_ELTS() + 1);
      const GLuint elts = ELTS_BUFSZ(nr_aos) * elt_count;
      const GLuint index = INDEX_BUFSZ * elt_count;
      const GLuint vbuf = VBUF_BUFSZ;
      if ( (!VB->Elts && VB->Primitive[i].count >= MAX_CONVERSION_SIZE)
	  || vbuf > index + elts)
	space_required += vbuf;
      else
	space_required += index + elts;
      space_required += AOS_BUFSZ(nr_aos);
    }
  }

  radeon_print(RADEON_RENDER,RADEON_VERBOSE,
      "%s space %u, aos %d\n",
      __func__, space_required, AOS_BUFSZ(nr_aos) );
  /* flush the buffer in case we need more than is left. */
  if (rcommonEnsureCmdBufSpace(&rmesa->radeon, space_required + state_size, __func__))
    return space_required + radeonCountStateEmitSize( &rmesa->radeon );
  else
    return space_required + state_size;
}
Exemple #3
0
static void radeon_predict_emit_size( r100ContextPtr rmesa )
{

    if (!rmesa->radeon.swtcl.emit_prediction) {
        const int state_size = radeonCountStateEmitSize( &rmesa->radeon );
        const int scissor_size = 8;
        const int prims_size = 8;
        const int vertex_size = 7;

        if (rcommonEnsureCmdBufSpace(&rmesa->radeon,
                    state_size +
                    (scissor_size + prims_size + vertex_size),
                    __func__))
            rmesa->radeon.swtcl.emit_prediction = radeonCountStateEmitSize( &rmesa->radeon );
        else
            rmesa->radeon.swtcl.emit_prediction = state_size;
        rmesa->radeon.swtcl.emit_prediction += scissor_size + prims_size + vertex_size
            + rmesa->radeon.cmdbuf.cs->cdw;
    }
}
Exemple #4
0
static GLuint evergreenPredictRenderSize(GLcontext* ctx,
				    const struct _mesa_prim *prim,
				    const struct _mesa_index_buffer *ib,
				    GLuint nr_prims)
{
    context_t *context = EVERGREEN_CONTEXT(ctx);
    GLboolean flushed;
    GLuint dwords, i;
    GLuint state_size;

    dwords = PRE_EMIT_STATE_BUFSZ;
    if (ib)
	    dwords += nr_prims * 18;
    else {
	    for (i = 0; i < nr_prims; ++i)
	    {
		    if (prim[i].start == 0)
			    dwords += 14;
		    else if (prim[i].count > 0xffff)
			    dwords += prim[i].count + 14;
		    else
			    dwords += ((prim[i].count + 1) / 2) + 14;
	    }
    }

    state_size = radeonCountStateEmitSize(&context->radeon);
    flushed = rcommonEnsureCmdBufSpace(&context->radeon,
				       dwords + state_size,
				       __FUNCTION__);
    if (flushed)
	    dwords += radeonCountStateEmitSize(&context->radeon);
    else
	    dwords += state_size;

    radeon_print(RADEON_RENDER, RADEON_VERBOSE, "%s: total prediction size is %d.\n", __FUNCTION__, dwords);
    return dwords;

}
Exemple #5
0
static GLuint r300PredictTryDrawPrimsSize(GLcontext *ctx,
		GLuint nr_prims, const struct _mesa_prim *prim)
{
	struct r300_context *r300 = R300_CONTEXT(ctx);
	struct r300_vertex_buffer *vbuf = &r300->vbuf;
	GLboolean flushed;
	GLuint dwords;
	GLuint state_size;
	int i;
	GLuint extra_prims = 0;

	/* Check for primitive splitting. */
	for (i = 0; i < nr_prims; ++i) {
		const GLuint num_verts =  r300NumVerts(r300, prim[i].count, prim[i].mode);
		extra_prims += num_verts/(65535 - 32);
	}
	nr_prims += extra_prims;

	dwords = 2*CACHE_FLUSH_BUFSZ;
	dwords += PRE_EMIT_STATE_BUFSZ;
	dwords += (AOS_BUFSZ(vbuf->num_attribs)
		+ SCISSORS_BUFSZ*2
		+ FIREAOS_BUFSZ )*nr_prims;

	state_size = radeonCountStateEmitSize(&r300->radeon);
	flushed = rcommonEnsureCmdBufSpace(&r300->radeon,
			dwords + state_size,
			__FUNCTION__);
	if (flushed)
		dwords += radeonCountStateEmitSize(&r300->radeon);
	else
		dwords += state_size;

	radeon_print(RADEON_RENDER, RADEON_VERBOSE, "%s: total prediction size is %d.\n", __FUNCTION__, dwords);
	return dwords;
}
Exemple #6
0
/**
 * Predict total emit size for next rendering operation so there is no flush in middle of rendering
 * Prediction has to aim towards the best possible value that is worse than worst case scenario
 */
static GLuint radeonEnsureEmitSize( struct gl_context * ctx , GLuint inputs )
{
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
    GLuint space_required;
    GLuint state_size;
    GLuint nr_aos = 1; /* radeonEmitArrays does always emit one */
    int i;
    /* list of flags that are allocating aos object */
    const GLuint flags_to_check[] = {
        VERT_BIT_NORMAL,
        VERT_BIT_COLOR0,
        VERT_BIT_COLOR1,
        VERT_BIT_FOG
    };
    /* predict number of aos to emit */
    for (i=0; i < sizeof(flags_to_check)/sizeof(flags_to_check[0]); ++i)
    {
        if (inputs & flags_to_check[i])
            ++nr_aos;
    }
    for (i = 0; i < ctx->Const.MaxTextureUnits; ++i)
    {
        if (inputs & VERT_BIT_TEX(i))
            ++nr_aos;
    }

    {
        /* count the prediction for state size */
        space_required = 0;
        state_size = radeonCountStateEmitSize( &rmesa->radeon );
        /* tcl may be changed in radeonEmitArrays so account for it if not dirty */
        if (!rmesa->hw.tcl.dirty)
            state_size += rmesa->hw.tcl.check( rmesa->radeon.glCtx, &rmesa->hw.tcl );
        /* predict size for elements */
        for (i = 0; i < VB->PrimitiveCount; ++i)
        {
            if (!VB->Primitive[i].count)
                continue;
            /* If primitive.count is less than MAX_CONVERSION_SIZE
            rendering code may decide convert to elts.
             In that case we have to make pessimistic prediction.
             and use larger of 2 paths. */
            const GLuint elts = ELTS_BUFSZ(nr_aos);
            const GLuint index = INDEX_BUFSZ;
            const GLuint vbuf = VBUF_BUFSZ;
            if ( (!VB->Elts && VB->Primitive[i].count >= MAX_CONVERSION_SIZE)
                    || vbuf > index + elts)
                space_required += vbuf;
            else
                space_required += index + elts;
            space_required += VB->Primitive[i].count * 3;
            space_required += AOS_BUFSZ(nr_aos);
        }
        space_required += SCISSOR_BUFSZ;
    }
    /* flush the buffer in case we need more than is left. */
    if (rcommonEnsureCmdBufSpace(&rmesa->radeon, space_required, __FUNCTION__))
        return space_required + radeonCountStateEmitSize( &rmesa->radeon );
    else
        return space_required + state_size;
}