diff options
author | Alex Deucher <[email protected]> | 2009-08-24 17:41:01 -0400 |
---|---|---|
committer | Alex Deucher <[email protected]> | 2009-08-24 17:51:00 -0400 |
commit | 8dd151b947c36100f38cf83eca674bd427b23e47 (patch) | |
tree | ce9a8321cf2c2b015f64cc6dc502d5db03eab97b /src/mesa | |
parent | dea10381864269bd6251a8b0af7a88de88296b32 (diff) |
r600: code cleanup
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/r600/r700_fragprog.c | 21 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r600/r700_fragprog.h | 11 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r600/r700_state.c | 102 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r600/r700_vertprog.c | 26 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r600/r700_vertprog.h | 22 |
5 files changed, 74 insertions, 108 deletions
diff --git a/src/mesa/drivers/dri/r600/r700_fragprog.c b/src/mesa/drivers/dri/r600/r700_fragprog.c index 098b420dfcc..e4a6d4cedf8 100644 --- a/src/mesa/drivers/dri/r600/r700_fragprog.c +++ b/src/mesa/drivers/dri/r600/r700_fragprog.c @@ -121,13 +121,13 @@ void Map_Fragment_Program(r700_AssemblerBase *pAsm, pAsm->pR700Shader->depthIsExported = 1; } - pAsm->pucOutMask = (unsigned char*) MALLOC(pAsm->number_of_exports); + pAsm->pucOutMask = (unsigned char*) MALLOC(pAsm->number_of_exports); for(ui=0; ui<pAsm->number_of_exports; ui++) { pAsm->pucOutMask[ui] = 0x0; } - - pAsm->uFirstHelpReg = pAsm->number_used_registers; + + pAsm->uFirstHelpReg = pAsm->number_used_registers; } GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp, @@ -258,6 +258,19 @@ GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp, return GL_TRUE; } +void r700SelectFragmentShader(GLcontext *ctx) +{ + context_t *context = R700_CONTEXT(ctx); + struct r700_fragment_program *fp = (struct r700_fragment_program *) + (ctx->FragmentProgram._Current); + if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770) + { + fp->r700AsmCode.bR6xx = 1; + } + + r700TranslateFragmentShader(fp, &(fp->mesa_program)); +} + void * r700GetActiveFpShaderBo(GLcontext * ctx) { struct r700_fragment_program *fp = (struct r700_fragment_program *) @@ -283,7 +296,7 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx) if(GL_FALSE == fp->loaded) { - if(fp->r700Shader.bNeedsAssembly == GL_TRUE) + if(fp->r700Shader.bNeedsAssembly == GL_TRUE) { Assemble( &(fp->r700Shader) ); } diff --git a/src/mesa/drivers/dri/r600/r700_fragprog.h b/src/mesa/drivers/dri/r600/r700_fragprog.h index 9c7813e9084..cbb108d2128 100644 --- a/src/mesa/drivers/dri/r600/r700_fragprog.h +++ b/src/mesa/drivers/dri/r600/r700_fragprog.h @@ -49,13 +49,16 @@ struct r700_fragment_program /* Internal */ void Map_Fragment_Program(r700_AssemblerBase *pAsm, - struct gl_fragment_program *mesa_fp); + struct gl_fragment_program *mesa_fp); GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp, - struct gl_fragment_program *mesa_fp); + struct gl_fragment_program *mesa_fp); + +GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp, + struct gl_fragment_program *mesa_vp); /* Interface */ -extern GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp, - struct gl_fragment_program *mesa_vp); +extern void r700SelectFragmentShader(GLcontext *ctx); + extern GLboolean r700SetupFragmentProgram(GLcontext * ctx); extern void * r700GetActiveFpShaderBo(GLcontext * ctx); diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 15f40b2771e..efa1daf2d3c 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -71,65 +71,37 @@ void r700SetDefaultStates(context_t *context) //-------------------- void r700UpdateShaders (GLcontext * ctx) //---------------------------------- { context_t *context = R700_CONTEXT(ctx); - GLvector4f dummy_attrib[_TNL_ATTRIB_MAX]; GLvector4f *temp_attrib[_TNL_ATTRIB_MAX]; int i; - if (ctx->FragmentProgram._Current) { - struct r700_fragment_program *fp = (struct r700_fragment_program *) - (ctx->FragmentProgram._Current); - if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770) - { - fp->r700AsmCode.bR6xx = 1; - } - - if(GL_FALSE == fp->translated) - { - if( GL_FALSE == r700TranslateFragmentShader(fp, &(fp->mesa_program)) ) - { - //return GL_TRUE; - } - } + /* should only happenen once, just after context is created */ + /* TODO: shouldn't we fallback to sw here? */ + if (!ctx->FragmentProgram._Current) { + _mesa_fprintf(stderr, "No ctx->FragmentProgram._Current!!\n"); + return; } - if (context->radeon.NewGLState) - { - struct r700_vertex_program *vp; - context->radeon.NewGLState = 0; - - for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) - { - /* mat states from state var not array for sw */ - dummy_attrib[i].stride = 0; + r700SelectFragmentShader(ctx); - temp_attrib[i] = TNL_CONTEXT(ctx)->vb.AttribPtr[i]; - TNL_CONTEXT(ctx)->vb.AttribPtr[i] = &(dummy_attrib[i]); - } - - _tnl_UpdateFixedFunctionProgram(ctx); - - for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) - { - TNL_CONTEXT(ctx)->vb.AttribPtr[i] = temp_attrib[i]; - } + if (context->radeon.NewGLState) { + for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { + /* mat states from state var not array for sw */ + dummy_attrib[i].stride = 0; + temp_attrib[i] = TNL_CONTEXT(ctx)->vb.AttribPtr[i]; + TNL_CONTEXT(ctx)->vb.AttribPtr[i] = &(dummy_attrib[i]); + } - r700SelectVertexShader(ctx); - vp = (struct r700_vertex_program *)ctx->VertexProgram._Current; + _tnl_UpdateFixedFunctionProgram(ctx); - if (vp->translated == GL_FALSE) - { - // TODO - //fprintf(stderr, "Failing back to sw-tcl\n"); - //hw_tcl_on = future_hw_tcl_on = 0; - //r300ResetHwState(rmesa); - // - r700UpdateStateParameters(ctx, _NEW_PROGRAM); - return; - } + for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { + TNL_CONTEXT(ctx)->vb.AttribPtr[i] = temp_attrib[i]; + } } - r700UpdateStateParameters(ctx, _NEW_PROGRAM); + r700SelectVertexShader(ctx); + r700UpdateStateParameters(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); + context->radeon.NewGLState = 0; } /* @@ -176,45 +148,25 @@ void r700UpdateDrawBuffer(GLcontext * ctx) /* TODO */ //--------------------- r700SetDepthTarget(context); } -static void r700FetchStateParameter(GLcontext * ctx, - const gl_state_index state[STATE_LENGTH], - GLfloat * value) -{ - /* TODO */ -} - void r700UpdateStateParameters(GLcontext * ctx, GLuint new_state) //-------------------- { - struct r700_fragment_program *fp; + struct r700_fragment_program *fp = + (struct r700_fragment_program *)ctx->FragmentProgram._Current; struct gl_program_parameter_list *paramList; - GLuint i; - if (!(new_state & (_NEW_BUFFERS | _NEW_PROGRAM))) + if (!(new_state & (_NEW_BUFFERS | _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS))) return; - fp = (struct r700_fragment_program *)ctx->FragmentProgram._Current; - if (!fp) - { + if (!ctx->FragmentProgram._Current || !fp) return; - } - paramList = fp->mesa_program.Base.Parameters; + paramList = ctx->FragmentProgram._Current->Base.Parameters; if (!paramList) - { return; - } - for (i = 0; i < paramList->NumParameters; i++) - { - if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) - { - r700FetchStateParameter(ctx, - paramList->Parameters[i]. - StateIndexes, - paramList->ParameterValues[i]); - } - } + _mesa_load_state_parameters(ctx, paramList); + } /** diff --git a/src/mesa/drivers/dri/r600/r700_vertprog.c b/src/mesa/drivers/dri/r600/r700_vertprog.c index 550594e9df8..f8f862b33aa 100644 --- a/src/mesa/drivers/dri/r600/r700_vertprog.c +++ b/src/mesa/drivers/dri/r600/r700_vertprog.c @@ -296,16 +296,16 @@ void r700SelectVertexShader(GLcontext *ctx) context_t *context = R700_CONTEXT(ctx); struct r700_vertex_program *vpc = (struct r700_vertex_program *)ctx->VertexProgram._Current; + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *vb = &tnl->vb; + unsigned int unBit; + unsigned int i; + if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770) { vpc->r700AsmCode.bR6xx = 1; } - - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *vb = &tnl->vb; - unsigned int unBit; - unsigned int i; for(i=0; i<VERT_ATTRIB_MAX; i++) { unBit = 1 << i; @@ -317,11 +317,9 @@ void r700SelectVertexShader(GLcontext *ctx) } } - if(GL_FALSE == vpc->translated) - { - r700TranslateVertexShader(vpc, - &(vpc->mesa_program) ); - } + if(GL_FALSE == vpc->translated) { + r700TranslateVertexShader(vpc, &(vpc->mesa_program) ); + } } void * r700GetActiveVpShaderBo(GLcontext * ctx) @@ -345,17 +343,17 @@ GLboolean r700SetupVertexProgram(GLcontext * ctx) if(GL_FALSE == vp->loaded) { - if(vp->r700Shader.bNeedsAssembly == GL_TRUE) + if(vp->r700Shader.bNeedsAssembly == GL_TRUE) { Assemble( &(vp->r700Shader) ); } /* Load vp to gpu */ - r600EmitShader(ctx, - &(vp->shaderbo), + r600EmitShader(ctx, + &(vp->shaderbo), (GLvoid *)(vp->r700Shader.pProgram), vp->r700Shader.uShaderBinaryDWORDSize, - "VS"); + "VS"); vp->loaded = GL_TRUE; } diff --git a/src/mesa/drivers/dri/r600/r700_vertprog.h b/src/mesa/drivers/dri/r600/r700_vertprog.h index 6a9726a3d0f..4c3b7ee453d 100644 --- a/src/mesa/drivers/dri/r600/r700_vertprog.h +++ b/src/mesa/drivers/dri/r600/r700_vertprog.h @@ -62,23 +62,23 @@ struct r700_vertex_program //Internal unsigned int Map_Vertex_Output(r700_AssemblerBase *pAsm, - struct gl_vertex_program *mesa_vp, - unsigned int unStart); + struct gl_vertex_program *mesa_vp, + unsigned int unStart); unsigned int Map_Vertex_Input(r700_AssemblerBase *pAsm, - struct gl_vertex_program *mesa_vp, - unsigned int unStart); + struct gl_vertex_program *mesa_vp, + unsigned int unStart); GLboolean Process_Vertex_Program_Vfetch_Instructions( - struct r700_vertex_program *vp, - struct gl_vertex_program *mesa_vp); + struct r700_vertex_program *vp, + struct gl_vertex_program *mesa_vp); void Map_Vertex_Program(struct r700_vertex_program *vp, - struct gl_vertex_program *mesa_vp); + struct gl_vertex_program *mesa_vp); GLboolean Find_Instruction_Dependencies_vp(struct r700_vertex_program *vp, - struct gl_vertex_program *mesa_vp); + struct gl_vertex_program *mesa_vp); -/* Interface */ -extern GLboolean r700TranslateVertexShader(struct r700_vertex_program *vp, - struct gl_vertex_program *mesa_vp); +GLboolean r700TranslateVertexShader(struct r700_vertex_program *vp, + struct gl_vertex_program *mesa_vp); +/* Interface */ extern void r700SelectVertexShader(GLcontext *ctx); extern GLboolean r700SetupVertexProgram(GLcontext * ctx); |