Example #1
0
struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx,
        struct gl_vertex_program *mesa_vp)
{
    context_t *context = R700_CONTEXT(ctx);
    struct r700_vertex_program *vp;
    unsigned int i;

    vp = _mesa_calloc(sizeof(*vp));
    vp->mesa_program = (struct gl_vertex_program *)_mesa_clone_program(ctx, &mesa_vp->Base);

    if (mesa_vp->IsPositionInvariant)
    {
        _mesa_insert_mvp_code(ctx, vp->mesa_program);
    }

    for(i=0; i<context->nNumActiveAos; i++)
    {
        vp->aos_desc[i].size   = context->stream_desc[i].size;
        vp->aos_desc[i].stride = context->stream_desc[i].stride;
        vp->aos_desc[i].type   = context->stream_desc[i].type;
    }

    if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770)
    {
        vp->r700AsmCode.bR6xx = 1;
    }

    //Init_Program
    Init_r700_AssemblerBase(SPT_VP, &(vp->r700AsmCode), &(vp->r700Shader) );
    Map_Vertex_Program(ctx, vp, vp->mesa_program );

    if(GL_FALSE == Find_Instruction_Dependencies_vp(vp, vp->mesa_program))
    {
        return NULL;
    }

    if(GL_FALSE == AssembleInstr(vp->mesa_program->Base.NumInstructions,
                                 &(vp->mesa_program->Base.Instructions[0]),
                                 &(vp->r700AsmCode)) )
    {
        return NULL;
    }

    if(GL_FALSE == Process_Vertex_Exports(&(vp->r700AsmCode), vp->mesa_program->Base.OutputsWritten) )
    {
        return NULL;
    }

    vp->r700Shader.nRegs = (vp->r700AsmCode.number_used_registers == 0) ? 0
                           : (vp->r700AsmCode.number_used_registers - 1);

    vp->r700Shader.nParamExports = vp->r700AsmCode.number_of_exports;

    vp->translated = GL_TRUE;

    return vp;
}
struct r700_vertex_program* r700TranslateVertexShader(struct gl_context *ctx,
						      struct gl_vertex_program *mesa_vp)
{
	context_t *context = R700_CONTEXT(ctx);

    R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw);

	struct r700_vertex_program *vp;
	unsigned int i;

	vp = calloc(1, sizeof(*vp));
	vp->mesa_program = _mesa_clone_vertex_program(ctx, mesa_vp);

    vp->constbo0 = NULL;

	if (mesa_vp->IsPositionInvariant)
	{
                _mesa_insert_mvp_code(ctx, vp->mesa_program);
        }

	for(i=0; i<context->nNumActiveAos; i++)
	{
		vp->aos_desc[i].size   = context->stream_desc[i].size;
		vp->aos_desc[i].stride = context->stream_desc[i].stride;
		vp->aos_desc[i].type   = context->stream_desc[i].type;
		vp->aos_desc[i].format = context->stream_desc[i].format;
	}

	if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770)
	{
		vp->r700AsmCode.bR6xx = 1;
	}

	//Init_Program
	Init_r700_AssemblerBase(SPT_VP, &(vp->r700AsmCode), &(vp->r700Shader) );

    if(GL_TRUE == r700->bShaderUseMemConstant)
    {
        vp->r700AsmCode.bUseMemConstant = GL_TRUE;
    }
    else
    {
        vp->r700AsmCode.bUseMemConstant = GL_FALSE;
    }

    vp->r700AsmCode.unAsic = 7;

	Map_Vertex_Program(ctx, vp, vp->mesa_program );

	if(GL_FALSE == Find_Instruction_Dependencies_vp(vp, vp->mesa_program))
	{
		return NULL;
	}

    InitShaderProgram(&(vp->r700AsmCode));

    for(i=0; i < MAX_SAMPLERS; i++)
    {
        vp->r700AsmCode.SamplerUnits[i] = vp->mesa_program->Base.SamplerUnits[i];
    }

    vp->r700AsmCode.unCurNumILInsts = vp->mesa_program->Base.NumInstructions;

	if(GL_FALSE == AssembleInstr(0,
                                 0,
                                 vp->mesa_program->Base.NumInstructions,
                                 &(vp->mesa_program->Base.Instructions[0]),
                                 &(vp->r700AsmCode)) )
	{
		return NULL;
	}

    if(GL_FALSE == Process_Vertex_Exports(&(vp->r700AsmCode), vp->mesa_program->Base.OutputsWritten) )
    {
        return NULL;
    }

    if( GL_FALSE == RelocProgram(&(vp->r700AsmCode), &(vp->mesa_program->Base)) )
    {
        return GL_FALSE;
    }

    vp->r700Shader.nRegs = (vp->r700AsmCode.number_used_registers == 0) ? 0 
                         : (vp->r700AsmCode.number_used_registers - 1);

	vp->r700Shader.nParamExports = vp->r700AsmCode.number_of_exports;

    vp->translated = GL_TRUE;

	return vp;
}