r300: Remove GLcontext requirement from radeon_nqssadce
authorNicolai Hähnle <nhaehnle@gmail.com>
Thu, 16 Jul 2009 20:32:46 +0000 (22:32 +0200)
committerNicolai Hähnle <nhaehnle@gmail.com>
Mon, 27 Jul 2009 18:32:03 +0000 (20:32 +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_nqssadce.c
src/mesa/drivers/dri/r300/compiler/radeon_nqssadce.h
src/mesa/drivers/dri/r300/r300_vertprog.c

index 75abdcfc42afa963f511112f07e89340459f4899..8b8c957e5c4cc6f092e9adf2ccc44e663a139011 100644 (file)
@@ -281,14 +281,14 @@ GLboolean r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c
                        .IsNativeSwizzle = &r500FPIsNativeSwizzle,
                        .BuildSwizzle = &r500FPBuildSwizzle
                };
-               radeonNqssaDce(c->ctx, c->program, &nqssadce);
+               radeonNqssaDce(c->program, &nqssadce, 0);
        } else {
                struct radeon_nqssadce_descr nqssadce = {
                        .Init = &nqssadce_init,
                        .IsNativeSwizzle = &r300FPIsNativeSwizzle,
                        .BuildSwizzle = &r300FPBuildSwizzle
                };
-               radeonNqssaDce(c->ctx, c->program, &nqssadce);
+               radeonNqssaDce(c->program, &nqssadce, 0);
        }
 
        if (c->debug) {
index 202a8532b6d9931aaf785d91cf69bcd9d909c7fd..ee2e1cbc54bea0748fb52556cac0b0d68c40bf84 100644 (file)
@@ -166,7 +166,7 @@ static void process_instruction(struct nqssadce_state* s)
        if (inst->Opcode != OPCODE_KIL) {
                struct register_state *regstate = get_reg_state(s, inst->DstReg.File, inst->DstReg.Index);
                if (!regstate) {
-                       _mesa_problem(s->Ctx, "NqssaDce: bad destination register (%i[%i])\n",
+                       fprintf(stderr, "r300 driver: NqssaDce: bad destination register (%i[%i])\n",
                                inst->DstReg.File, inst->DstReg.Index);
                        return;
                }
@@ -244,7 +244,7 @@ static void process_instruction(struct nqssadce_state* s)
                inst = track_used_srcreg(s, inst, 0, 0xb);
                break;
        default:
-               _mesa_problem(s->Ctx, "NqssaDce: Unknown opcode %d\n", inst->Opcode);
+               fprintf(stderr, "r300 driver: NqssaDce: Unknown opcode %d\n", inst->Opcode);
                return;
        }
 }
@@ -277,14 +277,14 @@ static void calculateInputsOutputs(struct gl_program *p)
        p->OutputsWritten = OutputsWritten;
 }
 
-void radeonNqssaDce(GLcontext *ctx, struct gl_program *p, struct radeon_nqssadce_descr* descr)
+void radeonNqssaDce(struct gl_program *p, struct radeon_nqssadce_descr* descr, void * data)
 {
        struct nqssadce_state s;
 
        _mesa_bzero(&s, sizeof(s));
-       s.Ctx = ctx;
        s.Program = p;
        s.Descr = descr;
+       s.UserData = data;
        s.Descr->Init(&s);
        s.IP = p->NumInstructions;
 
index 8626f21c25e1e3b5becbc3f1e766c6800555395d..8059b3b66d650375f7dde8e111e722574d42b087 100644 (file)
@@ -44,7 +44,6 @@ struct register_state {
  * read from, etc.
  */
 struct nqssadce_state {
-       GLcontext *Ctx;
        struct gl_program *Program;
        struct radeon_nqssadce_descr *Descr;
 
@@ -59,6 +58,8 @@ struct nqssadce_state {
        struct register_state Temps[MAX_PROGRAM_TEMPS];
        struct register_state Outputs[VERT_RESULT_MAX];
        struct register_state Address;
+
+       void * UserData;
 };
 
 
@@ -83,11 +84,9 @@ struct radeon_nqssadce_descr {
         * The transformation will work recursively on the emitted instruction(s).
         */
        void (*BuildSwizzle)(struct nqssadce_state*, struct prog_dst_register dst, struct prog_src_register src);
-
-       void *Data;
 };
 
-void radeonNqssaDce(GLcontext *ctx, struct gl_program *p, struct radeon_nqssadce_descr* descr);
+void radeonNqssaDce(struct gl_program *p, struct radeon_nqssadce_descr* descr, void * data);
 struct prog_src_register lmul_swizzle(GLuint swizzle, struct prog_src_register srcreg);
 
 #endif /* __RADEON_PROGRAM_NQSSADCE_H_ */
index ab5ca4322e272ac080f1f8b99645a55716e91341..f98de34e93c018bd2a33eb7e085876c2a5e1e1d7 100644 (file)
@@ -1496,7 +1496,7 @@ static void addArtificialOutputs(GLcontext *ctx, struct gl_program *prog)
 
 static void nqssadceInit(struct nqssadce_state* s)
 {
-       r300ContextPtr r300 = R300_CONTEXT(s->Ctx);
+       r300ContextPtr r300 = (r300ContextPtr)(s->UserData);
        GLuint fp_reads;
 
        fp_reads = r300->selected_fp->Base->InputsRead;
@@ -1582,7 +1582,7 @@ static struct r300_vertex_program *build_program(GLcontext *ctx,
                        .IsNativeSwizzle = &swizzleIsNative,
                        .BuildSwizzle = NULL
                };
-               radeonNqssaDce(ctx, prog, &nqssadce);
+               radeonNqssaDce(prog, &nqssadce, r300);
 
                /* We need this step for reusing temporary registers */
                _mesa_optimize_program(ctx, prog);