nouveau: more work on nv04, this time buffer format/pitches/...
authorStephane Marchesin <marchesin@icps.u-strasbg.fr>
Sat, 27 Jan 2007 02:03:25 +0000 (03:03 +0100)
committerStephane Marchesin <marchesin@icps.u-strasbg.fr>
Sat, 27 Jan 2007 02:08:01 +0000 (03:08 +0100)
src/mesa/drivers/dri/nouveau/nouveau_object.c
src/mesa/drivers/dri/nouveau/nouveau_object.h
src/mesa/drivers/dri/nouveau/nv04_state.c

index 26086e16e43e50216e42a5a90e63239cd830f0e4..302009c8b170dba96ce5faba195d9538fd00f76e 100644 (file)
@@ -70,6 +70,8 @@ void nouveauObjectInit(nouveauContextPtr nmesa)
        } else {
                nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D,
                                   0, 0, 0, 0);
+               nouveauCreateContextObject(nmesa, NvCtxSurf3D, NV04_CONTEXT_SURFACES_3D,
+                                  0, 0, 0, 0);
                nouveauCreateContextObject(nmesa, NvImageBlit, NV_IMAGE_BLIT,
                                   NV_DMA_CONTEXT_FLAGS_PATCH_SRCCOPY, 0, 0, 0);
        }
index b1ff5a5d0dcfe9501f5f5971c01cdb6300ddeda0..e154e0acff0f77fc1680c73bc7839d1c8ecd790f 100644 (file)
@@ -12,6 +12,7 @@ enum DMAObjects {
        NvCtxSurf2D             = 0x80000020,
        NvImageBlit             = 0x80000021,
        NvMemFormat             = 0x80000022,
+       NvCtxSurf3D             = 0x80000023,
        NvDmaFB                 = 0xD0FB0001,
        NvDmaAGP                = 0xD0AA0001,
        NvSyncNotify            = 0xD0000001
@@ -21,6 +22,7 @@ enum DMASubchannel {
        NvSubCtxSurf2D  = 0,
        NvSubImageBlit  = 1,
        NvSubMemFormat  = 2,
+       NvSubCtxSurf3D  = 3,
        NvSub3D         = 7,
 };
 
index 83ad8ae4327e2dd7c6e5c4f9afbf78e91bb4f495..ec4cd40d877df93ff1d7b1a0de90b2cc0e0b3d4a 100644 (file)
@@ -267,6 +267,7 @@ static void nv04Enable(GLcontext *ctx, GLenum cap, GLboolean state)
                        break;
                case GL_FOG:
                        nv04_emit_blend(ctx);
+                       nv04_emit_fog_color(ctx);
                        break;
 //             case GL_HISTOGRAM:
 //             case GL_INDEX_LOGIC_OP:
@@ -436,14 +437,54 @@ static void nv04WindowMoved(nouveauContextPtr nmesa)
 /* Initialise any card-specific non-GL related state */
 static GLboolean nv04InitCard(nouveauContextPtr nmesa)
 {
+       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
+       nouveauObjectOnSubchannel(nmesa, NvSubCtxSurf3D, NvCtxSurf3D);
+
+       BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_DMA_NOTIFY, 3);
+       OUT_RING(NvDmaFB);
+       OUT_RING(NvDmaFB);
+       OUT_RING(NvDmaFB);
+       BEGIN_RING_SIZE(NvSub3D, NV04_DX5_TEXTURED_TRIANGLE_SURFACE, 1);
+       OUT_RING(NvCtxSurf3D);
        return GL_TRUE;
 }
 
 /* Update buffer offset/pitch/format */
 static GLboolean nv04BindBuffers(nouveauContextPtr nmesa, int num_color,
-                                nouveau_renderbuffer **color,
-                                nouveau_renderbuffer *depth)
+               nouveau_renderbuffer **color,
+               nouveau_renderbuffer *depth)
 {
+       GLuint x, y, w, h;
+
+       w = color[0]->mesa.Width;
+       h = color[0]->mesa.Height;
+       x = nmesa->drawX;
+       y = nmesa->drawY;
+
+       /* FIXME pitches have to be aligned ! */
+       BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
+       OUT_RING(color[0]->pitch|(depth->pitch<<16));
+       OUT_RING(color[0]->offset);
+
+       if (depth) {
+               BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
+               OUT_RING(depth->offset);
+       }
+
+       BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL, 2);
+       OUT_RING((w<<16)|x);
+       OUT_RING((h<<16)|y);
+
+       /* FIXME not sure... */
+       BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_CLIP_SIZE, 1);
+       OUT_RING((h<<16)|w);
+
+       BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_FORMAT, 1);
+       if (color[0]->mesa._ActualFormat == GL_RGBA8)
+               OUT_RING(108/*A8R8G8B8*/);
+       else
+               OUT_RING(103/*R5G6B5*/);
+
        return GL_TRUE;
 }