evergreen : fix shader const allocation and instruction bugs.
authorRichard Li <richardradeon@gmail.com>
Sun, 29 Aug 2010 23:27:46 +0000 (19:27 -0400)
committerRichard Li <richardradeon@gmail.com>
Sun, 29 Aug 2010 23:27:46 +0000 (19:27 -0400)
src/mesa/drivers/dri/r600/evergreen_fragprog.c
src/mesa/drivers/dri/r600/evergreen_fragprog.h
src/mesa/drivers/dri/r600/evergreen_render.c
src/mesa/drivers/dri/r600/evergreen_vertprog.c
src/mesa/drivers/dri/r600/evergreen_vertprog.h
src/mesa/drivers/dri/r600/r700_assembler.c

index 9568f446daa1a11164cb6254679dbf903e9f4e9f..b53ff424a01dde282c5440c821125d094417761a 100644 (file)
@@ -501,9 +501,7 @@ GLboolean evergreenSetupFragmentProgram(GLcontext * ctx)
     struct evergreen_fragment_program *fp = (struct evergreen_fragment_program *)
                                           (ctx->FragmentProgram._Current);
     r700_AssemblerBase         *pAsm = &(fp->r700AsmCode);
-    struct gl_fragment_program *mesa_fp = &(fp->mesa_program);
-    struct gl_program_parameter_list *paramList;
-    unsigned int unNumParamData;
+    struct gl_fragment_program *mesa_fp = &(fp->mesa_program);    
     unsigned int ui, i;
     unsigned int unNumOfReg;
     unsigned int unBit;
@@ -742,7 +740,22 @@ GLboolean evergreenSetupFragmentProgram(GLcontext * ctx)
     }
 
     exportCount = (evergreen->SQ_PGM_EXPORTS_PS.u32All & EXPORT_MODE_mask) / (1 << EXPORT_MODE_shift);
-    
+
+    return GL_TRUE;
+}
+
+GLboolean evergreenSetupFPconstants(GLcontext * ctx)
+{
+    context_t *context = EVERGREEN_CONTEXT(ctx);
+    EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
+    struct evergreen_fragment_program *fp = (struct evergreen_fragment_program *)
+                                          (ctx->FragmentProgram._Current);
+    r700_AssemblerBase *pAsm = &(fp->r700AsmCode);
+
+    struct gl_program_parameter_list *paramList;
+    unsigned int unNumParamData;
+    unsigned int ui;
+
     /* sent out shader constants. */
     paramList = fp->mesa_program.Base.Parameters;
 
@@ -801,7 +814,4 @@ GLboolean evergreenSetupFragmentProgram(GLcontext * ctx)
         }
         unConstOffset += pCompiledSub->NumParameters;
     }
-
-    return GL_TRUE;
-}
-
+}
\ No newline at end of file
index 0547d1f63dd943902e4b69d229f0587f4012db7f..0e200bf3833a3aea3043a7591752dacb50786b11 100644 (file)
@@ -68,6 +68,8 @@ extern void evergreenSelectFragmentShader(GLcontext *ctx);
 
 extern GLboolean evergreenSetupFragmentProgram(GLcontext * ctx);
 
+extern GLboolean evergreenSetupFPconstants(GLcontext * ctx);
+
 extern void *    evergreenGetActiveFpShaderBo(GLcontext * ctx);
 
 extern void *    evergreenGetActiveFpShaderConstBo(GLcontext * ctx);
