Merge branch 'gallium-0.2' of git+ssh://marcheu@git.freedesktop.org/git/nouveau/mesa...
[mesa.git] / src / gallium / drivers / nv10 / nv10_context.c
index 42c496b95902a2c3fc516a1bb12bc930c0d73dda..e9b61daae7f9ed0b4a8493bcb06c3cd1f2f04bcc 100644 (file)
@@ -1,7 +1,6 @@
 #include "draw/draw_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
 
 #include "nv10_context.h"
 #include "nv10_screen.h"
@@ -12,6 +11,8 @@ nv10_flush(struct pipe_context *pipe, unsigned flags,
 {
        struct nv10_context *nv10 = nv10_context(pipe);
 
+       draw_flush(nv10->draw);
+
        FIRE_RING(fence);
 }
 
@@ -31,6 +32,7 @@ static void nv10_init_hwctx(struct nv10_context *nv10)
        struct nv10_screen *screen = nv10->screen;
        struct nouveau_winsys *nvws = screen->nvws;
        int i;
+       float projectionmatrix[16];
 
        BEGIN_RING(celsius, NV10TCL_DMA_NOTIFY, 1);
        OUT_RING  (screen->sync->handle);
@@ -93,13 +95,21 @@ static void nv10_init_hwctx(struct nv10_context *nv10)
        BEGIN_RING(celsius, NV10TCL_TX_ENABLE(0), 2);
        OUT_RING  (0);
        OUT_RING  (0);
-       BEGIN_RING(celsius, NV10TCL_RC_OUT_ALPHA(0), 6);
+
+       BEGIN_RING(celsius, NV10TCL_RC_IN_ALPHA(0), 12);
+       OUT_RING  (0x30141010);
+       OUT_RING  (0);
+       OUT_RING  (0x20040000);
+       OUT_RING  (0);
+       OUT_RING  (0);
+       OUT_RING  (0);
        OUT_RING  (0x00000c00);
        OUT_RING  (0);
        OUT_RING  (0x00000c00);
        OUT_RING  (0x18000000);
-       OUT_RING  (0x300c0000);
-       OUT_RING  (0x00001c80);
+       OUT_RING  (0x300e0300);
+       OUT_RING  (0x0c091c80);
+
        BEGIN_RING(celsius, NV10TCL_BLEND_FUNC_ENABLE, 1);
        OUT_RING  (0);
        BEGIN_RING(celsius, NV10TCL_DITHER_ENABLE, 2);
@@ -219,17 +229,40 @@ static void nv10_init_hwctx(struct nv10_context *nv10)
        BEGIN_RING(celsius, NV10TCL_EDGEFLAG_ENABLE, 1);
        OUT_RING  (1);
 
+       memset(projectionmatrix, 0, sizeof(projectionmatrix));
+       BEGIN_RING(celsius, NV10TCL_PROJECTION_MATRIX(0), 16);
+       projectionmatrix[0*4+0] = 1.0;
+       projectionmatrix[1*4+1] = 1.0;
+       projectionmatrix[2*4+2] = 1.0;
+       projectionmatrix[3*4+3] = 1.0;
+       for (i=0;i<16;i++) {
+               OUT_RINGf  (projectionmatrix[i]);
+       }
+
+       BEGIN_RING(celsius, NV10TCL_DEPTH_RANGE_NEAR, 2);
+       OUT_RING  (0.0);
+       OUT_RINGf  (16777216.0);
+
+       BEGIN_RING(celsius, NV10TCL_VIEWPORT_SCALE_X, 4);
+       OUT_RINGf  (-2048.0);
+       OUT_RINGf  (-2048.0);
+       OUT_RINGf  (16777215.0 * 0.5);
+       OUT_RING  (0);
 
        FIRE_RING (NULL);
 }
 
+static void
+nv10_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
+{
+}
+
 struct pipe_context *
 nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
        struct nv10_screen *screen = nv10_screen(pscreen);
        struct pipe_winsys *ws = pscreen->winsys;
        struct nv10_context *nv10;
-       unsigned chipset = screen->chipset;
        struct nouveau_winsys *nvws = screen->nvws;
 
        nv10 = CALLOC(1, sizeof(struct nv10_context));
@@ -238,12 +271,12 @@ nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv10->screen = screen;
        nv10->pctx_id = pctx_id;
 
-       nv10->chipset = chipset;
        nv10->nvws = nvws;
 
        nv10->pipe.winsys = ws;
        nv10->pipe.screen = pscreen;
        nv10->pipe.destroy = nv10_destroy;
+       nv10->pipe.set_edgeflags = nv10_set_edgeflags;
        nv10->pipe.draw_arrays = nv10_draw_arrays;
        nv10->pipe.draw_elements = nv10_draw_elements;
        nv10->pipe.clear = nv10_clear;
@@ -251,7 +284,6 @@ nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
 
        nv10_init_surface_functions(nv10);
        nv10_init_state_functions(nv10);
-       nv10_init_miptree_functions(nv10);
 
        nv10->draw = draw_create();
        assert(nv10->draw);