r600: glsl - allow specifying texture sampler via uniforms
authorAndre Maasikas <amaasikas@gmail.com>
Fri, 4 Dec 2009 14:36:41 +0000 (16:36 +0200)
committerAndre Maasikas <amaasikas@gmail.com>
Tue, 8 Dec 2009 13:39:39 +0000 (15:39 +0200)
looks kinda hackish, should rethink later

src/mesa/drivers/dri/r600/r700_assembler.c
src/mesa/drivers/dri/r600/r700_assembler.h
src/mesa/drivers/dri/r600/r700_fragprog.c
src/mesa/drivers/dri/r600/r700_vertprog.c

index 3738edbc2f9889cf606b683b379b6e9564acc54f..158c5fa5491d0026dfbf270e977b8bd84f9b8e20 100644 (file)
@@ -4840,7 +4840,7 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm)
         pAsm->need_tex_barrier = GL_TRUE;
     }
     // Set src1 to tex unit id
-    pAsm->S[1].src.reg   = pAsm->pILInst[pAsm->uiCurInst].TexSrcUnit;
+    pAsm->S[1].src.reg   = pAsm->SamplerUnits[pAsm->pILInst[pAsm->uiCurInst].TexSrcUnit];
     pAsm->S[1].src.rtype = SRC_REG_TEMPORARY;
 
     //No sw info from mesa compiler, so hard code here.
index ef1f924add9679afc1d9d1e6a22412d6a66579d7..48ffef501f4de85a05312d2274fe2d7f8e1f1b26 100644 (file)
@@ -416,6 +416,7 @@ typedef struct r700_AssemblerBase
     SHADER_PIPE_TYPE currentShaderType;
     struct prog_instruction * pILInst;
     GLuint             uiCurInst;
+    GLubyte SamplerUnits[MAX_SAMPLERS];
     GLboolean   bR6xx;
     /* helper to decide which type of instruction to assemble */
     GLboolean is_tex;
index 0cb9707ee6fbea71228b28ddcd86ac81b4f2ffaf..8eb439a9519da49357541fa5b11dd8ab628fecbd 100644 (file)
@@ -308,6 +308,7 @@ GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp,
        GLuint    number_of_colors_exported;
        GLboolean z_enabled = GL_FALSE;
        GLuint    unBit;
+       int i;
 
     //Init_Program
        Init_r700_AssemblerBase( SPT_FP, &(fp->r700AsmCode), &(fp->r700Shader) );
@@ -320,6 +321,10 @@ GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp,
 
     InitShaderProgram(&(fp->r700AsmCode));
        
+    for(i=0; i < MAX_SAMPLERS; i++)
+    {
+         fp->r700AsmCode.SamplerUnits[i] = fp->mesa_program.Base.SamplerUnits[i];
+    }
        if( GL_FALSE == AssembleInstr(0,
                                   mesa_fp->Base.NumInstructions,
                                   &(mesa_fp->Base.Instructions[0]), 
index d3d1da79592a52804df82ce0f80ad551fd19cc2d..759b74dc7e9ab2a35cc9ded2b317fbe182ad0c0c 100644 (file)
@@ -337,6 +337,10 @@ struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx,
 
     InitShaderProgram(&(vp->r700AsmCode));
 
+    for(i=0; i < MAX_SAMPLERS; i++)
+    {
+        vp->r700AsmCode.SamplerUnits[i] = vp->mesa_program->Base.SamplerUnits[i];
+    }
        if(GL_FALSE == AssembleInstr(0,
                                  vp->mesa_program->Base.NumInstructions,
                                  &(vp->mesa_program->Base.Instructions[0]),