aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Hellstrom <[email protected]>2011-12-06 10:16:13 +0100
committerThomas Hellstrom <[email protected]>2011-12-07 20:05:24 +0100
commit576161289df68eedade591fbca4013329c9e5ded (patch)
tree7e44f394ca67c45a3f16aec8f1b1daf5bf77fd1c /src
parent6781fd05e9ea2ba45a615dacafca57291a220bb0 (diff)
st/dri: Use depth instead of bpp when communicating formats with the X server v3
Some hardware can't reinterpret the format of hardware buffers and thus the X server needs to know the format when the buffer is created. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Michel Daenzer <[email protected]> Reviewed-by: Jakob Bornecrantz <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 4e3f1067ce2..2f7f1cba7e6 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -104,7 +104,7 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
for (i = 0; i < *count; i++) {
enum pipe_format format;
unsigned bind;
- int att, bpp;
+ int att, depth;
dri_drawable_get_format(drawable, statts[i], &format, &bind);
if (format == PIPE_FORMAT_NONE)
@@ -134,12 +134,47 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
break;
}
- bpp = util_format_get_blocksizebits(format);
+ /*
+ * In this switch statement we must support all formats that
+ * may occur as the stvis->color_format or
+ * stvis->depth_stencil_format.
+ */
+ switch(format) {
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ depth = 32;
+ break;
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ depth = 24;
+ break;
+ case PIPE_FORMAT_B5G6R5_UNORM:
+ depth = 16;
+ break;
+ case PIPE_FORMAT_Z16_UNORM:
+ att = __DRI_BUFFER_DEPTH;
+ depth = 16;
+ break;
+ case PIPE_FORMAT_Z24X8_UNORM:
+ case PIPE_FORMAT_X8Z24_UNORM:
+ att = __DRI_BUFFER_DEPTH;
+ depth = 24;
+ break;
+ case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+ case PIPE_FORMAT_S8_UINT_Z24_UNORM:
+ depth = 32;
+ break;
+ case PIPE_FORMAT_Z32_UNORM:
+ att = __DRI_BUFFER_DEPTH;
+ depth = 32;
+ break;
+ default:
+ depth = util_format_get_blocksizebits(format);
+ assert(!"Unexpected format in dri2_drawable_get_buffers()");
+ }
if (att >= 0) {
attachments[num_attachments++] = att;
if (with_format) {
- attachments[num_attachments++] = bpp;
+ attachments[num_attachments++] = depth;
}
}
}