[Mesa-dev] [PATCH] st/dri: Use depth instead of bpp when communicating formats with the X server
Michel Dänzer
michel at daenzer.net
Tue Dec 6 02:54:17 PST 2011
On Die, 2011-12-06 at 10:19 +0100, Thomas Hellstrom wrote:
> 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 <thellstrom at vmware.com>
> ---
> src/gallium/state_trackers/dri/drm/dri2.c | 43 +++++++++++++++++++++++++++--
> 1 files changed, 40 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
> index 4e3f106..1aab749 100644
> --- a/src/gallium/state_trackers/dri/drm/dri2.c
> +++ b/src/gallium/state_trackers/dri/drm/dri2.c
> @@ -134,12 +134,49 @@ 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->
> + *
> + */
> +
> +
> + 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 = 0;
> + }
I think the default case should have something like assert(0) to catch
missing formats in debugging builds, and set depth to something more
useful for non-debugging builds, e.g. to
util_format_get_blocksizebits(format) still.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Debian, X and DRI developer
More information about the mesa-dev
mailing list