#ifndef __NOUVEAU_STATEOBJ_H__
#define __NOUVEAU_STATEOBJ_H__
+#include "pipe/p_util.h"
+
struct nouveau_stateobj_reloc {
struct pipe_buffer *bo;
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;
return so;
}
-static inline void
+static INLINE void
so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso)
{
struct nouveau_stateobj *so;
}
}
-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)
{
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)
{
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;
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;
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;
{
struct nv40_context *nv40;
- nv40 = calloc(1, sizeof(struct nv40_context));
+ nv40 = CALLOC(1, sizeof(struct nv40_context));
if (!nv40)
return NULL;
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;
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;
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);
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;
uint64_t result;
};
-static inline struct nv40_query *
+static INLINE struct nv40_query *
nv40_query(struct pipe_query *pipe)
{
return (struct nv40_query *)pipe;
{
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;
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)
{
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;
{
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;
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;
}
}
{
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));
}
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));
nv40_draw_elements_u32(nv40, map, start, count);
break;
default:
- assert(0);
+ NOUVEAU_ERR("invalid idxbuf fmt %d\n", ib_size);
break;
}
{
struct nv40_context *nv40 = nv40_context(pipe);
unsigned nr, type;
+ boolean ret;
switch (ib_size) {
case 2:
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));
* 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,
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);
}
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;