nouveau: get 16bpp working
authorBen Skeggs <darktama@iinet.net.au>
Fri, 22 Dec 2006 23:56:19 +0000 (10:56 +1100)
committerBen Skeggs <darktama@iinet.net.au>
Fri, 22 Dec 2006 23:56:19 +0000 (10:56 +1100)
src/mesa/drivers/dri/nouveau/nouveau_buffers.c
src/mesa/drivers/dri/nouveau/nouveau_context.c
src/mesa/drivers/dri/nouveau/nouveau_screen.c
src/mesa/drivers/dri/nouveau/nv30_state.c

index 42d8691752647a4169d754cea4eff88d8626996b..f30e59323d20a28f29327d4153d1e5cab3cfe1db 100644 (file)
@@ -89,6 +89,7 @@ nouveau_renderbuffer_pixelformat(nouveau_renderbuffer *nrb,
         nrb->mesa.AlphaBits    = 8;
         nrb->cpp               = 4;
         break;
+      case GL_RGB:
       case GL_RGB5:
         nrb->mesa._BaseFormat  = GL_RGB;
         nrb->mesa._ActualFormat= GL_RGB5;
index 22c1f5887427a20986b3c8f93719835f8b9d6285..ac940ac595f31fdbcedd20e0e1d616500a1345d0 100644 (file)
@@ -319,7 +319,10 @@ static void nouveauDoSwapBuffers(nouveauContextPtr nmesa,
        if (nbox) {
                BEGIN_RING_SIZE(NvSubCtxSurf2D,
                                NV10_CONTEXT_SURFACES_2D_FORMAT, 4);
-               OUT_RING       (6); /* X8R8G8B8 */
+               if (src->mesa._ActualFormat == GL_RGBA8)
+                       OUT_RING       (6); /* X8R8G8B8 */
+               else
+                       OUT_RING       (4); /* R5G6B5 */
                OUT_RING       ((dst->pitch << 16) | src->pitch);
                OUT_RING       (src->offset);
                OUT_RING       (dst->offset);
index 8e548dbcbdf96af7c06493cf683521d587c032c2..140db496b2ec377aeb9f79da16546a6f1d3a17b0 100644 (file)
@@ -129,6 +129,7 @@ nouveauCreateBuffer(__DRIscreenPrivate *driScrnPriv,
        struct gl_framebuffer *fb;
        const GLboolean swAccum = mesaVis->accumRedBits > 0;
        const GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24;
+       GLenum color_format = screen->fbFormat == 4 ? GL_RGBA8 : GL_RGB5;
 
        if (isPixmap)
                return GL_FALSE; /* not implemented */
@@ -138,10 +139,10 @@ nouveauCreateBuffer(__DRIscreenPrivate *driScrnPriv,
                return GL_FALSE;
 
        /* Front buffer */
-       nrb = nouveau_renderbuffer_new(GL_RGBA,
+       nrb = nouveau_renderbuffer_new(color_format,
                                       driScrnPriv->pFB + screen->frontOffset,
                                       screen->frontOffset,
-                                      screen->frontPitch * 4,
+                                      screen->frontPitch * screen->fbFormat,
                                       driDrawPriv);
        nouveauSpanSetFunctions(nrb, mesaVis);
        _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &nrb->mesa);
@@ -149,7 +150,7 @@ nouveauCreateBuffer(__DRIscreenPrivate *driScrnPriv,
        if (0 /* unified buffers if we choose to support them.. */) {
        } else {
                if (mesaVis->doubleBufferMode) {
-                       nrb = nouveau_renderbuffer_new(GL_RGBA, NULL,
+                       nrb = nouveau_renderbuffer_new(color_format, NULL,
                                                       0, 0,
                                                       driDrawPriv);
                        nouveauSpanSetFunctions(nrb, mesaVis);
index 7592c3fa0aff9b75d2caf0a734441b9cccdd6fad..4169dad66161bda3e373eb42530deb62a9b2645d 100644 (file)
@@ -790,7 +790,10 @@ static GLboolean nv30BindBuffers(nouveauContextPtr nmesa, int num_color,
    BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_DIM0, 5);
    OUT_RING        (((w+x)<<16)|x);
    OUT_RING        (((h+y)<<16)|y);
-   OUT_RING        (0x148);
+   if (color[0]->mesa._ActualFormat == GL_RGBA8)
+      OUT_RING        (0x148);
+   else
+      OUT_RING        (0x143);
    OUT_RING        (color[0]->pitch);
    OUT_RING        (color[0]->offset);