r300/fragprog: Finally get rid of the duplicate program copy
authorNicolai Hähnle <nhaehnle@gmail.com>
Fri, 24 Jul 2009 23:08:37 +0000 (01:08 +0200)
committerNicolai Hähnle <nhaehnle@gmail.com>
Mon, 27 Jul 2009 20:51:38 +0000 (22:51 +0200)
Signed-off-by: Nicolai Hähnle <nhaehnle@gmail.com>
src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c
src/mesa/drivers/dri/r300/compiler/radeon_compiler.h
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_fragprog_common.c
src/mesa/drivers/dri/r300/r300_shader.c
src/mesa/drivers/dri/r300/r300_state.c

index 014c5fbac0194fdc9eec1c5b23a7900461442e5c..3c63da817665d5afdc17f5be56d431c0b105ddaa 100644 (file)
@@ -146,15 +146,6 @@ static void rewrite_depth_out(struct r300_fragment_program_compiler * c)
 
 void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
 {
-       if (c->Base.Debug) {
-               fflush(stdout);
-               _mesa_printf("Fragment Program: Initial program:\n");
-               _mesa_print_program(c->program);
-               fflush(stdout);
-       }
-
-       rc_mesa_to_rc_program(&c->Base, c->program);
-
        insert_WPOS_trailer(c);
 
        rewriteFog(c);
index 6b251ba7f19e97948d2db54b20ab39f81c8d8300..b9e1a7959af437430ad50f537e99f34728660f6b 100644 (file)
@@ -74,7 +74,6 @@ void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsig
 struct r300_fragment_program_compiler {
        struct radeon_compiler Base;
        struct rX00_fragment_program_code *code;
-       struct gl_program * program;
        struct r300_fragment_program_external_state state;
        GLboolean is_r500;
 };
index 629fd0af27453e946594a9f919f28bc2bc72b350..56f05723b8c4aa83a4b55feb4fd8be6f248347c4 100644 (file)
@@ -428,7 +428,6 @@ struct r300_vertex_program_cont {
 */
 struct r300_fragment_program {
        GLboolean error;
-       struct gl_program *Base;
        struct r300_fragment_program *next;
        struct r300_fragment_program_external_state state;
 
index 0ce57e834b4084c94ef91d2b15b15d0d611cb8bb..05f46ad0607132f912b07fca5030371ab9e5b39b 100644 (file)
@@ -96,14 +96,21 @@ static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_prog
 
        compiler.code = &fp->code;
        compiler.state = fp->state;
-       compiler.program = _mesa_clone_program(ctx, &cont->Base.Base);
        compiler.is_r500 = (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) ? GL_TRUE : GL_FALSE;
 
+       if (compiler.Base.Debug) {
+               fflush(stdout);
+               _mesa_printf("Fragment Program: Initial program:\n");
+               _mesa_print_program(&cont->Base.Base);
+               fflush(stdout);
+       }
+
+       rc_mesa_to_rc_program(&compiler.Base, &cont->Base.Base);
+
        r3xx_compile_fragment_program(&compiler);
        fp->error = compiler.Base.Error;
 
        fp->InputsRead = compiler.Base.Program.InputsRead;
-       fp->Base = compiler.program;
 
        rc_destroy(&compiler.Base);
 }
index 40b073f2c73e37d9f0842bae1194f040a3ec55e4..a4f9db13ecfd34c35b7d0d2614f9943d39020351 100644 (file)
@@ -39,7 +39,6 @@ static void freeFragProgCache(GLcontext *ctx, struct r300_fragment_program_cont
        while (fp) {
                tmp = fp->next;
                rc_constants_destroy(&fp->code.constants);
-               _mesa_reference_program(ctx, &fp->Base, NULL);
                _mesa_free(fp);
                fp = tmp;
        }
index c79601bcb1ef02a888db0ea2d5f628540d88c342..1f799d5a6ff85d2a2e0691cc1034ac8cfeb4a601 100644 (file)
@@ -1044,35 +1044,6 @@ void r300UpdateViewportOffset(GLcontext * ctx)
        radeonUpdateScissor(ctx);
 }
 
-static void
-r300FetchStateParameter(GLcontext * ctx,
-                       const gl_state_index state[STATE_LENGTH],
-                       GLfloat * value)
-{
-       r300ContextPtr r300 = R300_CONTEXT(ctx);
-
-       switch (state[0]) {
-       case STATE_INTERNAL:
-               switch (state[1]) {
-               case STATE_R300_WINDOW_DIMENSION: {
-                               __DRIdrawablePrivate * drawable = radeon_get_drawable(&r300->radeon);
-                               value[0] = drawable->w * 0.5f;  /* width*0.5 */
-                               value[1] = drawable->h * 0.5f;  /* height*0.5 */
-                               value[2] = 0.5F;        /* for moving range [-1 1] -> [0 1] */
-                               value[3] = 1.0F;        /* not used */
-                               break;
-                       }
-
-               default:
-                       break;
-               }
-               break;
-
-       default:
-               break;
-       }
-}
-
 /**
  * Update R300's own internal state parameters.
  * For now just STATE_R300_WINDOW_DIMENSION
@@ -1081,7 +1052,6 @@ static void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        struct gl_program_parameter_list *paramList;
-       GLuint i;
 
        if (!(new_state & (_NEW_BUFFERS | _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS)))
                return;
@@ -1089,21 +1059,12 @@ static void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state)
        if (!ctx->FragmentProgram._Current || !rmesa->selected_fp)
                return;
 
-       paramList = rmesa->selected_fp->Base->Parameters;
+       paramList = ctx->FragmentProgram._Current->Base.Parameters;
 
        if (!paramList)
                return;
 
        _mesa_load_state_parameters(ctx, paramList);
-
-       for (i = 0; i < paramList->NumParameters; i++) {
-               if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) {
-                       r300FetchStateParameter(ctx,
-                                               paramList->Parameters[i].
-                                               StateIndexes,
-                                               paramList->ParameterValues[i]);
-               }
-       }
 }
 
 /* =============================================================
@@ -2015,12 +1976,11 @@ static const GLfloat *get_fragmentprogram_constant(GLcontext *ctx, GLuint index,
 {
        static const GLfloat dummy[4] = { 0, 0, 0, 0 };
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct r300_fragment_program * fp = rmesa->selected_fp;
-       struct rc_constant * rcc = &fp->code.constants.Constants[index];
+       struct rc_constant * rcc = &rmesa->selected_fp->code.constants.Constants[index];
 
        switch(rcc->Type) {
        case RC_CONSTANT_EXTERNAL:
-               return fp->Base->Parameters->ParameterValues[rcc->u.External];
+               return ctx->FragmentProgram._Current->Base.Parameters->ParameterValues[rcc->u.External];
        case RC_CONSTANT_IMMEDIATE:
                return rcc->u.Immediate;
        case RC_CONSTANT_STATE: