st/xorg: Temporary fix for none stencil visuals
authorJakob Bornecrantz <jakob@vmware.com>
Wed, 26 Aug 2009 12:27:50 +0000 (14:27 +0200)
committerJakob Bornecrantz <jakob@vmware.com>
Wed, 26 Aug 2009 12:27:50 +0000 (14:27 +0200)
Should be replaced with something looking at the proper
glx visual for the buffers.

src/gallium/state_trackers/xorg/xorg_dri2.c

index e72710befb0ea31ef28b04a0f82d9e0b9e6c15ac..7d6954016fe70053c919dad6ce9aba12d39d01c0 100644 (file)
@@ -60,6 +60,7 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
     DRI2BufferPtr buffers;
     PixmapPtr pPixmap;
     unsigned stride, handle;
+    boolean have_depth = FALSE, have_stencil = FALSE;
     int i;
 
     buffers = xcalloc(count, sizeof *buffers);
@@ -70,6 +71,16 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
     if (!privates)
        goto fail_privates;
 
+    for (i = 0; i < count; i++) {
+       if (attachments[i] == DRI2BufferDepth)
+           have_depth = TRUE;
+       else if (attachments[i] == DRI2BufferStencil)
+           have_stencil = TRUE;
+    }
+
+    if (have_stencil && !have_depth)
+       FatalError("Doesn't support only stencil yet\n");
+
     depth = NULL;
     for (i = 0; i < count; i++) {
        pPixmap = NULL;
@@ -88,8 +99,12 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
            struct pipe_texture template;
            memset(&template, 0, sizeof(template));
            template.target = PIPE_TEXTURE_2D;
-           template.format = ms->ds_depth_bits_last ?
-               PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM;
+           if (have_stencil)
+               template.format = ms->ds_depth_bits_last ?
+                   PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM;
+           else
+               template.format = ms->d_depth_bits_last ?
+                   PIPE_FORMAT_X8Z24_UNORM : PIPE_FORMAT_Z24X8_UNORM;
            pf_get_block(template.format, &template.block);
            template.width[0] = pDraw->width;
            template.height[0] = pDraw->height;