From: Ben Skeggs Date: Fri, 15 Feb 2008 15:30:56 +0000 (+1100) Subject: nv40: fix non-debug builds + start on obeying portability guidelines. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e82eabaf5e6cb91984476a991ec24e8105989dc4;p=mesa.git nv40: fix non-debug builds + start on obeying portability guidelines. --- diff --git a/src/mesa/pipe/nouveau/nouveau_stateobj.h b/src/mesa/pipe/nouveau/nouveau_stateobj.h index 58167a24de7..07c31b014a5 100644 --- a/src/mesa/pipe/nouveau/nouveau_stateobj.h +++ b/src/mesa/pipe/nouveau/nouveau_stateobj.h @@ -1,6 +1,8 @@ #ifndef __NOUVEAU_STATEOBJ_H__ #define __NOUVEAU_STATEOBJ_H__ +#include "pipe/p_util.h" + struct nouveau_stateobj_reloc { struct pipe_buffer *bo; @@ -24,15 +26,15 @@ struct nouveau_stateobj { unsigned cur_reloc; }; -static inline struct nouveau_stateobj * +static INLINE struct nouveau_stateobj * so_new(unsigned push, unsigned reloc) { struct nouveau_stateobj *so; - so = malloc(sizeof(struct nouveau_stateobj)); + so = MALLOC(sizeof(struct nouveau_stateobj)); so->refcount = 1; - so->push = malloc(sizeof(unsigned) * push); - so->reloc = malloc(sizeof(struct nouveau_stateobj_reloc) * reloc); + so->push = MALLOC(sizeof(unsigned) * push); + so->reloc = MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc); so->cur = so->push; so->cur_reloc = so->cur_packet = 0; @@ -40,7 +42,7 @@ so_new(unsigned push, unsigned reloc) return so; } -static inline void +static INLINE void so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso) { struct nouveau_stateobj *so; @@ -61,14 +63,14 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso) } } -static inline void +static INLINE void so_data(struct nouveau_stateobj *so, unsigned data) { (*so->cur++) = (data); so->cur_packet += 4; } -static inline void +static INLINE void so_method(struct nouveau_stateobj *so, struct nouveau_grobj *gr, unsigned mthd, unsigned size) { @@ -76,7 +78,7 @@ so_method(struct nouveau_stateobj *so, struct nouveau_grobj *gr, so_data(so, (gr->subc << 13) | (size << 18) | mthd); } -static inline void +static INLINE void so_reloc(struct nouveau_stateobj *so, struct pipe_buffer *bo, unsigned data, unsigned flags, unsigned vor, unsigned tor) { @@ -92,7 +94,7 @@ so_reloc(struct nouveau_stateobj *so, struct pipe_buffer *bo, so_data(so, data); } -static inline void +static INLINE void so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) { struct nouveau_pushbuf *pb = nvws->channel->pushbuf; @@ -113,7 +115,7 @@ so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) pb->cur += nr; } -static inline void +static INLINE void so_emit_reloc_markers(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) { struct nouveau_pushbuf *pb = nvws->channel->pushbuf; diff --git a/src/mesa/pipe/nv40/nv40_context.c b/src/mesa/pipe/nv40/nv40_context.c index a8a2eaf2157..6e86ca00816 100644 --- a/src/mesa/pipe/nv40/nv40_context.c +++ b/src/mesa/pipe/nv40/nv40_context.c @@ -154,7 +154,7 @@ nv40_channel_init(struct pipe_winsys *ws, struct nouveau_winsys *nvws, return NULL; } - cnv40 = calloc(1, sizeof(struct nv40_channel_context)); + cnv40 = CALLOC(1, sizeof(struct nv40_channel_context)); if (!cnv40) return NULL; cnv40->chipset = chipset; @@ -274,7 +274,7 @@ nv40_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws, { struct nv40_context *nv40; - nv40 = calloc(1, sizeof(struct nv40_context)); + nv40 = CALLOC(1, sizeof(struct nv40_context)); if (!nv40) return NULL; diff --git a/src/mesa/pipe/nv40/nv40_context.h b/src/mesa/pipe/nv40/nv40_context.h index d7c9ee7851e..cf2a14405a4 100644 --- a/src/mesa/pipe/nv40/nv40_context.h +++ b/src/mesa/pipe/nv40/nv40_context.h @@ -100,7 +100,7 @@ struct nv40_context { struct pipe_vertex_element vtxelt[PIPE_ATTRIB_MAX]; }; -static inline struct nv40_context * +static INLINE struct nv40_context * nv40_context(struct pipe_context *pipe) { return (struct nv40_context *)pipe; diff --git a/src/mesa/pipe/nv40/nv40_fragprog.c b/src/mesa/pipe/nv40/nv40_fragprog.c index cc637f5dae2..7487fb896f3 100644 --- a/src/mesa/pipe/nv40/nv40_fragprog.c +++ b/src/mesa/pipe/nv40/nv40_fragprog.c @@ -675,7 +675,7 @@ nv40_fragprog_translate(struct nv40_context *nv40, struct tgsi_parse_context parse; struct nv40_fpc *fpc = NULL; - fpc = calloc(1, sizeof(struct nv40_fpc)); + fpc = CALLOC(1, sizeof(struct nv40_fpc)); if (!fpc) return; fpc->fp = fp; diff --git a/src/mesa/pipe/nv40/nv40_miptree.c b/src/mesa/pipe/nv40/nv40_miptree.c index 1b3c27dc45b..92e6b3a43df 100644 --- a/src/mesa/pipe/nv40/nv40_miptree.c +++ b/src/mesa/pipe/nv40/nv40_miptree.c @@ -35,7 +35,7 @@ nv40_miptree_layout(struct nv40_miptree *nv40mt) nv40mt->level[l].pitch = (nv40mt->level[l].pitch + 63) & ~63; nv40mt->level[l].image_offset = - calloc(nr_faces, sizeof(unsigned)); + CALLOC(nr_faces, sizeof(unsigned)); width = MAX2(1, width >> 1); height = MAX2(1, height >> 1); @@ -59,7 +59,7 @@ nv40_miptree_create(struct pipe_context *pipe, const struct pipe_texture *pt) struct pipe_winsys *ws = pipe->winsys; struct nv40_miptree *mt; - mt = malloc(sizeof(struct nv40_miptree)); + mt = MALLOC(sizeof(struct nv40_miptree)); if (!mt) return NULL; mt->base = *pt; diff --git a/src/mesa/pipe/nv40/nv40_query.c b/src/mesa/pipe/nv40/nv40_query.c index eb305e64446..8bca2788b93 100644 --- a/src/mesa/pipe/nv40/nv40_query.c +++ b/src/mesa/pipe/nv40/nv40_query.c @@ -9,7 +9,7 @@ struct nv40_query { uint64_t result; }; -static inline struct nv40_query * +static INLINE struct nv40_query * nv40_query(struct pipe_query *pipe) { return (struct nv40_query *)pipe; @@ -20,7 +20,7 @@ nv40_query_create(struct pipe_context *pipe, unsigned query_type) { struct nv40_query *q; - q = calloc(1, sizeof(struct nv40_query)); + q = CALLOC(1, sizeof(struct nv40_query)); q->type = query_type; return (struct pipe_query *)q; diff --git a/src/mesa/pipe/nv40/nv40_state.c b/src/mesa/pipe/nv40/nv40_state.c index bcd244528d5..713f31dbb12 100644 --- a/src/mesa/pipe/nv40/nv40_state.c +++ b/src/mesa/pipe/nv40/nv40_state.c @@ -112,7 +112,7 @@ nv40_sampler_state_create(struct pipe_context *pipe, struct nv40_sampler_state *ps; uint32_t filter = 0; - ps = malloc(sizeof(struct nv40_sampler_state)); + ps = MALLOC(sizeof(struct nv40_sampler_state)); ps->fmt = 0; if (!cso->normalized_coords) @@ -455,7 +455,7 @@ nv40_vp_state_create(struct pipe_context *pipe, { struct nv40_vertex_program *vp; - vp = calloc(1, sizeof(struct nv40_vertex_program)); + vp = CALLOC(1, sizeof(struct nv40_vertex_program)); vp->pipe = cso; return (void *)vp; @@ -487,7 +487,7 @@ nv40_fp_state_create(struct pipe_context *pipe, { struct nv40_fragment_program *fp; - fp = calloc(1, sizeof(struct nv40_fragment_program)); + fp = CALLOC(1, sizeof(struct nv40_fragment_program)); fp->pipe = cso; return (void *)fp; diff --git a/src/mesa/pipe/nv40/nv40_vbo.c b/src/mesa/pipe/nv40/nv40_vbo.c index 4e9cdb4585a..a18d0f9b251 100644 --- a/src/mesa/pipe/nv40/nv40_vbo.c +++ b/src/mesa/pipe/nv40/nv40_vbo.c @@ -30,7 +30,8 @@ nv40_vbo_type(uint format) case PIPE_FORMAT_TYPE_UNORM: return NV40TCL_VTXFMT_TYPE_UBYTE; default: - assert(0); + NOUVEAU_ERR("Unknown format 0x%08x\n", format); + return NV40TCL_VTXFMT_TYPE_FLOAT; } } @@ -188,8 +189,13 @@ nv40_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, { struct nv40_context *nv40 = nv40_context(pipe); unsigned nr; + boolean ret; - assert(nv40_vbo_validate_state(nv40, NULL, 0)); + ret = nv40_vbo_validate_state(nv40, NULL, 0); + if (!ret) { + NOUVEAU_ERR("state validate failed\n"); + return FALSE; + } BEGIN_RING(curie, NV40TCL_BEGIN_END, 1); OUT_RING (nvgl_primitive(mode)); @@ -290,19 +296,26 @@ nv40_draw_elements_u32(struct nv40_context *nv40, void *ib, } static boolean -nv40_draw_elements_inline(struct pipe_context *pipe, +nv40_draw_elements_INLINE(struct pipe_context *pipe, struct pipe_buffer *ib, unsigned ib_size, unsigned mode, unsigned start, unsigned count) { struct nv40_context *nv40 = nv40_context(pipe); struct pipe_winsys *ws = pipe->winsys; + boolean ret; void *map; - assert(nv40_vbo_validate_state(nv40, NULL, 0)); + ret = nv40_vbo_validate_state(nv40, 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(curie, NV40TCL_BEGIN_END, 1); OUT_RING (nvgl_primitive(mode)); @@ -318,7 +331,7 @@ nv40_draw_elements_inline(struct pipe_context *pipe, nv40_draw_elements_u32(nv40, map, start, count); break; default: - assert(0); + NOUVEAU_ERR("invalid idxbuf fmt %d\n", ib_size); break; } @@ -337,6 +350,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe, { struct nv40_context *nv40 = nv40_context(pipe); unsigned nr, type; + boolean ret; switch (ib_size) { case 2: @@ -346,10 +360,15 @@ nv40_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(nv40_vbo_validate_state(nv40, ib, type)); + ret = nv40_vbo_validate_state(nv40, ib, type); + if (!ret) { + NOUVEAU_ERR("failed state validation\n"); + return FALSE; + } BEGIN_RING(curie, NV40TCL_BEGIN_END, 1); OUT_RING (nvgl_primitive(mode)); @@ -391,7 +410,7 @@ nv40_draw_elements(struct pipe_context *pipe, * to be support on any chipset for 8-bit indices. */ if (nv40->hw->curie->grclass == NV44TCL || indexSize == 1) { - nv40_draw_elements_inline(pipe, indexBuffer, indexSize, + nv40_draw_elements_INLINE(pipe, indexBuffer, indexSize, mode, start, count); } else { nv40_draw_elements_vbo(pipe, indexBuffer, indexSize, diff --git a/src/mesa/pipe/nv40/nv40_vertprog.c b/src/mesa/pipe/nv40/nv40_vertprog.c index 415b3c70c79..d57e3ca350b 100644 --- a/src/mesa/pipe/nv40/nv40_vertprog.c +++ b/src/mesa/pipe/nv40/nv40_vertprog.c @@ -551,7 +551,7 @@ nv40_vertprog_prepare(struct nv40_vpc *vpc) tgsi_parse_free(&p); if (nr_imm) { - vpc->imm = calloc(nr_imm, sizeof(struct nv40_sreg)); + vpc->imm = CALLOC(nr_imm, sizeof(struct nv40_sreg)); assert(vpc->imm); } @@ -565,7 +565,7 @@ nv40_vertprog_translate(struct nv40_context *nv40, struct tgsi_parse_context parse; struct nv40_vpc *vpc = NULL; - vpc = calloc(1, sizeof(struct nv40_vpc)); + vpc = CALLOC(1, sizeof(struct nv40_vpc)); if (!vpc) return; vpc->vp = vp;