r300: Fix handling of NV_vertex_program parameters
authorNicolai Hähnle <nhaehnle@gmail.com>
Wed, 9 Sep 2009 17:56:57 +0000 (19:56 +0200)
committerNicolai Hähnle <nhaehnle@gmail.com>
Mon, 21 Sep 2009 10:56:16 +0000 (12:56 +0200)
The handling is a bit inefficient, unfortunately, but I don't want to make
any intrusive changes for Mesa 7.6.

Signed-off-by: Nicolai Hähnle <nhaehnle@gmail.com>
src/mesa/drivers/dri/r300/compiler/radeon_program.c
src/mesa/shader/program.c

index bbbf0dd776832b2212849a630974c9664377b3a5..b636f90a968c929d2426aac169910089c65d7efe 100644 (file)
@@ -150,14 +150,37 @@ void rc_mesa_to_rc_program(struct radeon_compiler * c, struct gl_program * progr
        c->Program.InputsRead = program->InputsRead;
        c->Program.OutputsWritten = program->OutputsWritten;
 
-       for(i = 0; i < program->Parameters->NumParameters; ++i) {
-               struct rc_constant constant;
+       int isNVProgram = 0;
 
-               constant.Type = RC_CONSTANT_EXTERNAL;
-               constant.Size = 4;
-               constant.u.External = i;
+       if (program->Target == GL_VERTEX_PROGRAM_ARB) {
+               struct gl_vertex_program * vp = (struct gl_vertex_program *) program;
+               isNVProgram = vp->IsNVProgram;
+       }
+
+       if (isNVProgram) {
+               /* NV_vertex_program has a fixed-sized constant environment.
+                * This could be handled more efficiently for programs that
+                * do not use relative addressing.
+                */
+               for(i = 0; i < 96; ++i) {
+                       struct rc_constant constant;
 
-               rc_constants_add(&c->Program.Constants, &constant);
+                       constant.Type = RC_CONSTANT_EXTERNAL;
+                       constant.Size = 4;
+                       constant.u.External = i;
+
+                       rc_constants_add(&c->Program.Constants, &constant);
+               }
+       } else {
+               for(i = 0; i < program->Parameters->NumParameters; ++i) {
+                       struct rc_constant constant;
+
+                       constant.Type = RC_CONSTANT_EXTERNAL;
+                       constant.Size = 4;
+                       constant.u.External = i;
+
+                       rc_constants_add(&c->Program.Constants, &constant);
+               }
        }
 }
 
index 963478fccdbdfa9e3de918222034d80997d6aef2..2cd6eb8a389d556ac7c8bae3ce18e31cff1a6cde 100644 (file)
@@ -502,6 +502,7 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog)
             = (const struct gl_vertex_program *) prog;
          struct gl_vertex_program *vpc = (struct gl_vertex_program *) clone;
          vpc->IsPositionInvariant = vp->IsPositionInvariant;
+         vpc->IsNVProgram = vp->IsNVProgram;
       }
       break;
    case GL_FRAGMENT_PROGRAM_ARB: