r300: implement proper IsProgramNative check for vertex programs
authorMaciej Cencora <m.cencora@gmail.com>
Fri, 3 Jul 2009 18:14:24 +0000 (20:14 +0200)
committerMaciej Cencora <m.cencora@gmail.com>
Mon, 13 Jul 2009 17:25:57 +0000 (19:25 +0200)
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_shader.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_vertprog.c
src/mesa/drivers/dri/r300/r300_vertprog.h

index 30b6e75039848bf8b87ae040100e68ae8a9f8309..44211a45b31d1229903b4a20194831bff200e056 100644 (file)
@@ -673,7 +673,6 @@ extern GLboolean r300CreateContext(const __GLcontextModes * glVisual,
                                   __DRIcontextPrivate * driContextPriv,
                                   void *sharedContextPrivate);
 
-extern void r300SelectVertexShader(r300ContextPtr r300);
 extern void r300InitShaderFuncs(struct dd_function_table *functions);
 
 extern void r300InitShaderFunctions(r300ContextPtr r300);
index 7206379ea0598c246d5192f5cafbc18b4a74b7aa..854eb5d80ae668ce84b66c1beb3ebbd416cc8346 100644 (file)
@@ -128,8 +128,13 @@ r300IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
                        r300TranslateFragmentShader(ctx, fp);
 
                return !fp->error;
-       } else
-               return GL_TRUE;
+       } else {
+               struct r300_vertex_program *vp = r300SelectVertexShader(ctx);
+               if (!vp->translated)
+                       r300TranslateVertexShader(vp);
+
+               return !vp->error;
+       }
 }
 
 void r300InitShaderFuncs(struct dd_function_table *functions)
index e0996383ebbe2ccb26e151aa239ff0f2f362b2a9..8c228ab5e7bfb0a5e3c384e8a303c2ed6d3dd64b 100644 (file)
@@ -2045,6 +2045,7 @@ void r300UpdateShaders(r300ContextPtr rmesa)
        }
 
        if (rmesa->radeon.NewGLState && rmesa->options.hw_tcl_enabled) {
+               struct r300_vertex_program *vp;
                int i;
                for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) {
                        rmesa->temp_attrib[i] =
@@ -2060,8 +2061,11 @@ void r300UpdateShaders(r300ContextPtr rmesa)
                            rmesa->temp_attrib[i];
                }
 
-               r300SelectVertexShader(rmesa);
-               r300SwitchFallback(ctx, R300_FALLBACK_VERTEX_PROGRAM, rmesa->selected_vp->error);
+               vp = r300SelectVertexShader(ctx);
+               if (!vp->translated)
+                       r300TranslateVertexShader(vp);
+
+               r300SwitchFallback(ctx, R300_FALLBACK_VERTEX_PROGRAM, vp->error);
        }
 
        fp = r300SelectFragmentShader(ctx);
index 25c42814ec72bf494db1e7f289b6f443999aa7f8..326183bda42a2572cea9a1f175dcf391148549de 100644 (file)
@@ -1027,7 +1027,7 @@ static void t_inputs_outputs(struct r300_vertex_program *vp)
        }
 }
 
-static void r300TranslateVertexShader(struct r300_vertex_program *vp)
+void r300TranslateVertexShader(struct r300_vertex_program *vp)
 {
        struct prog_instruction *vpi = vp->Base->Base.Instructions;
        int i;
@@ -1524,7 +1524,6 @@ static struct r300_vertex_program *build_program(GLcontext *ctx,
 
        assert(prog->NumInstructions);
        vp->num_temporaries = prog->NumTemporaries;
-       r300TranslateVertexShader(vp);
 
        return vp;
 }
@@ -1538,9 +1537,9 @@ static void add_outputs(struct r300_vertex_program_key *key, GLint vert)
        key->OutputsAdded |= 1 << vert;
 }
 
-void r300SelectVertexShader(r300ContextPtr r300)
+struct r300_vertex_program * r300SelectVertexShader(GLcontext *ctx)
 {
-       GLcontext *ctx = ctx = r300->radeon.glCtx;
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
        GLuint InputsRead;
        struct r300_vertex_program_key wanted_key = { 0 };
        GLint i;
@@ -1596,14 +1595,14 @@ void r300SelectVertexShader(r300ContextPtr r300)
        for (vp = vpc->progs; vp; vp = vp->next)
                if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key))
                    == 0) {
-                       r300->selected_vp = vp;
-                       return;
+                       return r300->selected_vp = vp;
                }
 
        vp = build_program(ctx, &wanted_key, &vpc->mesa_program, wpos_idx);
        vp->next = vpc->progs;
        vpc->progs = vp;
-       r300->selected_vp = vp;
+
+       return r300->selected_vp = vp;
 }
 
 #define bump_vpu_count(ptr, new_count)   do { \
index b552e3fb1bda138e02e6f04f7eb874e55f1ae3b4..2dab11c33781557de9787464d20449ce5fdb01b9 100644 (file)
@@ -34,4 +34,8 @@
 
 void r300SetupVertexProgram(r300ContextPtr rmesa);
 
+struct r300_vertex_program * r300SelectVertexShader(GLcontext *ctx);
+
+void r300TranslateVertexShader(struct r300_vertex_program *vp);
+
 #endif