Fix progs/fp/tri-xpd
authorBen Skeggs <darktama@iinet.net.au>
Sun, 26 Nov 2006 10:19:44 +0000 (10:19 +0000)
committerBen Skeggs <darktama@iinet.net.au>
Sun, 26 Nov 2006 10:19:44 +0000 (10:19 +0000)
Fragprog consts are inlined, so make sure we update *all* occurances of a
    param :)

src/mesa/drivers/dri/nouveau/nouveau_shader.h
src/mesa/drivers/dri/nouveau/nouveau_shader_2.c
src/mesa/drivers/dri/nouveau/nv30_fragprog.c

index baf59d0..fac8851 100644 (file)
@@ -47,7 +47,11 @@ typedef struct _nouveauShader {
    struct {
       GLfloat  *source_val;    /* NULL if invariant */
       float    val[4];
-      int      hw_index;       /* hw-specific value */
+      /* Hardware-specific tracking, currently only nv30_fragprog
+       * makes use of it.
+       */
+      int      *hw_index;
+      int        hw_index_cnt;
    } params[NVS_MAX_CONSTS];
 
    struct {
index 1f09b6d..1cb0ca4 100644 (file)
@@ -130,8 +130,12 @@ pass2_add_instruction(nvsPtr nvs, nvsInstruction *inst,
            nvs->inputs_read |= (1 << reg.index);
         shader->SetSource(shader, &reg, op->srcpos[i]);
         srcpos_used |= (1<<op->srcpos[i]);
-        if (reg.file == NVS_FILE_CONST && shader->GetSourceConstVal)
-           nvs->params[reg.index].hw_index = nvs->program_current + 4;
+        if (reg.file == NVS_FILE_CONST && shader->GetSourceConstVal) {
+           int idx_slot = nvs->params[reg.index].hw_index_cnt++;
+           nvs->params[reg.index].hw_index = realloc(
+                 nvs->params[reg.index].hw_index, sizeof(int) * idx_slot+1);
+           nvs->params[reg.index].hw_index[idx_slot] = nvs->program_current + 4;
+        }
       }
    }
    for (i = 0; i < 3; i++) {
index 2e35d08..46391eb 100644 (file)
@@ -60,11 +60,15 @@ NV30FPUploadToHW(GLcontext *ctx, nouveauShader *nvs)
 static void
 NV30FPUpdateConst(GLcontext *ctx, nouveauShader *nvs, int id)
 {
-   uint32_t *current = nvs->program + nvs->params[id].hw_index;
    uint32_t *new     = nvs->params[id].source_val ?
       nvs->params[id].source_val : nvs->params[id].val;
+   uint32_t *current;
+   int i;
 
-   COPY_4V(current, new);
+   for (i=0; i<nvs->params[id].hw_index_cnt; i++) {
+      current = nvs->program + nvs->params[id].hw_index[i];
+      COPY_4V(current, new);
+   }
    nvs->on_hardware = 0;
 }