nvfx: restore BEGIN_RING usage
PATCH 1/1 nvfx: restore BEGIN_RING usage
As curro said, "let's keep it simple for the maintainers until the big bottlenecks are gone"
Benchmarked on nv35 with openarena, nexuiz and ut2004 and no performance regression.
The core of this patch was made with Coccinelle, with minor manual fixes made on top.
--- src/gallium/drivers/nvfx/nv30_fragtex.c | 3 +- src/gallium/drivers/nvfx/nv40_fragtex.c | 5 +- src/gallium/drivers/nvfx/nvfx_context.c | 6 +- src/gallium/drivers/nvfx/nvfx_context.h | 13 +++-- src/gallium/drivers/nvfx/nvfx_draw.c | 14 +++-- src/gallium/drivers/nvfx/nvfx_fragprog.c | 12 ++-- src/gallium/drivers/nvfx/nvfx_fragtex.c | 4 +- src/gallium/drivers/nvfx/nvfx_push.c | 57 +++++++++++++++-------- src/gallium/drivers/nvfx/nvfx_query.c | 12 ++-- src/gallium/drivers/nvfx/nvfx_screen.c | 70 ++++++++++++++------------- src/gallium/drivers/nvfx/nvfx_state_emit.c | 68 +++++++++++++-------------- src/gallium/drivers/nvfx/nvfx_state_fb.c | 39 ++++++++-------- src/gallium/drivers/nvfx/nvfx_surface.c | 8 ++-- src/gallium/drivers/nvfx/nvfx_vbo.c | 23 +++++---- src/gallium/drivers/nvfx/nvfx_vertprog.c | 14 ++--- 15 files changed, 184 insertions(+), 164 deletions(-)
src/gallium/drivers/nvfx/nv30_fragtex.c +2 -1
@@ -71,6 +71,7 @@ nv30_fragtex_set(struct nvfx_context *nvfx, int unit)struct nvfx_sampler_view * sv = (struct nvfx_sampler_view *)nvfx->fragment_sampler_views[unit];struct nouveau_bo *bo = ((struct nvfx_miptree *)sv->base.texture)->base.bo;struct nouveau_channel * chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;unsigned txf;unsigned tex_flags =NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD ;unsigned use_rect;
@@ -102,7 +103,7 @@ nv30_fragtex_set(struct nvfx_context *nvfx, int unit) txf = sv->u.nv30.fmt[ps->compare + (use_rect ?2 :0 )];MARK_RING (chan,9 ,2 ); -OUT_RING (chan,RING_3D (NV30_3D_TEX_OFFSET (unit),8 )); +BEGIN_RING (chan, eng3d,NV30_3D_TEX_OFFSET (unit),8 );OUT_RELOC (chan, bo, sv->offset, tex_flags |NOUVEAU_BO_LOW ,0 ,0 ); OUT_RELOC(chan, bo, txf, tex_flags | NOUVEAU_BO_OR,
src/gallium/drivers/nvfx/nv40_fragtex.c +3 -2
@@ -76,6 +76,7 @@ void nv40_fragtex_set(struct nvfx_context *nvfx, int unit) {struct nouveau_channel * chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];struct nvfx_sampler_view * sv = (struct nvfx_sampler_view *)nvfx->fragment_sampler_views[unit];struct nouveau_bo *bo = ((struct nvfx_miptree *)sv->base.texture)->base.bo;
@@ -87,7 +88,7 @@ nv40_fragtex_set(struct nvfx_context *nvfx, int unit) txf = sv->u.nv40.fmt[ps->compare] | ps->fmt;MARK_RING (chan,11 ,2 ); -OUT_RING (chan,RING_3D (NV30_3D_TEX_OFFSET (unit),8 )); +BEGIN_RING (chan, eng3d,NV30_3D_TEX_OFFSET (unit),8 );OUT_RELOC (chan, bo, sv->offset, tex_flags |NOUVEAU_BO_LOW ,0 ,0 );OUT_RELOC (chan, bo, txf, tex_flags |NOUVEAU_BO_OR ,NV30_3D_TEX_FORMAT_DMA0 ,NV30_3D_TEX_FORMAT_DMA1 );
@@ -97,7 +98,7 @@ nv40_fragtex_set(struct nvfx_context *nvfx, int unit)OUT_RING (chan, ps->filt | sv->filt);OUT_RING (chan, sv->npot_size);OUT_RING (chan, ps->bcol); -OUT_RING (chan,RING_3D (NV40_3D_TEX_SIZE1 (unit),1 )); +BEGIN_RING (chan, eng3d,NV40_3D_TEX_SIZE1 (unit),1 );OUT_RING (chan, sv->u.nv40.npot_size2); nvfx->hw_txf[unit] = txf;
src/gallium/drivers/nvfx/nvfx_context.c +3 -3
@@ -13,13 +13,13 @@ nvfx_flush(struct pipe_context *pipe, unsigned flags,struct nvfx_context *nvfx =nvfx_context (pipe);struct nvfx_screen *screen = nvfx->screen;struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *eng3d = screen->eng3d;/* XXX: we need to actually be intelligent here */ if (flags &PIPE_FLUSH_TEXTURE_CACHE ) { -WAIT_RING (chan,4 ); -OUT_RING (chan,RING_3D (0x1fd8 ,1 )); +BEGIN_RING (chan, eng3d,0x1fd8 ,1 );OUT_RING (chan,2 ); -OUT_RING (chan,RING_3D (0x1fd8 ,1 )); +BEGIN_RING (chan, eng3d,0x1fd8 ,1 );OUT_RING (chan,1 ); }
src/gallium/drivers/nvfx/nvfx_context.h +7 -6
@@ -339,30 +339,31 @@ extern void nvfx_init_vertprog_functions(struct nvfx_context *nvfx);/* nvfx_push.c */ extern void nvfx_push_vbo (struct pipe_context *pipe,const struct pipe_draw_info *info); -/* must WAIT_RING(chan, ncomp + 1) or equivalent beforehand! */ -static inline void nvfx_emit_vtx_attr (struct nouveau_channel * chan,unsigned attrib,const float * v,unsigned ncomp) +static inline void nvfx_emit_vtx_attr (struct nouveau_channel * chan, +struct nouveau_grobj *eng3d,unsigned attrib,const float * v, +unsigned ncomp) {switch (ncomp) {case 4 : -OUT_RING (chan,RING_3D (NV30_3D_VTX_ATTR_4F_X (attrib),4 )); +BEGIN_RING (chan, eng3d,NV30_3D_VTX_ATTR_4F_X (attrib),4 );OUT_RING (chan,fui (v[0 ]));OUT_RING (chan,fui (v[1 ]));OUT_RING (chan,fui (v[2 ]));OUT_RING (chan,fui (v[3 ]));break ;case 3 : -OUT_RING (chan,RING_3D (NV30_3D_VTX_ATTR_3F_X (attrib),3 )); +BEGIN_RING (chan, eng3d,NV30_3D_VTX_ATTR_3F_X (attrib),3 );OUT_RING (chan,fui (v[0 ]));OUT_RING (chan,fui (v[1 ]));OUT_RING (chan,fui (v[2 ]));break ;case 2 : -OUT_RING (chan,RING_3D (NV30_3D_VTX_ATTR_2F_X (attrib),2 )); +BEGIN_RING (chan, eng3d,NV30_3D_VTX_ATTR_2F_X (attrib),2 );OUT_RING (chan,fui (v[0 ]));OUT_RING (chan,fui (v[1 ]));break ;case 1 : -OUT_RING (chan,RING_3D (NV30_3D_VTX_ATTR_1F (attrib),1 )); +BEGIN_RING (chan, eng3d,NV30_3D_VTX_ATTR_1F (attrib),1 );OUT_RING (chan,fui (v[0 ]));break ; }
src/gallium/drivers/nvfx/nvfx_draw.c +8 -6
@@ -28,10 +28,10 @@ nvfx_render_flush(struct draw_stage *stage, unsigned flags)struct nvfx_render_stage *rs =nvfx_render_stage (stage);struct nvfx_context *nvfx = rs->nvfx;struct nouveau_channel *chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;if (rs->prim !=NV30_3D_VERTEX_BEGIN_END_STOP ) { -assert (AVAIL_RING (chan) >=2 ); -OUT_RING (chan,RING_3D (NV30_3D_VERTEX_BEGIN_END ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_VERTEX_BEGIN_END ,1 );OUT_RING (chan,NV30_3D_VERTEX_BEGIN_END_STOP ); rs->prim =NV30_3D_VERTEX_BEGIN_END_STOP ; }
@@ -46,6 +46,7 @@ nvfx_render_prim(struct draw_stage *stage, struct prim_header *prim,struct nvfx_screen *screen = nvfx->screen;struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *eng3d = screen->eng3d;boolean no_elements = nvfx->vertprog->draw_no_elements;unsigned num_attribs = nvfx->vertprog->draw_elements;
@@ -63,7 +64,7 @@ nvfx_render_prim(struct draw_stage *stage, struct prim_header *prim,/* Switch primitive modes if necessary */ if (rs->prim != mode) {if (rs->prim !=NV30_3D_VERTEX_BEGIN_END_STOP ) { -OUT_RING (chan,RING_3D (NV30_3D_VERTEX_BEGIN_END ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_VERTEX_BEGIN_END ,1 );OUT_RING (chan,NV30_3D_VERTEX_BEGIN_END_STOP ); }
@@ -74,23 +75,24 @@ nvfx_render_prim(struct draw_stage *stage, struct prim_header *prim,int i;for (i =0 ; i <32 ; ++i) { -OUT_RING (chan,RING_3D (0x1dac ,1 )); +BEGIN_RING (chan, eng3d,0x1dac ,1 );OUT_RING (chan,0 ); } } -OUT_RING (chan,RING_3D (NV30_3D_VERTEX_BEGIN_END ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_VERTEX_BEGIN_END ,1 );OUT_RING (chan, mode); rs->prim = mode; } -OUT_RING (chan,RING_3D_NI (NV30_3D_VERTEX_DATA , num_attribs *4 * count));if (no_elements) { +BEGIN_RING_NI (chan, eng3d,NV30_3D_VERTEX_DATA ,4 );OUT_RING (chan,0 );OUT_RING (chan,0 );OUT_RING (chan,0 );OUT_RING (chan,0 ); }else { +BEGIN_RING_NI (chan, eng3d,NV30_3D_VERTEX_DATA , num_attribs *4 * count);for (unsigned i =0 ; i < count; ++i) {struct vertex_header * v = prim->v[i];
src/gallium/drivers/nvfx/nvfx_fragprog.c +6 -6
@@ -1233,6 +1233,7 @@ void nvfx_fragprog_validate(struct nvfx_context *nvfx) {struct nouveau_channel * chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;struct nvfx_pipe_fragment_program *pfp = nvfx->fragprog;struct nvfx_vertex_program * vp;
@@ -1499,17 +1500,17 @@ update: nvfx->hw_fragprog = fp;MARK_RING (chan,8 ,1 ); -OUT_RING (chan,RING_3D (NV30_3D_FP_ACTIVE_PROGRAM ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_FP_ACTIVE_PROGRAM ,1 );OUT_RELOC (chan, fp->fpbo->bo, offset,NOUVEAU_BO_VRAM |NOUVEAU_BO_GART |NOUVEAU_BO_RD |NOUVEAU_BO_LOW |NOUVEAU_BO_OR ,NV30_3D_FP_ACTIVE_PROGRAM_DMA0 ,NV30_3D_FP_ACTIVE_PROGRAM_DMA1 ); -OUT_RING (chan,RING_3D (NV30_3D_FP_CONTROL ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_FP_CONTROL ,1 );OUT_RING (chan, fp->fp_control);if (!nvfx->is_nv4x) { -OUT_RING (chan,RING_3D (NV30_3D_FP_REG_CONTROL ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_FP_REG_CONTROL ,1 );OUT_RING (chan, (1 <<16 )|0x4 ); -OUT_RING (chan,RING_3D (NV30_3D_TEX_UNITS_ENABLE ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_TEX_UNITS_ENABLE ,1 );OUT_RING (chan, fp->samplers); } }
@@ -1518,8 +1519,7 @@ update:unsigned pointsprite_control = fp->point_sprite_control | nvfx->rasterizer->pipe.point_quad_rasterization;if (pointsprite_control != nvfx->hw_pointsprite_control) { -WAIT_RING (chan,2 ); -OUT_RING (chan,RING_3D (NV30_3D_POINT_SPRITE ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_POINT_SPRITE ,1 );OUT_RING (chan, pointsprite_control); nvfx->hw_pointsprite_control = pointsprite_control; }
src/gallium/drivers/nvfx/nvfx_fragtex.c +2 -2
@@ -177,6 +177,7 @@ void nvfx_fragtex_validate(struct nvfx_context *nvfx) {struct nouveau_channel * chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;unsigned samplers, unit; samplers = nvfx->dirty_samplers;
@@ -197,9 +198,8 @@ nvfx_fragtex_validate(struct nvfx_context *nvfx)else nv40_fragtex_set (nvfx, unit); }else { -WAIT_RING (chan,2 );/* this is OK for nv40 too */ -OUT_RING (chan,RING_3D (NV30_3D_TEX_ENABLE (unit),1 )); +BEGIN_RING (chan, eng3d,NV30_3D_TEX_ENABLE (unit),1 );OUT_RING (chan,0 ); nvfx->hw_samplers &= ~(1 << unit); }
src/gallium/drivers/nvfx/nvfx_push.c +37 -20
216 lines not on this page · raw message
src/gallium/drivers/nvfx/nvfx_query.c +6 -6
@@ -49,6 +49,7 @@ nvfx_query_begin(struct pipe_context *pipe, struct pipe_query *pq)struct nvfx_query *q =nvfx_query (pq);struct nvfx_screen *screen = nvfx->screen;struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *eng3d = screen->eng3d;uint64_t tmp;assert (!nvfx->query);
@@ -72,10 +73,9 @@ nvfx_query_begin(struct pipe_context *pipe, struct pipe_query *pq)nouveau_notifier_reset (nvfx->screen->query, q->object->start); -WAIT_RING (chan,4 ); -OUT_RING (chan,RING_3D (NV30_3D_QUERY_RESET ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_QUERY_RESET ,1 );OUT_RING (chan,1 ); -OUT_RING (chan,RING_3D (NV30_3D_QUERY_ENABLE ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_QUERY_ENABLE ,1 );OUT_RING (chan,1 ); q->ready = FALSE;
@@ -88,15 +88,15 @@ nvfx_query_end(struct pipe_context *pipe, struct pipe_query *pq) {struct nvfx_context *nvfx =nvfx_context (pipe);struct nouveau_channel *chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;struct nvfx_query *q =nvfx_query (pq);assert (nvfx->query == pq); -WAIT_RING (chan,4 ); -OUT_RING (chan,RING_3D (NV30_3D_QUERY_GET ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_QUERY_GET ,1 );OUT_RING (chan, (0x01 <<NV30_3D_QUERY_GET_UNK24__SHIFT ) | ((q->object->start *32 ) <<NV30_3D_QUERY_GET_OFFSET__SHIFT )); -OUT_RING (chan,RING_3D (NV30_3D_QUERY_ENABLE ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_QUERY_ENABLE ,1 );OUT_RING (chan,0 );FIRE_RING (chan);
src/gallium/drivers/nvfx/nvfx_screen.c +36 -34
159 lines not on this page · raw message
src/gallium/drivers/nvfx/nvfx_state_emit.c +32 -36
210 lines not on this page · raw message
src/gallium/drivers/nvfx/nvfx_state_fb.c +20 -19
@@ -96,6 +96,7 @@ nvfx_framebuffer_validate(struct nvfx_context *nvfx, unsigned prepare_result) {struct pipe_framebuffer_state *fb = &nvfx->framebuffer;struct nouveau_channel *chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;uint32_t rt_enable, rt_format;int i;unsigned rt_flags =NOUVEAU_BO_RDWR |NOUVEAU_BO_VRAM ;
@@ -204,11 +205,11 @@ nvfx_framebuffer_validate(struct nvfx_context *nvfx, unsigned prepare_result)//printf("rendering to bo %p [%i] at offset %i with pitch %i\n", rt0->bo, rt0->bo->handle, rt0->offset, pitch); -OUT_RING (chan,RING_3D (NV30_3D_DMA_COLOR0 ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_DMA_COLOR0 ,1 );OUT_RELOC (chan, rt0->bo,0 , rt_flags |NOUVEAU_BO_OR , chan->vram->handle, chan->gart->handle); -OUT_RING (chan,RING_3D (NV30_3D_COLOR0_PITCH ,2 )); +BEGIN_RING (chan, eng3d,NV30_3D_COLOR0_PITCH ,2 );OUT_RING (chan, pitch); OUT_RELOC(chan, rt0->bo, rt0->offset, rt_flags | NOUVEAU_BO_LOW,
@@ -216,11 +217,11 @@ nvfx_framebuffer_validate(struct nvfx_context *nvfx, unsigned prepare_result) }if (rt_enable &NV30_3D_RT_ENABLE_COLOR1 ) { -OUT_RING (chan,RING_3D (NV30_3D_DMA_COLOR1 ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_DMA_COLOR1 ,1 );OUT_RELOC (chan, nvfx->hw_rt[1 ].bo,0 , rt_flags |NOUVEAU_BO_OR , chan->vram->handle, chan->gart->handle); -OUT_RING (chan,RING_3D (NV30_3D_COLOR1_OFFSET ,2 )); +BEGIN_RING (chan, eng3d,NV30_3D_COLOR1_OFFSET ,2 );OUT_RELOC (chan, nvfx->hw_rt[1 ].bo, nvfx->hw_rt[1 ].offset, rt_flags |NOUVEAU_BO_LOW ,0 ,0 );
@@ -230,68 +231,68 @@ nvfx_framebuffer_validate(struct nvfx_context *nvfx, unsigned prepare_result)if (nvfx->is_nv4x) {if (rt_enable &NV40_3D_RT_ENABLE_COLOR2 ) { -OUT_RING (chan,RING_3D (NV40_3D_DMA_COLOR2 ,1 )); +BEGIN_RING (chan, eng3d,NV40_3D_DMA_COLOR2 ,1 );OUT_RELOC (chan, nvfx->hw_rt[2 ].bo,0 , rt_flags |NOUVEAU_BO_OR , chan->vram->handle, chan->gart->handle); -OUT_RING (chan,RING_3D (NV40_3D_COLOR2_OFFSET ,1 )); +BEGIN_RING (chan, eng3d,NV40_3D_COLOR2_OFFSET ,1 );OUT_RELOC (chan, nvfx->hw_rt[2 ].bo, nvfx->hw_rt[2 ].offset, rt_flags |NOUVEAU_BO_LOW ,0 ,0 ); -OUT_RING (chan,RING_3D (NV40_3D_COLOR2_PITCH ,1 )); +BEGIN_RING (chan, eng3d,NV40_3D_COLOR2_PITCH ,1 );OUT_RING (chan, nvfx->hw_rt[2 ].pitch); }if (rt_enable &NV40_3D_RT_ENABLE_COLOR3 ) { -OUT_RING (chan,RING_3D (NV40_3D_DMA_COLOR3 ,1 )); +BEGIN_RING (chan, eng3d,NV40_3D_DMA_COLOR3 ,1 );OUT_RELOC (chan, nvfx->hw_rt[3 ].bo,0 , rt_flags |NOUVEAU_BO_OR , chan->vram->handle, chan->gart->handle); -OUT_RING (chan,RING_3D (NV40_3D_COLOR3_OFFSET ,1 )); +BEGIN_RING (chan, eng3d,NV40_3D_COLOR3_OFFSET ,1 );OUT_RELOC (chan, nvfx->hw_rt[3 ].bo, nvfx->hw_rt[3 ].offset, rt_flags |NOUVEAU_BO_LOW ,0 ,0 ); -OUT_RING (chan,RING_3D (NV40_3D_COLOR3_PITCH ,1 )); +BEGIN_RING (chan, eng3d,NV40_3D_COLOR3_PITCH ,1 );OUT_RING (chan, nvfx->hw_rt[3 ].pitch); } }if (fb->zsbuf) { -OUT_RING (chan,RING_3D (NV30_3D_DMA_ZETA ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_DMA_ZETA ,1 );OUT_RELOC (chan, nvfx->hw_zeta.bo,0 , rt_flags |NOUVEAU_BO_OR , chan->vram->handle, chan->gart->handle); -OUT_RING (chan,RING_3D (NV30_3D_ZETA_OFFSET ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_ZETA_OFFSET ,1 );/* TODO: reverse engineer LMA */ OUT_RELOC (chan, nvfx->hw_zeta.bo, nvfx->hw_zeta.offset, rt_flags |NOUVEAU_BO_LOW ,0 ,0 );if (nvfx->is_nv4x) { -OUT_RING (chan,RING_3D (NV40_3D_ZETA_PITCH ,1 )); +BEGIN_RING (chan, eng3d,NV40_3D_ZETA_PITCH ,1 );OUT_RING (chan, nvfx->hw_zeta.pitch); } }else if (nvfx->is_nv4x) { -OUT_RING (chan,RING_3D (NV40_3D_ZETA_PITCH ,1 )); +BEGIN_RING (chan, eng3d,NV40_3D_ZETA_PITCH ,1 );OUT_RING (chan,64 ); } -OUT_RING (chan,RING_3D (NV30_3D_RT_ENABLE ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_RT_ENABLE ,1 );OUT_RING (chan, rt_enable); -OUT_RING (chan,RING_3D (NV30_3D_RT_HORIZ ,3 )); +BEGIN_RING (chan, eng3d,NV30_3D_RT_HORIZ ,3 );OUT_RING (chan, (w <<16 ) |0 );OUT_RING (chan, (h <<16 ) |0 );OUT_RING (chan, rt_format); -OUT_RING (chan,RING_3D (NV30_3D_VIEWPORT_HORIZ ,2 )); +BEGIN_RING (chan, eng3d,NV30_3D_VIEWPORT_HORIZ ,2 );OUT_RING (chan, (w <<16 ) |0 );OUT_RING (chan, (h <<16 ) |0 ); -OUT_RING (chan,RING_3D (NV30_3D_VIEWPORT_CLIP_HORIZ (0 ),2 )); +BEGIN_RING (chan, eng3d,NV30_3D_VIEWPORT_CLIP_HORIZ (0 ),2 );OUT_RING (chan, ((w -1 ) <<16 ) |0 );OUT_RING (chan, ((h -1 ) <<16 ) |0 );if (!nvfx->is_nv4x) {/* Wonder why this is needed, context should all be set to zero on init */ /* TODO: we can most likely remove this, after putting it in context init */ -OUT_RING (chan,RING_3D (NV30_3D_VIEWPORT_TX_ORIGIN ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_VIEWPORT_TX_ORIGIN ,1 );OUT_RING (chan,0 ); } nvfx->relocs_needed &=~NVFX_RELOCATE_FRAMEBUFFER ;
src/gallium/drivers/nvfx/nvfx_surface.c +4 -4
@@ -168,8 +168,8 @@ nvfx_get_blitter(struct pipe_context* pipe, int copy)if (nvfx->query && !nvfx->blitters_in_use) {struct nouveau_channel * chan = nvfx->screen->base.channel; -WAIT_RING (chan,2 ); -OUT_RING (chan,RING_3D (NV30_3D_QUERY_ENABLE ,1 )); +struct nouveau_grobj *eng3d = nvfx->screen->eng3d; +BEGIN_RING (chan, eng3d,NV30_3D_QUERY_ENABLE ,1 );OUT_RING (chan,0 ); }
@@ -209,8 +209,8 @@ nvfx_put_blitter(struct pipe_context* pipe, struct blitter_context* blitter)if (nvfx->query && !nvfx->blitters_in_use) {struct nouveau_channel * chan = nvfx->screen->base.channel; -WAIT_RING (chan,2 ); -OUT_RING (chan,RING_3D (NV30_3D_QUERY_ENABLE ,1 )); +struct nouveau_grobj *eng3d = nvfx->screen->eng3d; +BEGIN_RING (chan, eng3d,NV30_3D_QUERY_ENABLE ,1 );OUT_RING (chan,1 ); } }
src/gallium/drivers/nvfx/nvfx_vbo.c +12 -11
@@ -247,6 +247,7 @@ boolean nvfx_vbo_validate(struct nvfx_context *nvfx) {struct nouveau_channel * chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;int i;int elements =MAX2 (nvfx->vtxelt->num_elements, nvfx->hw_vtxelt_nr);unsigned vb_flags = nvfx->screen->vertex_buffer_reloc_flags |NOUVEAU_BO_RD ;
@@ -262,11 +263,11 @@ nvfx_vbo_validate(struct nvfx_context *nvfx)struct nvfx_buffer * buffer =nvfx_buffer (vb->buffer);float v[4 ]; ve->fetch_rgba_float (v, buffer->data + vb->buffer_offset + ve->src_offset,0 ,0 ); -nvfx_emit_vtx_attr (chan, ve->idx, v, ve->ncomp); +nvfx_emit_vtx_attr (chan, eng3d, ve->idx, v, ve->ncomp); } -OUT_RING (chan,RING_3D (NV30_3D_VTXFMT (0 ), elements)); +BEGIN_RING (chan, eng3d,NV30_3D_VTXFMT (0 ), elements);if (nvfx->use_vertex_buffers) {unsigned idx =0 ;
@@ -297,12 +298,12 @@ nvfx_vbo_validate(struct nvfx_context *nvfx)unsigned i;/* seems to be some kind of cache flushing */ for (i =0 ; i <3 ; ++i) { -OUT_RING (chan,RING_3D (0x1718 ,1 )); +BEGIN_RING (chan, eng3d,0x1718 ,1 );OUT_RING (chan,0 ); } } -OUT_RING (chan,RING_3D (NV30_3D_VTXBUF (0 ), elements)); +BEGIN_RING (chan, eng3d,NV30_3D_VTXBUF (0 ), elements);if (nvfx->use_vertex_buffers) {unsigned idx =0 ;
@@ -330,7 +331,7 @@ nvfx_vbo_validate(struct nvfx_context *nvfx)OUT_RING (chan,0 ); } -OUT_RING (chan,RING_3D (0x1710 ,1 )); +BEGIN_RING (chan, eng3d,0x1710 ,1 );OUT_RING (chan,0 ); nvfx->hw_vtxelt_nr = nvfx->vtxelt->num_elements;
@@ -342,15 +343,14 @@ void nvfx_vbo_swtnl_validate(struct nvfx_context *nvfx) {struct nouveau_channel * chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;unsigned num_outputs = nvfx->vertprog->draw_elements;int elements =MAX2 (num_outputs, nvfx->hw_vtxelt_nr);if (!elements)return ; -WAIT_RING (chan, (1 +6 +1 +2 ) + elements *2 ); - -OUT_RING (chan,RING_3D (NV30_3D_VTXFMT (0 ), elements)); +BEGIN_RING (chan, eng3d,NV30_3D_VTXFMT (0 ), elements);for (unsigned i =0 ; i < num_outputs; ++i)OUT_RING (chan, (4 <<NV30_3D_VTXFMT_SIZE__SHIFT ) |NV30_3D_VTXFMT_TYPE_V32_FLOAT );for (unsigned i = num_outputs; i < elements; ++i)
@@ -360,16 +360,16 @@ nvfx_vbo_swtnl_validate(struct nvfx_context *nvfx)unsigned i;/* seems to be some kind of cache flushing */ for (i =0 ; i <3 ; ++i) { -OUT_RING (chan,RING_3D (0x1718 ,1 )); +BEGIN_RING (chan, eng3d,0x1718 ,1 );OUT_RING (chan,0 ); } } -OUT_RING (chan,RING_3D (NV30_3D_VTXBUF (0 ), elements)); +BEGIN_RING (chan, eng3d,NV30_3D_VTXBUF (0 ), elements);for (unsigned i =0 ; i < elements; i++)OUT_RING (chan,0 ); -OUT_RING (chan,RING_3D (0x1710 ,1 )); +BEGIN_RING (chan, eng3d,0x1710 ,1 );OUT_RING (chan,0 ); nvfx->hw_vtxelt_nr = num_outputs;
@@ -408,6 +408,7 @@ static void nvfx_idxbuf_emit(struct nvfx_context* nvfx, unsigned ib_flags) {struct nouveau_channel * chan = nvfx->screen->base.channel; +struct nouveau_grobj *eng3d = nvfx->screen->eng3d;unsigned ib_format = (nvfx->idxbuf.index_size ==2 ) ?NV30_3D_IDXBUF_FORMAT_TYPE_U16 :NV30_3D_IDXBUF_FORMAT_TYPE_U32 ;struct nouveau_bo * bo =nvfx_resource (nvfx->idxbuf.buffer)->bo; ib_flags |= nvfx->screen->index_buffer_reloc_flags |NOUVEAU_BO_RD ;
src/gallium/drivers/nvfx/nvfx_vertprog.c +6 -8
@@ -1182,6 +1182,7 @@ nvfx_vertprog_validate(struct nvfx_context *nvfx) {struct nvfx_screen *screen = nvfx->screen;struct nouveau_channel *chan = screen->base.channel; +struct nouveau_grobj *eng3d = screen->eng3d;struct nvfx_pipe_vertex_program *pvp = nvfx->vertprog;struct nvfx_vertex_program * vp;struct pipe_resource *constbuf;
@@ -1341,7 +1342,6 @@ nvfx_vertprog_validate(struct nvfx_context *nvfx)} */ -WAIT_RING (chan,6 * vp->nr_consts);for (i = nvfx->use_vp_clipping ?6 :0 ; i < vp->nr_consts; i++) {struct nvfx_vertex_program_data *vpd = &vp->consts[i];
@@ -1356,7 +1356,7 @@ nvfx_vertprog_validate(struct nvfx_context *nvfx)//printf("upload into %i + %i: %f %f %f %f\n", vp->data->start, i, vpd->value[0], vpd->value[1], vpd->value[2], vpd->value[3]); -OUT_RING (chan,RING_3D (NV30_3D_VP_UPLOAD_CONST_ID ,5 )); +BEGIN_RING (chan, eng3d,NV30_3D_VP_UPLOAD_CONST_ID ,5 );OUT_RING (chan, i + vp->data->start);OUT_RINGp (chan, (uint32_t *)vpd->value,4 ); }
@@ -1364,11 +1364,10 @@ nvfx_vertprog_validate(struct nvfx_context *nvfx)/* Upload vtxprog */ if (upload_code) { -WAIT_RING (chan,2 +5 * vp->nr_insns); -OUT_RING (chan,RING_3D (NV30_3D_VP_UPLOAD_FROM_ID ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_VP_UPLOAD_FROM_ID ,1 );OUT_RING (chan, vp->exec->start);for (i =0 ; i < vp->nr_insns; i++) { -OUT_RING (chan,RING_3D (NV30_3D_VP_UPLOAD_INST (0 ),4 )); +BEGIN_RING (chan, eng3d,NV30_3D_VP_UPLOAD_INST (0 ),4 );//printf("%08x %08x %08x %08x\n", vp->insns[i].data[0], vp->insns[i].data[1], vp->insns[i].data[2], vp->insns[i].data[3]); OUT_RINGp (chan, vp->insns[i].data,4 ); }
@@ -1377,11 +1376,10 @@ nvfx_vertprog_validate(struct nvfx_context *nvfx)if (nvfx->dirty & (NVFX_NEW_VERTPROG )) { -WAIT_RING (chan,6 ); -OUT_RING (chan,RING_3D (NV30_3D_VP_START_FROM_ID ,1 )); +BEGIN_RING (chan, eng3d,NV30_3D_VP_START_FROM_ID ,1 );OUT_RING (chan, vp->exec->start);if (nvfx->is_nv4x) { -OUT_RING (chan,RING_3D (NV40_3D_VP_ATTRIB_EN ,1 )); +BEGIN_RING (chan, eng3d,NV40_3D_VP_ATTRIB_EN ,1 );OUT_RING (chan, vp->ir); } }
Signature · 1 line
1.7.3.3
A message that is not in the archive (sent off-list or not yet received): 1292845814-23623-1-git-send-email-chantry.xavier-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Just for my personnal information, how did you benchmarked ? By juging the fps ?
If you have the binaries could you also comparbinary size (for reference/culture)
2010/12/20 Xavier Chantry <[email protected]>:
Quoted 24 lines
As curro said, "let's keep it simple for the maintainers until the big bottlenecks are gone"
Benchmarked on nv35 with openarena, nexuiz and ut2004 and no performance regression.
The core of this patch was made with Coccinelle, with minor manual fixes made on top.
---src/gallium/drivers/nvfx/nv30_fragtex.c | 3 +- src/gallium/drivers/nvfx/nv40_fragtex.c | 5 +- src/gallium/drivers/nvfx/nvfx_context.c | 6 +- src/gallium/drivers/nvfx/nvfx_context.h | 13 +++--src/gallium/drivers/nvfx/nvfx_draw.c | 14 +++--
src/gallium/drivers/nvfx/nvfx_fragprog.c| 12 ++--src/gallium/drivers/nvfx/nvfx_fragtex.c| 4 +-src/gallium/drivers/nvfx/nvfx_push.c| 57 +++++++++++++++--------src/gallium/drivers/nvfx/nvfx_query.c| 12 ++--src/gallium/drivers/nvfx/nvfx_screen.c| 70 ++++++++++++++-------------src/gallium/drivers/nvfx/nvfx_state_emit.c| 68 +++++++++++++--------------src/gallium/drivers/nvfx/nvfx_state_fb.c| 39 ++++++++--------src/gallium/drivers/nvfx/nvfx_surface.c| 8 ++--src/gallium/drivers/nvfx/nvfx_vbo.c| 23 +++++----src/gallium/drivers/nvfx/nvfx_vertprog.c| 14 ++---
Quoted 2 lines
15 files changed, 184 insertions(+), 164 deletions(-)
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): AANLkTimdVTJ6PLxOFqGM1qF-2x454EY1if93TumSu9Cv-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 2 lines · Michel Hermier
Just for my personnal information, how did you benchmarked ? By juging the fps ?
These 3 games have built-in benchmark/demo system so I just used it.
20 dec : no patch
840 frames 6.6 seconds 126.4 fps 3.0/7.9/60.0/2.7 ms 931 frames 15.2444695 seconds 61.0713283 fps, one-second fps min/avg/max: 34 71 135 (44 seconds)
9.655401 / 29.729643 / 113.846779 fps -- Score = 29.773331 rand[1490382222]
20 dec : begin ring patch
840 frames 6.7 seconds 126.2 fps 4.0/7.9/59.0/2.7 ms 931 frames 15.4498180 seconds 60.2596096 fps, one-second fps min/avg/max: 33 70 133 (44 seconds)
9.668166 / 29.757431 / 117.643478 fps -- Score = 29.799963 rand[1490382222]
I usually see a variation of 0.5 - 1 fps between consecutive runs.
I don't know if nvfx is more performant on nv40 / pci express, so anyone with the hardware is also welcome to test.
Quoted 3 lines
If you have the binaries could you also comparbinary size (for reference/culture)
I cannot see a difference, but I don't usually look at binary size so feel free to check.
I would really like to test your patch on nv47, but it doesn't apply to current master. It seems to be fixable manually, as only the line numbers in the diff are wrong, but i wonder what's the reason for this.
-- lynxeye
Am Montag, den 20.12.2010, 22:58 +0100 schrieb Xavier Chantry:
Quoted 2 lines
I don't know if nvfx is more performant on nv40 / pci express, so anyone with the hardware is also welcome to test.
Quoted 4 lines · Lucas Stach
I would really like to test your patch on nv47, but it doesn't apply to current master. It seems to be fixable manually, as only the line numbers in the diff are wrong, but i wonder what's the reason for this.
I just applied the mail patch on another box with a fresh master pull. No problem.
git am < mail.txt
Could you regen the patch with a more uptodate head, I have rejects now.
2010/12/20 Xavier Chantry <[email protected]>:
Quoted 9 lines
As curro said, "let's keep it simple for the maintainers until the big bottlenecks are gone"
Benchmarked on nv35 with openarena, nexuiz and ut2004 and no performance regression.
The core of this patch was made with Coccinelle, with minor manual fixes made on top.
---
A message that is not in the archive (sent off-list or not yet received): AANLkTin2OhsqFW0aXK9qEo0G2C7sq+HLSLEHaioSTBJs-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
I said nothing, my bad. Trying to patch with fscked web formatting is a bad idea ...
2010/12/25 Michel Hermier <[email protected]>:
Quoted 13 lines
Could you regen the patch with a more uptodate head, I have rejects now.
2010/12/20 Xavier Chantry <[email protected]>:
Quoted 9 lines
As curro said, "let's keep it simple for the maintainers until the big bottlenecks are gone"
Benchmarked on nv35 with openarena, nexuiz and ut2004 and no performance regression.
The core of this patch was made with Coccinelle, with minor manual fixes made on top.
---