nv50: remove vtxbuf stateobject after a referenced vtxbuf is mapped
PATCH 1/3 nv50: remove vtxbuf stateobject after a referenced vtxbuf is mapped
- This avoids problematic "reloc'ed while mapped" messages and some associated corruption as well.
--- src/gallium/drivers/nouveau/nouveau_screen.c | 21 +++++++++++++++++++++ src/gallium/drivers/nouveau/nouveau_screen.h | 3 +++ src/gallium/drivers/nouveau/nouveau_stateobj.h | 13 +++++++++++++ src/gallium/drivers/nv50/nv50_screen.c | 23 +++++++++++++++++++++++ src/gallium/drivers/nv50/nv50_screen.h | 2 ++ src/gallium/drivers/nv50/nv50_state_validate.c | 3 +++ 6 files changed, 65 insertions(+), 0 deletions(-)
src/gallium/drivers/nouveau/nouveau_screen.c +21 -0
@@ -127,8 +127,18 @@ nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned usage) {struct nouveau_bo *bo =nouveau_bo (pb); +struct nouveau_screen *nscreen =nouveau_screen (pscreen);int ret; +if (nscreen->pre_pipebuffer_map_callback) { + ret = nscreen->pre_pipebuffer_map_callback (pscreen, pb, usage); +if (ret) { +debug_printf ("pre_pipebuffer_map_callback failed %d\n" , + ret); +return NULL ; + } + } + ret =nouveau_bo_map (bo,nouveau_screen_map_flags (usage));if (ret) {debug_printf ("map failed: %d\n" , ret);
@@ -143,11 +153,22 @@ nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned offset, unsigned length, unsigned usage) { struct nouveau_bo *bo = nouveau_bo(pb); +struct nouveau_screen *nscreen =nouveau_screen (pscreen);uint32_t flags =nouveau_screen_map_flags (usage);int ret; +if (nscreen->pre_pipebuffer_map_callback) { + ret = nscreen->pre_pipebuffer_map_callback (pscreen, pb, usage); +if (ret) { +debug_printf ("pre_pipebuffer_map_callback failed %d\n" , + ret); +return NULL ; + } + } + ret =nouveau_bo_map_range (bo, offset, length, flags);if (ret) { +nouveau_bo_unmap (bo);if (!(flags &NOUVEAU_BO_NOWAIT ) || ret != -EBUSY )debug_printf ("map_range failed: %d\n" , ret);return NULL ;
src/gallium/drivers/nouveau/nouveau_screen.h +3 -0
@@ -5,6 +5,9 @@ struct nouveau_screen {struct pipe_screen base;struct nouveau_device *device;struct nouveau_channel *channel; + +int (*pre_pipebuffer_map_callback) (struct pipe_screen *pscreen, +struct pipe_buffer *pb,unsigned usage); }; static inline struct nouveau_screen *
src/gallium/drivers/nouveau/nouveau_stateobj.h +13 -0
@@ -98,6 +98,19 @@ so_reloc(struct nouveau_stateobj *so, struct nouveau_bo *bo,so_data (so, data); } +/* Determine if this buffer object is referenced by this state object. */ +static INLINE bool +so_bo_is_reloc (struct nouveau_stateobj *so,struct nouveau_bo *bo) +{ +int i; + +for (i =0 ; i < so->cur_reloc; i++) +if (so->reloc[i].bo == bo) +return true; + +return false; +} + static INLINE voidso_dump (struct nouveau_stateobj *so) {
src/gallium/drivers/nv50/nv50_screen.c +23 -0
@@ -189,6 +189,28 @@ nv50_screen_destroy(struct pipe_screen *pscreen)FREE (screen); } +static int +nv50_pre_pipebuffer_map (struct pipe_screen *pscreen,struct pipe_buffer *pb, +unsigned usage) +{ +struct nv50_screen *screen =nv50_screen (pscreen); +struct nv50_context *ctx = screen->cur_ctx; + +if (!(pb->usage &PIPE_BUFFER_USAGE_VERTEX )) +return 0 ; + +/* Our vtxbuf got mapped, it can no longer be considered part of current +* state, remove it to avoid emitting reloc markers. +*/ +if (ctx && ctx->state.vtxbuf &&so_bo_is_reloc (ctx->state.vtxbuf, +nouveau_bo (pb))) { +so_ref (NULL , &ctx->state.vtxbuf); + ctx->dirty |=NV50_NEW_ARRAYS ; + } + +return 0 ; +} +struct pipe_screen *nv50_screen_create (struct pipe_winsys *ws,struct nouveau_device *dev) {
@@ -216,6 +238,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) pscreen->get_param = nv50_screen_get_param; pscreen->get_paramf = nv50_screen_get_paramf; pscreen->is_format_supported = nv50_screen_is_format_supported; + screen->base.pre_pipebuffer_map_callback = nv50_pre_pipebuffer_map;nv50_screen_init_miptree_functions (pscreen);nv50_transfer_init_screen_functions (pscreen);
src/gallium/drivers/nv50/nv50_screen.h +2 -0
@@ -2,6 +2,7 @@#define __NV50_SCREEN_H__#include "nouveau/nouveau_screen.h" +#include "nv50_context.h" struct nv50_screen {struct nouveau_screen base;
@@ -9,6 +10,7 @@ struct nv50_screen {struct nouveau_winsys *nvws;unsigned cur_pctx; +struct nv50_context *cur_ctx;struct nouveau_grobj *tesla;struct nouveau_grobj *eng2d;
src/gallium/drivers/nv50/nv50_state_validate.c +3 -0
@@ -185,6 +185,9 @@ nv50_state_emit(struct nv50_context *nv50)struct nv50_screen *screen = nv50->screen;struct nouveau_channel *chan = screen->base.channel; +/* I don't want to copy headers from the winsys. */ + screen->cur_ctx = nv50; +if (nv50->pctx_id != screen->cur_pctx) {if (nv50->state.fb) nv50->state.dirty |=NV50_NEW_FRAMEBUFFER ;
Signature · 1 line
1.6.6.rc4
A message that is not in the archive (sent off-list or not yet received): 1262209002-10778-1-git-send-email-madman2003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 2/3 nouveau: kill nouveau_push.h and use libdrm versions of BEGIN_RINGs, etc
From: Marcin Slusarz <[email protected]>
--- src/gallium/drivers/nouveau/nouveau_push.h | 93 ----- src/gallium/drivers/nv04/nv04_context.c | 44 ++- src/gallium/drivers/nv04/nv04_context.h | 4 - src/gallium/drivers/nv04/nv04_prim_vbuf.c | 84 +++-- src/gallium/drivers/nv04/nv04_state_emit.c | 72 +++-- src/gallium/drivers/nv10/nv10_context.c | 367 ++++++++++---------- src/gallium/drivers/nv10/nv10_context.h | 4 - src/gallium/drivers/nv10/nv10_fragtex.c | 28 +- src/gallium/drivers/nv10/nv10_prim_vbuf.c | 34 +- src/gallium/drivers/nv10/nv10_state_emit.c | 166 +++++---- src/gallium/drivers/nv20/nv20_context.c | 530 ++++++++++++++-------------- src/gallium/drivers/nv20/nv20_context.h | 4 - src/gallium/drivers/nv20/nv20_fragtex.c | 28 +- src/gallium/drivers/nv20/nv20_prim_vbuf.c | 56 ++-- src/gallium/drivers/nv20/nv20_state_emit.c | 181 ++++++---- src/gallium/drivers/nv30/nv30_context.c | 15 +- src/gallium/drivers/nv30/nv30_context.h | 4 - src/gallium/drivers/nv30/nv30_query.c | 20 +- src/gallium/drivers/nv30/nv30_vbo.c | 106 +++--- src/gallium/drivers/nv30/nv30_vertprog.c | 18 +- src/gallium/drivers/nv40/nv40_context.c | 15 +- src/gallium/drivers/nv40/nv40_context.h | 4 - src/gallium/drivers/nv40/nv40_draw.c | 62 ++-- src/gallium/drivers/nv40/nv40_query.c | 20 +- src/gallium/drivers/nv40/nv40_state_emit.c | 11 +- src/gallium/drivers/nv40/nv40_vbo.c | 106 +++--- src/gallium/drivers/nv40/nv40_vertprog.c | 18 +- 27 files changed, 1089 insertions(+), 1005 deletions(-) delete mode 100644 src/gallium/drivers/nouveau/nouveau_push.h
src/gallium/drivers/nouveau/nouveau_push.h deleted +0 -93
@@ -1,93 +0,0 @@ -#ifndef __NOUVEAU_PUSH_H__ -#define __NOUVEAU_PUSH_H__ - -#include "nouveau/nouveau_winsys.h" - -#ifndef NOUVEAU_PUSH_CONTEXT -#error undefined push context -#endif - -#define OUT_RING (data) do { \ - NOUVEAU_PUSH_CONTEXT(pc); \ - (*pc->base.channel->pushbuf->cur++) = (data); \ -} while(0) - -#define OUT_RINGp (src,size) do { \ - NOUVEAU_PUSH_CONTEXT(pc); \ - memcpy(pc->base.channel->pushbuf->cur, (src), (size) * 4); \ - pc->base.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 { \ - NOUVEAU_PUSH_CONTEXT(pc); \ - struct nouveau_channel *chan = pc->base.channel; \ - if (chan->pushbuf->remaining < ((size) + 1)) \ - nouveau_pushbuf_flush(chan, ((size) + 1)); \ - OUT_RING((pc->obj->subc << 13) | ((size) << 18) | (mthd)); \ - chan->pushbuf->remaining -= ((size) + 1); \ -} while(0) - -#define BEGIN_RING_NI (obj,mthd,size) do { \ - BEGIN_RING(obj, (mthd) | 0x40000000, (size)); \ -} while(0) - -static inline void -DO_FIRE_RING (struct nouveau_channel *chan,struct pipe_fence_handle **fence) -{ -nouveau_pushbuf_flush (chan,0 ); -if (fence) - *fence =NULL ; -} - -#define FIRE_RING (fence) do { \ - NOUVEAU_PUSH_CONTEXT(pc); \ - DO_FIRE_RING(pc->base.channel, fence); \ -} while(0) - -#define OUT_RELOC (bo,data,flags,vor,tor) do { \ - NOUVEAU_PUSH_CONTEXT(pc); \ - struct nouveau_channel *chan = pc->base.channel; \ - nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, nouveau_bo(bo), \ - (data), 0, (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, \ - pc->base.channel->vram->handle, \ - pc->base.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) - -/* A reloc which'll recombine into a NV_DMA_METHOD packet header */ -#define OUT_RELOCm (bo, flags, obj, mthd, size) do { \ - NOUVEAU_PUSH_CONTEXT(pc); \ - struct nouveau_channel *chan = pc->base.channel; \ - if (chan->pushbuf->remaining < ((size) + 1)) \ - nouveau_pushbuf_flush(chan, ((size) + 1)); \ - OUT_RELOCd((bo), (pc->obj->subc << 13) | ((size) << 18) | (mthd), \ - (flags), 0, 0); \ - chan->pushbuf->remaining -= ((size) + 1); \ -} while(0) - -#endif
src/gallium/drivers/nv04/nv04_context.c +26 -18
68 lines not on this page · raw message
src/gallium/drivers/nv04/nv04_context.h +0 -4
@@ -15,10 +15,6 @@#include "nouveau/nouveau_gldefs.h" #include "nouveau/nouveau_context.h" -#define NOUVEAU_PUSH_CONTEXT (ctx) \ - struct nv04_screen *ctx = nv04->screen -#include "nouveau/nouveau_push.h" -#include "nv04_state.h" #define NOUVEAU_ERR(fmt, args...) \
src/gallium/drivers/nv04/nv04_prim_vbuf.c +51 -33
133 lines not on this page · raw message
src/gallium/drivers/nv04/nv04_state_emit.c +46 -26
137 lines not on this page · raw message
src/gallium/drivers/nv10/nv10_context.c +186 -181
421 lines not on this page · raw message
src/gallium/drivers/nv10/nv10_context.h +0 -4
@@ -15,10 +15,6 @@#include "nouveau/nouveau_gldefs.h" #include "nouveau/nouveau_context.h" -#define NOUVEAU_PUSH_CONTEXT (ctx) \ - struct nv10_screen *ctx = nv10->screen -#include "nouveau/nouveau_push.h" -#include "nv10_state.h" #define NOUVEAU_ERR(fmt, args...) \
src/gallium/drivers/nv10/nv10_fragtex.c +17 -11
@@ -52,6 +52,9 @@ nv10_fragtex_build(struct nv10_context *nv10, int unit)struct nv10_miptree *nv10mt = nv10->tex_miptree[unit];struct pipe_texture *pt = &nv10mt->base;struct nv10_texture_format *tf; +struct nv10_screen *screen = nv10->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *celsius = screen->celsius;uint32_t txf, txs, txp; tf =nv10_fragtex_format (pt->format);
@@ -82,15 +85,15 @@ nv10_fragtex_build(struct nv10_context *nv10, int unit) return; } -BEGIN_RING (celsius,NV10TCL_TX_OFFSET (unit),8 ); -OUT_RELOCl (nv10mt->buffer,0 ,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD ); -OUT_RELOCd (nv10mt->buffer,txf,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_OR |NOUVEAU_BO_RD ,1 /*VRAM*/ ,2 /*TT*/ ); -OUT_RING (ps->wrap); -OUT_RING (0x40000000 );/* enable */ -OUT_RING (txs); -OUT_RING (ps->filt |0x2000 /* magic */ ); -OUT_RING ((pt->width0 <<16 ) | pt->height0); -OUT_RING (ps->bcol); +BEGIN_RING (chan, celsius,NV10TCL_TX_OFFSET (unit),8 ); +OUT_RELOCl (chan,nouveau_bo (nv10mt->buffer),0 ,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD ); +OUT_RELOCd (chan,nouveau_bo (nv10mt->buffer),txf,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_OR |NOUVEAU_BO_RD ,1 /*VRAM*/ ,2 /*TT*/ ); +OUT_RING (chan, ps->wrap); +OUT_RING (chan,0x40000000 );/* enable */ +OUT_RING (chan, txs); +OUT_RING (chan, ps->filt |0x2000 /* magic */ ); +OUT_RING (chan, (pt->width0 <<16 ) | pt->height0); +OUT_RING (chan, ps->bcol);#endif }
@@ -99,6 +102,9 @@ nv10_fragtex_bind(struct nv10_context *nv10) {#if 0 struct nv10_fragment_program *fp = nv10->fragprog.active; +struct nv10_screen *screen = nv10->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *celsius = screen->celsius;unsigned samplers, unit; samplers = nv10->fp_samplers & ~fp->samplers;
@@ -106,8 +112,8 @@ nv10_fragtex_bind(struct nv10_context *nv10) unit =ffs (samplers) -1 ; samplers &= ~(1 << unit); -BEGIN_RING (celsius,NV10TCL_TX_ENABLE (unit),1 ); -OUT_RING (0 ); +BEGIN_RING (chan, celsius,NV10TCL_TX_ENABLE (unit),1 ); +OUT_RING (chan,0 ); } samplers = nv10->dirty_samplers & fp->samplers;
src/gallium/drivers/nv10/nv10_prim_vbuf.c +20 -14
@@ -67,12 +67,15 @@ struct nv10_vbuf_render {void nv10_vtxbuf_bind (struct nv10_context * nv10 ) { +struct nv10_screen *screen = nv10->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *celsius = screen->celsius;int i;for (i =0 ; i <8 ; i++) { -BEGIN_RING (celsius,NV10TCL_VTXBUF_ADDRESS (i),1 ); -OUT_RING (0 /*nv10->vtxbuf*/ ); -BEGIN_RING (celsius,NV10TCL_VTXFMT (i),1 ); -OUT_RING (0 /*XXX*/ ); +BEGIN_RING (chan, celsius,NV10TCL_VTXBUF_ADDRESS (i),1 ); +OUT_RING (chan,0 /*nv10->vtxbuf*/ ); +BEGIN_RING (chan, celsius,NV10TCL_VTXFMT (i),1 ); +OUT_RING (chan,0 /*XXX*/ ); } }
@@ -163,19 +166,22 @@ nv10_vbuf_render_draw( struct vbuf_render *render, {struct nv10_vbuf_render *nv10_render =nv10_vbuf_render (render);struct nv10_context *nv10 = nv10_render->nv10; +struct nv10_screen *screen = nv10->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *celsius = screen->celsius;int push, i;nv10_emit_hw_state (nv10); -BEGIN_RING (celsius,NV10TCL_VERTEX_ARRAY_OFFSET_POS ,1 ); -OUT_RELOCl (nv10_render->buffer,0 ,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD ); +BEGIN_RING (chan, celsius,NV10TCL_VERTEX_ARRAY_OFFSET_POS ,1 ); +OUT_RELOCl (chan,nouveau_bo (nv10_render->buffer),0 ,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD ); -BEGIN_RING (celsius,NV10TCL_VERTEX_BUFFER_BEGIN_END ,1 ); -OUT_RING (nv10_render->hwprim); +BEGIN_RING (chan, celsius,NV10TCL_VERTEX_BUFFER_BEGIN_END ,1 ); +OUT_RING (chan, nv10_render->hwprim);if (nr_indices &1 ) { -BEGIN_RING (celsius,NV10TCL_VB_ELEMENT_U32 ,1 ); -OUT_RING (indices[0 ]); +BEGIN_RING (chan, celsius,NV10TCL_VB_ELEMENT_U32 ,1 ); +OUT_RING (chan, indices[0 ]); indices++; nr_indices--; }
@@ -183,16 +189,16 @@ nv10_vbuf_render_draw( struct vbuf_render *render,// XXX too big/small ? check the size push =MIN2 (nr_indices,1200 *2 ); -BEGIN_RING_NI (celsius,NV10TCL_VB_ELEMENT_U16 , push >>1 ); +BEGIN_RING_NI (chan, celsius,NV10TCL_VB_ELEMENT_U16 , push >>1 );for (i =0 ; i < push; i+=2 ) -OUT_RING ((indices[i+1 ] <<16 ) | indices[i]); +OUT_RING (chan, (indices[i+1 ] <<16 ) | indices[i]); nr_indices -= push; indices += push; } -BEGIN_RING (celsius,NV10TCL_VERTEX_BUFFER_BEGIN_END ,1 ); -OUT_RING (0 ); +BEGIN_RING (chan, celsius,NV10TCL_VERTEX_BUFFER_BEGIN_END ,1 ); +OUT_RING (chan,0 ); }
src/gallium/drivers/nv10/nv10_state_emit.c +95 -71
254 lines not on this page · raw message
src/gallium/drivers/nv20/nv20_context.c +269 -261
627 lines not on this page · raw message
src/gallium/drivers/nv20/nv20_context.h +0 -4
@@ -15,10 +15,6 @@#include "nouveau/nouveau_gldefs.h" #include "nouveau/nouveau_context.h" -#define NOUVEAU_PUSH_CONTEXT (ctx) \ - struct nv20_screen *ctx = nv20->screen -#include "nouveau/nouveau_push.h" -#include "nv20_state.h" #define NOUVEAU_ERR(fmt, args...) \
src/gallium/drivers/nv20/nv20_fragtex.c +17 -11
@@ -52,6 +52,9 @@ nv20_fragtex_build(struct nv20_context *nv20, int unit)struct nv20_miptree *nv20mt = nv20->tex_miptree[unit];struct pipe_texture *pt = &nv20mt->base;struct nv20_texture_format *tf; +struct nv20_screen *screen = nv20->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *kelvin = screen->kelvin;uint32_t txf, txs, txp; tf =nv20_fragtex_format (pt->format);
@@ -82,15 +85,15 @@ nv20_fragtex_build(struct nv20_context *nv20, int unit) return; } -BEGIN_RING (kelvin,NV10TCL_TX_OFFSET (unit),8 ); -OUT_RELOCl (nv20mt->buffer,0 ,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD ); -OUT_RELOCd (nv20mt->buffer,txf,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_OR |NOUVEAU_BO_RD ,1 /*VRAM*/ ,2 /*TT*/ ); -OUT_RING (ps->wrap); -OUT_RING (0x40000000 );/* enable */ -OUT_RING (txs); -OUT_RING (ps->filt |0x2000 /* magic */ ); -OUT_RING ((pt->width0 <<16 ) | pt->height0); -OUT_RING (ps->bcol); +BEGIN_RING (chan, kelvin,NV10TCL_TX_OFFSET (unit),8 ); +OUT_RELOCl (chan,nouveau_bo (nv20mt->buffer),0 ,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD ); +OUT_RELOCd (chan,nouveau_bo (nv20mt->buffer),txf,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_OR |NOUVEAU_BO_RD ,1 /*VRAM*/ ,2 /*TT*/ ); +OUT_RING (chan, ps->wrap); +OUT_RING (chan,0x40000000 );/* enable */ +OUT_RING (chan, txs); +OUT_RING (chan, ps->filt |0x2000 /* magic */ ); +OUT_RING (chan, (pt->width0 <<16 ) | pt->height0); +OUT_RING (chan, ps->bcol);#endif }
@@ -99,6 +102,9 @@ nv20_fragtex_bind(struct nv20_context *nv20) {#if 0 struct nv20_fragment_program *fp = nv20->fragprog.active; +struct nv20_screen *screen = nv20->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *kelvin = screen->kelvin;unsigned samplers, unit; samplers = nv20->fp_samplers & ~fp->samplers;
@@ -106,8 +112,8 @@ nv20_fragtex_bind(struct nv20_context *nv20) unit =ffs (samplers) -1 ; samplers &= ~(1 << unit); -BEGIN_RING (kelvin,NV10TCL_TX_ENABLE (unit),1 ); -OUT_RING (0 ); +BEGIN_RING (chan, kelvin,NV10TCL_TX_ENABLE (unit),1 ); +OUT_RING (chan,0 ); } samplers = nv20->dirty_samplers & fp->samplers;
src/gallium/drivers/nv20/nv20_prim_vbuf.c +34 -22
131 lines not on this page · raw message
src/gallium/drivers/nv20/nv20_state_emit.c +104 -77
275 lines not on this page · raw message
src/gallium/drivers/nv30/nv30_context.c +10 -5
@@ -10,15 +10,20 @@ nv30_flush(struct pipe_context *pipe, unsigned flags, struct pipe_fence_handle **fence) {struct nv30_context *nv30 =nv30_context (pipe); +struct nv30_screen *screen = nv30->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *rankine = screen->rankine;if (flags &PIPE_FLUSH_TEXTURE_CACHE ) { -BEGIN_RING (rankine,0x1fd8 ,1 ); -OUT_RING (2 ); -BEGIN_RING (rankine,0x1fd8 ,1 ); -OUT_RING (1 ); +BEGIN_RING (chan, rankine,0x1fd8 ,1 ); +OUT_RING (chan,2 ); +BEGIN_RING (chan, rankine,0x1fd8 ,1 ); +OUT_RING (chan,1 ); } -FIRE_RING (fence); +FIRE_RING (chan); +if (fence) + *fence =NULL ; } static void
src/gallium/drivers/nv30/nv30_context.h +0 -4
@@ -14,10 +14,6 @@#include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_gldefs.h" #include "nouveau/nouveau_context.h" - -#define NOUVEAU_PUSH_CONTEXT (ctx) \ - struct nv30_screen *ctx = nv30->screen -#include "nouveau/nouveau_push.h" #include "nouveau/nouveau_stateobj.h" #include "nv30_state.h"
src/gallium/drivers/nv30/nv30_query.c +13 -7
@@ -41,6 +41,9 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq) {struct nv30_context *nv30 =nv30_context (pipe);struct nv30_query *q =nv30_query (pq); +struct nv30_screen *screen = nv30->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *rankine = screen->rankine;assert (q->type ==PIPE_QUERY_OCCLUSION_COUNTER );
@@ -57,10 +60,10 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)assert (0 );nouveau_notifier_reset (nv30->screen->query, q->object->start); -BEGIN_RING (rankine,NV34TCL_QUERY_RESET ,1 ); -OUT_RING (1 ); -BEGIN_RING (rankine,NV34TCL_QUERY_UNK17CC ,1 ); -OUT_RING (1 ); +BEGIN_RING (chan, rankine,NV34TCL_QUERY_RESET ,1 ); +OUT_RING (chan,1 ); +BEGIN_RING (chan, rankine,NV34TCL_QUERY_UNK17CC ,1 ); +OUT_RING (chan,1 ); q->ready = FALSE; }
@@ -69,12 +72,15 @@ static void nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq) { struct nv30_context *nv30 = nv30_context(pipe); +struct nv30_screen *screen = nv30->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *rankine = screen->rankine;struct nv30_query *q =nv30_query (pq); -BEGIN_RING (rankine,NV34TCL_QUERY_GET ,1 ); -OUT_RING ((0x01 <<NV34TCL_QUERY_GET_UNK24_SHIFT ) | +BEGIN_RING (chan, rankine,NV34TCL_QUERY_GET ,1 ); +OUT_RING (chan, (0x01 <<NV34TCL_QUERY_GET_UNK24_SHIFT ) | ((q->object->start *32 ) <<NV34TCL_QUERY_GET_OFFSET_SHIFT )); -FIRE_RING (NULL ); +FIRE_RING (chan); } static boolean
src/gallium/drivers/nv30/nv30_vbo.c +58 -48
249 lines not on this page · raw message
src/gallium/drivers/nv30/nv30_vertprog.c +10 -8
@@ -650,7 +650,9 @@ static boolean nv30_vertprog_validate(struct nv30_context *nv30) {struct pipe_screen *pscreen = nv30->pipe.screen; -struct nouveau_grobj *rankine = nv30->screen->rankine; +struct nv30_screen *screen = nv30->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *rankine = screen->rankine;struct nv30_vertex_program *vp;struct pipe_buffer *constbuf;boolean upload_code = FALSE, upload_data = FALSE;
@@ -770,9 +772,9 @@ nv30_vertprog_validate(struct nv30_context *nv30) 4 * sizeof(float)); } -BEGIN_RING (rankine,NV34TCL_VP_UPLOAD_CONST_ID ,5 ); -OUT_RING (i + vp->data->start); -OUT_RINGp ((uint32_t *)vpd->value,4 ); +BEGIN_RING (chan, rankine,NV34TCL_VP_UPLOAD_CONST_ID ,5 ); +OUT_RING (chan, i + vp->data->start); +OUT_RINGp (chan, (uint32_t *)vpd->value,4 ); }if (constbuf)
@@ -788,11 +790,11 @@ nv30_vertprog_validate(struct nv30_context *nv30) vp->insns[i].data[2], vp->insns[i].data[3]); }#endif -BEGIN_RING (rankine,NV34TCL_VP_UPLOAD_FROM_ID ,1 ); -OUT_RING (vp->exec->start); +BEGIN_RING (chan, rankine,NV34TCL_VP_UPLOAD_FROM_ID ,1 ); +OUT_RING (chan, vp->exec->start);for (i =0 ; i < vp->nr_insns; i++) { -BEGIN_RING (rankine,NV34TCL_VP_UPLOAD_INST (0 ),4 ); -OUT_RINGp (vp->insns[i].data,4 ); +BEGIN_RING (chan, rankine,NV34TCL_VP_UPLOAD_INST (0 ),4 ); +OUT_RINGp (chan, vp->insns[i].data,4 ); } }
src/gallium/drivers/nv40/nv40_context.c +10 -5
@@ -10,15 +10,20 @@ nv40_flush(struct pipe_context *pipe, unsigned flags, struct pipe_fence_handle **fence) {struct nv40_context *nv40 =nv40_context (pipe); +struct nv40_screen *screen = nv40->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *curie = screen->curie;if (flags &PIPE_FLUSH_TEXTURE_CACHE ) { -BEGIN_RING (curie,0x1fd8 ,1 ); -OUT_RING (2 ); -BEGIN_RING (curie,0x1fd8 ,1 ); -OUT_RING (1 ); +BEGIN_RING (chan, curie,0x1fd8 ,1 ); +OUT_RING (chan,2 ); +BEGIN_RING (chan, curie,0x1fd8 ,1 ); +OUT_RING (chan,1 ); } -FIRE_RING (fence); +FIRE_RING (chan); +if (fence) + *fence =NULL ; } static void
src/gallium/drivers/nv40/nv40_context.h +0 -4
@@ -14,10 +14,6 @@#include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_gldefs.h" #include "nouveau/nouveau_context.h" - -#define NOUVEAU_PUSH_CONTEXT (ctx) \ - struct nv40_screen *ctx = nv40->screen -#include "nouveau/nouveau_push.h" #include "nouveau/nouveau_stateobj.h" #include "nv40_state.h"
src/gallium/drivers/nv40/nv40_draw.c +36 -26
116 lines not on this page · raw message
src/gallium/drivers/nv40/nv40_query.c +13 -7
@@ -41,6 +41,9 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq) {struct nv40_context *nv40 =nv40_context (pipe);struct nv40_query *q =nv40_query (pq); +struct nv40_screen *screen = nv40->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *curie = screen->curie;assert (q->type ==PIPE_QUERY_OCCLUSION_COUNTER );
@@ -57,10 +60,10 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)assert (0 );nouveau_notifier_reset (nv40->screen->query, q->object->start); -BEGIN_RING (curie,NV40TCL_QUERY_RESET ,1 ); -OUT_RING (1 ); -BEGIN_RING (curie,NV40TCL_QUERY_UNK17CC ,1 ); -OUT_RING (1 ); +BEGIN_RING (chan, curie,NV40TCL_QUERY_RESET ,1 ); +OUT_RING (chan,1 ); +BEGIN_RING (chan, curie,NV40TCL_QUERY_UNK17CC ,1 ); +OUT_RING (chan,1 ); q->ready = FALSE; }
@@ -70,11 +73,14 @@ nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq) {struct nv40_context *nv40 =nv40_context (pipe);struct nv40_query *q =nv40_query (pq); +struct nv40_screen *screen = nv40->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *curie = screen->curie; -BEGIN_RING (curie,NV40TCL_QUERY_GET ,1 ); -OUT_RING ((0x01 <<NV40TCL_QUERY_GET_UNK24_SHIFT ) | +BEGIN_RING (chan, curie,NV40TCL_QUERY_GET ,1 ); +OUT_RING (chan, (0x01 <<NV40TCL_QUERY_GET_UNK24_SHIFT ) | ((q->object->start *32 ) <<NV40TCL_QUERY_GET_OFFSET_SHIFT )); -FIRE_RING (NULL ); +FIRE_RING (chan); } static boolean
src/gallium/drivers/nv40/nv40_state_emit.c +6 -5
@@ -54,9 +54,10 @@ nv40_state_do_validate(struct nv40_context *nv40,void nv40_state_emit (struct nv40_context *nv40) { -struct nouveau_channel *chan = nv40->screen->base.channel;struct nv40_state *state = &nv40->state;struct nv40_screen *screen = nv40->screen; +struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *curie = screen->curie;unsigned i;uint64_t states;
@@ -80,10 +81,10 @@ nv40_state_emit(struct nv40_context *nv40)if (state->dirty & ((1ULL <<NV40_STATE_FRAGPROG ) | (1ULL <<NV40_STATE_FRAGTEX0 ))) { -BEGIN_RING (curie,NV40TCL_TEX_CACHE_CTL ,1 ); -OUT_RING (2 ); -BEGIN_RING (curie,NV40TCL_TEX_CACHE_CTL ,1 ); -OUT_RING (1 ); +BEGIN_RING (chan, curie,NV40TCL_TEX_CACHE_CTL ,1 ); +OUT_RING (chan,2 ); +BEGIN_RING (chan, curie,NV40TCL_TEX_CACHE_CTL ,1 ); +OUT_RING (chan,1 ); } state->dirty =0 ;
src/gallium/drivers/nv40/nv40_vbo.c +58 -48
82 lines not on this page · raw message
src/gallium/drivers/nv40/nv40_vertprog.c +10 -8
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.6.rc4
Part of the diff is not shown here. View the raw message.
A message that is not in the archive (sent off-list or not yet received): 1262209002-10778-2-git-send-email-madman2003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 3/3 nouveau: rewrite nouveau_stateobj to use BEGIN_RING properly
- The previous solution was hacky and didn't do subchannel autobinding.
- The beheaviour should match what libdrm_nouveau does closely.
- There appears to be a minor performance loss, probably due to having multiple memcpy's instead of one.
- The solution remains statically sized, but when debugging is on it will check for abuse.
- The values for nv30/nv40 may be off, but this should be easily caught with DEBUG on.
--- src/gallium/drivers/nouveau/nouveau_stateobj.h | 289 +++++++++++++++++------- src/gallium/drivers/nv04/nv04_screen.c | 2 - src/gallium/drivers/nv10/nv10_screen.c | 1 - src/gallium/drivers/nv20/nv20_screen.c | 1 - src/gallium/drivers/nv30/nv30_fragprog.c | 2 +- src/gallium/drivers/nv30/nv30_fragtex.c | 4 +- src/gallium/drivers/nv30/nv30_screen.c | 3 +- src/gallium/drivers/nv30/nv30_state.c | 6 +- src/gallium/drivers/nv30/nv30_state_blend.c | 2 +- src/gallium/drivers/nv30/nv30_state_fb.c | 2 +- src/gallium/drivers/nv30/nv30_state_scissor.c | 2 +- src/gallium/drivers/nv30/nv30_state_stipple.c | 4 +- src/gallium/drivers/nv30/nv30_state_viewport.c | 2 +- src/gallium/drivers/nv30/nv30_vbo.c | 6 +- src/gallium/drivers/nv30/nv30_vertprog.c | 2 +- src/gallium/drivers/nv40/nv40_fragprog.c | 2 +- src/gallium/drivers/nv40/nv40_fragtex.c | 4 +- src/gallium/drivers/nv40/nv40_screen.c | 3 +- src/gallium/drivers/nv40/nv40_state.c | 6 +- src/gallium/drivers/nv40/nv40_state_blend.c | 2 +- src/gallium/drivers/nv40/nv40_state_fb.c | 2 +- src/gallium/drivers/nv40/nv40_state_scissor.c | 2 +- src/gallium/drivers/nv40/nv40_state_stipple.c | 4 +- src/gallium/drivers/nv40/nv40_state_viewport.c | 2 +- src/gallium/drivers/nv40/nv40_vbo.c | 6 +- src/gallium/drivers/nv40/nv40_vertprog.c | 2 +- src/gallium/drivers/nv50/nv50_program.c | 6 +- src/gallium/drivers/nv50/nv50_screen.c | 9 +- src/gallium/drivers/nv50/nv50_state.c | 6 +- src/gallium/drivers/nv50/nv50_state_validate.c | 13 +- src/gallium/drivers/nv50/nv50_tex.c | 10 +- src/gallium/drivers/nv50/nv50_vbo.c | 6 +- 32 files changed, 266 insertions(+), 147 deletions(-)
src/gallium/drivers/nouveau/nouveau_stateobj.h +207 -82
@@ -3,41 +3,96 @@#include "util/u_debug.h" +#ifdef DEBUG +#define DEBUG_NOUVEAU_STATEOBJ +#endif /* DEBUG */ +struct nouveau_stateobj_reloc {struct nouveau_bo *bo; -unsigned offset; -unsigned packet; +struct nouveau_grobj *gr; +uint32_t push_offset; +uint32_t mthd; -unsigned data; +uint32_t data;unsigned flags;unsigned vor;unsigned tor; }; +struct nouveau_stateobj_start { +struct nouveau_grobj *gr; +uint32_t mthd; +uint32_t size; +unsigned offset; +}; +struct nouveau_stateobj {struct pipe_reference reference; -unsigned *push; +struct nouveau_stateobj_start *start;struct nouveau_stateobj_reloc *reloc; -unsigned *cur; -unsigned cur_packet; +/* Common memory pool for data. */ +uint32_t *pool; +unsigned pool_cur; + +#ifdef DEBUG_NOUVEAU_STATEOBJ +unsigned start_alloc; +unsigned reloc_alloc; +unsigned pool_alloc; +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + +unsigned total;/* includes begin_ring */ +unsigned cur;/* excludes begin_ring, offset from "cur_start" */ +unsigned cur_start;unsigned cur_reloc; }; +static INLINE void +so_dump (struct nouveau_stateobj *so) +{ +unsigned i, nr, total =0 ; + +for (i =0 ; i < so->cur_start; i++) { +if (so->start[i].gr->subc >-1 ) +debug_printf ("+0x%04x: 0x%08x\n" , total++, + (so->start[i].size <<18 ) | (so->start[i].gr->subc <<13 ) + | so->start[i].mthd); +else +debug_printf ("+0x%04x: 0x%08x\n" , total++, + (so->start[i].size <<18 ) | so->start[i].mthd); +for (nr =0 ; nr < so->start[i].size; nr++, total++) +debug_printf ("+0x%04x: 0x%08x\n" , total, + so->pool[so->start[i].offset + nr]); + } +} + +/* Arguments are ignored, dynamic allocation. */ static INLINE struct nouveau_stateobj * -so_new (unsigned push,unsigned reloc) +so_new (unsigned start,unsigned push,unsigned reloc) {struct nouveau_stateobj *so; so =MALLOC (sizeof (struct nouveau_stateobj ));pipe_reference_init (&so->reference,1 ); - 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 ; + so->total = so->cur = so->cur_start = so->cur_reloc =0 ; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + so->start_alloc = start; + so->reloc_alloc = reloc; + so->pool_alloc = push; +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->start =MALLOC (start *sizeof (struct nouveau_stateobj_start )); + so->reloc =MALLOC (reloc *sizeof (struct nouveau_stateobj_reloc )); + so->pool =MALLOC (push *sizeof (uint32_t )); + so->pool_cur =0 ; + +if (!so->start || !so->reloc || !so->pool) { +debug_printf ("malloc failed\n" ); +assert (0 ); + }return so; }
@@ -48,54 +103,115 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso)struct nouveau_stateobj *so = *pso;int i; -if (pipe_reference (&(*pso)->reference, &ref->reference)) { -free (so->push); +if (pipe_reference (&(*pso)->reference, &ref->reference)) { +FREE (so->start);for (i =0 ; i < so->cur_reloc; i++)nouveau_bo_ref (NULL , &so->reloc[i].bo); -free (so->reloc); -free (so); +FREE (so->reloc); +FREE (so->pool); +FREE (so); } *pso = ref; } static INLINE void -so_data (struct nouveau_stateobj *so,unsigned data) +so_data (struct nouveau_stateobj *so,uint32_t data) { - (*so->cur++) = (data); - so->cur_packet +=4 ; +#ifdef DEBUG_NOUVEAU_STATEOBJ +if (so->cur >= so->start[so->cur_start -1 ].size) { +debug_printf ("exceeding specified size\n" ); +assert (0 ); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->pool[so->start[so->cur_start -1 ].offset + so->cur++] = data; } static INLINE void -so_datap (struct nouveau_stateobj *so,unsigned *data,unsigned size) +so_datap (struct nouveau_stateobj *so,uint32_t *data,unsigned size) { - so->cur_packet += (4 * size); +#ifdef DEBUG_NOUVEAU_STATEOBJ +if ((so->cur + size) > so->start[so->cur_start -1 ].size) { +debug_printf ("exceeding specified size\n" ); +assert (0 ); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ +while (size--) - (*so->cur++) = (*data++); + so->pool[so->start[so->cur_start -1 ].offset + so->cur++] = + *data++; } static INLINE voidso_method (struct nouveau_stateobj *so,struct nouveau_grobj *gr,unsigned mthd,unsigned size) { - so->cur_packet = (gr->subc <<13 ) | (1 <<18 ) | (mthd -4 ); -so_data (so, (gr->subc <<13 ) | (size <<18 ) | mthd); +struct nouveau_stateobj_start *start; + +#ifdef DEBUG_NOUVEAU_STATEOBJ +if (so->start_alloc <= so->cur_start) { +debug_printf ("exceeding num_start size\n" ); +assert (0 ); + } else +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + start = so->start; + +#ifdef DEBUG_NOUVEAU_STATEOBJ +if (so->cur_start >0 && start[so->cur_start -1 ].size > so->cur) { +debug_printf ("previous so_method was not filled\n" ); +assert (0 ); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->start = start; + start[so->cur_start].gr = gr; + start[so->cur_start].mthd = mthd; + start[so->cur_start].size = size; + +#ifdef DEBUG_NOUVEAU_STATEOBJ +if (so->pool_alloc < (size + so->pool_cur)) { +debug_printf ("exceeding num_pool size\n" ); +assert (0 ); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + start[so->cur_start].offset = so->pool_cur; + so->pool_cur += size; + + so->cur_start++; +/* The 1 is for *this* begin_ring. */ + so->total += so->cur +1 ; + so->cur =0 ; } static INLINE voidso_reloc (struct nouveau_stateobj *so,struct nouveau_bo *bo,unsigned data,unsigned flags,unsigned vor,unsigned tor) { -struct nouveau_stateobj_reloc *r = &so->reloc[so->cur_reloc++]; - - r->bo =NULL ; -nouveau_bo_ref (bo, &r->bo); - r->offset = so->cur - so->push; - r->packet = so->cur_packet; - r->data = data; - r->flags = flags; - r->vor = vor; - r->tor = tor; +struct nouveau_stateobj_reloc *r; + +#ifdef DEBUG_NOUVEAU_STATEOBJ +if (so->reloc_alloc <= so->cur_reloc) { +debug_printf ("exceeding num_reloc size\n" ); +assert (0 ); + } else +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + r = so->reloc; + + so->reloc = r; + r[so->cur_reloc].bo =NULL ; +nouveau_bo_ref (bo, &(r[so->cur_reloc].bo)); + r[so->cur_reloc].gr = so->start[so->cur_start-1 ].gr; + r[so->cur_reloc].push_offset = so->total + so->cur; + r[so->cur_reloc].data = data; + r[so->cur_reloc].flags = flags; + r[so->cur_reloc].mthd = so->start[so->cur_start-1 ].mthd + + (so->cur <<2 ); + r[so->cur_reloc].vor = vor; + r[so->cur_reloc].tor = tor; +so_data (so, data); + so->cur_reloc++; }/* Determine if this buffer object is referenced by this state object. */
@@ -112,90 +228,99 @@ so_bo_is_reloc(struct nouveau_stateobj *so, struct nouveau_bo *bo) } static INLINE void -so_dump (struct nouveau_stateobj *so) -{ -unsigned i, nr = so->cur - so->push; - -for (i =0 ; i < nr; i++) -debug_printf ("+0x%04x: 0x%08x\n" , i, so->push[i]); -} - -static INLINE voidso_emit (struct nouveau_channel *chan,struct nouveau_stateobj *so) {struct nouveau_pushbuf *pb = chan->pushbuf;unsigned nr, i;int ret =0 ; - nr = so->cur - so->push; +#ifdef DEBUG_NOUVEAU_STATEOBJ +if (so->start[so->cur_start -1 ].size > so->cur) { +debug_printf ("emit: previous so_method was not filled\n" ); +assert (0 ); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + +/* We cannot update total in case we so_emit again. */ + nr = so->total + so->cur; +/* This will flush if we need space. * We don't actually need the marker. */ if ((ret =nouveau_pushbuf_marker_emit (chan, nr, so->cur_reloc))) {debug_printf ("so_emit failed marker emit with error %d\n" , ret); -return ; +assert (0 ); + } + +/* Submit data. This will ensure proper binding of objects. */ +for (i =0 ; i < so->cur_start; i++) { +BEGIN_RING (chan, so->start[i].gr, so->start[i].mthd, so->start[i].size); +OUT_RINGp (chan, &(so->pool[so->start[i].offset]), so->start[i].size); } - pb->remaining -= nr; -memcpy (pb->cur, so->push, nr *4 );for (i =0 ; i < so->cur_reloc; i++) {struct nouveau_stateobj_reloc *r = &so->reloc[i]; -if ((ret =nouveau_pushbuf_emit_reloc (chan, pb->cur + r->offset, - r->bo, r->data,0 , r->flags, - r->vor, r->tor))) { +if ((ret =nouveau_pushbuf_emit_reloc (chan, pb->cur - nr + + r->push_offset, r->bo, r->data, +0 , r->flags, r->vor, r->tor))) {debug_printf ("so_emit failed reloc with error %d\n" , ret); - goto out; +assert (0 ); } } -out: - pb->cur += nr; } static INLINE voidso_emit_reloc_markers (struct nouveau_channel *chan,struct nouveau_stateobj *so) {struct nouveau_pushbuf *pb = chan->pushbuf; +struct nouveau_grobj *gr =NULL ;unsigned i;int ret =0 ;if (!so)return ; - i = so->cur_reloc <<1 ; -/* This will flush if we need space. -* We don't actually need the marker. -*/ -if ((ret =nouveau_pushbuf_marker_emit (chan, i, i))) { -debug_printf ("so_emit_reloc_markers failed marker emit with" \ -"error %d\n" , ret); -return ; - } - pb->remaining -= i; - +/* If we need to flush in flush notify, then we have a problem anyway. */ for (i =0 ; i < so->cur_reloc; i++) {struct nouveau_stateobj_reloc *r = &so->reloc[i]; -if ((ret =nouveau_pushbuf_emit_reloc (chan, pb->cur++, r->bo, - r->packet,0 , - (r->flags & (NOUVEAU_BO_VRAM | -NOUVEAU_BO_GART | -NOUVEAU_BO_RDWR )) | -NOUVEAU_BO_DUMMY ,0 ,0 ))) { -debug_printf ("so_emit_reloc_markers failed reloc" \ -"with error %d\n" , ret); - pb->remaining += ((so->cur_reloc - i) <<1 ); -return ; +#ifdef DEBUG_NOUVEAU_STATEOBJ +if (r->mthd &0x40000000 ) { +debug_printf ("error: NI mthd 0x%08X\n" , r->mthd); +continue ; + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + +/* The object needs to be bound and the system must know the +* subchannel is being used. Otherwise it will discard it. +*/ +if (gr != r->gr) { +BEGIN_RING (chan, r->gr,0x100 ,1 ); +OUT_RING (chan,0 ); + gr = r->gr; + } + +/* Some relocs really don't like to be hammered, +* NOUVEAU_BO_DUMMY makes sure it only +* happens when needed. +*/ + ret =OUT_RELOC (chan, r->bo, (r->gr->subc <<13 ) | (1 <<18 ) | + r->mthd, (r->flags & (NOUVEAU_BO_VRAM |NOUVEAU_BO_GART + |NOUVEAU_BO_RDWR )) |NOUVEAU_BO_DUMMY ,0 ,0 ); +if (ret) { +debug_printf ("OUT_RELOC failed %d\n" , ret); +assert (0 ); } -if ((ret =nouveau_pushbuf_emit_reloc (chan, pb->cur++, r->bo, - r->data,0 , - r->flags |NOUVEAU_BO_DUMMY , - r->vor, r->tor))) { -debug_printf ("so_emit_reloc_markers failed reloc" \ -"with error %d\n" , ret); - pb->remaining += ((so->cur_reloc - i) <<1 ) -1 ; -return ; + + ret =OUT_RELOC (chan, r->bo, r->data, r->flags | +NOUVEAU_BO_DUMMY , r->vor, r->tor); +if (ret) { +debug_printf ("OUT_RELOC failed %d\n" , ret); +assert (0 ); } + + pb->remaining -=2 ; } }
src/gallium/drivers/nv04/nv04_screen.c +0 -2
@@ -184,7 +184,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)NOUVEAU_ERR ("Error creating 3D object: %d\n" , ret);return NULL ; } -BIND_RING (chan, screen->fahrenheit,7 );/* 3D surface object */ ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class,
@@ -193,7 +192,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)NOUVEAU_ERR ("Error creating 3D surface object: %d\n" , ret);return NULL ; } -BIND_RING (chan, screen->context_surfaces_3d,6 );/* 2D engine setup */ screen->eng2d =nv04_surface_2d_init (&screen->base);
src/gallium/drivers/nv10/nv10_screen.c +0 -1
@@ -180,7 +180,6 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)NOUVEAU_ERR ("Error creating 3D object: %d\n" , ret);return FALSE; } -BIND_RING (chan, screen->celsius,7 );/* 2D engine setup */ screen->eng2d =nv04_surface_2d_init (&screen->base);
src/gallium/drivers/nv20/nv20_screen.c +0 -1
@@ -176,7 +176,6 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)NOUVEAU_ERR ("Error creating 3D object: %d\n" , ret);return FALSE; } -BIND_RING (chan, screen->kelvin,7 );/* 2D engine setup */ screen->eng2d =nv04_surface_2d_init (&screen->base);
src/gallium/drivers/nv30/nv30_fragprog.c +1 -1
@@ -837,7 +837,7 @@ nv30_fragprog_validate(struct nv30_context *nv30) fp->buffer = pscreen->buffer_create (pscreen,0x100 ,0 , fp->insn_len *4 );nv30_fragprog_upload (nv30, fp); - so =so_new (8 ,1 ); + so =so_new (4 ,4 ,1 );so_method (so, nv30->screen->rankine,NV34TCL_FP_ACTIVE_PROGRAM ,1 ); so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
src/gallium/drivers/nv30/nv30_fragtex.c +2 -2
@@ -106,7 +106,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit) txs = tf->swizzle; - so =so_new (16 ,2 ); + so =so_new (1 ,8 ,2 );so_method (so, nv30->screen->rankine,NV34TCL_TX_OFFSET (unit),8 );so_reloc (so, bo,0 , tex_flags |NOUVEAU_BO_LOW ,0 ,0 ); so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
@@ -135,7 +135,7 @@ nv30_fragtex_validate(struct nv30_context *nv30) unit =ffs (samplers) -1 ; samplers &= ~(1 << unit); - so =so_new (2 ,0 ); + so =so_new (1 ,1 ,0 );so_method (so, nv30->screen->rankine,NV34TCL_TX_ENABLE (unit),1 );so_data (so,0 );so_ref (so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);
src/gallium/drivers/nv30/nv30_screen.c +1 -2
@@ -233,7 +233,6 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)NOUVEAU_ERR ("Error creating 3D object: %d\n" , ret);return FALSE; } -BIND_RING (chan, screen->rankine,7 );/* 2D engine setup */ screen->eng2d =nv04_surface_2d_init (&screen->base);
@@ -270,7 +269,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) }/* Static rankine initialisation */ - so =so_new (128 ,0 ); + so =so_new (36 ,60 ,0 );so_method (so, screen->rankine,NV34TCL_DMA_NOTIFY ,1 );so_data (so, screen->sync->handle);so_method (so, screen->rankine,NV34TCL_DMA_TEXTURE0 ,2 );
src/gallium/drivers/nv30/nv30_state.c +3 -3
@@ -14,7 +14,7 @@ nv30_blend_state_create(struct pipe_context *pipe,struct nv30_context *nv30 =nv30_context (pipe);struct nouveau_grobj *rankine = nv30->screen->rankine;struct nv30_blend_state *bso =CALLOC (1 ,sizeof (*bso)); -struct nouveau_stateobj *so =so_new (16 ,0 ); +struct nouveau_stateobj *so =so_new (5 ,8 ,0 );if (cso->blend_enable) {so_method (so, rankine,NV34TCL_BLEND_FUNC_ENABLE ,3 );
@@ -300,7 +300,7 @@ nv30_rasterizer_state_create(struct pipe_context *pipe, {struct nv30_context *nv30 =nv30_context (pipe);struct nv30_rasterizer_state *rsso =CALLOC (1 ,sizeof (*rsso)); -struct nouveau_stateobj *so =so_new (32 ,0 ); +struct nouveau_stateobj *so =so_new (9 ,19 ,0 );struct nouveau_grobj *rankine = nv30->screen->rankine;/*XXX: ignored:
@@ -435,7 +435,7 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, {struct nv30_context *nv30 =nv30_context (pipe);struct nv30_zsa_state *zsaso =CALLOC (1 ,sizeof (*zsaso)); -struct nouveau_stateobj *so =so_new (32 ,0 ); +struct nouveau_stateobj *so =so_new (5 ,21 ,0 );struct nouveau_grobj *rankine = nv30->screen->rankine;so_method (so, rankine,NV34TCL_DEPTH_FUNC ,3 );
src/gallium/drivers/nv30/nv30_state_blend.c +1 -1
@@ -18,7 +18,7 @@ struct nv30_state_entry nv30_state_blend = {static boolean nv30_state_blend_colour_validate (struct nv30_context *nv30) { -struct nouveau_stateobj *so =so_new (2 ,0 ); +struct nouveau_stateobj *so =so_new (1 ,1 ,0 );struct pipe_blend_color *bcol = &nv30->blend_colour;so_method (so, nv30->screen->rankine,NV34TCL_BLEND_COLOR ,1 );
src/gallium/drivers/nv30/nv30_state_fb.c +1 -1
@@ -10,7 +10,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)struct nv04_surface *rt[2 ], *zeta =NULL ;uint32_t rt_enable =0 , rt_format =0 ;int i, colour_format =0 , zeta_format =0 , depth_only =0 ; -struct nouveau_stateobj *so =so_new (64 ,10 ); +struct nouveau_stateobj *so =so_new (12 ,18 ,10 );unsigned rt_flags =NOUVEAU_BO_RDWR |NOUVEAU_BO_VRAM ;unsigned w = fb->width;unsigned h = fb->height;
src/gallium/drivers/nv30/nv30_state_scissor.c +1 -1
@@ -12,7 +12,7 @@ nv30_state_scissor_validate(struct nv30_context *nv30)return FALSE; nv30->state.scissor_enabled = rast->scissor; - so =so_new (3 ,0 ); + so =so_new (1 ,2 ,0 );so_method (so, nv30->screen->rankine,NV34TCL_SCISSOR_HORIZ ,2 );if (nv30->state.scissor_enabled) {so_data (so, ((s->maxx - s->minx) <<16 ) | s->minx);
src/gallium/drivers/nv30/nv30_state_stipple.c +2 -2
@@ -14,14 +14,14 @@ nv30_state_stipple_validate(struct nv30_context *nv30)if (rast->poly_stipple_enable) {unsigned i; - so =so_new (35 ,0 ); + so =so_new (2 ,33 ,0 );so_method (so, rankine,NV34TCL_POLYGON_STIPPLE_ENABLE ,1 );so_data (so,1 );so_method (so, rankine,NV34TCL_POLYGON_STIPPLE_PATTERN (0 ),32 );for (i =0 ; i <32 ; i++)so_data (so, nv30->stipple[i]); }else { - so =so_new (2 ,0 ); + so =so_new (1 ,1 ,0 );so_method (so, rankine,NV34TCL_POLYGON_STIPPLE_ENABLE ,1 );so_data (so,0 ); }
src/gallium/drivers/nv30/nv30_state_viewport.c +1 -1
@@ -19,7 +19,7 @@ nv30_state_viewport_validate(struct nv30_context *nv30)return FALSE; nv30->state.viewport_bypass = bypass; - so =so_new (11 ,0 ); + so =so_new (3 ,10 ,0 );if (!bypass) {so_method (so, nv30->screen->rankine,NV34TCL_VIEWPORT_TRANSLATE_X ,8 );
src/gallium/drivers/nv30/nv30_vbo.c +3 -3
@@ -495,9 +495,9 @@ nv30_vbo_validate(struct nv30_context *nv30)unsigned vb_flags =NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD ;int hw; - vtxbuf =so_new (20 ,18 ); + vtxbuf =so_new (3 ,17 ,18 );so_method (vtxbuf, rankine,NV34TCL_VTXBUF_ADDRESS (0 ), nv30->vtxelt_nr); - vtxfmt =so_new (17 ,0 ); + vtxfmt =so_new (1 ,16 ,0 );so_method (vtxfmt, rankine,NV34TCL_VTXFMT (0 ), nv30->vtxelt_nr);for (hw =0 ; hw < nv30->vtxelt_nr; hw++) {
@@ -510,7 +510,7 @@ nv30_vbo_validate(struct nv30_context *nv30)if (!vb->stride) {if (!sattr) - sattr =so_new (16 *5 ,0 ); + sattr =so_new (16 ,16 *4 ,0 );if (nv30_vbo_static_attrib (nv30, sattr, hw, ve, vb)) {so_data (vtxbuf,0 );
src/gallium/drivers/nv30/nv30_vertprog.c +1 -1
@@ -686,7 +686,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)assert (0 ); } - so =so_new (2 ,0 ); + so =so_new (1 ,1 ,0 );so_method (so, rankine,NV34TCL_VP_START_FROM_ID ,1 );so_data (so, vp->exec->start);so_ref (so, &vp->so);
src/gallium/drivers/nv40/nv40_fragprog.c +1 -1
@@ -919,7 +919,7 @@ nv40_fragprog_validate(struct nv40_context *nv40) fp->buffer = pscreen->buffer_create (pscreen,0x100 ,0 , fp->insn_len *4 );nv40_fragprog_upload (nv40, fp); - so =so_new (4 ,1 ); + so =so_new (2 ,2 ,1 );so_method (so, nv40->screen->curie,NV40TCL_FP_ADDRESS ,1 ); so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
src/gallium/drivers/nv40/nv40_fragtex.c +2 -2
@@ -108,7 +108,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit) txs = tf->swizzle; - so =so_new (16 ,2 ); + so =so_new (2 ,9 ,2 );so_method (so, nv40->screen->curie,NV40TCL_TEX_OFFSET (unit),8 );so_reloc (so, bo,0 , tex_flags |NOUVEAU_BO_LOW ,0 ,0 ); so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
@@ -139,7 +139,7 @@ nv40_fragtex_validate(struct nv40_context *nv40) unit =ffs (samplers) -1 ; samplers &= ~(1 << unit); - so =so_new (2 ,0 ); + so =so_new (1 ,1 ,0 );so_method (so, nv40->screen->curie,NV40TCL_TEX_ENABLE (unit),1 );so_data (so,0 );so_ref (so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
src/gallium/drivers/nv40/nv40_screen.c +1 -2
@@ -215,7 +215,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)NOUVEAU_ERR ("Error creating 3D object: %d\n" , ret);return FALSE; } -BIND_RING (chan, screen->curie,7 );/* 2D engine setup */ screen->eng2d =nv04_surface_2d_init (&screen->base);
@@ -252,7 +251,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) }/* Static curie initialisation */ - so =so_new (128 ,0 ); + so =so_new (16 ,25 ,0 );so_method (so, screen->curie,NV40TCL_DMA_NOTIFY ,1 );so_data (so, screen->sync->handle);so_method (so, screen->curie,NV40TCL_DMA_TEXTURE0 ,2 );
src/gallium/drivers/nv40/nv40_state.c +3 -3
@@ -16,7 +16,7 @@ nv40_blend_state_create(struct pipe_context *pipe,struct nv40_context *nv40 =nv40_context (pipe);struct nouveau_grobj *curie = nv40->screen->curie;struct nv40_blend_state *bso =CALLOC (1 ,sizeof (*bso)); -struct nouveau_stateobj *so =so_new (16 ,0 ); +struct nouveau_stateobj *so =so_new (5 ,8 ,0 );if (cso->blend_enable) {so_method (so, curie,NV40TCL_BLEND_ENABLE ,3 );
@@ -310,7 +310,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe, {struct nv40_context *nv40 =nv40_context (pipe);struct nv40_rasterizer_state *rsso =CALLOC (1 ,sizeof (*rsso)); -struct nouveau_stateobj *so =so_new (32 ,0 ); +struct nouveau_stateobj *so =so_new (8 ,18 ,0 );struct nouveau_grobj *curie = nv40->screen->curie;/*XXX: ignored:
@@ -445,7 +445,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe, {struct nv40_context *nv40 =nv40_context (pipe);struct nv40_zsa_state *zsaso =CALLOC (1 ,sizeof (*zsaso)); -struct nouveau_stateobj *so =so_new (32 ,0 ); +struct nouveau_stateobj *so =so_new (4 ,21 ,0 );struct nouveau_grobj *curie = nv40->screen->curie;so_method (so, curie,NV40TCL_DEPTH_FUNC ,3 );
src/gallium/drivers/nv40/nv40_state_blend.c +1 -1
@@ -18,7 +18,7 @@ struct nv40_state_entry nv40_state_blend = {static boolean nv40_state_blend_colour_validate (struct nv40_context *nv40) { -struct nouveau_stateobj *so =so_new (2 ,0 ); +struct nouveau_stateobj *so =so_new (1 ,1 ,0 );struct pipe_blend_color *bcol = &nv40->blend_colour;so_method (so, nv40->screen->curie,NV40TCL_BLEND_COLOR ,1 );
src/gallium/drivers/nv40/nv40_state_fb.c +1 -1
@@ -19,7 +19,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)struct nv04_surface *rt[4 ], *zeta;uint32_t rt_enable, rt_format;int i, colour_format =0 , zeta_format =0 ; -struct nouveau_stateobj *so =so_new (64 ,10 ); +struct nouveau_stateobj *so =so_new (18 ,24 ,10 );unsigned rt_flags =NOUVEAU_BO_RDWR |NOUVEAU_BO_VRAM ;unsigned w = fb->width;unsigned h = fb->height;
src/gallium/drivers/nv40/nv40_state_scissor.c +1 -1
@@ -12,7 +12,7 @@ nv40_state_scissor_validate(struct nv40_context *nv40)return FALSE; nv40->state.scissor_enabled = rast->scissor; - so =so_new (3 ,0 ); + so =so_new (1 ,2 ,0 );so_method (so, nv40->screen->curie,NV40TCL_SCISSOR_HORIZ ,2 );if (nv40->state.scissor_enabled) {so_data (so, ((s->maxx - s->minx) <<16 ) | s->minx);
src/gallium/drivers/nv40/nv40_state_stipple.c +2 -2
@@ -14,14 +14,14 @@ nv40_state_stipple_validate(struct nv40_context *nv40)if (rast->poly_stipple_enable) {unsigned i; - so =so_new (35 ,0 ); + so =so_new (2 ,33 ,0 );so_method (so, curie,NV40TCL_POLYGON_STIPPLE_ENABLE ,1 );so_data (so,1 );so_method (so, curie,NV40TCL_POLYGON_STIPPLE_PATTERN (0 ),32 );for (i =0 ; i <32 ; i++)so_data (so, nv40->stipple[i]); }else { - so =so_new (2 ,0 ); + so =so_new (1 ,1 ,0 );so_method (so, curie,NV40TCL_POLYGON_STIPPLE_ENABLE ,1 );so_data (so,0 ); }
src/gallium/drivers/nv40/nv40_state_viewport.c +1 -1
@@ -19,7 +19,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40)return FALSE; nv40->state.viewport_bypass = bypass; - so =so_new (11 ,0 ); + so =so_new (2 ,9 ,0 );if (!bypass) {so_method (so, nv40->screen->curie,NV40TCL_VIEWPORT_TRANSLATE_X ,8 );
src/gallium/drivers/nv40/nv40_vbo.c +3 -3
@@ -494,9 +494,9 @@ nv40_vbo_validate(struct nv40_context *nv40)unsigned vb_flags =NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD ;int hw; - vtxbuf =so_new (20 ,18 ); + vtxbuf =so_new (3 ,17 ,18 );so_method (vtxbuf, curie,NV40TCL_VTXBUF_ADDRESS (0 ), nv40->vtxelt_nr); - vtxfmt =so_new (17 ,0 ); + vtxfmt =so_new (1 ,16 ,0 );so_method (vtxfmt, curie,NV40TCL_VTXFMT (0 ), nv40->vtxelt_nr);for (hw =0 ; hw < nv40->vtxelt_nr; hw++) {
@@ -509,7 +509,7 @@ nv40_vbo_validate(struct nv40_context *nv40)if (!vb->stride) {if (!sattr) - sattr =so_new (16 *5 ,0 ); + sattr =so_new (16 ,16 *4 ,0 );if (nv40_vbo_static_attrib (nv40, sattr, hw, ve, vb)) {so_data (vtxbuf,0 );
src/gallium/drivers/nv40/nv40_vertprog.c +1 -1
@@ -886,7 +886,7 @@ check_gpu_resources:assert (0 ); } - so =so_new (7 ,0 ); + so =so_new (3 ,4 ,0 );so_method (so, curie,NV40TCL_VP_START_FROM_ID ,1 );so_data (so, vp->exec->start);so_method (so, curie,NV40TCL_VP_ATTRIB_EN ,2 );
src/gallium/drivers/nv50/nv50_program.c +3 -3
@@ -3452,7 +3452,7 @@ nv50_vertprog_validate(struct nv50_context *nv50)nv50_program_validate_data (nv50, p);nv50_program_validate_code (nv50, p); - so =so_new (13 ,2 ); + so =so_new (5 ,8 ,2 );so_method (so, tesla,NV50TCL_VP_ADDRESS_HIGH ,2 );so_reloc (so, p->bo,0 ,NOUVEAU_BO_VRAM |NOUVEAU_BO_RD |NOUVEAU_BO_HIGH ,0 ,0 );
@@ -3488,7 +3488,7 @@ nv50_fragprog_validate(struct nv50_context *nv50)nv50_program_validate_data (nv50, p);nv50_program_validate_code (nv50, p); - so =so_new (64 ,2 ); + so =so_new (6 ,7 ,2 );so_method (so, tesla,NV50TCL_FP_ADDRESS_HIGH ,2 );so_reloc (so, p->bo,0 ,NOUVEAU_BO_VRAM |NOUVEAU_BO_RD |NOUVEAU_BO_HIGH ,0 ,0 );
@@ -3656,7 +3656,7 @@ nv50_linkage_validate(struct nv50_context *nv50) }/* now fill the stateobj */ - so =so_new (64 ,0 ); + so =so_new (6 ,58 ,0 ); n = (m +3 ) /4 ;so_method (so, tesla,NV50TCL_VP_RESULT_MAP_SIZE ,1 );
src/gallium/drivers/nv50/nv50_screen.c +3 -6
@@ -251,7 +251,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)nv50_screen_destroy (pscreen);return NULL ; } -BIND_RING (chan, screen->m2mf,1 );/* 2D object */ ret =nouveau_grobj_alloc (chan,0xbeef502d ,NV50_2D , &screen->eng2d);
@@ -260,7 +259,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)nv50_screen_destroy (pscreen);return NULL ; } -BIND_RING (chan, screen->eng2d,2 );/* 3D object */ switch (chipset &0xf0 ) {
@@ -296,7 +294,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)nv50_screen_destroy (pscreen);return NULL ; } -BIND_RING (chan, screen->tesla,3 );/* Sync notifier */ ret =nouveau_notifier_alloc (chan,0xbeef0301 ,1 , &screen->sync);
@@ -307,7 +304,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) }/* Static M2MF init */ - so =so_new (32 ,0 ); + so =so_new (1 ,3 ,0 );so_method (so, screen->m2mf,NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY ,3 );so_data (so, screen->sync->handle);so_data (so, chan->vram->handle);
@@ -316,7 +313,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)so_ref (NULL , &so);/* Static 2D init */ - so =so_new (64 ,0 ); + so =so_new (4 ,7 ,0 );so_method (so, screen->eng2d,NV50_2D_DMA_NOTIFY ,4 );so_data (so, screen->sync->handle);so_data (so, chan->vram->handle);
@@ -332,7 +329,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)so_ref (NULL , &so);/* Static tesla init */ - so =so_new (256 ,20 ); + so =so_new (40 ,84 ,20 );so_method (so, screen->tesla,NV50TCL_COND_MODE ,1 );so_data (so,NV50TCL_COND_MODE_ALWAYS );
src/gallium/drivers/nv50/nv50_state.c +3 -3
@@ -35,7 +35,7 @@ static void * nv50_blend_state_create(struct pipe_context *pipe, const struct pipe_blend_state *cso) { - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(5, 24, 0);struct nouveau_grobj *tesla =nv50_context (pipe)->screen->tesla;struct nv50_blend_stateobj *bso =CALLOC_STRUCT (nv50_blend_stateobj);unsigned cmask =0 , i;
@@ -280,7 +280,7 @@ static void * nv50_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) { - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(15, 21, 0);struct nouveau_grobj *tesla =nv50_context (pipe)->screen->tesla;struct nv50_rasterizer_stateobj *rso =CALLOC_STRUCT (nv50_rasterizer_stateobj);
@@ -425,7 +425,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe, {struct nouveau_grobj *tesla =nv50_context (pipe)->screen->tesla;struct nv50_zsa_stateobj *zsa =CALLOC_STRUCT (nv50_zsa_stateobj); -struct nouveau_stateobj *so =so_new (64 ,0 ); +struct nouveau_stateobj *so =so_new (8 ,22 ,0 );so_method (so, tesla,NV50TCL_DEPTH_WRITE_ENABLE ,1 );so_data (so, cso->depth.writemask ?1 :0 );
src/gallium/drivers/nv50/nv50_state_validate.c +7 -6
@@ -33,7 +33,7 @@ static void nv50_state_validate_fb(struct nv50_context *nv50) {struct nouveau_grobj *tesla = nv50->screen->tesla; -struct nouveau_stateobj *so =so_new (128 ,18 ); +struct nouveau_stateobj *so =so_new (32 ,79 ,18 );struct pipe_framebuffer_state *fb = &nv50->framebuffer;unsigned i, w, h, gw =0 ;
@@ -299,7 +299,7 @@ nv50_state_validate(struct nv50_context *nv50)so_ref (nv50->rasterizer->so, &nv50->state.rast);if (nv50->dirty &NV50_NEW_BLEND_COLOUR ) { - so =so_new (5 ,0 ); + so =so_new (1 ,4 ,0 );so_method (so, tesla,NV50TCL_BLEND_COLOR (0 ),4 );so_data (so,fui (nv50->blend_colour.color[0 ]));so_data (so,fui (nv50->blend_colour.color[1 ]));
@@ -310,7 +310,7 @@ nv50_state_validate(struct nv50_context *nv50) }if (nv50->dirty &NV50_NEW_STIPPLE ) { - so =so_new (33 ,0 ); + so =so_new (1 ,32 ,0 );so_method (so, tesla,NV50TCL_POLYGON_STIPPLE_PATTERN (0 ),32 );for (i =0 ; i <32 ; i++)so_data (so,util_bswap32 (nv50->stipple.stipple[i]));
@@ -327,7 +327,7 @@ nv50_state_validate(struct nv50_context *nv50) goto scissor_uptodate; nv50->state.scissor_enabled = rast->scissor; - so =so_new (3 ,0 ); + so =so_new (1 ,2 ,0 );so_method (so, tesla,NV50TCL_SCISSOR_HORIZ (0 ),2 );if (nv50->state.scissor_enabled) {so_data (so, (s->maxx <<16 ) | s->minx);
@@ -356,7 +356,7 @@ scissor_uptodate: goto viewport_uptodate; nv50->state.viewport_bypass = bypass; - so =so_new (14 ,0 ); + so =so_new (5 ,9 ,0 );if (!bypass) {so_method (so, tesla,NV50TCL_VIEWPORT_TRANSLATE_X (0 ),3 );so_data (so,fui (nv50->viewport.translate[0 ]));
@@ -400,7 +400,8 @@ viewport_uptodate:for (i =0 ; i <PIPE_SHADER_TYPES ; ++i) nr += nv50->sampler_nr[i]; - so =so_new (nr *8 +24 *PIPE_SHADER_TYPES +2 ,4 ); + so =so_new (1 +5 *PIPE_SHADER_TYPES ,1 +19 *PIPE_SHADER_TYPES + + nr *8 ,PIPE_SHADER_TYPES *2 );nv50_validate_samplers (nv50, so,PIPE_SHADER_VERTEX );nv50_validate_samplers (nv50, so,PIPE_SHADER_FRAGMENT );
src/gallium/drivers/nv50/nv50_tex.c +6 -4
@@ -199,16 +199,18 @@ nv50_tex_validate(struct nv50_context *nv50) {struct nouveau_stateobj *so;struct nouveau_grobj *tesla = nv50->screen->tesla; -unsigned p, push, nrlc; +unsigned p, start, push, nrlc; -for (nrlc =0 , push =0 , p =0 ; p <PIPE_SHADER_TYPES ; ++p) { +for (nrlc =0 , start =0 , push =0 , p =0 ; p <PIPE_SHADER_TYPES ; ++p) { + start +=MAX2 (nv50->miptree_nr[p], nv50->state.miptree_nr[p]); push +=MAX2 (nv50->miptree_nr[p], nv50->state.miptree_nr[p]); nrlc += nv50->miptree_nr[p]; } - push = push *11 +23 *PIPE_SHADER_TYPES +4 ; + start = start *2 +4 *PIPE_SHADER_TYPES +2 ; + push = push *9 +19 *PIPE_SHADER_TYPES +2 ; nrlc = nrlc *2 +2 *PIPE_SHADER_TYPES ; - so =so_new (push, nrlc); + so =so_new (start, push, nrlc);if (nv50_validate_textures (nv50, so,PIPE_SHADER_VERTEX ) == FALSE ||nv50_validate_textures (nv50, so,PIPE_SHADER_FRAGMENT ) == FALSE) {
src/gallium/drivers/nv50/nv50_vbo.c +3 -3
@@ -350,7 +350,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib, so = *pso;if (!so) - *pso = so =so_new (nv50->vtxelt_nr *5 ,0 ); + *pso = so =so_new (nv50->vtxelt_nr, nv50->vtxelt_nr *4 ,0 );switch (ve->nr_components) {case 4 :
@@ -411,8 +411,8 @@ nv50_vbo_validate(struct nv50_context *nv50) n_ve =MAX2 (nv50->vtxelt_nr, nv50->state.vtxelt_nr); vtxattr =NULL ; - vtxbuf =so_new (n_ve *7 , nv50->vtxelt_nr *4 ); - vtxfmt =so_new (n_ve +1 ,0 ); + vtxbuf =so_new (n_ve *2 , n_ve *5 , nv50->vtxelt_nr *4 ); + vtxfmt =so_new (1 , n_ve,0 );so_method (vtxfmt, tesla,NV50TCL_VERTEX_ARRAY_ATTRIB (0 ), n_ve);for (i =0 ; i < nv50->vtxelt_nr; i++) {
Signature · 1 line
1.6.6.rc4
A message that is not in the archive (sent off-list or not yet received): 1262209002-10778-3-git-send-email-madman2003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 3/3] nouveau: rewrite nouveau_stateobj to use BEGIN_RING properly
The prerequisite patch (which kills nouveau_push) got stuck in queue because of it's size.
This patch is here for discussion, and it needs testing on nv30/nv40 for miscalculated so sizes.
Quoted 1,115 lines · Maarten Maathuis
- The previous solution was hacky and didn't do subchannel autobinding.
- The beheaviour should match whatlibdrm_nouveaudoes closely.
- There appears to be a minor performance loss, probably due to having multiple memcpy's instead of one.
- The solution remains statically sized, but when debugging is on it will check for abuse.
- The values for nv30/nv40 may be off, but this should be easily caught with DEBUG on.Signed-off-by Maarten Maathuis <[email protected]>---
src/gallium/drivers/nouveau/nouveau_stateobj.h | 289 +++++++++++++++++-------src/gallium/drivers/nv04/nv04_screen.c | 2 - src/gallium/drivers/nv10/nv10_screen.c | 1 - src/gallium/drivers/nv20/nv20_screen.c | 1 -src/gallium/drivers/nv30/nv30_fragprog.c | 2 +-
src/gallium/drivers/nv30/nv30_fragtex.c| 4 +-src/gallium/drivers/nv30/nv30_screen.c| 3 +-src/gallium/drivers/nv30/nv30_state.c| 6 +-src/gallium/drivers/nv30/nv30_state_blend.c| 2 +-src/gallium/drivers/nv30/nv30_state_fb.c| 2 +-src/gallium/drivers/nv30/nv30_state_scissor.c| 2 +-src/gallium/drivers/nv30/nv30_state_stipple.c| 4 +-src/gallium/drivers/nv30/nv30_state_viewport.c| 2 +-src/gallium/drivers/nv30/nv30_vbo.c| 6 +-src/gallium/drivers/nv30/nv30_vertprog.c| 2 +-src/gallium/drivers/nv40/nv40_fragprog.c| 2 +-src/gallium/drivers/nv40/nv40_fragtex.c| 4 +-src/gallium/drivers/nv40/nv40_screen.c| 3 +-src/gallium/drivers/nv40/nv40_state.c| 6 +-src/gallium/drivers/nv40/nv40_state_blend.c| 2 +-src/gallium/drivers/nv40/nv40_state_fb.c| 2 +-src/gallium/drivers/nv40/nv40_state_scissor.c| 2 +-src/gallium/drivers/nv40/nv40_state_stipple.c| 4 +-src/gallium/drivers/nv40/nv40_state_viewport.c| 2 +-src/gallium/drivers/nv40/nv40_vbo.c| 6 +-src/gallium/drivers/nv40/nv40_vertprog.c| 2 +-src/gallium/drivers/nv50/nv50_program.c| 6 +-src/gallium/drivers/nv50/nv50_screen.c| 9 +-src/gallium/drivers/nv50/nv50_state.c| 6 +-src/gallium/drivers/nv50/nv50_state_validate.c| 13 +-src/gallium/drivers/nv50/nv50_tex.c| 10 +-src/gallium/drivers/nv50/nv50_vbo.c| 6 +-32 files changed, 266 insertions(+), 147 deletions(-)src/gallium/drivers/nouveau/nouveau_stateobj.h +49
-6@@ -3,41 +3,96 @@ #include "util/u_debug.h" +#ifdef DEBUG +#define DEBUG_NOUVEAU_STATEOBJ +#endif /* DEBUG */ + struct nouveau_stateobj_reloc { struct nouveau_bo *bo; - unsigned offset; - unsigned packet; + struct nouveau_grobj *gr; + uint32_t push_offset; + uint32_t mthd; - unsigned data; + uint32_t data; unsigned flags; unsigned vor; unsigned tor; }; +struct nouveau_stateobj_start { + struct nouveau_grobj *gr; + uint32_t mthd; + uint32_t size; + unsigned offset; +}; + struct nouveau_stateobj { struct pipe_reference reference; - unsigned *push; + struct nouveau_stateobj_start *start; struct nouveau_stateobj_reloc *reloc; - unsigned *cur; - unsigned cur_packet; + /* Common memory pool for data. */ + uint32_t *pool; + unsigned pool_cur; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + unsigned start_alloc; + unsigned reloc_alloc; + unsigned pool_alloc; +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + unsigned total; /* includes begin_ring */ + unsigned cur; /* excludes begin_ring, offset from "cur_start" */ + unsigned cur_start; unsigned cur_reloc; }; +static INLINE void +so_dump (struct nouveau_stateobj *so) +{ + unsigned i, nr, total = 0; + + for (i = 0; i < so->cur_start; i++) { + if (so->start[i].gr->subc > -1) + debug_printf("+0x%04x: 0x%08x\n", total++, + (so->start[i].size << 18) | (so->start[i].gr->subc << 13) + | so->start[i].mthd); + else + debug_printf("+0x%04x: 0x%08x\n", total++, + (so->start[i].size << 18) | so->start[i].mthd); + for (nr = 0; nr < so->start[i].size; nr++, total++) + debug_printf("+0x%04x: 0x%08x\n", total, + so->pool[so->start[i].offset + nr]); + } +} + +/* Arguments are ignored, dynamic allocation. */ static INLINE struct
nouveau_stateobj*src/gallium/drivers/nouveau/nouveau_stateobj.h +1
-1-so_new(unsigned push, unsigned reloc) +so_new(unsigned start, unsigned push, unsigned reloc){
structnouveau_stateobj*so;so =
MALLOC(sizeof(struct nouveau_stateobj));pipe_reference_init(&so->reference, 1);
-so->push=MALLOC(sizeof(unsigned) * push);
-so->reloc=MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc);src/gallium/drivers/nouveau/nouveau_stateobj.h +17
-3- - so->cur = so->push; - so->cur_reloc = so->cur_packet = 0; + so->total = so->cur = so->cur_start = so->cur_reloc = 0; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + so->start_alloc = start; + so->reloc_alloc = reloc; + so->pool_alloc = push; +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->start = MALLOC(start * sizeof(struct nouveau_stateobj_start)); + so->reloc = MALLOC(reloc * sizeof(struct nouveau_stateobj_reloc)); + so->pool = MALLOC(push * sizeof(uint32_t)); + so->pool_cur = 0; + + if (!so->start || !so->reloc || !so->pool) { + debug_printf("malloc failed\n"); + assert(0); + }return so;
}src/gallium/drivers/nouveau/nouveau_stateobj.h +5
-4@@ -48,54 +103,115 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso) struct nouveau_stateobj *so = *pso; int i; - if (pipe_reference(&(*pso)->reference, &ref->reference)) { - free(so->push); + if (pipe_reference(&(*pso)->reference, &ref->reference)) { + FREE(so->start); for (i = 0; i < so->cur_reloc; i++) nouveau_bo_ref(NULL, &so->reloc[i].bo); - free(so->reloc); - free(so); + FREE(so->reloc); + FREE(so->pool); + FREE(so); } *pso = ref; }static INLINE void
src/gallium/drivers/nouveau/nouveau_stateobj.h +1
-1-so_data(struct nouveau_stateobj *so, unsigned data) +so_data(struct nouveau_stateobj *so, uint32_t data){
- (*so->cur++) = (data);
-so->cur_packet+= 4;src/gallium/drivers/nouveau/nouveau_stateobj.h +8
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->cur >= so->start[so->cur_start - 1].size) { + debug_printf("exceeding specified size\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->pool[so->start[so->cur_start - 1].offset + so->cur++] = data;}
static INLINE void
src/gallium/drivers/nouveau/nouveau_stateobj.h +1
-1-so_datap(struct nouveau_stateobj *so, unsigned *data, unsigned size) +so_datap(struct nouveau_stateobj *so, uint32_t *data, unsigned size){
-so->cur_packet+= (4 * size);src/gallium/drivers/nouveau/nouveau_stateobj.h +7
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if ((so->cur + size) > so->start[so->cur_start - 1].size) { + debug_printf("exceeding specified size\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ +while (size--)
- (*so->cur++) = (*data++);
+ so->pool[so->start[so->cur_start - 1].offset + so->cur++] =
+ *data++;
}static INLINE void
so_method(structnouveau_stateobj*so, structnouveau_grobj*gr, unsigned mthd, unsigned size)
{
-so->cur_packet= (gr->subc<< 13) | (1 << 18) | (mthd - 4);
-so_data(so, (gr->subc << 13) | (size << 18) | mthd);
+ structnouveau_stateobj_start*start;src/gallium/drivers/nouveau/nouveau_stateobj.h +35
-0+ +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->start_alloc <= so->cur_start) { + debug_printf("exceeding num_start size\n"); + assert(0); + } else +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + start = so->start; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->cur_start > 0 && start[so->cur_start - 1].size > so->cur) { + debug_printf("previous so_method was not filled\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->start = start; + start[so->cur_start].gr = gr; + start[so->cur_start].mthd = mthd; + start[so->cur_start].size = size; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->pool_alloc < (size + so->pool_cur)) { + debug_printf("exceeding num_pool size\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + start[so->cur_start].offset = so->pool_cur; + so->pool_cur += size; + + so->cur_start++; + /* The 1 is for *this* begin_ring. */ + so->total += so->cur + 1; + so->cur = 0;}
static INLINE void
so_reloc(structnouveau_stateobj*so, structnouveau_bo*bo, unsigned data, unsigned flags, unsigned vor, unsigned tor) {
- structnouveau_stateobj_reloc*r = &so->reloc[so->cur_reloc++];src/gallium/drivers/nouveau/nouveau_stateobj.h +22
-9- - r->bo = NULL; - nouveau_bo_ref(bo, &r->bo); - r->offset = so->cur - so->push; - r->packet = so->cur_packet; - r->data = data; - r->flags = flags; - r->vor = vor; - r->tor = tor; + struct nouveau_stateobj_reloc *r; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->reloc_alloc <= so->cur_reloc) { + debug_printf("exceeding num_reloc size\n"); + assert(0); + } else +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + r = so->reloc; + + so->reloc = r; + r[so->cur_reloc].bo = NULL; + nouveau_bo_ref(bo, &(r[so->cur_reloc].bo)); + r[so->cur_reloc].gr = so->start[so->cur_start-1].gr; + r[so->cur_reloc].push_offset = so->total + so->cur; + r[so->cur_reloc].data = data; + r[so->cur_reloc].flags = flags; + r[so->cur_reloc].mthd = so->start[so->cur_start-1].mthd + + (so->cur << 2); + r[so->cur_reloc].vor = vor; + r[so->cur_reloc].tor = tor; +so_data(so, data);
+ so->cur_reloc++;
}/* Determine if this buffer object is referenced by this state object. */
src/gallium/drivers/nouveau/nouveau_stateobj.h +0
-0@@ -112,90 +228,99 @@ so_bo_is_reloc(struct nouveau_stateobj *so, struct nouveau_bo *bo) }static INLINE void
src/gallium/drivers/nouveau/nouveau_stateobj.h +0
-9-so_dump(struct nouveau_stateobj *so) -{ - unsigned i, nr = so->cur - so->push; - - for (i = 0; i < nr; i++) - debug_printf("+0x%04x: 0x%08x\n", i, so->push[i]); -} - -static INLINE voidso_emit(struct
nouveau_channel*chan, structnouveau_stateobj*so) {
structnouveau_pushbuf*pb =chan->pushbuf; unsigned nr, i;
int ret = 0;- nr =
so->cur-so->push;src/gallium/drivers/nouveau/nouveau_stateobj.h +10
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->start[so->cur_start - 1].size > so->cur) { + debug_printf("emit: previous so_method was not filled\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + /* We cannot update total in case we so_emit again. */ + nr = so->total + so->cur; +/* This will flush if we need space.
* We don't actually need the marker.
*/
if ((ret =nouveau_pushbuf_marker_emit(chan, nr, so->cur_reloc))) {debug_printf("so_emit failed marker emit with error %d\n", ret);
- return;
+ assert(0);
+ }
+
+ /* Submit data. This will ensure proper binding of objects. */
+ for (i = 0; i <so->cur_start; i++) {
+BEGIN_RING(chan, so->start[i].gr, so->start[i].mthd, so->start[i].size);
+OUT_RINGp(chan, &(so->pool[so->start[i].offset]), so->start[i].size); }
-pb->remaining-= nr;-
memcpy(pb->cur, so->push, nr * 4);
for (i = 0; i <so->cur_reloc; i++) {
structnouveau_stateobj_reloc*r = &so->reloc[i];- if ((ret = nouveau_pushbuf_emit_reloc(chan,
pb->cur+r->offset,
- r->bo,r->data, 0,r->flags,
- r->vor,r->tor))) {
+ if ((ret = nouveau_pushbuf_emit_reloc(chan,pb->cur- nr +
+r->push_offset,r->bo,r->data,
+ 0,r->flags,r->vor,r->tor))) {debug_printf("so_emit failed reloc with error %d\n", ret);
- goto out;
+ assert(0);
}
}
-out:
-pb->cur+= nr;
}static INLINE void
so_emit_reloc_markers(structnouveau_channel*chan, structnouveau_stateobj*so) {
structnouveau_pushbuf*pb =chan->pushbuf;
+ structnouveau_grobj*gr = NULL;
unsigned i;
int ret = 0;if (!so)
return;- i =
so->cur_reloc<< 1;
- /* This will flush if we need space.
- * We don't actually need the marker.
- */
- if ((ret =nouveau_pushbuf_marker_emit(chan, i, i))) {
- debug_printf("so_emit_reloc_markers failed marker emit with" \
- "error %d\n", ret);
- return;
- }
-pb->remaining-= i;
-
+ /* If we need to flush in flush notify, then we have a problem anyway. */ for (i = 0; i <so->cur_reloc; i++) {
structnouveau_stateobj_reloc*r = &so->reloc[i];- if ((ret = nouveau_pushbuf_emit_reloc(chan, pb->cur++,
r->bo,
- r->packet, 0,
- (r->flags & (NOUVEAU_BO_VRAM|
-NOUVEAU_BO_GART|
-NOUVEAU_BO_RDWR)) |
- NOUVEAU_BO_DUMMY, 0, 0))) {
- debug_printf("so_emit_reloc_markers failed reloc" \
- "with error %d\n", ret);
-pb->remaining+= ((so->cur_reloc- i) << 1);
- return;src/gallium/drivers/nouveau/nouveau_stateobj.h +26
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if (r->mthd & 0x40000000) { + debug_printf("error: NI mthd 0x%08X\n", r->mthd); + continue; + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + /* The object needs to be bound and the system must know the + * subchannel is being used. Otherwise it will discard it. + */ + if (gr != r->gr) { + BEGIN_RING(chan, r->gr, 0x100, 1); + OUT_RING(chan, 0); + gr = r->gr; + } + + /* Some relocs really don't like to be hammered, + * NOUVEAU_BO_DUMMY makes sure it only + * happens when needed. + */ + ret = OUT_RELOC(chan, r->bo, (r->gr->subc << 13) | (1<< 18) | + r->mthd, (r->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART + | NOUVEAU_BO_RDWR)) | NOUVEAU_BO_DUMMY, 0, 0); + if (ret) { + debug_printf("OUT_RELOC failed %d\n", ret); + assert(0);}
- if ((ret = nouveau_pushbuf_emit_reloc(chan, pb->cur++,r->bo,
- r->data, 0,
- r->flags |NOUVEAU_BO_DUMMY,
- r->vor,r->tor))) {
- debug_printf("so_emit_reloc_markers failed reloc" \
- "with error %d\n", ret);
-pb->remaining+= ((so->cur_reloc- i) << 1) - 1;
- return;
+
+ ret = OUT_RELOC(chan,r->bo,r->data,r->flags|
+NOUVEAU_BO_DUMMY,r->vor,r->tor);
+ if (ret) {
+debug_printf("OUT_RELOC failed %d\n", ret);
+ assert(0);
}
+
+pb->remaining-= 2;
}
}src/gallium/drivers/nv04/nv04_screen.c +0
-2@@ -184,7 +184,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return NULL; } - BIND_RING(chan, screen->fahrenheit, 7); /* 3D surface object */ ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class,@@ -193,7 +192,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D surface object: %d\n", ret); return NULL; } - BIND_RING(chan, screen->context_surfaces_3d, 6); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);src/gallium/drivers/nv10/nv10_screen.c +0
-1@@ -180,7 +180,6 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->celsius, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);src/gallium/drivers/nv20/nv20_screen.c +0
-1@@ -176,7 +176,6 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->kelvin, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);src/gallium/drivers/nv30/nv30_fragprog.c +1
-1@@ -837,7 +837,7 @@ nv30_fragprog_validate(struct nv30_context *nv30) fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv30_fragprog_upload(nv30, fp); - so = so_new(8, 1); + so = so_new(4, 4, 1); so_method(so, nv30->screen->rankine, NV34TCL_FP_ACTIVE_PROGRAM, 1);so_reloc (so,
nouveau_bo(fp->buffer), 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_GART|NOUVEAU_BO_RD|NOUVEAU_BO_LOW|src/gallium/drivers/nv30/nv30_fragtex.c +2
-2@@ -106,7 +106,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit) txs = tf->swizzle; - so = so_new(16, 2); + so = so_new(1, 8, 2); so_method(so, nv30->screen->rankine, NV34TCL_TX_OFFSET(unit), 8); so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,@@ -135,7 +135,7 @@ nv30_fragtex_validate(struct nv30_context *nv30) unit = ffs(samplers) - 1; samplers &= ~(1 << unit); - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, nv30->screen->rankine, NV34TCL_TX_ENABLE(unit), 1); so_data (so, 0); so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);src/gallium/drivers/nv30/nv30_screen.c +1
-2@@ -233,7 +233,6 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->rankine, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);@@ -270,7 +269,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static rankine initialisation */ - so = so_new(128, 0); + so = so_new(36, 60, 0); so_method(so, screen->rankine, NV34TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->rankine, NV34TCL_DMA_TEXTURE0, 2);src/gallium/drivers/nv30/nv30_state.c +3
-3@@ -14,7 +14,7 @@ nv30_blend_state_create(struct pipe_context *pipe, struct nv30_context *nv30 = nv30_context(pipe); struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv30_blend_state *bso = CALLOC(1, sizeof(*bso)); - struct nouveau_stateobj *so = so_new(16, 0); + struct nouveau_stateobj *so = so_new(5, 8, 0); if (cso->blend_enable) { so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 3);@@ -300,7 +300,7 @@ nv30_rasterizer_state_create(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(9, 19, 0); struct nouveau_grobj *rankine = nv30->screen->rankine; /*XXX: ignored:@@ -435,7 +435,7 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(5, 21, 0); struct nouveau_grobj *rankine = nv30->screen->rankine; so_method(so, rankine, NV34TCL_DEPTH_FUNC, 3);src/gallium/drivers/nv30/nv30_state_blend.c +0
-0@@ -18,7 +18,7 @@ struct nv30_state_entry nv30_state_blend = {static boolean
nv30_state_blend_colour_validate(struct nv30_context *nv30){
- structnouveau_stateobj*so =so_new(2, 0);
+ structnouveau_stateobj*so =so_new(1, 1, 0); structpipe_blend_color*bcol =&nv30->blend_colour;so_method(so,
nv30->screen->rankine,NV34TCL_BLEND_COLOR, 1);src/gallium/drivers/nv30/nv30_state_fb.c +1
-1@@ -10,7 +10,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) struct nv04_surface *rt[2], *zeta = NULL; uint32_t rt_enable = 0, rt_format = 0; int i, colour_format = 0, zeta_format = 0, depth_only = 0; - struct nouveau_stateobj *so = so_new(64, 10); + struct nouveau_stateobj *so = so_new(12, 18, 10); unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM; unsigned w = fb->width; unsigned h = fb->height;src/gallium/drivers/nv30/nv30_state_scissor.c +1
-1@@ -12,7 +12,7 @@ nv30_state_scissor_validate(struct nv30_context *nv30) return FALSE; nv30->state.scissor_enabled = rast->scissor; - so = so_new(3, 0); + so = so_new(1, 2, 0); so_method(so, nv30->screen->rankine, NV34TCL_SCISSOR_HORIZ, 2); if (nv30->state.scissor_enabled) { so_data (so, ((s->maxx - s->minx) << 16) | s->minx);src/gallium/drivers/nv30/nv30_state_stipple.c +2
-2@@ -14,14 +14,14 @@ nv30_state_stipple_validate(struct nv30_context *nv30) if (rast->poly_stipple_enable) { unsigned i; - so = so_new(35, 0); + so = so_new(2, 33, 0); so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 1); so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32); for (i = 0; i < 32; i++) so_data(so, nv30->stipple[i]); } else { - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 0); }src/gallium/drivers/nv30/nv30_state_viewport.c +1
-1@@ -19,7 +19,7 @@ nv30_state_viewport_validate(struct nv30_context *nv30) return FALSE; nv30->state.viewport_bypass = bypass; - so = so_new(11, 0); + so = so_new(3, 10, 0); if (!bypass) { so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_TRANSLATE_X, 8);src/gallium/drivers/nv30/nv30_vbo.c +3
-3@@ -495,9 +495,9 @@ nv30_vbo_validate(struct nv30_context *nv30) unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; int hw; - vtxbuf = so_new(20, 18); + vtxbuf = so_new(3, 17, 18); so_method(vtxbuf, rankine, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt_nr); - vtxfmt = so_new(17, 0); + vtxfmt = so_new(1, 16, 0); so_method(vtxfmt, rankine, NV34TCL_VTXFMT(0), nv30->vtxelt_nr); for (hw = 0; hw < nv30->vtxelt_nr; hw++) {@@ -510,7 +510,7 @@ nv30_vbo_validate(struct nv30_context *nv30) if (!vb->stride) { if (!sattr) - sattr = so_new(16 * 5, 0); + sattr = so_new(16, 16 * 4, 0); if (nv30_vbo_static_attrib(nv30, sattr, hw, ve, vb)) { so_data(vtxbuf, 0);src/gallium/drivers/nv30/nv30_vertprog.c +1
-1@@ -686,7 +686,7 @@ nv30_vertprog_validate(struct nv30_context *nv30) assert(0); } - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1); so_data (so, vp->exec->start); so_ref(so, &vp->so);src/gallium/drivers/nv40/nv40_fragprog.c +1
-1@@ -919,7 +919,7 @@ nv40_fragprog_validate(struct nv40_context *nv40) fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv40_fragprog_upload(nv40, fp); - so = so_new(4, 1); + so = so_new(2, 2, 1); so_method(so, nv40->screen->curie, NV40TCL_FP_ADDRESS, 1);so_reloc (so,
nouveau_bo(fp->buffer), 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_GART|NOUVEAU_BO_RD|NOUVEAU_BO_LOW|src/gallium/drivers/nv40/nv40_fragtex.c +2
-2@@ -108,7 +108,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit) txs = tf->swizzle; - so = so_new(16, 2); + so = so_new(2, 9, 2); so_method(so, nv40->screen->curie, NV40TCL_TEX_OFFSET(unit), 8); so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,@@ -139,7 +139,7 @@ nv40_fragtex_validate(struct nv40_context *nv40) unit = ffs(samplers) - 1; samplers &= ~(1 << unit); - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, nv40->screen->curie, NV40TCL_TEX_ENABLE(unit), 1); so_data (so, 0); so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);src/gallium/drivers/nv40/nv40_screen.c +1
-2@@ -215,7 +215,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->curie, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);@@ -252,7 +251,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static curie initialisation */ - so = so_new(128, 0); + so = so_new(16, 25, 0); so_method(so, screen->curie, NV40TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->curie, NV40TCL_DMA_TEXTURE0, 2);src/gallium/drivers/nv40/nv40_state.c +3
-3@@ -16,7 +16,7 @@ nv40_blend_state_create(struct pipe_context *pipe, struct nv40_context *nv40 = nv40_context(pipe); struct nouveau_grobj *curie = nv40->screen->curie; struct nv40_blend_state *bso = CALLOC(1, sizeof(*bso)); - struct nouveau_stateobj *so = so_new(16, 0); + struct nouveau_stateobj *so = so_new(5, 8, 0); if (cso->blend_enable) { so_method(so, curie, NV40TCL_BLEND_ENABLE, 3);@@ -310,7 +310,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe, { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(8, 18, 0); struct nouveau_grobj *curie = nv40->screen->curie; /*XXX: ignored:@@ -445,7 +445,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(4, 21, 0); struct nouveau_grobj *curie = nv40->screen->curie; so_method(so, curie, NV40TCL_DEPTH_FUNC, 3);src/gallium/drivers/nv40/nv40_state_blend.c +0
-0@@ -18,7 +18,7 @@ struct nv40_state_entry nv40_state_blend = {static boolean
nv40_state_blend_colour_validate(struct nv40_context *nv40){
- structnouveau_stateobj*so =so_new(2, 0);
+ structnouveau_stateobj*so =so_new(1, 1, 0); structpipe_blend_color*bcol =&nv40->blend_colour;so_method(so,
nv40->screen->curie,NV40TCL_BLEND_COLOR, 1);src/gallium/drivers/nv40/nv40_state_fb.c +1
-1@@ -19,7 +19,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40) struct nv04_surface *rt[4], *zeta; uint32_t rt_enable, rt_format; int i, colour_format = 0, zeta_format = 0; - struct nouveau_stateobj *so = so_new(64, 10); + struct nouveau_stateobj *so = so_new(18, 24, 10); unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM; unsigned w = fb->width; unsigned h = fb->height;src/gallium/drivers/nv40/nv40_state_scissor.c +1
-1@@ -12,7 +12,7 @@ nv40_state_scissor_validate(struct nv40_context *nv40) return FALSE; nv40->state.scissor_enabled = rast->scissor; - so = so_new(3, 0); + so = so_new(1, 2, 0); so_method(so, nv40->screen->curie, NV40TCL_SCISSOR_HORIZ, 2); if (nv40->state.scissor_enabled) { so_data (so, ((s->maxx - s->minx) << 16) | s->minx);src/gallium/drivers/nv40/nv40_state_stipple.c +2
-2@@ -14,14 +14,14 @@ nv40_state_stipple_validate(struct nv40_context *nv40) if (rast->poly_stipple_enable) { unsigned i; - so = so_new(35, 0); + so = so_new(2, 33, 0); so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 1); so_method(so, curie, NV40TCL_POLYGON_STIPPLE_PATTERN(0), 32); for (i = 0; i < 32; i++) so_data(so, nv40->stipple[i]); } else { - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 0); }src/gallium/drivers/nv40/nv40_state_viewport.c +1
-1@@ -19,7 +19,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40) return FALSE; nv40->state.viewport_bypass = bypass; - so = so_new(11, 0); + so = so_new(2, 9, 0); if (!bypass) { so_method(so, nv40->screen->curie, NV40TCL_VIEWPORT_TRANSLATE_X, 8);src/gallium/drivers/nv40/nv40_vbo.c +3
-3@@ -494,9 +494,9 @@ nv40_vbo_validate(struct nv40_context *nv40) unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; int hw; - vtxbuf = so_new(20, 18); + vtxbuf = so_new(3, 17, 18); so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt_nr); - vtxfmt = so_new(17, 0); + vtxfmt = so_new(1, 16, 0); so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt_nr); for (hw = 0; hw < nv40->vtxelt_nr; hw++) {@@ -509,7 +509,7 @@ nv40_vbo_validate(struct nv40_context *nv40) if (!vb->stride) { if (!sattr) - sattr = so_new(16 * 5, 0); + sattr = so_new(16, 16 * 4, 0); if (nv40_vbo_static_attrib(nv40, sattr, hw, ve, vb)) { so_data(vtxbuf, 0);src/gallium/drivers/nv40/nv40_vertprog.c +1
-1@@ -886,7 +886,7 @@ check_gpu_resources: assert(0); } - so = so_new(7, 0); + so = so_new(3, 4, 0); so_method(so, curie, NV40TCL_VP_START_FROM_ID, 1); so_data (so, vp->exec->start); so_method(so, curie, NV40TCL_VP_ATTRIB_EN, 2);src/gallium/drivers/nv50/nv50_program.c +1
-1@@ -3452,7 +3452,7 @@ nv50_vertprog_validate(struct nv50_context *nv50) nv50_program_validate_data(nv50, p); nv50_program_validate_code(nv50, p); - so = so_new(13, 2); + so = so_new(5, 8, 2); so_method(so, tesla, NV50TCL_VP_ADDRESS_HIGH, 2);so_reloc (so,
p->bo, 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_RD|NOUVEAU_BO_HIGH, 0, 0);src/gallium/drivers/nv50/nv50_program.c +1
-1@@ -3488,7 +3488,7 @@ nv50_fragprog_validate(struct nv50_context *nv50) nv50_program_validate_data(nv50, p); nv50_program_validate_code(nv50, p); - so = so_new(64, 2); + so = so_new(6, 7, 2); so_method(so, tesla, NV50TCL_FP_ADDRESS_HIGH, 2);so_reloc (so,
p->bo, 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_RD|NOUVEAU_BO_HIGH, 0, 0);src/gallium/drivers/nv50/nv50_program.c +1
-1@@ -3656,7 +3656,7 @@ nv50_linkage_validate(struct nv50_context *nv50) } /* now fill the stateobj */ - so = so_new(64, 0); + so = so_new(6, 58, 0); n = (m + 3) / 4; so_method(so, tesla, NV50TCL_VP_RESULT_MAP_SIZE, 1);src/gallium/drivers/nv50/nv50_screen.c +3
-6@@ -251,7 +251,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } - BIND_RING(chan, screen->m2mf, 1); /* 2D object */ ret = nouveau_grobj_alloc(chan, 0xbeef502d, NV50_2D, &screen->eng2d);@@ -260,7 +259,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } - BIND_RING(chan, screen->eng2d, 2); /* 3D object */ switch (chipset & 0xf0) {@@ -296,7 +294,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } - BIND_RING(chan, screen->tesla, 3); /* Sync notifier */ ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);@@ -307,7 +304,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static M2MF init */ - so = so_new(32, 0); + so = so_new(1, 3, 0); so_method(so, screen->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3); so_data (so, screen->sync->handle); so_data (so, chan->vram->handle);@@ -316,7 +313,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_ref (NULL, &so); /* Static 2D init */ - so = so_new(64, 0); + so = so_new(4, 7, 0); so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4); so_data (so, screen->sync->handle); so_data (so, chan->vram->handle);@@ -332,7 +329,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_ref(NULL, &so); /* Static tesla init */ - so = so_new(256, 20); + so = so_new(40, 84, 20); so_method(so, screen->tesla, NV50TCL_COND_MODE, 1); so_data (so, NV50TCL_COND_MODE_ALWAYS);src/gallium/drivers/nv50/nv50_state.c +2
-2@@ -35,7 +35,7 @@ static void * nv50_blend_state_create(struct pipe_context *pipe, const struct pipe_blend_state *cso) { - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(5, 24, 0); struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla; struct nv50_blend_stateobj *bso = CALLOC_STRUCT(nv50_blend_stateobj); unsigned cmask = 0, i;@@ -280,7 +280,7 @@ static void * nv50_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) { - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(15, 21, 0); struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla;struct
nv50_rasterizer_stateobj*rso =CALLOC_STRUCT(nv50_rasterizer_stateobj);src/gallium/drivers/nv50/nv50_state.c +1
-1@@ -425,7 +425,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla; struct nv50_zsa_stateobj *zsa = CALLOC_STRUCT(nv50_zsa_stateobj); - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(8, 22, 0); so_method(so, tesla, NV50TCL_DEPTH_WRITE_ENABLE, 1); so_data (so, cso->depth.writemask ? 1 : 0);src/gallium/drivers/nv50/nv50_state_validate.c +7
-6@@ -33,7 +33,7 @@ static void nv50_state_validate_fb(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nouveau_stateobj *so = so_new(128, 18); + struct nouveau_stateobj *so = so_new(32, 79, 18); struct pipe_framebuffer_state *fb = &nv50->framebuffer; unsigned i, w, h, gw = 0;@@ -299,7 +299,7 @@ nv50_state_validate(struct nv50_context *nv50) so_ref(nv50->rasterizer->so, &nv50->state.rast); if (nv50->dirty & NV50_NEW_BLEND_COLOUR) { - so = so_new(5, 0); + so = so_new(1, 4, 0); so_method(so, tesla, NV50TCL_BLEND_COLOR(0), 4); so_data (so, fui(nv50->blend_colour.color[0])); so_data (so, fui(nv50->blend_colour.color[1]));@@ -310,7 +310,7 @@ nv50_state_validate(struct nv50_context *nv50) } if (nv50->dirty & NV50_NEW_STIPPLE) { - so = so_new(33, 0); + so = so_new(1, 32, 0); so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_PATTERN(0), 32); for (i = 0; i < 32; i++) so_data(so, util_bswap32(nv50->stipple.stipple[i]));@@ -327,7 +327,7 @@ nv50_state_validate(struct nv50_context *nv50) goto scissor_uptodate; nv50->state.scissor_enabled = rast->scissor; - so = so_new(3, 0); + so = so_new(1, 2, 0); so_method(so, tesla, NV50TCL_SCISSOR_HORIZ(0), 2); if (nv50->state.scissor_enabled) { so_data(so, (s->maxx << 16) | s->minx);@@ -356,7 +356,7 @@ scissor_uptodate: goto viewport_uptodate; nv50->state.viewport_bypass = bypass; - so = so_new(14, 0); + so = so_new(5, 9, 0); if (!bypass) { so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE_X(0), 3); so_data (so, fui(nv50->viewport.translate[0]));@@ -400,7 +400,8 @@ viewport_uptodate: for (i = 0; i < PIPE_SHADER_TYPES; ++i) nr += nv50->sampler_nr[i]; - so = so_new(nr * 8 + 24 * PIPE_SHADER_TYPES + 2, 4); + so = so_new(1+ 5 * PIPE_SHADER_TYPES, 1+ 19 * PIPE_SHADER_TYPES + + nr * 8, PIPE_SHADER_TYPES * 2); nv50_validate_samplers(nv50, so, PIPE_SHADER_VERTEX); nv50_validate_samplers(nv50, so, PIPE_SHADER_FRAGMENT);src/gallium/drivers/nv50/nv50_tex.c +6
-4@@ -199,16 +199,18 @@ nv50_tex_validate(struct nv50_context *nv50) { struct nouveau_stateobj *so; struct nouveau_grobj *tesla = nv50->screen->tesla; - unsigned p, push, nrlc; + unsigned p, start, push, nrlc; - for (nrlc = 0, push = 0, p = 0; p < PIPE_SHADER_TYPES; ++p) { + for (nrlc = 0, start = 0, push = 0, p = 0; p < PIPE_SHADER_TYPES; ++p) { + start += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]); push += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]); nrlc += nv50->miptree_nr[p]; } - push = push * 11 + 23 * PIPE_SHADER_TYPES + 4; + start = start * 2 + 4 * PIPE_SHADER_TYPES + 2; + push = push * 9 + 19 * PIPE_SHADER_TYPES + 2; nrlc = nrlc * 2 + 2 * PIPE_SHADER_TYPES; - so = so_new(push, nrlc); + so = so_new(start, push, nrlc);if (
nv50_validate_textures(nv50, so, PIPE_SHADER_VERTEX)== FALSE ||nv50_validate_textures(nv50, so, PIPE_SHADER_FRAGMENT)== FALSE) {src/gallium/drivers/nv50/nv50_vbo.c +1
-1@@ -350,7 +350,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib, so = *pso; if (!so) - *pso = so = so_new(nv50->vtxelt_nr * 5, 0); + *pso = so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 4, 0); switch (ve->nr_components) {case 4:
src/gallium/drivers/nv50/nv50_vbo.c +2
-3@@ -411,8 +411,8 @@ nv50_vbo_validate(struct nv50_context *nv50) n_ve = MAX2(nv50->vtxelt_nr, nv50->state.vtxelt_nr); vtxattr = NULL; - vtxbuf = so_new(n_ve * 7, nv50->vtxelt_nr * 4); - vtxfmt = so_new(n_ve + 1, 0); + vtxbuf = so_new(n_ve * 2, n_ve * 5, nv50->vtxelt_nr * 4); + vtxfmt = so_new(1, n_ve, 0); so_method(vtxfmt, tesla, NV50TCL_VERTEX_ARRAY_ATTRIB(0), n_ve); for (i = 0; i < nv50->vtxelt_nr; i++) { --1.6.6.rc4
A message that is not in the archive (sent off-list or not yet received): 6d4bc9fc0912301339l6e639d46oef3bab28dad70e15-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/3] nouveau: rewrite nouveau_stateobj to use BEGIN_RING properly
If anyone experiences a sustained performance loss of more than 1%, then i'm curious how much it is, if it can be reproduced with something free, even better :-)
Quoted 1,123 lines · Maarten Maathuis
The prerequisite patch (which kills
nouveau_push) got stuck in queue because of it's size.This patch is here for discussion, and it needs testing on nv30/nv40 for miscalculated so sizes.
Quoted 1,115 lines · Maarten Maathuis
- The previous solution was hacky and didn't do subchannel autobinding.
- The beheaviour should match whatlibdrm_nouveaudoes closely.
- There appears to be a minor performance loss, probably due to having multiple memcpy's instead of one.
- The solution remains statically sized, but when debugging is on it will check for abuse.
- The values for nv30/nv40 may be off, but this should be easily caught with DEBUG on.Signed-off-by Maarten Maathuis <[email protected]>---
src/gallium/drivers/nouveau/nouveau_stateobj.h | 289 +++++++++++++++++-------src/gallium/drivers/nv04/nv04_screen.c | 2 - src/gallium/drivers/nv10/nv10_screen.c | 1 - src/gallium/drivers/nv20/nv20_screen.c | 1 -src/gallium/drivers/nv30/nv30_fragprog.c | 2 +-
src/gallium/drivers/nv30/nv30_fragtex.c| 4 +-src/gallium/drivers/nv30/nv30_screen.c| 3 +-src/gallium/drivers/nv30/nv30_state.c| 6 +-src/gallium/drivers/nv30/nv30_state_blend.c| 2 +-src/gallium/drivers/nv30/nv30_state_fb.c| 2 +-src/gallium/drivers/nv30/nv30_state_scissor.c| 2 +-src/gallium/drivers/nv30/nv30_state_stipple.c| 4 +-src/gallium/drivers/nv30/nv30_state_viewport.c| 2 +-src/gallium/drivers/nv30/nv30_vbo.c| 6 +-src/gallium/drivers/nv30/nv30_vertprog.c| 2 +-src/gallium/drivers/nv40/nv40_fragprog.c| 2 +-src/gallium/drivers/nv40/nv40_fragtex.c| 4 +-src/gallium/drivers/nv40/nv40_screen.c| 3 +-src/gallium/drivers/nv40/nv40_state.c| 6 +-src/gallium/drivers/nv40/nv40_state_blend.c| 2 +-src/gallium/drivers/nv40/nv40_state_fb.c| 2 +-src/gallium/drivers/nv40/nv40_state_scissor.c| 2 +-src/gallium/drivers/nv40/nv40_state_stipple.c| 4 +-src/gallium/drivers/nv40/nv40_state_viewport.c| 2 +-src/gallium/drivers/nv40/nv40_vbo.c| 6 +-src/gallium/drivers/nv40/nv40_vertprog.c| 2 +-src/gallium/drivers/nv50/nv50_program.c| 6 +-src/gallium/drivers/nv50/nv50_screen.c| 9 +-src/gallium/drivers/nv50/nv50_state.c| 6 +-src/gallium/drivers/nv50/nv50_state_validate.c| 13 +-src/gallium/drivers/nv50/nv50_tex.c| 10 +-src/gallium/drivers/nv50/nv50_vbo.c| 6 +-32 files changed, 266 insertions(+), 147 deletions(-)src/gallium/drivers/nouveau/nouveau_stateobj.h +49
-6@@ -3,41 +3,96 @@ #include "util/u_debug.h" +#ifdef DEBUG +#define DEBUG_NOUVEAU_STATEOBJ +#endif /* DEBUG */ + struct nouveau_stateobj_reloc { struct nouveau_bo *bo; - unsigned offset; - unsigned packet; + struct nouveau_grobj *gr; + uint32_t push_offset; + uint32_t mthd; - unsigned data; + uint32_t data; unsigned flags; unsigned vor; unsigned tor; }; +struct nouveau_stateobj_start { + struct nouveau_grobj *gr; + uint32_t mthd; + uint32_t size; + unsigned offset; +}; + struct nouveau_stateobj { struct pipe_reference reference; - unsigned *push; + struct nouveau_stateobj_start *start; struct nouveau_stateobj_reloc *reloc; - unsigned *cur; - unsigned cur_packet; + /* Common memory pool for data. */ + uint32_t *pool; + unsigned pool_cur; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + unsigned start_alloc; + unsigned reloc_alloc; + unsigned pool_alloc; +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + unsigned total; /* includes begin_ring */ + unsigned cur; /* excludes begin_ring, offset from "cur_start" */ + unsigned cur_start; unsigned cur_reloc; }; +static INLINE void +so_dump (struct nouveau_stateobj *so) +{ + unsigned i, nr, total = 0; + + for (i = 0; i < so->cur_start; i++) { + if (so->start[i].gr->subc > -1) + debug_printf("+0x%04x: 0x%08x\n", total++, + (so->start[i].size << 18) | (so->start[i].gr->subc << 13) + | so->start[i].mthd); + else + debug_printf("+0x%04x: 0x%08x\n", total++, + (so->start[i].size << 18) | so->start[i].mthd); + for (nr = 0; nr < so->start[i].size; nr++, total++) + debug_printf("+0x%04x: 0x%08x\n", total, + so->pool[so->start[i].offset + nr]); + } +} + +/* Arguments are ignored, dynamic allocation. */ static INLINE struct
nouveau_stateobj*src/gallium/drivers/nouveau/nouveau_stateobj.h +1
-1-so_new(unsigned push, unsigned reloc) +so_new(unsigned start, unsigned push, unsigned reloc){
structnouveau_stateobj*so;so =
MALLOC(sizeof(struct nouveau_stateobj));pipe_reference_init(&so->reference, 1);
-so->push=MALLOC(sizeof(unsigned) * push);
-so->reloc=MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc);src/gallium/drivers/nouveau/nouveau_stateobj.h +17
-3- - so->cur = so->push; - so->cur_reloc = so->cur_packet = 0; + so->total = so->cur = so->cur_start = so->cur_reloc = 0; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + so->start_alloc = start; + so->reloc_alloc = reloc; + so->pool_alloc = push; +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->start = MALLOC(start * sizeof(struct nouveau_stateobj_start)); + so->reloc = MALLOC(reloc * sizeof(struct nouveau_stateobj_reloc)); + so->pool = MALLOC(push * sizeof(uint32_t)); + so->pool_cur = 0; + + if (!so->start || !so->reloc || !so->pool) { + debug_printf("malloc failed\n"); + assert(0); + }return so;
}src/gallium/drivers/nouveau/nouveau_stateobj.h +5
-4@@ -48,54 +103,115 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso) struct nouveau_stateobj *so = *pso; int i; - if (pipe_reference(&(*pso)->reference, &ref->reference)) { - free(so->push); + if (pipe_reference(&(*pso)->reference, &ref->reference)) { + FREE(so->start); for (i = 0; i < so->cur_reloc; i++) nouveau_bo_ref(NULL, &so->reloc[i].bo); - free(so->reloc); - free(so); + FREE(so->reloc); + FREE(so->pool); + FREE(so); } *pso = ref; }static INLINE void
src/gallium/drivers/nouveau/nouveau_stateobj.h +1
-1-so_data(struct nouveau_stateobj *so, unsigned data) +so_data(struct nouveau_stateobj *so, uint32_t data){
- (*so->cur++) = (data);
-so->cur_packet+= 4;src/gallium/drivers/nouveau/nouveau_stateobj.h +8
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->cur >= so->start[so->cur_start - 1].size) { + debug_printf("exceeding specified size\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->pool[so->start[so->cur_start - 1].offset + so->cur++] = data;}
static INLINE void
src/gallium/drivers/nouveau/nouveau_stateobj.h +1
-1-so_datap(struct nouveau_stateobj *so, unsigned *data, unsigned size) +so_datap(struct nouveau_stateobj *so, uint32_t *data, unsigned size){
-so->cur_packet+= (4 * size);src/gallium/drivers/nouveau/nouveau_stateobj.h +7
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if ((so->cur + size) > so->start[so->cur_start - 1].size) { + debug_printf("exceeding specified size\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ +while (size--)
- (*so->cur++) = (*data++);
+ so->pool[so->start[so->cur_start - 1].offset + so->cur++] =
+ *data++;
}static INLINE void
so_method(structnouveau_stateobj*so, structnouveau_grobj*gr, unsigned mthd, unsigned size)
{
-so->cur_packet= (gr->subc<< 13) | (1 << 18) | (mthd - 4);
-so_data(so, (gr->subc << 13) | (size << 18) | mthd);
+ structnouveau_stateobj_start*start;src/gallium/drivers/nouveau/nouveau_stateobj.h +35
-0+ +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->start_alloc <= so->cur_start) { + debug_printf("exceeding num_start size\n"); + assert(0); + } else +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + start = so->start; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->cur_start > 0 && start[so->cur_start - 1].size > so->cur) { + debug_printf("previous so_method was not filled\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->start = start; + start[so->cur_start].gr = gr; + start[so->cur_start].mthd = mthd; + start[so->cur_start].size = size; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->pool_alloc < (size + so->pool_cur)) { + debug_printf("exceeding num_pool size\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + start[so->cur_start].offset = so->pool_cur; + so->pool_cur += size; + + so->cur_start++; + /* The 1 is for *this* begin_ring. */ + so->total += so->cur + 1; + so->cur = 0;}
static INLINE void
so_reloc(structnouveau_stateobj*so, structnouveau_bo*bo, unsigned data, unsigned flags, unsigned vor, unsigned tor) {
- structnouveau_stateobj_reloc*r = &so->reloc[so->cur_reloc++];src/gallium/drivers/nouveau/nouveau_stateobj.h +22
-9- - r->bo = NULL; - nouveau_bo_ref(bo, &r->bo); - r->offset = so->cur - so->push; - r->packet = so->cur_packet; - r->data = data; - r->flags = flags; - r->vor = vor; - r->tor = tor; + struct nouveau_stateobj_reloc *r; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->reloc_alloc <= so->cur_reloc) { + debug_printf("exceeding num_reloc size\n"); + assert(0); + } else +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + r = so->reloc; + + so->reloc = r; + r[so->cur_reloc].bo = NULL; + nouveau_bo_ref(bo, &(r[so->cur_reloc].bo)); + r[so->cur_reloc].gr = so->start[so->cur_start-1].gr; + r[so->cur_reloc].push_offset = so->total + so->cur; + r[so->cur_reloc].data = data; + r[so->cur_reloc].flags = flags; + r[so->cur_reloc].mthd = so->start[so->cur_start-1].mthd + + (so->cur << 2); + r[so->cur_reloc].vor = vor; + r[so->cur_reloc].tor = tor; +so_data(so, data);
+ so->cur_reloc++;
}/* Determine if this buffer object is referenced by this state object. */
src/gallium/drivers/nouveau/nouveau_stateobj.h +0
-0@@ -112,90 +228,99 @@ so_bo_is_reloc(struct nouveau_stateobj *so, struct nouveau_bo *bo) }static INLINE void
src/gallium/drivers/nouveau/nouveau_stateobj.h +0
-9-so_dump(struct nouveau_stateobj *so) -{ - unsigned i, nr = so->cur - so->push; - - for (i = 0; i < nr; i++) - debug_printf("+0x%04x: 0x%08x\n", i, so->push[i]); -} - -static INLINE voidso_emit(struct
nouveau_channel*chan, structnouveau_stateobj*so) {
structnouveau_pushbuf*pb =chan->pushbuf; unsigned nr, i;
int ret = 0;- nr =
so->cur-so->push;src/gallium/drivers/nouveau/nouveau_stateobj.h +10
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->start[so->cur_start - 1].size > so->cur) { + debug_printf("emit: previous so_method was not filled\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + /* We cannot update total in case we so_emit again. */ + nr = so->total + so->cur; +/* This will flush if we need space.
* We don't actually need the marker.
*/
if ((ret =nouveau_pushbuf_marker_emit(chan, nr, so->cur_reloc))) {debug_printf("so_emit failed marker emit with error %d\n", ret);
- return;
+ assert(0);
+ }
+
+ /* Submit data. This will ensure proper binding of objects. */
+ for (i = 0; i <so->cur_start; i++) {
+BEGIN_RING(chan, so->start[i].gr, so->start[i].mthd, so->start[i].size);
+OUT_RINGp(chan, &(so->pool[so->start[i].offset]), so->start[i].size); }
-pb->remaining-= nr;-
memcpy(pb->cur, so->push, nr * 4);
for (i = 0; i <so->cur_reloc; i++) {
structnouveau_stateobj_reloc*r = &so->reloc[i];- if ((ret = nouveau_pushbuf_emit_reloc(chan,
pb->cur+r->offset,
- r->bo,r->data, 0,r->flags,
- r->vor,r->tor))) {
+ if ((ret = nouveau_pushbuf_emit_reloc(chan,pb->cur- nr +
+r->push_offset,r->bo,r->data,
+ 0,r->flags,r->vor,r->tor))) {debug_printf("so_emit failed reloc with error %d\n", ret);
- goto out;
+ assert(0);
}
}
-out:
-pb->cur+= nr;
}static INLINE void
so_emit_reloc_markers(structnouveau_channel*chan, structnouveau_stateobj*so) {
structnouveau_pushbuf*pb =chan->pushbuf;
+ structnouveau_grobj*gr = NULL;
unsigned i;
int ret = 0;if (!so)
return;- i =
so->cur_reloc<< 1;
- /* This will flush if we need space.
- * We don't actually need the marker.
- */
- if ((ret =nouveau_pushbuf_marker_emit(chan, i, i))) {
- debug_printf("so_emit_reloc_markers failed marker emit with" \
- "error %d\n", ret);
- return;
- }
-pb->remaining-= i;
-
+ /* If we need to flush in flush notify, then we have a problem anyway. */ for (i = 0; i <so->cur_reloc; i++) {
structnouveau_stateobj_reloc*r = &so->reloc[i];- if ((ret = nouveau_pushbuf_emit_reloc(chan, pb->cur++,
r->bo,
- r->packet, 0,
- (r->flags & (NOUVEAU_BO_VRAM|
-NOUVEAU_BO_GART|
-NOUVEAU_BO_RDWR)) |
- NOUVEAU_BO_DUMMY, 0, 0))) {
- debug_printf("so_emit_reloc_markers failed reloc" \
- "with error %d\n", ret);
-pb->remaining+= ((so->cur_reloc- i) << 1);
- return;src/gallium/drivers/nouveau/nouveau_stateobj.h +26
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if (r->mthd & 0x40000000) { + debug_printf("error: NI mthd 0x%08X\n", r->mthd); + continue; + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + /* The object needs to be bound and the system must know the + * subchannel is being used. Otherwise it will discard it. + */ + if (gr != r->gr) { + BEGIN_RING(chan, r->gr, 0x100, 1); + OUT_RING(chan, 0); + gr = r->gr; + } + + /* Some relocs really don't like to be hammered, + * NOUVEAU_BO_DUMMY makes sure it only + * happens when needed. + */ + ret = OUT_RELOC(chan, r->bo, (r->gr->subc << 13) | (1<< 18) | + r->mthd, (r->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART + | NOUVEAU_BO_RDWR)) | NOUVEAU_BO_DUMMY, 0, 0); + if (ret) { + debug_printf("OUT_RELOC failed %d\n", ret); + assert(0);}
- if ((ret = nouveau_pushbuf_emit_reloc(chan, pb->cur++,r->bo,
- r->data, 0,
- r->flags |NOUVEAU_BO_DUMMY,
- r->vor,r->tor))) {
- debug_printf("so_emit_reloc_markers failed reloc" \
- "with error %d\n", ret);
-pb->remaining+= ((so->cur_reloc- i) << 1) - 1;
- return;
+
+ ret = OUT_RELOC(chan,r->bo,r->data,r->flags|
+NOUVEAU_BO_DUMMY,r->vor,r->tor);
+ if (ret) {
+debug_printf("OUT_RELOC failed %d\n", ret);
+ assert(0);
}
+
+pb->remaining-= 2;
}
}src/gallium/drivers/nv04/nv04_screen.c +0
-2@@ -184,7 +184,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return NULL; } - BIND_RING(chan, screen->fahrenheit, 7); /* 3D surface object */ ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class,@@ -193,7 +192,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D surface object: %d\n", ret); return NULL; } - BIND_RING(chan, screen->context_surfaces_3d, 6); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);src/gallium/drivers/nv10/nv10_screen.c +0
-1@@ -180,7 +180,6 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->celsius, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);src/gallium/drivers/nv20/nv20_screen.c +0
-1@@ -176,7 +176,6 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->kelvin, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);src/gallium/drivers/nv30/nv30_fragprog.c +1
-1@@ -837,7 +837,7 @@ nv30_fragprog_validate(struct nv30_context *nv30) fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv30_fragprog_upload(nv30, fp); - so = so_new(8, 1); + so = so_new(4, 4, 1); so_method(so, nv30->screen->rankine, NV34TCL_FP_ACTIVE_PROGRAM, 1);so_reloc (so,
nouveau_bo(fp->buffer), 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_GART|NOUVEAU_BO_RD|NOUVEAU_BO_LOW|src/gallium/drivers/nv30/nv30_fragtex.c +2
-2@@ -106,7 +106,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit) txs = tf->swizzle; - so = so_new(16, 2); + so = so_new(1, 8, 2); so_method(so, nv30->screen->rankine, NV34TCL_TX_OFFSET(unit), 8); so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,@@ -135,7 +135,7 @@ nv30_fragtex_validate(struct nv30_context *nv30) unit = ffs(samplers) - 1; samplers &= ~(1 << unit); - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, nv30->screen->rankine, NV34TCL_TX_ENABLE(unit), 1); so_data (so, 0); so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);src/gallium/drivers/nv30/nv30_screen.c +1
-2@@ -233,7 +233,6 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->rankine, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);@@ -270,7 +269,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static rankine initialisation */ - so = so_new(128, 0); + so = so_new(36, 60, 0); so_method(so, screen->rankine, NV34TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->rankine, NV34TCL_DMA_TEXTURE0, 2);src/gallium/drivers/nv30/nv30_state.c +3
-3@@ -14,7 +14,7 @@ nv30_blend_state_create(struct pipe_context *pipe, struct nv30_context *nv30 = nv30_context(pipe); struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv30_blend_state *bso = CALLOC(1, sizeof(*bso)); - struct nouveau_stateobj *so = so_new(16, 0); + struct nouveau_stateobj *so = so_new(5, 8, 0); if (cso->blend_enable) { so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 3);@@ -300,7 +300,7 @@ nv30_rasterizer_state_create(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(9, 19, 0); struct nouveau_grobj *rankine = nv30->screen->rankine; /*XXX: ignored:@@ -435,7 +435,7 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(5, 21, 0); struct nouveau_grobj *rankine = nv30->screen->rankine; so_method(so, rankine, NV34TCL_DEPTH_FUNC, 3);src/gallium/drivers/nv30/nv30_state_blend.c +0
-0@@ -18,7 +18,7 @@ struct nv30_state_entry nv30_state_blend = {static boolean
nv30_state_blend_colour_validate(struct nv30_context *nv30){
- structnouveau_stateobj*so =so_new(2, 0);
+ structnouveau_stateobj*so =so_new(1, 1, 0); structpipe_blend_color*bcol =&nv30->blend_colour;so_method(so,
nv30->screen->rankine,NV34TCL_BLEND_COLOR, 1);src/gallium/drivers/nv30/nv30_state_fb.c +1
-1@@ -10,7 +10,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) struct nv04_surface *rt[2], *zeta = NULL; uint32_t rt_enable = 0, rt_format = 0; int i, colour_format = 0, zeta_format = 0, depth_only = 0; - struct nouveau_stateobj *so = so_new(64, 10); + struct nouveau_stateobj *so = so_new(12, 18, 10); unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM; unsigned w = fb->width; unsigned h = fb->height;src/gallium/drivers/nv30/nv30_state_scissor.c +1
-1@@ -12,7 +12,7 @@ nv30_state_scissor_validate(struct nv30_context *nv30) return FALSE; nv30->state.scissor_enabled = rast->scissor; - so = so_new(3, 0); + so = so_new(1, 2, 0); so_method(so, nv30->screen->rankine, NV34TCL_SCISSOR_HORIZ, 2); if (nv30->state.scissor_enabled) { so_data (so, ((s->maxx - s->minx) << 16) | s->minx);src/gallium/drivers/nv30/nv30_state_stipple.c +2
-2@@ -14,14 +14,14 @@ nv30_state_stipple_validate(struct nv30_context *nv30) if (rast->poly_stipple_enable) { unsigned i; - so = so_new(35, 0); + so = so_new(2, 33, 0); so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 1); so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32); for (i = 0; i < 32; i++) so_data(so, nv30->stipple[i]); } else { - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 0); }src/gallium/drivers/nv30/nv30_state_viewport.c +1
-1@@ -19,7 +19,7 @@ nv30_state_viewport_validate(struct nv30_context *nv30) return FALSE; nv30->state.viewport_bypass = bypass; - so = so_new(11, 0); + so = so_new(3, 10, 0); if (!bypass) { so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_TRANSLATE_X, 8);src/gallium/drivers/nv30/nv30_vbo.c +3
-3@@ -495,9 +495,9 @@ nv30_vbo_validate(struct nv30_context *nv30) unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; int hw; - vtxbuf = so_new(20, 18); + vtxbuf = so_new(3, 17, 18); so_method(vtxbuf, rankine, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt_nr); - vtxfmt = so_new(17, 0); + vtxfmt = so_new(1, 16, 0); so_method(vtxfmt, rankine, NV34TCL_VTXFMT(0), nv30->vtxelt_nr); for (hw = 0; hw < nv30->vtxelt_nr; hw++) {@@ -510,7 +510,7 @@ nv30_vbo_validate(struct nv30_context *nv30) if (!vb->stride) { if (!sattr) - sattr = so_new(16 * 5, 0); + sattr = so_new(16, 16 * 4, 0); if (nv30_vbo_static_attrib(nv30, sattr, hw, ve, vb)) { so_data(vtxbuf, 0);src/gallium/drivers/nv30/nv30_vertprog.c +1
-1@@ -686,7 +686,7 @@ nv30_vertprog_validate(struct nv30_context *nv30) assert(0); } - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1); so_data (so, vp->exec->start); so_ref(so, &vp->so);src/gallium/drivers/nv40/nv40_fragprog.c +1
-1@@ -919,7 +919,7 @@ nv40_fragprog_validate(struct nv40_context *nv40) fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv40_fragprog_upload(nv40, fp); - so = so_new(4, 1); + so = so_new(2, 2, 1); so_method(so, nv40->screen->curie, NV40TCL_FP_ADDRESS, 1);so_reloc (so,
nouveau_bo(fp->buffer), 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_GART|NOUVEAU_BO_RD|NOUVEAU_BO_LOW|src/gallium/drivers/nv40/nv40_fragtex.c +2
-2@@ -108,7 +108,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit) txs = tf->swizzle; - so = so_new(16, 2); + so = so_new(2, 9, 2); so_method(so, nv40->screen->curie, NV40TCL_TEX_OFFSET(unit), 8); so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,@@ -139,7 +139,7 @@ nv40_fragtex_validate(struct nv40_context *nv40) unit = ffs(samplers) - 1; samplers &= ~(1 << unit); - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, nv40->screen->curie, NV40TCL_TEX_ENABLE(unit), 1); so_data (so, 0); so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);src/gallium/drivers/nv40/nv40_screen.c +1
-2@@ -215,7 +215,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->curie, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);@@ -252,7 +251,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static curie initialisation */ - so = so_new(128, 0); + so = so_new(16, 25, 0); so_method(so, screen->curie, NV40TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->curie, NV40TCL_DMA_TEXTURE0, 2);src/gallium/drivers/nv40/nv40_state.c +3
-3@@ -16,7 +16,7 @@ nv40_blend_state_create(struct pipe_context *pipe, struct nv40_context *nv40 = nv40_context(pipe); struct nouveau_grobj *curie = nv40->screen->curie; struct nv40_blend_state *bso = CALLOC(1, sizeof(*bso)); - struct nouveau_stateobj *so = so_new(16, 0); + struct nouveau_stateobj *so = so_new(5, 8, 0); if (cso->blend_enable) { so_method(so, curie, NV40TCL_BLEND_ENABLE, 3);@@ -310,7 +310,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe, { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(8, 18, 0); struct nouveau_grobj *curie = nv40->screen->curie; /*XXX: ignored:@@ -445,7 +445,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(4, 21, 0); struct nouveau_grobj *curie = nv40->screen->curie; so_method(so, curie, NV40TCL_DEPTH_FUNC, 3);src/gallium/drivers/nv40/nv40_state_blend.c +0
-0@@ -18,7 +18,7 @@ struct nv40_state_entry nv40_state_blend = {static boolean
nv40_state_blend_colour_validate(struct nv40_context *nv40){
- structnouveau_stateobj*so =so_new(2, 0);
+ structnouveau_stateobj*so =so_new(1, 1, 0); structpipe_blend_color*bcol =&nv40->blend_colour;so_method(so,
nv40->screen->curie,NV40TCL_BLEND_COLOR, 1);src/gallium/drivers/nv40/nv40_state_fb.c +1
-1@@ -19,7 +19,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40) struct nv04_surface *rt[4], *zeta; uint32_t rt_enable, rt_format; int i, colour_format = 0, zeta_format = 0; - struct nouveau_stateobj *so = so_new(64, 10); + struct nouveau_stateobj *so = so_new(18, 24, 10); unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM; unsigned w = fb->width; unsigned h = fb->height;src/gallium/drivers/nv40/nv40_state_scissor.c +1
-1@@ -12,7 +12,7 @@ nv40_state_scissor_validate(struct nv40_context *nv40) return FALSE; nv40->state.scissor_enabled = rast->scissor; - so = so_new(3, 0); + so = so_new(1, 2, 0); so_method(so, nv40->screen->curie, NV40TCL_SCISSOR_HORIZ, 2); if (nv40->state.scissor_enabled) { so_data (so, ((s->maxx - s->minx) << 16) | s->minx);src/gallium/drivers/nv40/nv40_state_stipple.c +2
-2@@ -14,14 +14,14 @@ nv40_state_stipple_validate(struct nv40_context *nv40) if (rast->poly_stipple_enable) { unsigned i; - so = so_new(35, 0); + so = so_new(2, 33, 0); so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 1); so_method(so, curie, NV40TCL_POLYGON_STIPPLE_PATTERN(0), 32); for (i = 0; i < 32; i++) so_data(so, nv40->stipple[i]); } else { - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 0); }src/gallium/drivers/nv40/nv40_state_viewport.c +1
-1@@ -19,7 +19,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40) return FALSE; nv40->state.viewport_bypass = bypass; - so = so_new(11, 0); + so = so_new(2, 9, 0); if (!bypass) { so_method(so, nv40->screen->curie, NV40TCL_VIEWPORT_TRANSLATE_X, 8);src/gallium/drivers/nv40/nv40_vbo.c +3
-3@@ -494,9 +494,9 @@ nv40_vbo_validate(struct nv40_context *nv40) unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; int hw; - vtxbuf = so_new(20, 18); + vtxbuf = so_new(3, 17, 18); so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt_nr); - vtxfmt = so_new(17, 0); + vtxfmt = so_new(1, 16, 0); so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt_nr); for (hw = 0; hw < nv40->vtxelt_nr; hw++) {@@ -509,7 +509,7 @@ nv40_vbo_validate(struct nv40_context *nv40) if (!vb->stride) { if (!sattr) - sattr = so_new(16 * 5, 0); + sattr = so_new(16, 16 * 4, 0); if (nv40_vbo_static_attrib(nv40, sattr, hw, ve, vb)) { so_data(vtxbuf, 0);src/gallium/drivers/nv40/nv40_vertprog.c +1
-1@@ -886,7 +886,7 @@ check_gpu_resources: assert(0); } - so = so_new(7, 0); + so = so_new(3, 4, 0); so_method(so, curie, NV40TCL_VP_START_FROM_ID, 1); so_data (so, vp->exec->start); so_method(so, curie, NV40TCL_VP_ATTRIB_EN, 2);src/gallium/drivers/nv50/nv50_program.c +1
-1@@ -3452,7 +3452,7 @@ nv50_vertprog_validate(struct nv50_context *nv50) nv50_program_validate_data(nv50, p); nv50_program_validate_code(nv50, p); - so = so_new(13, 2); + so = so_new(5, 8, 2); so_method(so, tesla, NV50TCL_VP_ADDRESS_HIGH, 2);so_reloc (so,
p->bo, 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_RD|NOUVEAU_BO_HIGH, 0, 0);src/gallium/drivers/nv50/nv50_program.c +1
-1@@ -3488,7 +3488,7 @@ nv50_fragprog_validate(struct nv50_context *nv50) nv50_program_validate_data(nv50, p); nv50_program_validate_code(nv50, p); - so = so_new(64, 2); + so = so_new(6, 7, 2); so_method(so, tesla, NV50TCL_FP_ADDRESS_HIGH, 2);so_reloc (so,
p->bo, 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_RD|NOUVEAU_BO_HIGH, 0, 0);src/gallium/drivers/nv50/nv50_program.c +1
-1@@ -3656,7 +3656,7 @@ nv50_linkage_validate(struct nv50_context *nv50) } /* now fill the stateobj */ - so = so_new(64, 0); + so = so_new(6, 58, 0); n = (m + 3) / 4; so_method(so, tesla, NV50TCL_VP_RESULT_MAP_SIZE, 1);src/gallium/drivers/nv50/nv50_screen.c +3
-6@@ -251,7 +251,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } - BIND_RING(chan, screen->m2mf, 1); /* 2D object */ ret = nouveau_grobj_alloc(chan, 0xbeef502d, NV50_2D, &screen->eng2d);@@ -260,7 +259,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } - BIND_RING(chan, screen->eng2d, 2); /* 3D object */ switch (chipset & 0xf0) {@@ -296,7 +294,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } - BIND_RING(chan, screen->tesla, 3); /* Sync notifier */ ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);@@ -307,7 +304,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static M2MF init */ - so = so_new(32, 0); + so = so_new(1, 3, 0); so_method(so, screen->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3); so_data (so, screen->sync->handle); so_data (so, chan->vram->handle);@@ -316,7 +313,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_ref (NULL, &so); /* Static 2D init */ - so = so_new(64, 0); + so = so_new(4, 7, 0); so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4); so_data (so, screen->sync->handle); so_data (so, chan->vram->handle);@@ -332,7 +329,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_ref(NULL, &so); /* Static tesla init */ - so = so_new(256, 20); + so = so_new(40, 84, 20); so_method(so, screen->tesla, NV50TCL_COND_MODE, 1); so_data (so, NV50TCL_COND_MODE_ALWAYS);src/gallium/drivers/nv50/nv50_state.c +2
-2@@ -35,7 +35,7 @@ static void * nv50_blend_state_create(struct pipe_context *pipe, const struct pipe_blend_state *cso) { - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(5, 24, 0); struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla; struct nv50_blend_stateobj *bso = CALLOC_STRUCT(nv50_blend_stateobj); unsigned cmask = 0, i;@@ -280,7 +280,7 @@ static void * nv50_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) { - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(15, 21, 0); struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla;struct
nv50_rasterizer_stateobj*rso =CALLOC_STRUCT(nv50_rasterizer_stateobj);src/gallium/drivers/nv50/nv50_state.c +1
-1@@ -425,7 +425,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla; struct nv50_zsa_stateobj *zsa = CALLOC_STRUCT(nv50_zsa_stateobj); - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(8, 22, 0); so_method(so, tesla, NV50TCL_DEPTH_WRITE_ENABLE, 1); so_data (so, cso->depth.writemask ? 1 : 0);src/gallium/drivers/nv50/nv50_state_validate.c +7
-6@@ -33,7 +33,7 @@ static void nv50_state_validate_fb(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nouveau_stateobj *so = so_new(128, 18); + struct nouveau_stateobj *so = so_new(32, 79, 18); struct pipe_framebuffer_state *fb = &nv50->framebuffer; unsigned i, w, h, gw = 0;@@ -299,7 +299,7 @@ nv50_state_validate(struct nv50_context *nv50) so_ref(nv50->rasterizer->so, &nv50->state.rast); if (nv50->dirty & NV50_NEW_BLEND_COLOUR) { - so = so_new(5, 0); + so = so_new(1, 4, 0); so_method(so, tesla, NV50TCL_BLEND_COLOR(0), 4); so_data (so, fui(nv50->blend_colour.color[0])); so_data (so, fui(nv50->blend_colour.color[1]));@@ -310,7 +310,7 @@ nv50_state_validate(struct nv50_context *nv50) } if (nv50->dirty & NV50_NEW_STIPPLE) { - so = so_new(33, 0); + so = so_new(1, 32, 0); so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_PATTERN(0), 32); for (i = 0; i < 32; i++) so_data(so, util_bswap32(nv50->stipple.stipple[i]));@@ -327,7 +327,7 @@ nv50_state_validate(struct nv50_context *nv50) goto scissor_uptodate; nv50->state.scissor_enabled = rast->scissor; - so = so_new(3, 0); + so = so_new(1, 2, 0); so_method(so, tesla, NV50TCL_SCISSOR_HORIZ(0), 2); if (nv50->state.scissor_enabled) { so_data(so, (s->maxx << 16) | s->minx);@@ -356,7 +356,7 @@ scissor_uptodate: goto viewport_uptodate; nv50->state.viewport_bypass = bypass; - so = so_new(14, 0); + so = so_new(5, 9, 0); if (!bypass) { so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE_X(0), 3); so_data (so, fui(nv50->viewport.translate[0]));@@ -400,7 +400,8 @@ viewport_uptodate: for (i = 0; i < PIPE_SHADER_TYPES; ++i) nr += nv50->sampler_nr[i]; - so = so_new(nr * 8 + 24 * PIPE_SHADER_TYPES + 2, 4); + so = so_new(1+ 5 * PIPE_SHADER_TYPES, 1+ 19 * PIPE_SHADER_TYPES + + nr * 8, PIPE_SHADER_TYPES * 2); nv50_validate_samplers(nv50, so, PIPE_SHADER_VERTEX); nv50_validate_samplers(nv50, so, PIPE_SHADER_FRAGMENT);src/gallium/drivers/nv50/nv50_tex.c +6
-4@@ -199,16 +199,18 @@ nv50_tex_validate(struct nv50_context *nv50) { struct nouveau_stateobj *so; struct nouveau_grobj *tesla = nv50->screen->tesla; - unsigned p, push, nrlc; + unsigned p, start, push, nrlc; - for (nrlc = 0, push = 0, p = 0; p < PIPE_SHADER_TYPES; ++p) { + for (nrlc = 0, start = 0, push = 0, p = 0; p < PIPE_SHADER_TYPES; ++p) { + start += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]); push += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]); nrlc += nv50->miptree_nr[p]; } - push = push * 11 + 23 * PIPE_SHADER_TYPES + 4; + start = start * 2 + 4 * PIPE_SHADER_TYPES + 2; + push = push * 9 + 19 * PIPE_SHADER_TYPES + 2; nrlc = nrlc * 2 + 2 * PIPE_SHADER_TYPES; - so = so_new(push, nrlc); + so = so_new(start, push, nrlc);if (
nv50_validate_textures(nv50, so, PIPE_SHADER_VERTEX)== FALSE ||nv50_validate_textures(nv50, so, PIPE_SHADER_FRAGMENT)== FALSE) {src/gallium/drivers/nv50/nv50_vbo.c +1
-1@@ -350,7 +350,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib, so = *pso; if (!so) - *pso = so = so_new(nv50->vtxelt_nr * 5, 0); + *pso = so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 4, 0); switch (ve->nr_components) {case 4:
src/gallium/drivers/nv50/nv50_vbo.c +2
-3@@ -411,8 +411,8 @@ nv50_vbo_validate(struct nv50_context *nv50) n_ve = MAX2(nv50->vtxelt_nr, nv50->state.vtxelt_nr); vtxattr = NULL; - vtxbuf = so_new(n_ve * 7, nv50->vtxelt_nr * 4); - vtxfmt = so_new(n_ve + 1, 0); + vtxbuf = so_new(n_ve * 2, n_ve * 5, nv50->vtxelt_nr * 4); + vtxfmt = so_new(1, n_ve, 0); so_method(vtxfmt, tesla, NV50TCL_VERTEX_ARRAY_ATTRIB(0), n_ve); for (i = 0; i < nv50->vtxelt_nr; i++) { --1.6.6.rc4
A message that is not in the archive (sent off-list or not yet received): 6d4bc9fc0912301443g7721311anbe7ea2dbe6156eac-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/3] nouveau: rewrite nouveau_stateobj to use BEGIN_RING properly
Looks good on nv35 and nv84.
On nv35 I measured perf on xmoto and tremulous. xmoto is as good as before, tremulous as bad as before :)
On nv84 I did not benchmark, but if there is a regression, at least I cannot feel it while playing.
Quoted 1,133 lines · Maarten Maathuis
If anyone experiences a sustained performance loss of more than 1%, then i'm curious how much it is, if it can be reproduced with something free, even better :-)
Quoted 1,117 lines · Maarten Maathuis
The prerequisite patch (which kills
nouveau_push) got stuck in queue because of it's size.This patch is here for discussion, and it needs testing on nv30/nv40 for miscalculated so sizes.
Quoted 1,110 lines · Maarten Maathuis
- The previous solution was hacky and didn't do subchannel autobinding.
- The beheaviour should match whatlibdrm_nouveaudoes closely.
- There appears to be a minor performance loss, probably due to having multiple memcpy's instead of one.
- The solution remains statically sized, but when debugging is on it will check for abuse.
- The values for nv30/nv40 may be off, but this should be easily caught with DEBUG on.Signed-off-by Maarten Maathuis <[email protected]>---
src/gallium/drivers/nouveau/nouveau_stateobj.h | 289 +++++++++++++++++-------src/gallium/drivers/nv04/nv04_screen.c | 2 - src/gallium/drivers/nv10/nv10_screen.c | 1 - src/gallium/drivers/nv20/nv20_screen.c | 1 -src/gallium/drivers/nv30/nv30_fragprog.c | 2 +-
src/gallium/drivers/nv30/nv30_fragtex.c| 4 +-src/gallium/drivers/nv30/nv30_screen.c| 3 +-src/gallium/drivers/nv30/nv30_state.c| 6 +-src/gallium/drivers/nv30/nv30_state_blend.c| 2 +-src/gallium/drivers/nv30/nv30_state_fb.c| 2 +-src/gallium/drivers/nv30/nv30_state_scissor.c| 2 +-src/gallium/drivers/nv30/nv30_state_stipple.c| 4 +-src/gallium/drivers/nv30/nv30_state_viewport.c| 2 +-src/gallium/drivers/nv30/nv30_vbo.c| 6 +-src/gallium/drivers/nv30/nv30_vertprog.c| 2 +-src/gallium/drivers/nv40/nv40_fragprog.c| 2 +-src/gallium/drivers/nv40/nv40_fragtex.c| 4 +-src/gallium/drivers/nv40/nv40_screen.c| 3 +-src/gallium/drivers/nv40/nv40_state.c| 6 +-src/gallium/drivers/nv40/nv40_state_blend.c| 2 +-src/gallium/drivers/nv40/nv40_state_fb.c| 2 +-src/gallium/drivers/nv40/nv40_state_scissor.c| 2 +-src/gallium/drivers/nv40/nv40_state_stipple.c| 4 +-src/gallium/drivers/nv40/nv40_state_viewport.c| 2 +-src/gallium/drivers/nv40/nv40_vbo.c| 6 +-src/gallium/drivers/nv40/nv40_vertprog.c| 2 +-src/gallium/drivers/nv50/nv50_program.c| 6 +-src/gallium/drivers/nv50/nv50_screen.c| 9 +-src/gallium/drivers/nv50/nv50_state.c| 6 +-src/gallium/drivers/nv50/nv50_state_validate.c| 13 +-src/gallium/drivers/nv50/nv50_tex.c| 10 +-src/gallium/drivers/nv50/nv50_vbo.c| 6 +-32 files changed, 266 insertions(+), 147 deletions(-)src/gallium/drivers/nouveau/nouveau_stateobj.h +49
-6@@ -3,41 +3,96 @@ #include "util/u_debug.h" +#ifdef DEBUG +#define DEBUG_NOUVEAU_STATEOBJ +#endif /* DEBUG */ + struct nouveau_stateobj_reloc { struct nouveau_bo *bo; - unsigned offset; - unsigned packet; + struct nouveau_grobj *gr; + uint32_t push_offset; + uint32_t mthd; - unsigned data; + uint32_t data; unsigned flags; unsigned vor; unsigned tor; }; +struct nouveau_stateobj_start { + struct nouveau_grobj *gr; + uint32_t mthd; + uint32_t size; + unsigned offset; +}; + struct nouveau_stateobj { struct pipe_reference reference; - unsigned *push; + struct nouveau_stateobj_start *start; struct nouveau_stateobj_reloc *reloc; - unsigned *cur; - unsigned cur_packet; + /* Common memory pool for data. */ + uint32_t *pool; + unsigned pool_cur; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + unsigned start_alloc; + unsigned reloc_alloc; + unsigned pool_alloc; +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + unsigned total; /* includes begin_ring */ + unsigned cur; /* excludes begin_ring, offset from "cur_start" */ + unsigned cur_start; unsigned cur_reloc; }; +static INLINE void +so_dump (struct nouveau_stateobj *so) +{ + unsigned i, nr, total = 0; + + for (i = 0; i < so->cur_start; i++) { + if (so->start[i].gr->subc > -1) + debug_printf("+0x%04x: 0x%08x\n", total++, + (so->start[i].size << 18) | (so->start[i].gr->subc << 13) + | so->start[i].mthd); + else + debug_printf("+0x%04x: 0x%08x\n", total++, + (so->start[i].size << 18) | so->start[i].mthd); + for (nr = 0; nr < so->start[i].size; nr++, total++) + debug_printf("+0x%04x: 0x%08x\n", total, + so->pool[so->start[i].offset + nr]); + } +} + +/* Arguments are ignored, dynamic allocation. */ static INLINE struct
nouveau_stateobj*src/gallium/drivers/nouveau/nouveau_stateobj.h +1
-1-so_new(unsigned push, unsigned reloc) +so_new(unsigned start, unsigned push, unsigned reloc){
structnouveau_stateobj*so;so =
MALLOC(sizeof(struct nouveau_stateobj));pipe_reference_init(&so->reference, 1);
-so->push=MALLOC(sizeof(unsigned) * push);
-so->reloc=MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc);src/gallium/drivers/nouveau/nouveau_stateobj.h +17
-3- - so->cur = so->push; - so->cur_reloc = so->cur_packet = 0; + so->total = so->cur = so->cur_start = so->cur_reloc = 0; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + so->start_alloc = start; + so->reloc_alloc = reloc; + so->pool_alloc = push; +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->start = MALLOC(start * sizeof(struct nouveau_stateobj_start)); + so->reloc = MALLOC(reloc * sizeof(struct nouveau_stateobj_reloc)); + so->pool = MALLOC(push * sizeof(uint32_t)); + so->pool_cur = 0; + + if (!so->start || !so->reloc || !so->pool) { + debug_printf("malloc failed\n"); + assert(0); + }return so;
}src/gallium/drivers/nouveau/nouveau_stateobj.h +5
-4@@ -48,54 +103,115 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso) struct nouveau_stateobj *so = *pso; int i; - if (pipe_reference(&(*pso)->reference, &ref->reference)) { - free(so->push); + if (pipe_reference(&(*pso)->reference, &ref->reference)) { + FREE(so->start); for (i = 0; i < so->cur_reloc; i++) nouveau_bo_ref(NULL, &so->reloc[i].bo); - free(so->reloc); - free(so); + FREE(so->reloc); + FREE(so->pool); + FREE(so); } *pso = ref; }static INLINE void
src/gallium/drivers/nouveau/nouveau_stateobj.h +1
-1-so_data(struct nouveau_stateobj *so, unsigned data) +so_data(struct nouveau_stateobj *so, uint32_t data){
- (*so->cur++) = (data);
-so->cur_packet+= 4;src/gallium/drivers/nouveau/nouveau_stateobj.h +8
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->cur >= so->start[so->cur_start - 1].size) { + debug_printf("exceeding specified size\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->pool[so->start[so->cur_start - 1].offset + so->cur++] = data;}
static INLINE void
src/gallium/drivers/nouveau/nouveau_stateobj.h +1
-1-so_datap(struct nouveau_stateobj *so, unsigned *data, unsigned size) +so_datap(struct nouveau_stateobj *so, uint32_t *data, unsigned size){
-so->cur_packet+= (4 * size);src/gallium/drivers/nouveau/nouveau_stateobj.h +7
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if ((so->cur + size) > so->start[so->cur_start - 1].size) { + debug_printf("exceeding specified size\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ +while (size--)
- (*so->cur++) = (*data++);
+ so->pool[so->start[so->cur_start - 1].offset + so->cur++] =
+ *data++;
}static INLINE void
so_method(structnouveau_stateobj*so, structnouveau_grobj*gr, unsigned mthd, unsigned size)
{
-so->cur_packet= (gr->subc<< 13) | (1 << 18) | (mthd - 4);
-so_data(so, (gr->subc << 13) | (size << 18) | mthd);
+ structnouveau_stateobj_start*start;src/gallium/drivers/nouveau/nouveau_stateobj.h +35
-0+ +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->start_alloc <= so->cur_start) { + debug_printf("exceeding num_start size\n"); + assert(0); + } else +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + start = so->start; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->cur_start > 0 && start[so->cur_start - 1].size > so->cur) { + debug_printf("previous so_method was not filled\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + so->start = start; + start[so->cur_start].gr = gr; + start[so->cur_start].mthd = mthd; + start[so->cur_start].size = size; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->pool_alloc < (size + so->pool_cur)) { + debug_printf("exceeding num_pool size\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + start[so->cur_start].offset = so->pool_cur; + so->pool_cur += size; + + so->cur_start++; + /* The 1 is for *this* begin_ring. */ + so->total += so->cur + 1; + so->cur = 0;}
static INLINE void
so_reloc(structnouveau_stateobj*so, structnouveau_bo*bo, unsigned data, unsigned flags, unsigned vor, unsigned tor) {
- structnouveau_stateobj_reloc*r = &so->reloc[so->cur_reloc++];src/gallium/drivers/nouveau/nouveau_stateobj.h +22
-9- - r->bo = NULL; - nouveau_bo_ref(bo, &r->bo); - r->offset = so->cur - so->push; - r->packet = so->cur_packet; - r->data = data; - r->flags = flags; - r->vor = vor; - r->tor = tor; + struct nouveau_stateobj_reloc *r; + +#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->reloc_alloc <= so->cur_reloc) { + debug_printf("exceeding num_reloc size\n"); + assert(0); + } else +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + r = so->reloc; + + so->reloc = r; + r[so->cur_reloc].bo = NULL; + nouveau_bo_ref(bo, &(r[so->cur_reloc].bo)); + r[so->cur_reloc].gr = so->start[so->cur_start-1].gr; + r[so->cur_reloc].push_offset = so->total + so->cur; + r[so->cur_reloc].data = data; + r[so->cur_reloc].flags = flags; + r[so->cur_reloc].mthd = so->start[so->cur_start-1].mthd + + (so->cur << 2); + r[so->cur_reloc].vor = vor; + r[so->cur_reloc].tor = tor; +so_data(so, data);
+ so->cur_reloc++;
}/* Determine if this buffer object is referenced by this state object. */
src/gallium/drivers/nouveau/nouveau_stateobj.h +0
-0@@ -112,90 +228,99 @@ so_bo_is_reloc(struct nouveau_stateobj *so, struct nouveau_bo *bo) }static INLINE void
src/gallium/drivers/nouveau/nouveau_stateobj.h +0
-9-so_dump(struct nouveau_stateobj *so) -{ - unsigned i, nr = so->cur - so->push; - - for (i = 0; i < nr; i++) - debug_printf("+0x%04x: 0x%08x\n", i, so->push[i]); -} - -static INLINE voidso_emit(struct
nouveau_channel*chan, structnouveau_stateobj*so) {
structnouveau_pushbuf*pb =chan->pushbuf; unsigned nr, i;
int ret = 0;- nr =
so->cur-so->push;src/gallium/drivers/nouveau/nouveau_stateobj.h +10
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if (so->start[so->cur_start - 1].size > so->cur) { + debug_printf("emit: previous so_method was not filled\n"); + assert(0); + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + /* We cannot update total in case we so_emit again. */ + nr = so->total + so->cur; +/* This will flush if we need space.
* We don't actually need the marker.
*/
if ((ret =nouveau_pushbuf_marker_emit(chan, nr, so->cur_reloc))) {debug_printf("so_emit failed marker emit with error %d\n", ret);
- return;
+ assert(0);
+ }
+
+ /* Submit data. This will ensure proper binding of objects. */
+ for (i = 0; i <so->cur_start; i++) {
+BEGIN_RING(chan, so->start[i].gr, so->start[i].mthd, so->start[i].size);
+OUT_RINGp(chan, &(so->pool[so->start[i].offset]), so->start[i].size); }
-pb->remaining-= nr;-
memcpy(pb->cur, so->push, nr * 4);
for (i = 0; i <so->cur_reloc; i++) {
structnouveau_stateobj_reloc*r = &so->reloc[i];- if ((ret = nouveau_pushbuf_emit_reloc(chan,
pb->cur+r->offset,
- r->bo,r->data, 0,r->flags,
- r->vor,r->tor))) {
+ if ((ret = nouveau_pushbuf_emit_reloc(chan,pb->cur- nr +
+r->push_offset,r->bo,r->data,
+ 0,r->flags,r->vor,r->tor))) {debug_printf("so_emit failed reloc with error %d\n", ret);
- goto out;
+ assert(0);
}
}
-out:
-pb->cur+= nr;
}static INLINE void
so_emit_reloc_markers(structnouveau_channel*chan, structnouveau_stateobj*so) {
structnouveau_pushbuf*pb =chan->pushbuf;
+ structnouveau_grobj*gr = NULL;
unsigned i;
int ret = 0;if (!so)
return;- i =
so->cur_reloc<< 1;
- /* This will flush if we need space.
- * We don't actually need the marker.
- */
- if ((ret =nouveau_pushbuf_marker_emit(chan, i, i))) {
- debug_printf("so_emit_reloc_markers failed marker emit with" \
- "error %d\n", ret);
- return;
- }
-pb->remaining-= i;
-
+ /* If we need to flush in flush notify, then we have a problem anyway. */ for (i = 0; i <so->cur_reloc; i++) {
structnouveau_stateobj_reloc*r = &so->reloc[i];- if ((ret = nouveau_pushbuf_emit_reloc(chan, pb->cur++,
r->bo,
- r->packet, 0,
- (r->flags & (NOUVEAU_BO_VRAM|
-NOUVEAU_BO_GART|
-NOUVEAU_BO_RDWR)) |
- NOUVEAU_BO_DUMMY, 0, 0))) {
- debug_printf("so_emit_reloc_markers failed reloc" \
- "with error %d\n", ret);
-pb->remaining+= ((so->cur_reloc- i) << 1);
- return;src/gallium/drivers/nouveau/nouveau_stateobj.h +26
-0+#ifdef DEBUG_NOUVEAU_STATEOBJ + if (r->mthd & 0x40000000) { + debug_printf("error: NI mthd 0x%08X\n", r->mthd); + continue; + } +#endif /* DEBUG_NOUVEAU_STATEOBJ */ + + /* The object needs to be bound and the system must know the + * subchannel is being used. Otherwise it will discard it. + */ + if (gr != r->gr) { + BEGIN_RING(chan, r->gr, 0x100, 1); + OUT_RING(chan, 0); + gr = r->gr; + } + + /* Some relocs really don't like to be hammered, + * NOUVEAU_BO_DUMMY makes sure it only + * happens when needed. + */ + ret = OUT_RELOC(chan, r->bo, (r->gr->subc << 13) | (1<< 18) | + r->mthd, (r->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART + | NOUVEAU_BO_RDWR)) | NOUVEAU_BO_DUMMY, 0, 0); + if (ret) { + debug_printf("OUT_RELOC failed %d\n", ret); + assert(0);}
- if ((ret = nouveau_pushbuf_emit_reloc(chan, pb->cur++,r->bo,
- r->data, 0,
- r->flags |NOUVEAU_BO_DUMMY,
- r->vor,r->tor))) {
- debug_printf("so_emit_reloc_markers failed reloc" \
- "with error %d\n", ret);
-pb->remaining+= ((so->cur_reloc- i) << 1) - 1;
- return;
+
+ ret = OUT_RELOC(chan,r->bo,r->data,r->flags|
+NOUVEAU_BO_DUMMY,r->vor,r->tor);
+ if (ret) {
+debug_printf("OUT_RELOC failed %d\n", ret);
+ assert(0);
}
+
+pb->remaining-= 2;
}
}src/gallium/drivers/nv04/nv04_screen.c +0
-2@@ -184,7 +184,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return NULL; } - BIND_RING(chan, screen->fahrenheit, 7); /* 3D surface object */ ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class,@@ -193,7 +192,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D surface object: %d\n", ret); return NULL; } - BIND_RING(chan, screen->context_surfaces_3d, 6); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);src/gallium/drivers/nv10/nv10_screen.c +0
-1@@ -180,7 +180,6 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->celsius, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);src/gallium/drivers/nv20/nv20_screen.c +0
-1@@ -176,7 +176,6 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->kelvin, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);src/gallium/drivers/nv30/nv30_fragprog.c +1
-1@@ -837,7 +837,7 @@ nv30_fragprog_validate(struct nv30_context *nv30) fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv30_fragprog_upload(nv30, fp); - so = so_new(8, 1); + so = so_new(4, 4, 1); so_method(so, nv30->screen->rankine, NV34TCL_FP_ACTIVE_PROGRAM, 1);so_reloc (so,
nouveau_bo(fp->buffer), 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_GART|NOUVEAU_BO_RD|NOUVEAU_BO_LOW|src/gallium/drivers/nv30/nv30_fragtex.c +2
-2@@ -106,7 +106,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit) txs = tf->swizzle; - so = so_new(16, 2); + so = so_new(1, 8, 2); so_method(so, nv30->screen->rankine, NV34TCL_TX_OFFSET(unit), 8); so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,@@ -135,7 +135,7 @@ nv30_fragtex_validate(struct nv30_context *nv30) unit = ffs(samplers) - 1; samplers &= ~(1 << unit); - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, nv30->screen->rankine, NV34TCL_TX_ENABLE(unit), 1); so_data (so, 0); so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);src/gallium/drivers/nv30/nv30_screen.c +1
-2@@ -233,7 +233,6 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->rankine, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);@@ -270,7 +269,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static rankine initialisation */ - so = so_new(128, 0); + so = so_new(36, 60, 0); so_method(so, screen->rankine, NV34TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->rankine, NV34TCL_DMA_TEXTURE0, 2);src/gallium/drivers/nv30/nv30_state.c +3
-3@@ -14,7 +14,7 @@ nv30_blend_state_create(struct pipe_context *pipe, struct nv30_context *nv30 = nv30_context(pipe); struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv30_blend_state *bso = CALLOC(1, sizeof(*bso)); - struct nouveau_stateobj *so = so_new(16, 0); + struct nouveau_stateobj *so = so_new(5, 8, 0); if (cso->blend_enable) { so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 3);@@ -300,7 +300,7 @@ nv30_rasterizer_state_create(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(9, 19, 0); struct nouveau_grobj *rankine = nv30->screen->rankine; /*XXX: ignored:@@ -435,7 +435,7 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(5, 21, 0); struct nouveau_grobj *rankine = nv30->screen->rankine; so_method(so, rankine, NV34TCL_DEPTH_FUNC, 3);src/gallium/drivers/nv30/nv30_state_blend.c +0
-0@@ -18,7 +18,7 @@ struct nv30_state_entry nv30_state_blend = {static boolean
nv30_state_blend_colour_validate(struct nv30_context *nv30){
- structnouveau_stateobj*so =so_new(2, 0);
+ structnouveau_stateobj*so =so_new(1, 1, 0); structpipe_blend_color*bcol =&nv30->blend_colour;so_method(so,
nv30->screen->rankine,NV34TCL_BLEND_COLOR, 1);src/gallium/drivers/nv30/nv30_state_fb.c +1
-1@@ -10,7 +10,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) struct nv04_surface *rt[2], *zeta = NULL; uint32_t rt_enable = 0, rt_format = 0; int i, colour_format = 0, zeta_format = 0, depth_only = 0; - struct nouveau_stateobj *so = so_new(64, 10); + struct nouveau_stateobj *so = so_new(12, 18, 10); unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM; unsigned w = fb->width; unsigned h = fb->height;src/gallium/drivers/nv30/nv30_state_scissor.c +1
-1@@ -12,7 +12,7 @@ nv30_state_scissor_validate(struct nv30_context *nv30) return FALSE; nv30->state.scissor_enabled = rast->scissor; - so = so_new(3, 0); + so = so_new(1, 2, 0); so_method(so, nv30->screen->rankine, NV34TCL_SCISSOR_HORIZ, 2); if (nv30->state.scissor_enabled) { so_data (so, ((s->maxx - s->minx) << 16) | s->minx);src/gallium/drivers/nv30/nv30_state_stipple.c +2
-2@@ -14,14 +14,14 @@ nv30_state_stipple_validate(struct nv30_context *nv30) if (rast->poly_stipple_enable) { unsigned i; - so = so_new(35, 0); + so = so_new(2, 33, 0); so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 1); so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32); for (i = 0; i < 32; i++) so_data(so, nv30->stipple[i]); } else { - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 0); }src/gallium/drivers/nv30/nv30_state_viewport.c +1
-1@@ -19,7 +19,7 @@ nv30_state_viewport_validate(struct nv30_context *nv30) return FALSE; nv30->state.viewport_bypass = bypass; - so = so_new(11, 0); + so = so_new(3, 10, 0); if (!bypass) { so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_TRANSLATE_X, 8);src/gallium/drivers/nv30/nv30_vbo.c +3
-3@@ -495,9 +495,9 @@ nv30_vbo_validate(struct nv30_context *nv30) unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; int hw; - vtxbuf = so_new(20, 18); + vtxbuf = so_new(3, 17, 18); so_method(vtxbuf, rankine, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt_nr); - vtxfmt = so_new(17, 0); + vtxfmt = so_new(1, 16, 0); so_method(vtxfmt, rankine, NV34TCL_VTXFMT(0), nv30->vtxelt_nr); for (hw = 0; hw < nv30->vtxelt_nr; hw++) {@@ -510,7 +510,7 @@ nv30_vbo_validate(struct nv30_context *nv30) if (!vb->stride) { if (!sattr) - sattr = so_new(16 * 5, 0); + sattr = so_new(16, 16 * 4, 0); if (nv30_vbo_static_attrib(nv30, sattr, hw, ve, vb)) { so_data(vtxbuf, 0);src/gallium/drivers/nv30/nv30_vertprog.c +1
-1@@ -686,7 +686,7 @@ nv30_vertprog_validate(struct nv30_context *nv30) assert(0); } - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1); so_data (so, vp->exec->start); so_ref(so, &vp->so);src/gallium/drivers/nv40/nv40_fragprog.c +1
-1@@ -919,7 +919,7 @@ nv40_fragprog_validate(struct nv40_context *nv40) fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv40_fragprog_upload(nv40, fp); - so = so_new(4, 1); + so = so_new(2, 2, 1); so_method(so, nv40->screen->curie, NV40TCL_FP_ADDRESS, 1);so_reloc (so,
nouveau_bo(fp->buffer), 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_GART|NOUVEAU_BO_RD|NOUVEAU_BO_LOW|src/gallium/drivers/nv40/nv40_fragtex.c +2
-2@@ -108,7 +108,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit) txs = tf->swizzle; - so = so_new(16, 2); + so = so_new(2, 9, 2); so_method(so, nv40->screen->curie, NV40TCL_TEX_OFFSET(unit), 8); so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0); so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,@@ -139,7 +139,7 @@ nv40_fragtex_validate(struct nv40_context *nv40) unit = ffs(samplers) - 1; samplers &= ~(1 << unit); - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, nv40->screen->curie, NV40TCL_TEX_ENABLE(unit), 1); so_data (so, 0); so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);src/gallium/drivers/nv40/nv40_screen.c +1
-2@@ -215,7 +215,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } - BIND_RING(chan, screen->curie, 7); /* 2D engine setup */ screen->eng2d = nv04_surface_2d_init(&screen->base);@@ -252,7 +251,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static curie initialisation */ - so = so_new(128, 0); + so = so_new(16, 25, 0); so_method(so, screen->curie, NV40TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->curie, NV40TCL_DMA_TEXTURE0, 2);src/gallium/drivers/nv40/nv40_state.c +3
-3@@ -16,7 +16,7 @@ nv40_blend_state_create(struct pipe_context *pipe, struct nv40_context *nv40 = nv40_context(pipe); struct nouveau_grobj *curie = nv40->screen->curie; struct nv40_blend_state *bso = CALLOC(1, sizeof(*bso)); - struct nouveau_stateobj *so = so_new(16, 0); + struct nouveau_stateobj *so = so_new(5, 8, 0); if (cso->blend_enable) { so_method(so, curie, NV40TCL_BLEND_ENABLE, 3);@@ -310,7 +310,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe, { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(8, 18, 0); struct nouveau_grobj *curie = nv40->screen->curie; /*XXX: ignored:@@ -445,7 +445,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso)); - struct nouveau_stateobj *so = so_new(32, 0); + struct nouveau_stateobj *so = so_new(4, 21, 0); struct nouveau_grobj *curie = nv40->screen->curie; so_method(so, curie, NV40TCL_DEPTH_FUNC, 3);src/gallium/drivers/nv40/nv40_state_blend.c +0
-0@@ -18,7 +18,7 @@ struct nv40_state_entry nv40_state_blend = {static boolean
nv40_state_blend_colour_validate(struct nv40_context *nv40){
- structnouveau_stateobj*so =so_new(2, 0);
+ structnouveau_stateobj*so =so_new(1, 1, 0); structpipe_blend_color*bcol =&nv40->blend_colour;so_method(so,
nv40->screen->curie,NV40TCL_BLEND_COLOR, 1);src/gallium/drivers/nv40/nv40_state_fb.c +1
-1@@ -19,7 +19,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40) struct nv04_surface *rt[4], *zeta; uint32_t rt_enable, rt_format; int i, colour_format = 0, zeta_format = 0; - struct nouveau_stateobj *so = so_new(64, 10); + struct nouveau_stateobj *so = so_new(18, 24, 10); unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM; unsigned w = fb->width; unsigned h = fb->height;src/gallium/drivers/nv40/nv40_state_scissor.c +1
-1@@ -12,7 +12,7 @@ nv40_state_scissor_validate(struct nv40_context *nv40) return FALSE; nv40->state.scissor_enabled = rast->scissor; - so = so_new(3, 0); + so = so_new(1, 2, 0); so_method(so, nv40->screen->curie, NV40TCL_SCISSOR_HORIZ, 2); if (nv40->state.scissor_enabled) { so_data (so, ((s->maxx - s->minx) << 16) | s->minx);src/gallium/drivers/nv40/nv40_state_stipple.c +2
-2@@ -14,14 +14,14 @@ nv40_state_stipple_validate(struct nv40_context *nv40) if (rast->poly_stipple_enable) { unsigned i; - so = so_new(35, 0); + so = so_new(2, 33, 0); so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 1); so_method(so, curie, NV40TCL_POLYGON_STIPPLE_PATTERN(0), 32); for (i = 0; i < 32; i++) so_data(so, nv40->stipple[i]); } else { - so = so_new(2, 0); + so = so_new(1, 1, 0); so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, 0); }src/gallium/drivers/nv40/nv40_state_viewport.c +1
-1@@ -19,7 +19,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40) return FALSE; nv40->state.viewport_bypass = bypass; - so = so_new(11, 0); + so = so_new(2, 9, 0); if (!bypass) { so_method(so, nv40->screen->curie, NV40TCL_VIEWPORT_TRANSLATE_X, 8);src/gallium/drivers/nv40/nv40_vbo.c +3
-3@@ -494,9 +494,9 @@ nv40_vbo_validate(struct nv40_context *nv40) unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; int hw; - vtxbuf = so_new(20, 18); + vtxbuf = so_new(3, 17, 18); so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt_nr); - vtxfmt = so_new(17, 0); + vtxfmt = so_new(1, 16, 0); so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt_nr); for (hw = 0; hw < nv40->vtxelt_nr; hw++) {@@ -509,7 +509,7 @@ nv40_vbo_validate(struct nv40_context *nv40) if (!vb->stride) { if (!sattr) - sattr = so_new(16 * 5, 0); + sattr = so_new(16, 16 * 4, 0); if (nv40_vbo_static_attrib(nv40, sattr, hw, ve, vb)) { so_data(vtxbuf, 0);src/gallium/drivers/nv40/nv40_vertprog.c +1
-1@@ -886,7 +886,7 @@ check_gpu_resources: assert(0); } - so = so_new(7, 0); + so = so_new(3, 4, 0); so_method(so, curie, NV40TCL_VP_START_FROM_ID, 1); so_data (so, vp->exec->start); so_method(so, curie, NV40TCL_VP_ATTRIB_EN, 2);src/gallium/drivers/nv50/nv50_program.c +1
-1@@ -3452,7 +3452,7 @@ nv50_vertprog_validate(struct nv50_context *nv50) nv50_program_validate_data(nv50, p); nv50_program_validate_code(nv50, p); - so = so_new(13, 2); + so = so_new(5, 8, 2); so_method(so, tesla, NV50TCL_VP_ADDRESS_HIGH, 2);so_reloc (so,
p->bo, 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_RD|NOUVEAU_BO_HIGH, 0, 0);src/gallium/drivers/nv50/nv50_program.c +1
-1@@ -3488,7 +3488,7 @@ nv50_fragprog_validate(struct nv50_context *nv50) nv50_program_validate_data(nv50, p); nv50_program_validate_code(nv50, p); - so = so_new(64, 2); + so = so_new(6, 7, 2); so_method(so, tesla, NV50TCL_FP_ADDRESS_HIGH, 2);so_reloc (so,
p->bo, 0,NOUVEAU_BO_VRAM|NOUVEAU_BO_RD|NOUVEAU_BO_HIGH, 0, 0);src/gallium/drivers/nv50/nv50_program.c +1
-1@@ -3656,7 +3656,7 @@ nv50_linkage_validate(struct nv50_context *nv50) } /* now fill the stateobj */ - so = so_new(64, 0); + so = so_new(6, 58, 0); n = (m + 3) / 4; so_method(so, tesla, NV50TCL_VP_RESULT_MAP_SIZE, 1);src/gallium/drivers/nv50/nv50_screen.c +3
-6@@ -251,7 +251,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } - BIND_RING(chan, screen->m2mf, 1); /* 2D object */ ret = nouveau_grobj_alloc(chan, 0xbeef502d, NV50_2D, &screen->eng2d);@@ -260,7 +259,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } - BIND_RING(chan, screen->eng2d, 2); /* 3D object */ switch (chipset & 0xf0) {@@ -296,7 +294,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) nv50_screen_destroy(pscreen); return NULL; } - BIND_RING(chan, screen->tesla, 3); /* Sync notifier */ ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);@@ -307,7 +304,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } /* Static M2MF init */ - so = so_new(32, 0); + so = so_new(1, 3, 0); so_method(so, screen->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3); so_data (so, screen->sync->handle); so_data (so, chan->vram->handle);@@ -316,7 +313,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_ref (NULL, &so); /* Static 2D init */ - so = so_new(64, 0); + so = so_new(4, 7, 0); so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4); so_data (so, screen->sync->handle); so_data (so, chan->vram->handle);@@ -332,7 +329,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_ref(NULL, &so); /* Static tesla init */ - so = so_new(256, 20); + so = so_new(40, 84, 20); so_method(so, screen->tesla, NV50TCL_COND_MODE, 1); so_data (so, NV50TCL_COND_MODE_ALWAYS);src/gallium/drivers/nv50/nv50_state.c +2
-2@@ -35,7 +35,7 @@ static void * nv50_blend_state_create(struct pipe_context *pipe, const struct pipe_blend_state *cso) { - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(5, 24, 0); struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla; struct nv50_blend_stateobj *bso = CALLOC_STRUCT(nv50_blend_stateobj); unsigned cmask = 0, i;@@ -280,7 +280,7 @@ static void * nv50_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) { - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(15, 21, 0); struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla;struct
nv50_rasterizer_stateobj*rso =CALLOC_STRUCT(nv50_rasterizer_stateobj);src/gallium/drivers/nv50/nv50_state.c +1
-1@@ -425,7 +425,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla; struct nv50_zsa_stateobj *zsa = CALLOC_STRUCT(nv50_zsa_stateobj); - struct nouveau_stateobj *so = so_new(64, 0); + struct nouveau_stateobj *so = so_new(8, 22, 0); so_method(so, tesla, NV50TCL_DEPTH_WRITE_ENABLE, 1); so_data (so, cso->depth.writemask ? 1 : 0);src/gallium/drivers/nv50/nv50_state_validate.c +7
-6@@ -33,7 +33,7 @@ static void nv50_state_validate_fb(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nouveau_stateobj *so = so_new(128, 18); + struct nouveau_stateobj *so = so_new(32, 79, 18); struct pipe_framebuffer_state *fb = &nv50->framebuffer; unsigned i, w, h, gw = 0;@@ -299,7 +299,7 @@ nv50_state_validate(struct nv50_context *nv50) so_ref(nv50->rasterizer->so, &nv50->state.rast); if (nv50->dirty & NV50_NEW_BLEND_COLOUR) { - so = so_new(5, 0); + so = so_new(1, 4, 0); so_method(so, tesla, NV50TCL_BLEND_COLOR(0), 4); so_data (so, fui(nv50->blend_colour.color[0])); so_data (so, fui(nv50->blend_colour.color[1]));@@ -310,7 +310,7 @@ nv50_state_validate(struct nv50_context *nv50) } if (nv50->dirty & NV50_NEW_STIPPLE) { - so = so_new(33, 0); + so = so_new(1, 32, 0); so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_PATTERN(0), 32); for (i = 0; i < 32; i++) so_data(so, util_bswap32(nv50->stipple.stipple[i]));@@ -327,7 +327,7 @@ nv50_state_validate(struct nv50_context *nv50) goto scissor_uptodate; nv50->state.scissor_enabled = rast->scissor; - so = so_new(3, 0); + so = so_new(1, 2, 0); so_method(so, tesla, NV50TCL_SCISSOR_HORIZ(0), 2); if (nv50->state.scissor_enabled) { so_data(so, (s->maxx << 16) | s->minx);@@ -356,7 +356,7 @@ scissor_uptodate: goto viewport_uptodate; nv50->state.viewport_bypass = bypass; - so = so_new(14, 0); + so = so_new(5, 9, 0); if (!bypass) { so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE_X(0), 3); so_data (so, fui(nv50->viewport.translate[0]));@@ -400,7 +400,8 @@ viewport_uptodate: for (i = 0; i < PIPE_SHADER_TYPES; ++i) nr += nv50->sampler_nr[i]; - so = so_new(nr * 8 + 24 * PIPE_SHADER_TYPES + 2, 4); + so = so_new(1+ 5 * PIPE_SHADER_TYPES, 1+ 19 * PIPE_SHADER_TYPES + + nr * 8, PIPE_SHADER_TYPES * 2); nv50_validate_samplers(nv50, so, PIPE_SHADER_VERTEX); nv50_validate_samplers(nv50, so, PIPE_SHADER_FRAGMENT);src/gallium/drivers/nv50/nv50_tex.c +6
-4@@ -199,16 +199,18 @@ nv50_tex_validate(struct nv50_context *nv50) { struct nouveau_stateobj *so; struct nouveau_grobj *tesla = nv50->screen->tesla; - unsigned p, push, nrlc; + unsigned p, start, push, nrlc; - for (nrlc = 0, push = 0, p = 0; p < PIPE_SHADER_TYPES; ++p) { + for (nrlc = 0, start = 0, push = 0, p = 0; p < PIPE_SHADER_TYPES; ++p) { + start += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]); push += MAX2(nv50->miptree_nr[p], nv50->state.miptree_nr[p]); nrlc += nv50->miptree_nr[p]; } - push = push * 11 + 23 * PIPE_SHADER_TYPES + 4; + start = start * 2 + 4 * PIPE_SHADER_TYPES + 2; + push = push * 9 + 19 * PIPE_SHADER_TYPES + 2; nrlc = nrlc * 2 + 2 * PIPE_SHADER_TYPES; - so = so_new(push, nrlc); + so = so_new(start, push, nrlc);if (
nv50_validate_textures(nv50, so, PIPE_SHADER_VERTEX)== FALSE ||nv50_validate_textures(nv50, so, PIPE_SHADER_FRAGMENT)== FALSE) {src/gallium/drivers/nv50/nv50_vbo.c +1
-1@@ -350,7 +350,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib, so = *pso; if (!so) - *pso = so = so_new(nv50->vtxelt_nr * 5, 0); + *pso = so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 4, 0); switch (ve->nr_components) {case 4:
src/gallium/drivers/nv50/nv50_vbo.c +2
-2@@ -411,8 +411,8 @@ nv50_vbo_validate(struct nv50_context *nv50) n_ve = MAX2(nv50->vtxelt_nr, nv50->state.vtxelt_nr); vtxattr = NULL; - vtxbuf = so_new(n_ve * 7, nv50->vtxelt_nr * 4); - vtxfmt = so_new(n_ve + 1, 0); + vtxbuf = so_new(n_ve * 2, n_ve * 5, nv50->vtxelt_nr * 4); + vtxfmt = so_new(1, n_ve, 0); so_method(vtxfmt, tesla, NV50TCL_VERTEX_ARRAY_ATTRIB(0), n_ve);Quoted 6 lines
Quoted 5 lines
src/gallium/drivers/nv50/nv50_vbo.c +0
-1for (i = 0; i < nv50->vtxelt_nr; i++) { --1.6.6.rc4
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
Re: [PATCH 3/3] nouveau: rewrite nouveau_stateobj to use BEGIN_RING properly
In reply to a message not in the archiveQuoted 8 lines · Maarten Maathuis
- The previous solution was hacky and didn't do subchannel autobinding.
- The beheaviour should match whatlibdrm_nouveaudoes closely.
- There appears to be a minor performance loss, probably due to having multiple memcpy's instead of one.
- The solution remains statically sized, but when debugging is on it will check for abuse.
- The values for nv30/nv40 may be off, but this should be easily caught with DEBUG on.
Tried a few levels of xmoto, worked fine.
A message that is not in the archive (sent off-list or not yet received): 586c2acd1001041819q3f0662d4q84a5da7f57edf14f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/3] nouveau: rewrite nouveau_stateobj to use BEGIN_RING properly
Pushed after conformation that nv3x and nv4x work.
Quoted 12 lines · Younes Manton
Quoted 8 lines · Maarten Maathuis
- The previous solution was hacky and didn't do subchannel autobinding.
- The beheaviour should match whatlibdrm_nouveaudoes closely.
- There appears to be a minor performance loss, probably due to having multiple memcpy's instead of one.
- The solution remains statically sized, but when debugging is on it will check for abuse.
- The values for nv30/nv40 may be off, but this should be easily caught with DEBUG on.Tried a few levels of xmoto, worked fine.
Re: [PATCH 2/3] nouveau: kill nouveau_push.h and use libdrm versions of BEGIN_RINGs, etc
In reply to a message not in the archiveQuoted 24 lines · Maarten Maathuis
From: Marcin Slusarz <[email protected]>
--- src/gallium/drivers/nouveau/nouveau_push.h | 93 ----- src/gallium/drivers/nv04/nv04_context.c | 44 ++- src/gallium/drivers/nv04/nv04_context.h | 4 - src/gallium/drivers/nv04/nv04_prim_vbuf.c | 84 +++-- src/gallium/drivers/nv04/nv04_state_emit.c | 72 +++-- src/gallium/drivers/nv10/nv10_context.c | 367 ++++++++++---------- src/gallium/drivers/nv10/nv10_context.h | 4 - src/gallium/drivers/nv10/nv10_fragtex.c | 28 +- src/gallium/drivers/nv10/nv10_prim_vbuf.c | 34 +- src/gallium/drivers/nv10/nv10_state_emit.c | 166 +++++---- src/gallium/drivers/nv20/nv20_context.c | 530 ++++++++++++++-------------- src/gallium/drivers/nv20/nv20_context.h | 4 - src/gallium/drivers/nv20/nv20_fragtex.c | 28 +- src/gallium/drivers/nv20/nv20_prim_vbuf.c | 56 ++-- src/gallium/drivers/nv20/nv20_state_emit.c | 181 ++++++---- src/gallium/drivers/nv30/nv30_context.c | 15 +- src/gallium/drivers/nv30/nv30_context.h | 4 - src/gallium/drivers/nv30/nv30_query.c | 20 +- src/gallium/drivers/nv30/nv30_vbo.c | 106 +++--- src/gallium/drivers/nv30/nv30_vertprog.c | 18 +- src/gallium/drivers/nv40/nv40_context.c | 15 +-
Quoted 8 lines
src/gallium/drivers/nv40/nv40_context.h | 4 - src/gallium/drivers/nv40/nv40_draw.c | 62 ++-- src/gallium/drivers/nv40/nv40_query.c | 20 +- src/gallium/drivers/nv40/nv40_state_emit.c | 11 +- src/gallium/drivers/nv40/nv40_vbo.c | 106 +++--- src/gallium/drivers/nv40/nv40_vertprog.c | 18 +- 27 files changed, 1089 insertions(+), 1005 deletions(-) delete mode 100644 src/gallium/drivers/nouveau/nouveau_push.h
you can see this patch here:
http://alan.umcs.lublin.pl/~mslusarz/kill-pushbuf.h/0003-nouveau-kill-nouveau_push.h-and-use-libdrm-versions-.patch
Same patch from before, without the debatable unmap change.
Quoted 176 lines · Maarten Maathuis
- This avoids problematic "reloc'ed while mapped" messages and some associated corruption as well.
Signed-off-by Maarten Maathuis <[email protected]>---
src/gallium/drivers/nouveau/nouveau_screen.c | 21 +++++++++++++++++++++src/gallium/drivers/nouveau/nouveau_screen.h| 3 +++src/gallium/drivers/nouveau/nouveau_stateobj.h| 13 +++++++++++++src/gallium/drivers/nv50/nv50_screen.c| 23 +++++++++++++++++++++++src/gallium/drivers/nv50/nv50_screen.h| 2 ++src/gallium/drivers/nv50/nv50_state_validate.c| 3 +++6 files changed, 65 insertions(+), 0 deletions(-)src/gallium/drivers/nouveau/nouveau_screen.c +21
-0@@ -127,8 +127,18 @@ nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned usage) { struct nouveau_bo *bo = nouveau_bo(pb); + struct nouveau_screen *nscreen = nouveau_screen(pscreen); int ret; + if (nscreen->pre_pipebuffer_map_callback) { + ret = nscreen->pre_pipebuffer_map_callback(pscreen, pb, usage); + if (ret) { + debug_printf("pre_pipebuffer_map_callback failed %d\n", + ret); + return NULL; + } + } + ret = nouveau_bo_map(bo, nouveau_screen_map_flags(usage)); if (ret) { debug_printf("map failed: %d\n", ret);@@ -143,11 +153,22 @@ nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned offset, unsigned length, unsigned usage) { struct nouveau_bo *bo = nouveau_bo(pb); + struct nouveau_screen *nscreen = nouveau_screen(pscreen); uint32_t flags = nouveau_screen_map_flags(usage); int ret; + if (nscreen->pre_pipebuffer_map_callback) { + ret = nscreen->pre_pipebuffer_map_callback(pscreen, pb, usage); + if (ret) { + debug_printf("pre_pipebuffer_map_callback failed %d\n", + ret); + return NULL; + } + } + ret = nouveau_bo_map_range(bo, offset, length, flags); if (ret) { + nouveau_bo_unmap(bo); if (!(flags & NOUVEAU_BO_NOWAIT) || ret != -EBUSY) debug_printf("map_range failed: %d\n", ret); return NULL;src/gallium/drivers/nouveau/nouveau_screen.h +3
-0@@ -5,6 +5,9 @@ struct nouveau_screen { struct pipe_screen base; struct nouveau_device *device; struct nouveau_channel *channel; + + int (*pre_pipebuffer_map_callback) (struct pipe_screen *pscreen, + struct pipe_buffer *pb, unsigned usage); };static inline struct
nouveau_screen*src/gallium/drivers/nouveau/nouveau_stateobj.h +13
-0@@ -98,6 +98,19 @@ so_reloc(struct nouveau_stateobj *so, struct nouveau_bo *bo, so_data(so, data); } +/* Determine if this buffer object is referenced by this state object. */ +static INLINE bool +so_bo_is_reloc (struct nouveau_stateobj *so,struct nouveau_bo *bo) +{ + int i; + + for (i = 0; i < so->cur_reloc; i++) + if (so->reloc[i].bo == bo) + return true; + + return false; +} +static INLINE void
so_dump(structnouveau_stateobj*so)
{src/gallium/drivers/nv50/nv50_screen.c +22
-0@@ -189,6 +189,28 @@ nv50_screen_destroy(struct pipe_screen *pscreen) FREE(screen); } +static int +nv50_pre_pipebuffer_map (struct pipe_screen *pscreen,struct pipe_buffer *pb, + unsigned usage) +{ + struct nv50_screen *screen = nv50_screen(pscreen); + struct nv50_context *ctx = screen->cur_ctx; + + if (!(pb->usage & PIPE_BUFFER_USAGE_VERTEX)) + return 0; + + /* Our vtxbuf got mapped, it can no longer be considered part of current + * state, remove it to avoid emitting reloc markers. + */ + if (ctx && ctx->state.vtxbuf && so_bo_is_reloc(ctx->state.vtxbuf, + nouveau_bo(pb))) { + so_ref(NULL, &ctx->state.vtxbuf); + ctx->dirty |= NV50_NEW_ARRAYS; + } + + return 0; +} +struct
pipe_screen*
nv50_screen_create(structpipe_winsys*ws, structnouveau_device*dev) {src/gallium/drivers/nv50/nv50_screen.c +1
-0@@ -216,6 +238,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) pscreen->get_param = nv50_screen_get_param; pscreen->get_paramf = nv50_screen_get_paramf; pscreen->is_format_supported = nv50_screen_is_format_supported; + screen->base.pre_pipebuffer_map_callback = nv50_pre_pipebuffer_map; nv50_screen_init_miptree_functions(pscreen); nv50_transfer_init_screen_functions(pscreen);src/gallium/drivers/nv50/nv50_screen.h +2
-0@@ -2,6 +2,7 @@ #define __NV50_SCREEN_H__ #include "nouveau/nouveau_screen.h" +#include "nv50_context.h" struct nv50_screen { struct nouveau_screen base;@@ -9,6 +10,7 @@ struct nv50_screen { struct nouveau_winsys *nvws; unsigned cur_pctx; + struct nv50_context *cur_ctx; struct nouveau_grobj *tesla; struct nouveau_grobj *eng2d;src/gallium/drivers/nv50/nv50_state_validate.c +3
-1@@ -185,6 +185,9 @@ nv50_state_emit(struct nv50_context *nv50) struct nv50_screen *screen = nv50->screen; struct nouveau_channel *chan = screen->base.channel; + /* I don't want to copy headers from the winsys. */ + screen->cur_ctx = nv50; + if (nv50->pctx_id != screen->cur_pctx) { if (nv50->state.fb) nv50->state.dirty |= NV50_NEW_FRAMEBUFFER; --1.6.6.rc4