nv30: fixes.
authorStephane Marchesin <marchesin@icps.u-strasbg.fr>
Sat, 16 Feb 2008 01:54:11 +0000 (02:54 +0100)
committerStephane Marchesin <marchesin@icps.u-strasbg.fr>
Sat, 16 Feb 2008 01:54:22 +0000 (02:54 +0100)
src/mesa/pipe/nv30/nv30_context.h
src/mesa/pipe/nv30/nv30_dma.h [deleted file]
src/mesa/pipe/nv30/nv30_fragprog.c
src/mesa/pipe/nv30/nv30_fragtex.c
src/mesa/pipe/nv30/nv30_miptree.c
src/mesa/pipe/nv30/nv30_query.c
src/mesa/pipe/nv30/nv30_state.c
src/mesa/pipe/nv30/nv30_vbo.c
src/mesa/pipe/nv30/nv30_vertprog.c

index d2262c5065f1d7ffa61b891657563a003db16f90..f6c695459913d1d4c3cb6909acaa78c01c65a143 100644 (file)
@@ -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 (file)
index f8bc6ec..0000000
+++ /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
index 0233873d9257af78d998f714e38ab82db7de1714..0db1ac868c7285835d215c0729568df26c2e6bf8 100644 (file)
@@ -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);
                }
index 575f968cc53e906f60ccd2f7390a75f282ca5aa0..45ee6db8d6aed42124f26b271eefee6b1df15885 100644 (file)
@@ -1,6 +1,6 @@
 #include "nv30_context.h"
 
-static inline int log2i(int i)
+static INLINE int log2i(int i)
 {
        int r = 0;
 
index 475f1be8adf89f9721bce2776858b554be04f53c..5fb89f4cfdc0986838d1b79b66f322103e103dcf 100644 (file)
@@ -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);
index ea74c0f5f1f7c96f0a9011d55f94e1d80bc1cb9e..71fdcfa24dfa962c408fb4d852828ac79ef363ea 100644 (file)
@@ -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;
index 992afe033e99291d0fcd3d69c7ce662b7cdf8a83..53368561e07e79b452841debdf463288d426fe32 100644 (file)
@@ -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;
index 173a6e8fd7b5c5ea8316cc566be8d8fb4dceec5d..414cf55ac8d19962b795a0669c226903f00a00e6 100644 (file)
@@ -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);
        }
index 41957b67c4ef6a45639efce41c645a225c10cd20..c96210d3fa73b145918178dabe1adfb867248fc8 100644 (file)
@@ -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;