From 4c2a3356cf976e9e30f888bf57f6b140482a1e15 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Sun, 16 Dec 2007 21:26:09 +1100 Subject: nouveau: some cleanups --- .../dri/nouveau_winsys/nouveau_winsys_softpipe.c | 5 +- src/mesa/pipe/nv40/nv40_fragprog.c | 22 +++---- src/mesa/pipe/nv40/nv40_state.h | 4 +- src/mesa/pipe/nv40/nv40_surface.c | 68 ---------------------- 4 files changed, 13 insertions(+), 86 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_softpipe.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_softpipe.c index ebce4ddede1..3908c175088 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_softpipe.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_softpipe.c @@ -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; diff --git a/src/mesa/pipe/nv40/nv40_fragprog.c b/src/mesa/pipe/nv40/nv40_fragprog.c index 8e2689e27d2..9cc1267108d 100644 --- a/src/mesa/pipe/nv40/nv40_fragprog.c +++ b/src/mesa/pipe/nv40/nv40_fragprog.c @@ -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; } diff --git a/src/mesa/pipe/nv40/nv40_state.h b/src/mesa/pipe/nv40/nv40_state.h index cfc8b5637fb..eb8473842f6 100644 --- a/src/mesa/pipe/nv40/nv40_state.h +++ b/src/mesa/pipe/nv40/nv40_state.h @@ -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 { diff --git a/src/mesa/pipe/nv40/nv40_surface.c b/src/mesa/pipe/nv40/nv40_surface.c index da9e18ac136..15dc7f23252 100644 --- a/src/mesa/pipe/nv40/nv40_surface.c +++ b/src/mesa/pipe/nv40/nv40_surface.c @@ -46,74 +46,6 @@ 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 */ -- cgit v1.2.3