nouveau: some cleanups
authorBen Skeggs <skeggsb@gmail.com>
Sun, 16 Dec 2007 10:26:09 +0000 (21:26 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Sun, 16 Dec 2007 10:31:28 +0000 (21:31 +1100)
src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_softpipe.c
src/mesa/pipe/nv40/nv40_fragprog.c
src/mesa/pipe/nv40/nv40_state.h
src/mesa/pipe/nv40/nv40_surface.c

index ebce4ddede15ca1a0d2450cbf8f2cde523513409..3908c175088e51d393bf7ce1415c31d2d9afac6d 100644 (file)
@@ -31,8 +31,9 @@
 
 #include "imports.h"
 
-#include "pipe/softpipe/sp_winsys.h"
 #include "pipe/p_defines.h"
+#include "pipe/p_format.h"
+#include "pipe/softpipe/sp_winsys.h"
 
 #include "nouveau_context.h"
 #include "nouveau_winsys_pipe.h"
@@ -51,7 +52,7 @@ nouveau_is_format_supported(struct softpipe_winsys *sws, uint format)
        switch (format) {
        case PIPE_FORMAT_A8R8G8B8_UNORM:
        case PIPE_FORMAT_R5G6B5_UNORM:
-       case PIPE_FORMAT_S8Z24_UNORM:
+       case PIPE_FORMAT_Z24S8_UNORM:
                return TRUE;
        default:
                break;
index 8e2689e27d23be16c78de60f7237a5c7b37923dc..9cc1267108d27e1179d833bb2554610723603009 100644 (file)
@@ -36,6 +36,7 @@ struct nv40_fpc {
 
        int high_temp;
        int temp_temp_count;
+       int num_regs;
 
        uint depth_id;
        uint colour_id;
@@ -160,12 +161,12 @@ emit_dst(struct nv40_fpc *fpc, struct nv40_sreg dst)
 
        switch (dst.type) {
        case NV40SR_TEMP:
-               if (fp->num_regs < (dst.index + 1))
-                       fp->num_regs = dst.index + 1;
+               if (fpc->num_regs < (dst.index + 1))
+                       fpc->num_regs = dst.index + 1;
                break;
        case NV40SR_OUTPUT:
                if (dst.index == 1) {
-                       fp->writes_depth = 1;
+                       fp->fp_control |= 0xe;
                } else {
                        hw[0] |= NV40_FP_OP_OUT_REG_HALF;
                }
@@ -194,7 +195,7 @@ nv40_fp_arith(struct nv40_fpc *fpc, int sat, int op,
        memset(hw, 0, sizeof(uint32_t) * 4);
 
        if (op == NV40_FP_OP_OPCODE_KIL)
-               fp->uses_kil = TRUE;
+               fp->fp_control |= NV40TCL_FP_CONTROL_KIL;
        hw[0] |= (op << NV40_FP_OP_OPCODE_SHIFT);
        hw[0] |= (mask << NV40_FP_OP_OUTMASK_SHIFT);
        hw[2] |= (dst.dst_scale << NV40_FP_OP_DST_SCALE_SHIFT);
@@ -672,7 +673,7 @@ nv40_fragprog_translate(struct nv40_context *nv40,
                return;
        fpc->fp = fp;
        fpc->high_temp = -1;
-       fp->num_regs = 2;
+       fpc->num_regs = 2;
 
        tgsi_parse_init(&parse, fp->pipe->tokens);
 
@@ -727,6 +728,8 @@ nv40_fragprog_translate(struct nv40_context *nv40,
                }
        }
 
+       fp->fp_control |= fpc->num_regs << NV40TCL_FP_CONTROL_TEMP_COUNT_SHIFT;
+
        /* Terminate final instruction */
        fp->insn[fpc->inst_offset] |= 0x00000001;
 
@@ -749,7 +752,6 @@ void
 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) {
@@ -790,18 +792,12 @@ nv40_fragprog_bind(struct nv40_context *nv40, struct nv40_fragment_program *fp)
                fp->on_hw = TRUE;
        }
 
-       fp_control = fp->num_regs << NV40TCL_FP_CONTROL_TEMP_COUNT_SHIFT;
-       if (fp->uses_kil)
-               fp_control |= NV40TCL_FP_CONTROL_KIL;
-       if (fp->writes_depth)
-               fp_control |= 0xe;
-
        BEGIN_RING(curie, NV40TCL_FP_ADDRESS, 1);
        OUT_RELOC (fp->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
                   NOUVEAU_BO_RD | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
                   NV40TCL_FP_ADDRESS_DMA0, NV40TCL_FP_ADDRESS_DMA1);
        BEGIN_RING(curie, NV40TCL_FP_CONTROL, 1);
-       OUT_RING  (fp_control);
+       OUT_RING  (fp->fp_control);
 
        nv40->fragprog.active = fp;
 }
index cfc8b5637fb8c5a12188c4c10e3aec2953bbe3cd..eb8473842f68f8478b82543ed4b5c18da39151ac 100644 (file)
@@ -103,9 +103,7 @@ struct nv40_fragment_program {
 
        struct pipe_buffer_handle *buffer;
 
-       boolean uses_kil;
-       boolean writes_depth;
-       int     num_regs;
+       uint32_t fp_control;
 };
 
 struct nv40_depth_push {
index da9e18ac1363966326cf2a01a3056cce56f83ecd..15dc7f2325210642d70ae833d36417014f790dac 100644 (file)
          h = ps->height -y; \
    } while(0)
 
-
-/**
- * Note: this is exactly like a8r8g8b8_get_tile() in sp_surface.c
- * Share it someday.
- */
-static void
-nv40_get_tile_rgba(struct pipe_context *pipe,
-                   struct pipe_surface *ps,
-                   uint x, uint y, uint w, uint h, float *p)
-{
-   const unsigned *src
-      = ((const unsigned *) (ps->map + ps->offset))
-      + y * ps->pitch + x;
-   unsigned i, j;
-   unsigned w0 = w;
-
-   CLIP_TILE;
-
-   switch (ps->format) {
-   case PIPE_FORMAT_A8R8G8B8_UNORM:
-      for (i = 0; i < h; i++) {
-         float *pRow = p;
-         for (j = 0; j < w; j++) {
-            const unsigned pixel = src[j];
-            pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
-            pRow[1] = UBYTE_TO_FLOAT((pixel >>  8) & 0xff);
-            pRow[2] = UBYTE_TO_FLOAT((pixel >>  0) & 0xff);
-            pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
-            pRow += 4;
-         }
-         src += ps->pitch;
-         p += w0 * 4;
-      }
-      break;
-   case PIPE_FORMAT_Z24S8_UNORM:
-      {
-         const float scale = 1.0 / (float) 0xffffff;
-         for (i = 0; i < h; i++) {
-            float *pRow = p;
-            for (j = 0; j < w; j++) {
-               const unsigned pixel = src[j];
-               pRow[0] =
-               pRow[1] =
-               pRow[2] =
-               pRow[3] = ((pixel & 0xffffff) >> 8) * scale;
-               pRow += 4;
-            }
-            src += ps->pitch;
-            p += w0 * 4;
-         }
-      }
-      break;
-   default:
-      assert(0);
-   }
-}
-
-
-static void
-nv40_put_tile_rgba(struct pipe_context *pipe,
-                   struct pipe_surface *ps,
-                   uint x, uint y, uint w, uint h, const float *p)
-{
-   /* TODO */
-   assert(0);
-}
-
-
 /*
  * XXX note: same as code in sp_surface.c
  */