nvfx: Add support for two sided color
authorLuca Barbieri <luca@luca-barbieri.com>
Mon, 11 Jan 2010 00:09:44 +0000 (01:09 +0100)
committerLuca Barbieri <luca@luca-barbieri.com>
Mon, 12 Apr 2010 18:46:18 +0000 (20:46 +0200)
This patch adds support for two-sided vertex color to nv30/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.

src/gallium/drivers/nvfx/nvfx_context.h
src/gallium/drivers/nvfx/nvfx_state.c

index fea05ac..e2c6d09 100644 (file)
@@ -46,7 +46,7 @@
 struct nvfx_rasterizer_state {
        struct pipe_rasterizer_state pipe;
        unsigned sb_len;
-       uint32_t sb[30];
+       uint32_t sb[32];
 };
 
 struct nvfx_zsa_state {
index 0f03c2e..315de49 100644 (file)
@@ -193,7 +193,6 @@ nvfx_rasterizer_state_create(struct pipe_context *pipe,
        struct nouveau_statebuf_builder sb = sb_init(rsso->sb);
 
        /*XXX: ignored:
-        *      light_twoside
         *      point_smooth -nohw
         *      multisample
         */
@@ -202,6 +201,9 @@ nvfx_rasterizer_state_create(struct pipe_context *pipe,
        sb_data(sb, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
                                       NV34TCL_SHADE_MODEL_SMOOTH);
 
+       sb_method(sb, NV34TCL_VERTEX_TWO_SIDE_ENABLE, 1);
+       sb_data(sb, cso->light_twoside);
+
        sb_method(sb, NV34TCL_LINE_WIDTH, 2);
        sb_data(sb, (unsigned char)(cso->line_width * 8.0) & 0xff);
        sb_data(sb, cso->line_smooth ? 1 : 0);