From: Stephane Marchesin Date: Sat, 16 Feb 2008 01:54:11 +0000 (+0100) Subject: nv30: fixes. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4032ff3889021089debce1c43a0bb984b121cbf6;p=mesa.git nv30: fixes. --- diff --git a/src/mesa/pipe/nv30/nv30_context.h b/src/mesa/pipe/nv30/nv30_context.h index d2262c5065f..f6c69545991 100644 --- a/src/mesa/pipe/nv30/nv30_context.h +++ b/src/mesa/pipe/nv30/nv30_context.h @@ -83,7 +83,7 @@ struct nv30_context { struct pipe_vertex_element vtxelt[PIPE_ATTRIB_MAX]; }; -static inline struct nv30_context * +static INLINE struct nv30_context * nv30_context(struct pipe_context *pipe) { return (struct nv30_context *)pipe; diff --git a/src/mesa/pipe/nv30/nv30_dma.h b/src/mesa/pipe/nv30/nv30_dma.h deleted file mode 100644 index f8bc6eca76a..00000000000 --- a/src/mesa/pipe/nv30/nv30_dma.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __NV30_DMA_H__ -#define __NV30_DMA_H__ - -#include "pipe/nouveau/nouveau_winsys.h" - -#define OUT_RING(data) do { \ - (*nv30->nvws->channel->pushbuf->cur++) = (data); \ -} while(0) - -#define OUT_RINGp(src,size) do { \ - memcpy(nv30->nvws->channel->pushbuf->cur, (src), (size) * 4); \ - nv30->nvws->channel->pushbuf->cur += (size); \ -} while(0) - -#define OUT_RINGf(data) do { \ - union { float v; uint32_t u; } c; \ - c.v = (data); \ - OUT_RING(c.u); \ -} while(0) - -#define BEGIN_RING(obj,mthd,size) do { \ - if (nv30->nvws->channel->pushbuf->remaining < ((size) + 1)) \ - nv30->nvws->push_flush(nv30->nvws->channel, ((size) + 1)); \ - OUT_RING((nv30->obj->subc << 13) | ((size) << 18) | (mthd)); \ - nv30->nvws->channel->pushbuf->remaining -= ((size) + 1); \ -} while(0) - -#define BEGIN_RING_NI(obj,mthd,size) do { \ - BEGIN_RING(obj, (mthd) | 0x40000000, (size)); \ -} while(0) - -#define FIRE_RING() do { \ - nv30->nvws->push_flush(nv30->nvws->channel, 0); \ -} while(0) - -#define OUT_RELOC(bo,data,flags,vor,tor) do { \ - nv30->nvws->push_reloc(nv30->nvws->channel, \ - nv30->nvws->channel->pushbuf->cur++, \ - (struct nouveau_bo *)(bo), \ - (data), (flags), (vor), (tor)); \ -} while(0) - -/* Raw data + flags depending on FB/TT buffer */ -#define OUT_RELOCd(bo,data,flags,vor,tor) do { \ - OUT_RELOC((bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor)); \ -} while(0) - -/* FB/TT object handle */ -#define OUT_RELOCo(bo,flags) do { \ - OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR, \ - nv30->nvws->channel->vram->handle, \ - nv30->nvws->channel->gart->handle); \ -} while(0) - -/* Low 32-bits of offset */ -#define OUT_RELOCl(bo,delta,flags) do { \ - OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0); \ -} while(0) - -/* High 32-bits of offset */ -#define OUT_RELOCh(bo,delta,flags) do { \ - OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0); \ -} while(0) - -#endif diff --git a/src/mesa/pipe/nv30/nv30_fragprog.c b/src/mesa/pipe/nv30/nv30_fragprog.c index 0233873d925..0db1ac868c7 100644 --- a/src/mesa/pipe/nv30/nv30_fragprog.c +++ b/src/mesa/pipe/nv30/nv30_fragprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" #include "pipe/tgsi/util/tgsi_parse.h" @@ -675,7 +676,7 @@ nv30_fragprog_translate(struct nv30_context *nv30, struct tgsi_parse_context parse; struct nv30_fpc *fpc = NULL; - fpc = calloc(1, sizeof(struct nv30_fpc)); + fpc = CALLOC(1, sizeof(struct nv30_fpc)); if (!fpc) return; fpc->fp = fp; @@ -716,7 +717,7 @@ nv30_fragprog_translate(struct nv30_context *nv30, assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32); assert(fpc->nr_imm < MAX_IMM); - for (i = 0; i < imm->Immediate.Size; i++) + for (i = 0; i < 4; i++) vals[i] = imm->u.ImmediateFloat32[i].Float; fpc->imm[fpc->nr_imm++] = constant(fpc, -1, vals); } diff --git a/src/mesa/pipe/nv30/nv30_fragtex.c b/src/mesa/pipe/nv30/nv30_fragtex.c index 575f968cc53..45ee6db8d6a 100644 --- a/src/mesa/pipe/nv30/nv30_fragtex.c +++ b/src/mesa/pipe/nv30/nv30_fragtex.c @@ -1,6 +1,6 @@ #include "nv30_context.h" -static inline int log2i(int i) +static INLINE int log2i(int i) { int r = 0; diff --git a/src/mesa/pipe/nv30/nv30_miptree.c b/src/mesa/pipe/nv30/nv30_miptree.c index 475f1be8adf..5fb89f4cfdc 100644 --- a/src/mesa/pipe/nv30/nv30_miptree.c +++ b/src/mesa/pipe/nv30/nv30_miptree.c @@ -35,7 +35,7 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt) nv30mt->level[l].pitch = (nv30mt->level[l].pitch + 63) & ~63; nv30mt->level[l].image_offset = - calloc(nr_faces, sizeof(unsigned)); + CALLOC(nr_faces, sizeof(unsigned)); width = MAX2(1, width >> 1); height = MAX2(1, height >> 1); diff --git a/src/mesa/pipe/nv30/nv30_query.c b/src/mesa/pipe/nv30/nv30_query.c index ea74c0f5f1f..71fdcfa24df 100644 --- a/src/mesa/pipe/nv30/nv30_query.c +++ b/src/mesa/pipe/nv30/nv30_query.c @@ -1,4 +1,5 @@ #include "pipe/p_context.h" +#include "pipe/p_util.h" #include "nv30_context.h" @@ -20,7 +21,7 @@ nv30_query_create(struct pipe_context *pipe, unsigned query_type) { struct nv30_query *q; - q = calloc(1, sizeof(struct nv30_query)); + q = CALLOC(1, sizeof(struct nv30_query)); q->type = query_type; return (struct pipe_query *)q; diff --git a/src/mesa/pipe/nv30/nv30_state.c b/src/mesa/pipe/nv30/nv30_state.c index 992afe033e9..53368561e07 100644 --- a/src/mesa/pipe/nv30/nv30_state.c +++ b/src/mesa/pipe/nv30/nv30_state.c @@ -420,9 +420,9 @@ nv30_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso) BEGIN_RING(rankine, NV34TCL_DEPTH_FUNC, 3); OUT_RINGp ((uint32_t *)&hw->depth, 3); - BEGIN_RING(rankine, NV34TCL_STENCIL_FRONT_ENABLE, 16); - OUT_RINGp ((uint32_t *)&hw->stencil.front, 8); + BEGIN_RING(rankine, NV34TCL_STENCIL_BACK_ENABLE, 16); OUT_RINGp ((uint32_t *)&hw->stencil.back, 8); + OUT_RINGp ((uint32_t *)&hw->stencil.front, 8); BEGIN_RING(rankine, NV34TCL_ALPHA_FUNC_ENABLE, 3); OUT_RINGp ((uint32_t *)&hw->alpha.enabled, 3); } @@ -439,7 +439,7 @@ nv30_vp_state_create(struct pipe_context *pipe, { struct nv30_vertex_program *vp; - vp = calloc(1, sizeof(struct nv30_vertex_program)); + vp = CALLOC(1, sizeof(struct nv30_vertex_program)); vp->pipe = cso; return (void *)vp; @@ -471,7 +471,7 @@ nv30_fp_state_create(struct pipe_context *pipe, { struct nv30_fragment_program *fp; - fp = calloc(1, sizeof(struct nv30_fragment_program)); + fp = CALLOC(1, sizeof(struct nv30_fragment_program)); fp->pipe = cso; return (void *)fp; diff --git a/src/mesa/pipe/nv30/nv30_vbo.c b/src/mesa/pipe/nv30/nv30_vbo.c index 173a6e8fd7b..414cf55ac8d 100644 --- a/src/mesa/pipe/nv30/nv30_vbo.c +++ b/src/mesa/pipe/nv30/nv30_vbo.c @@ -30,7 +30,8 @@ nv30_vbo_type(uint format) case PIPE_FORMAT_TYPE_UNORM: return NV34TCL_VERTEX_ARRAY_FORMAT_TYPE_UBYTE; default: - assert(0); + NOUVEAU_ERR("Unknown format 0x%08x\n", format); + return NV40TCL_VTXFMT_TYPE_FLOAT; } } @@ -194,8 +195,13 @@ nv30_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, { struct nv30_context *nv30 = nv30_context(pipe); unsigned nr; + boolean ret; - assert(nv30_vbo_validate_state(nv30, NULL, 0)); + ret = nv30_vbo_validate_state(nv30, NULL, 0); + if (!ret) { + NOUVEAU_ERR("state validate failed\n"); + return FALSE; + } BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1); OUT_RING (nvgl_primitive(mode)); @@ -302,13 +308,20 @@ nv30_draw_elements_inline(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); struct pipe_winsys *ws = pipe->winsys; + boolean ret; void *map; - assert(nv30_vbo_validate_state(nv30, NULL, 0)); + ret = nv30_vbo_validate_state(nv30, NULL, 0); + if (!ret) { + NOUVEAU_ERR("state validate failed\n"); + return FALSE; + } map = ws->buffer_map(ws, ib, PIPE_BUFFER_USAGE_CPU_READ); - if (!ib) - assert(0); + if (!ib) { + NOUVEAU_ERR("failed mapping ib\n"); + return FALSE; + } BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1); OUT_RING (nvgl_primitive(mode)); @@ -324,7 +337,7 @@ nv30_draw_elements_inline(struct pipe_context *pipe, nv30_draw_elements_u32(nv30, map, start, count); break; default: - assert(0); + NOUVEAU_ERR("invalid idxbuf fmt %d\n", ib_size); break; } @@ -343,6 +356,7 @@ nv30_draw_elements_vbo(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); unsigned nr, type; + boolean ret; switch (ib_size) { case 2: @@ -352,10 +366,15 @@ nv30_draw_elements_vbo(struct pipe_context *pipe, type = NV40TCL_IDXBUF_FORMAT_TYPE_U32; break; default: - assert(0); + NOUVEAU_ERR("invalid idxbuf fmt %d\n", ib_size); + return FALSE; } - assert(nv30_vbo_validate_state(nv30, ib, type)); + ret = nv30_vbo_validate_state(nv30, ib, type); + if (!ret) { + NOUVEAU_ERR("failed state validation\n"); + return FALSE; + } BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1); OUT_RING (nvgl_primitive(mode)); @@ -391,10 +410,10 @@ nv30_draw_elements(struct pipe_context *pipe, struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count) { - if (indexSize != 1) { +/* if (indexSize != 1) { nv30_draw_elements_vbo(pipe, indexBuffer, indexSize, mode, start, count); - } else { + } else */{ nv30_draw_elements_inline(pipe, indexBuffer, indexSize, mode, start, count); } diff --git a/src/mesa/pipe/nv30/nv30_vertprog.c b/src/mesa/pipe/nv30/nv30_vertprog.c index 41957b67c4e..c96210d3fa7 100644 --- a/src/mesa/pipe/nv30/nv30_vertprog.c +++ b/src/mesa/pipe/nv30/nv30_vertprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" #include "pipe/tgsi/util/tgsi_parse.h" @@ -539,7 +540,7 @@ nv30_vertprog_prepare(struct nv30_vpc *vpc) tgsi_parse_free(&p); if (nr_imm) { - vpc->imm = calloc(nr_imm, sizeof(struct nv30_sreg)); + vpc->imm = CALLOC(nr_imm, sizeof(struct nv30_sreg)); assert(vpc->imm); } @@ -553,7 +554,7 @@ nv30_vertprog_translate(struct nv30_context *nv30, struct tgsi_parse_context parse; struct nv30_vpc *vpc = NULL; - vpc = calloc(1, sizeof(struct nv30_vpc)); + vpc = CALLOC(1, sizeof(struct nv30_vpc)); if (!vpc) return; vpc->vp = vp;