index 7f9c95e7655897679c8b501e91a42c738042b46f..85b2f9d6ab7ce36860ef33b097bc41f5380f9414 100644 (file)
@@ -839,6 +839,10 @@ static GLboolean evergreenTryDrawPrims(GLcontext *ctx,
     GLuint emit_end = evergreenPredictRenderSize(ctx, prim, ib, nr_prims)
                     + context->radeon.cmdbuf.cs->cdw;
 
+    /* evergreenPredictRenderSize will call radeonReleaseDmaRegions, so update VP/FP const buf after it. */
+    evergreenSetupVPconstants(ctx);
+    evergreenSetupFPconstants(ctx);
+
     evergreenSetupIndexBuffer(ctx, ib);
 
     evergreenSetupStreams(ctx, arrays, max_index + 1);
@@ -849,16 +853,12 @@ static GLboolean evergreenTryDrawPrims(GLcontext *ctx,
 
     for (i = 0; i < nr_prims; ++i)
     {
-/* richard test disable */
-#if 0
            if (context->ind_buf.bo)
                    evergreenRunRenderPrimitive(ctx,
                                           prim[i].start,
                                           prim[i].start + prim[i].count,
                                           prim[i].mode);
            else
-#endif //0
-//-------------
                    evergreenRunRenderPrimitiveImmediate(ctx,
                                                    prim[i].start,
                                                    prim[i].start + prim[i].count,
index 5e4844edf9f496187e1ee4bfb98ad91e95464a84..4f3db00c7d2b71169ef1cd7cd2b3914d0bf17d03 100644 (file)
@@ -599,10 +599,6 @@ GLboolean evergreenSetupVertexProgram(GLcontext * ctx)
     EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
     struct evergreen_vertex_program *vp = context->selected_vp;
 
-    struct gl_program_parameter_list *paramList;
-    unsigned int unNumParamData;
-    unsigned int ui;
-
     if(GL_FALSE == vp->loaded)
     {
            if(vp->r700Shader.bNeedsAssembly == GL_TRUE)
@@ -655,6 +651,19 @@ GLboolean evergreenSetupVertexProgram(GLcontext * ctx)
     CLEARbit(evergreen->SPI_PS_IN_CONTROL_0.u32All, LINEAR_GRADIENT_ENA_bit);
     */
 
+    return GL_TRUE;
+}
+
+GLboolean evergreenSetupVPconstants(GLcontext * ctx)
+{
+    context_t *context = EVERGREEN_CONTEXT(ctx);
+    EVERGREEN_CHIP_CONTEXT *evergreen = GET_EVERGREEN_CHIP(context);
+    struct evergreen_vertex_program *vp = context->selected_vp;
+
+    struct gl_program_parameter_list *paramList;
+    unsigned int unNumParamData;
+    unsigned int ui;
+
     /* sent out shader constants. */
     paramList = vp->mesa_program->Base.Parameters;
 
@@ -724,6 +733,4 @@ GLboolean evergreenSetupVertexProgram(GLcontext * ctx)
         }
         unConstOffset += pCompiledSub->NumParameters;
     }
-
-    return GL_TRUE;
-}
+}
\ No newline at end of file
index 4c2626de7708188da3d59cb7ff944823d0659a5b..58539021152ee9cfe79e9cc020a1203dee07944a 100644 (file)
@@ -98,6 +98,8 @@ extern void evergreenSetVertexFormat(GLcontext *ctx, const struct gl_client_arra
 
 extern GLboolean evergreenSetupVertexProgram(GLcontext * ctx);
 
+extern GLboolean evergreenSetupVPconstants(GLcontext * ctx);
+
 extern void * evergreenGetActiveVpShaderBo(GLcontext * ctx);
 
 extern void * evergreenGetActiveVpShaderConstBo(GLcontext * ctx);
index fbd8c45d25daa58b9cc77ec1d38de7e84462430b..45ff9c06249d93fad3e85e1e9600b6e048bdbc0b 100644 (file)
@@ -4408,7 +4408,14 @@ GLboolean assemble_LIT(r700_AssemblerBase *pAsm)
     swizzleagain_PVSSRC(&(pAsm->S[2].src), SQ_SEL_X, SQ_SEL_X, SQ_SEL_X, SQ_SEL_X);
 
     /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
-    pAsm->D.dst.opcode   = SQ_OP3_INST_MUL_LIT;
+    if(8 == pAsm->unAsic)
+    {
+        pAsm->D.dst.opcode = EG_OP3_INST_MUL_LIT;
+    }
+    else
+    {
+        pAsm->D.dst.opcode = SQ_OP3_INST_MUL_LIT;
+    }
     pAsm->D.dst.math     = 1;
     pAsm->D.dst.op3      = 1;
     pAsm->D.dst.rtype    = DST_REG_TEMPORARY;