summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/nv40/nv40_fragprog.c
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2007-12-14 01:51:43 +1100
committerBen Skeggs <skeggsb@gmail.com>2007-12-14 01:51:43 +1100
commit868048fcc77ec954e2823959285bfa7b8f82b13c (patch)
treefed7518ded7898e9579abead4a12460335cf967a /src/mesa/pipe/nv40/nv40_fragprog.c
parent00f0f0d0a4b474757becb99109cb2dd6574178f8 (diff)
nv40: Do all fp setup in nv40_fragprog.c
Diffstat (limited to 'src/mesa/pipe/nv40/nv40_fragprog.c')
-rw-r--r--src/mesa/pipe/nv40/nv40_fragprog.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/mesa/pipe/nv40/nv40_fragprog.c b/src/mesa/pipe/nv40/nv40_fragprog.c
index bad5f0020e..a0d98ae4dc 100644
--- a/src/mesa/pipe/nv40/nv40_fragprog.c
+++ b/src/mesa/pipe/nv40/nv40_fragprog.c
@@ -701,10 +701,34 @@ nv40_fragprog_bind(struct nv40_context *nv40, struct nv40_fragment_program *fp)
{
struct pipe_winsys *ws = nv40->pipe.winsys;
uint32_t fp_control;
+ int i;
if (!fp->translated) {
- NOUVEAU_ERR("fragprog invalid, using passthrough shader\n");
- fp = &passthrough_fp;
+ nv40_fragprog_translate(nv40, fp);
+ if (!fp->translated) {
+ NOUVEAU_ERR("invalid, using passthrough shader\n");
+ fp = &passthrough_fp;
+ }
+ }
+
+ if (fp->num_consts) {
+ float *map = ws->buffer_map(ws, nv40->fragprog.constant_buf,
+ PIPE_BUFFER_FLAG_READ);
+ for (i = 0; i < fp->num_consts; i++) {
+ uint pid = fp->consts[i].pipe_id;
+
+ if (pid == -1)
+ continue;
+
+ if (!memcmp(&fp->insn[fp->consts[i].hw_id], &map[pid*4],
+ 4 * sizeof(float)))
+ continue;
+
+ memcpy(&fp->insn[fp->consts[i].hw_id], &map[pid*4],
+ 4 * sizeof(float));
+ fp->on_hw = 0;
+ }
+ ws->buffer_unmap(ws, nv40->fragprog.constant_buf);
}
if (!fp->on_hw) {
@@ -712,7 +736,6 @@ nv40_fragprog_bind(struct nv40_context *nv40, struct nv40_fragment_program *fp)
fp->buffer = ws->buffer_create(ws, 0x100, 0, 0);
#if 0
- int i;
for (i = 0; i < fp->insn_len; i++)
NOUVEAU_ERR("%d 0x%08x\n", i, fp->insn[i]);
#endif