nv20-nv40: Add support for two sided color
PATCH 1/1 nv20-nv40: Add support for two sided color
This patch adds support for two-sided vertex color to NV20, NV30 and NV40. When set, the COLOR0/1 fs inputs on back faces will be wired to vs outputs BCOLOR0/1. This makes OpenGL two sided lighting work, which can be tested with progs/demos/projtex.
This is already supported on NV50 and seems to be unsupported on NV04 and NV10.
The following defines need to be added to nouveau_class.h:
In renouveau.xml, for both NV30 and NV40:
<reg32 offset="0x142c" name="VERTEX_TWO_SIDE_ENABLE" type="boolean"/>
Tested on NV40 only.
--- src/gallium/drivers/nv20/nv20_state.c | 3 ++- src/gallium/drivers/nv20/nv20_state.h | 2 ++ src/gallium/drivers/nv20/nv20_state_emit.c | 3 +++ src/gallium/drivers/nv30/nv30_state.c | 6 ++++-- src/gallium/drivers/nv40/nv40_state.c | 8 ++++++-- 5 files changed, 17 insertions(+), 5 deletions(-)
src/gallium/drivers/nv20/nv20_state.c +2 -1
@@ -234,7 +234,6 @@ nv20_rasterizer_state_create(struct pipe_context *pipe,int i;/*XXX: ignored: -* light_twoside * offset_cw/ccw -nohw * scissor * point_smooth -nohw
@@ -301,6 +300,8 @@ nv20_rasterizer_state_create(struct pipe_context *pipe, }else { rs->point_sprite =0 ; } + + rs->light_twoside = cso->light_twoside;return (void *)rs; }
src/gallium/drivers/nv20/nv20_state.h +2 -0
@@ -39,6 +39,8 @@ struct nv20_rasterizer_state {uint32_t cull_face_en;uint32_t point_sprite; + +uint32_t light_twoside;const struct pipe_rasterizer_state *templ; };
src/gallium/drivers/nv20/nv20_state_emit.c +3 -0
@@ -68,6 +68,9 @@ static void nv20_state_emit_rast(struct nv20_context* nv20)BEGIN_RING (chan, kelvin,NV20TCL_CULL_FACE_ENABLE ,1 );OUT_RING (chan, r->cull_face_en); + +BEGIN_RING (chan, kelvin,NV20TCL_LIGHT_MODEL_TWO_SIDE_ENABLE ,1 ); +OUT_RING (chan, r->light_twoside); }static void nv20_state_emit_dsa (struct nv20_context * nv20)
src/gallium/drivers/nv30/nv30_state.c +4 -2
@@ -300,11 +300,10 @@ 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 (9 ,19 ,0 ); +struct nouveau_stateobj *so =so_new (10 ,20 ,0 );struct nouveau_grobj *rankine = nv30->screen->rankine;/*XXX: ignored: -* light_twoside * point_smooth -nohw * multisample */
@@ -313,6 +312,9 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,so_data (so, cso->flatshade ?NV34TCL_SHADE_MODEL_FLAT :NV34TCL_SHADE_MODEL_SMOOTH ); +so_method (so, rankine,NV34TCL_VERTEX_TWO_SIDE_ENABLE ,1 ); +so_data (so, cso->light_twoside); +so_method (so, rankine,NV34TCL_LINE_WIDTH ,2 );so_data (so, (unsigned char )(cso->line_width *8.0 ) &0xff );so_data (so, cso->line_smooth ?1 :0 );
src/gallium/drivers/nv40/nv40_state.c +6 -2
@@ -310,11 +310,10 @@ 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 (8 ,18 ,0 ); +struct nouveau_stateobj *so =so_new (10 ,20 ,0 );struct nouveau_grobj *curie = nv40->screen->curie;/*XXX: ignored: -* light_twoside * point_smooth -nohw * multisample */
@@ -323,6 +322,11 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,so_data (so, cso->flatshade ?NV40TCL_SHADE_MODEL_FLAT :NV40TCL_SHADE_MODEL_SMOOTH ); +/* the blob also sets 0x1428 to 0 in the same block. +Its purpose is unclear and it does not seem to have any discernible effects. */ +so_method (so, curie,NV40TCL_VERTEX_TWO_SIDE_ENABLE ,1 ); +so_data (so, cso->light_twoside); +so_method (so, curie,NV40TCL_LINE_WIDTH ,2 );so_data (so, (unsigned char )(cso->line_width *8.0 ) &0xff );so_data (so, cso->line_smooth ?1 :0 );
Signature · 1 line
1.6.3.3