(this patch doesn't compile without the "st/dri: include xmlconfig.h" patch first:) http://lists.freedesktop.org/archives/mesa-dev/2010-August/001833.html http://github.com/nobled/mesa/commits/drisw --- Factor out the TexBuffer extension into a common file and share it between dri2 and drisw.
This gives swrastg/softpipe/llvmpipe support for GLX_EXT_texture_from_pixmap - so it can be used to run a composited desktop with pure software rendering. (File copyright headers just blindly copied from dri2.c; no idea who has the copyright on dri2_set_tex_buffer2 specifically or even if Brian Paul should still be named in the non-warranty or not.)
From 47b3e0f086081eb41b87c77c35253cf85c87619e Mon Sep 17 00:00:00 2001 From: nobled <nob...@dreamwidth.org> Date: Sat, 7 Aug 2010 12:27:48 +0000 Subject: [PATCH] st/dri: factor out TFP support and add it to drisw Factor out the TexBuffer extension into a common file and share it between dri2 and drisw. This gives swrastg/softpipe/llvmpipe support for GLX_EXT_texture_from_pixmap - so it can be used to run a composited desktop with pure software rendering. (File copyright headers just blindly copied from dri2.c) --- .../state_trackers/dri/common/dri_extensions.c | 91 ++++++++++++++++++++ .../state_trackers/dri/common/dri_extensions.h | 34 +++++++ src/gallium/state_trackers/dri/drm/Makefile | 1 + src/gallium/state_trackers/dri/drm/SConscript | 1 + src/gallium/state_trackers/dri/drm/dri2.c | 54 +----------- .../state_trackers/dri/drm/dri_extensions.c | 1 + src/gallium/state_trackers/dri/sw/Makefile | 1 + src/gallium/state_trackers/dri/sw/SConscript | 1 + src/gallium/state_trackers/dri/sw/dri_extensions.c | 1 + src/gallium/state_trackers/dri/sw/drisw.c | 2 + 10 files changed, 135 insertions(+), 52 deletions(-) create mode 100644 src/gallium/state_trackers/dri/common/dri_extensions.c create mode 100644 src/gallium/state_trackers/dri/common/dri_extensions.h create mode 120000 src/gallium/state_trackers/dri/drm/dri_extensions.c create mode 120000 src/gallium/state_trackers/dri/sw/dri_extensions.c diff --git a/src/gallium/state_trackers/dri/common/dri_extensions.c b/src/gallium/state_trackers/dri/common/dri_extensions.c new file mode 100644 index 0000000..a82ecbe --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_extensions.c @@ -0,0 +1,91 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Keith Whitwell <kei...@vmware.com> + * Jakob Bornecrantz <wallbra...@gmail.com> + * Chia-I Wu <o...@lunarg.com> + */ + +#include "pipe/p_format.h" +#include "pipe/p_state.h" +#include "state_tracker/st_api.h" + +#include "dri_context.h" +#include "dri_drawable.h" +#include "dri_extensions.h" + + +/** + * These are used for GLX_EXT_texture_from_pixmap + */ +static void +dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, + GLint format, __DRIdrawable *dPriv) +{ + struct dri_context *ctx = dri_context(pDRICtx); + struct dri_drawable *drawable = dri_drawable(dPriv); + struct pipe_resource *pt; + + dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT); + + pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT]; + + if (pt) { + enum pipe_format internal_format = pt->format; + + if (format == __DRI_TEXTURE_FORMAT_RGB) { + /* only need to cover the formats recognized by dri_fill_st_visual */ + switch (internal_format) { + case PIPE_FORMAT_B8G8R8A8_UNORM: + internal_format = PIPE_FORMAT_B8G8R8X8_UNORM; + break; + case PIPE_FORMAT_A8R8G8B8_UNORM: + internal_format = PIPE_FORMAT_X8R8G8B8_UNORM; + break; + default: + break; + } + } + + ctx->st->teximage(ctx->st, + (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT, + 0, internal_format, pt, FALSE); + } +} + +static void +dri_set_tex_buffer(__DRIcontext *pDRICtx, GLint target, + __DRIdrawable *dPriv) +{ + dri_set_tex_buffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv); +} + +const __DRItexBufferExtension driTexBufferExtension = { + { __DRI_TEX_BUFFER, 2 /* __DRI_TEX_BUFFER_VERSION */ }, + dri_set_tex_buffer, + dri_set_tex_buffer2, +}; + diff --git a/src/gallium/state_trackers/dri/common/dri_extensions.h b/src/gallium/state_trackers/dri/common/dri_extensions.h new file mode 100644 index 0000000..40959b1 --- /dev/null +++ b/src/gallium/state_trackers/dri/common/dri_extensions.h @@ -0,0 +1,34 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright 2009, VMware, Inc. + * All Rights Reserved. + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Keith Whitwell <kei...@vmware.com> + * Jakob Bornecrantz <wallbra...@gmail.com> + * Chia-I Wu <o...@lunarg.com> + */ + +#include "GL/internal/dri_interface.h" + +extern const __DRItexBufferExtension driTexBufferExtension; diff --git a/src/gallium/state_trackers/dri/drm/Makefile b/src/gallium/state_trackers/dri/drm/Makefile index c717b2b..b7d6d94 100644 --- a/src/gallium/state_trackers/dri/drm/Makefile +++ b/src/gallium/state_trackers/dri/drm/Makefile @@ -17,6 +17,7 @@ C_SOURCES = \ dri_context.c \ dri_screen.c \ dri_drawable.c \ + dri_extensions.c \ dri2.c # $(TOP)/src/mesa/drivers/dri/common/utils.c \ diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript index 2a0af65..fafe5a4 100644 --- a/src/gallium/state_trackers/dri/drm/SConscript +++ b/src/gallium/state_trackers/dri/drm/SConscript @@ -20,6 +20,7 @@ if env['dri']: target = 'st_dri', source = [ 'dri_context.c', 'dri_drawable.c', + 'dri_extensions.c', 'dri_screen.c', 'dri2.c', ] diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 1fb8996..e329d8b 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -38,6 +38,7 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" +#include "dri_extensions.h" /** * DRI2 flush extension. @@ -67,57 +68,6 @@ static const __DRI2flushExtension dri2FlushExtension = { }; /** - * These are used for GLX_EXT_texture_from_pixmap - */ -static void -dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, - GLint format, __DRIdrawable *dPriv) -{ - struct dri_context *ctx = dri_context(pDRICtx); - struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_resource *pt; - - dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT); - - pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT]; - - if (pt) { - enum pipe_format internal_format = pt->format; - - if (format == __DRI_TEXTURE_FORMAT_RGB) { - /* only need to cover the formats recognized by dri_fill_st_visual */ - switch (internal_format) { - case PIPE_FORMAT_B8G8R8A8_UNORM: - internal_format = PIPE_FORMAT_B8G8R8X8_UNORM; - break; - case PIPE_FORMAT_A8R8G8B8_UNORM: - internal_format = PIPE_FORMAT_X8R8G8B8_UNORM; - break; - default: - break; - } - } - - ctx->st->teximage(ctx->st, - (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT, - 0, internal_format, pt, FALSE); - } -} - -static void -dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target, - __DRIdrawable *dPriv) -{ - dri2_set_tex_buffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv); -} - -static const __DRItexBufferExtension dri2TexBufferExtension = { - { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION }, - dri2_set_tex_buffer, - dri2_set_tex_buffer2, -}; - -/** * Get the format and binding of an attachment. */ static INLINE void @@ -483,7 +433,7 @@ static const __DRIextension *dri_screen_extensions[] = { &driCopySubBufferExtension.base, &driSwapControlExtension.base, &driMediaStreamCounterExtension.base, - &dri2TexBufferExtension.base, + &driTexBufferExtension.base, &dri2FlushExtension.base, &dri2ImageExtension.base, &dri2ConfigQueryExtension.base, diff --git a/src/gallium/state_trackers/dri/drm/dri_extensions.c b/src/gallium/state_trackers/dri/drm/dri_extensions.c new file mode 120000 index 0000000..e0d06dc --- /dev/null +++ b/src/gallium/state_trackers/dri/drm/dri_extensions.c @@ -0,0 +1 @@ +../common/dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/Makefile b/src/gallium/state_trackers/dri/sw/Makefile index 33bc0ed..4be908d 100644 --- a/src/gallium/state_trackers/dri/sw/Makefile +++ b/src/gallium/state_trackers/dri/sw/Makefile @@ -20,6 +20,7 @@ C_SOURCES = \ dri_context.c \ dri_screen.c \ dri_drawable.c \ + dri_extensions.c \ drisw.c include ../../../Makefile.template diff --git a/src/gallium/state_trackers/dri/sw/SConscript b/src/gallium/state_trackers/dri/sw/SConscript index d2eb666..6664bf9 100644 --- a/src/gallium/state_trackers/dri/sw/SConscript +++ b/src/gallium/state_trackers/dri/sw/SConscript @@ -20,6 +20,7 @@ if env['dri']: target = 'st_drisw', source = [ 'dri_context.c', 'dri_drawable.c', + 'dri_extensions.c', 'dri_screen.c', 'drisw.c', ] diff --git a/src/gallium/state_trackers/dri/sw/dri_extensions.c b/src/gallium/state_trackers/dri/sw/dri_extensions.c new file mode 120000 index 0000000..e0d06dc --- /dev/null +++ b/src/gallium/state_trackers/dri/sw/dri_extensions.c @@ -0,0 +1 @@ +../common/dri_extensions.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index 249ccd7..2c0fb10 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -43,6 +43,7 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" +#include "dri_extensions.h" DEBUG_GET_ONCE_BOOL_OPTION(swrast_no_present, "SWRAST_NO_PRESENT", FALSE); static boolean swrast_no_present = FALSE; @@ -255,6 +256,7 @@ drisw_allocate_textures(struct dri_drawable *drawable, */ static const __DRIextension *drisw_screen_extensions[] = { + &driTexBufferExtension, NULL }; -- 1.5.4.3
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev