gallium: simplify tgsi_full_immediate struct
[mesa.git] / src / gallium / drivers / nv30 / nv30_fragprog.c
index 68058264e39627f15c94afe8f36f3f922129f3f0..a48ba9782b329e47e32431f5fb48379ed36ef1c3 100644 (file)
@@ -1,6 +1,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "pipe/p_shader_tokens.h"
 #include "tgsi/tgsi_parse.h"
@@ -494,10 +495,10 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
        case TGSI_OPCODE_FRC:
                arith(fpc, sat, FRC, dst, mask, src[0], none, none);
                break;
-       case TGSI_OPCODE_KIL:
+       case TGSI_OPCODE_KILP:
                arith(fpc, 0, KIL, none, 0, none, none, none);
                break;
-       case TGSI_OPCODE_KILP:
+       case TGSI_OPCODE_KIL:
                dst = nv30_sr(NV30SR_NONE, 0);
                dst.cc_update = 1;
                arith(fpc, 0, MOV, dst, MASK_ALL, src[0], none, none);
@@ -526,6 +527,12 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
        case TGSI_OPCODE_MUL:
                arith(fpc, sat, MUL, dst, mask, src[0], src[1], none);
                break;
+       case TGSI_OPCODE_NOISE1:
+       case TGSI_OPCODE_NOISE2:
+       case TGSI_OPCODE_NOISE3:
+       case TGSI_OPCODE_NOISE4:
+               arith(fpc, sat, SFL, dst, mask, none, none, none);
+               break;
        case TGSI_OPCODE_POW:
                arith(fpc, sat, POW, dst, mask, src[0], src[1], none);
                break;
@@ -557,6 +564,9 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
        case TGSI_OPCODE_SGE:
                arith(fpc, sat, SGE, dst, mask, src[0], src[1], none);
                break;
+       case TGSI_OPCODE_SGT:
+               arith(fpc, sat, SGT, dst, mask, src[0], src[1], none);
+               break;
        case TGSI_OPCODE_SLT:
                arith(fpc, sat, SLT, dst, mask, src[0], src[1], none);
                break;
@@ -694,10 +704,10 @@ nv30_fragprog_prepare(struct nv30_fpc *fpc)
                        assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
                        assert(fpc->nr_imm < MAX_IMM);
 
-                       vals[0] = imm->u.ImmediateFloat32[0].Float;
-                       vals[1] = imm->u.ImmediateFloat32[1].Float;
-                       vals[2] = imm->u.ImmediateFloat32[2].Float;
-                       vals[3] = imm->u.ImmediateFloat32[3].Float;
+                       vals[0] = imm->u[0].Float;
+                       vals[1] = imm->u[1].Float;
+                       vals[2] = imm->u[2].Float;
+                       vals[3] = imm->u[3].Float;
                        fpc->imm[fpc->nr_imm++] = constant(fpc, -1, vals);
                }
                        break;
@@ -730,6 +740,8 @@ nv30_fragprog_translate(struct nv30_context *nv30,
        struct tgsi_parse_context parse;
        struct nv30_fpc *fpc = NULL;
 
+       tgsi_dump(fp->pipe.tokens,0);
+
        fpc = CALLOC(1, sizeof(struct nv30_fpc));
        if (!fpc)
                return;
@@ -787,12 +799,12 @@ static void
 nv30_fragprog_upload(struct nv30_context *nv30,
                     struct nv30_fragment_program *fp)
 {
-       struct pipe_winsys *ws = nv30->pipe.winsys;
+       struct pipe_screen *pscreen = nv30->pipe.screen;
        const uint32_t le = 1;
        uint32_t *map;
        int i;
 
-       map = ws->buffer_map(ws, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+       map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
 
 #if 0
        for (i = 0; i < fp->insn_len; i++) {
@@ -814,7 +826,7 @@ nv30_fragprog_upload(struct nv30_context *nv30,
                }
        }
 
-       ws->buffer_unmap(ws, fp->buffer);
+       pipe_buffer_unmap(pscreen, fp->buffer);
 }
 
 static boolean
@@ -823,7 +835,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
        struct nv30_fragment_program *fp = nv30->fragprog;
        struct pipe_buffer *constbuf =
                nv30->constbuf[PIPE_SHADER_FRAGMENT];
-       struct pipe_winsys *ws = nv30->pipe.winsys;
+       struct pipe_screen *pscreen = nv30->pipe.screen;
        struct nouveau_stateobj *so;
        boolean new_consts = FALSE;
        int i;
@@ -838,25 +850,30 @@ nv30_fragprog_validate(struct nv30_context *nv30)
                return FALSE;
        }
 
-       fp->buffer = ws->buffer_create(ws, 0x100, 0, fp->insn_len * 4);
+       fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
        nv30_fragprog_upload(nv30, fp);
 
-       so = so_new(6, 1);
+       so = so_new(8, 1);
        so_method(so, nv30->screen->rankine, NV34TCL_FP_ACTIVE_PROGRAM, 1);
-       so_reloc (so, fp->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
-                 NOUVEAU_BO_RD | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
-                 NV34TCL_FP_ACTIVE_PROGRAM_DMA0, NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
+       so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
+                     NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
+                     NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
+                     NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
        so_method(so, nv30->screen->rankine, NV34TCL_FP_CONTROL, 1);
        so_data  (so, fp->fp_control);
        so_method(so, nv30->screen->rankine, NV34TCL_FP_REG_CONTROL, 1);
        so_data  (so, fp->fp_reg_control);
+       so_method(so, nv30->screen->rankine, NV34TCL_TX_UNITS_ENABLE, 1);
+       so_data  (so, fp->samplers);
        so_ref(so, &fp->so);
+       so_ref(NULL, &so);
 
 update_constants:
        if (fp->nr_consts) {
                float *map;
                
-               map = ws->buffer_map(ws, constbuf, PIPE_BUFFER_USAGE_CPU_READ);
+               map = pipe_buffer_map(pscreen, constbuf,
+                                     PIPE_BUFFER_USAGE_CPU_READ);
                for (i = 0; i < fp->nr_consts; i++) {
                        struct nv30_fragment_program_data *fpd = &fp->consts[i];
                        uint32_t *p = &fp->insn[fpd->offset];
@@ -867,7 +884,7 @@ update_constants:
                        memcpy(p, cb, 4 * sizeof(float));
                        new_consts = TRUE;
                }
-               ws->buffer_unmap(ws, constbuf);
+               pipe_buffer_unmap(pscreen, constbuf);
 
                if (new_consts)
                        nv30_fragprog_upload(nv30, fp);