From: Dave Airlie Date: Sun, 23 May 2010 12:10:04 +0000 (+1000) Subject: swrast: add TFP support to swrast. X-Git-Tag: 062012170305~12097 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d789be03430b80e0ba2fef19d56dd0b8e699ea2;p=profile%2Fivi%2Fmesa.git swrast: add TFP support to swrast. This adds TFP support to the swrast driver, with this I can run gnome-shell inside Xephyr slowly. I've no idea why I did it, and g-s has other rendering issues under swrast, but it might be useful to hook up llvmpipe later. I've no idea if I even want to commit it at this point. An enhanced version might just pass the pointer in the indirect rendering case and avoid the memcpy. Signed-off-by: Dave Airlie --- diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 7fa7e21..983b924 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -47,6 +47,12 @@ #include "drivers/common/meta.h" #include "utils.h" +#include "main/teximage.h" +#include "main/texfetch.h" +#include "main/texformat.h" +#include "main/texstate.h" +#include "main/texobj.h" + #include "swrast_priv.h" @@ -54,7 +60,59 @@ * Screen and config-related functions */ +static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, + GLint texture_format, __DRIdrawable *dPriv) +{ + struct dri_context *dri_ctx; + int x, y, w, h; + __DRIscreen *sPriv = dPriv->driScreenPriv; + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + uint32_t internalFormat; + + dri_ctx = pDRICtx->driverPrivate; + + internalFormat = (texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4); + + texUnit = _mesa_get_current_tex_unit(&dri_ctx->Base); + texObj = _mesa_select_tex_object(&dri_ctx->Base, texUnit, target); + texImage = _mesa_get_tex_image(&dri_ctx->Base, texObj, target, 0); + + _mesa_lock_texture(&dri_ctx->Base, texObj); + + sPriv->swrast_loader->getDrawableInfo(dPriv, &x, &y, &w, &h, dPriv->loaderPrivate); + + _mesa_init_teximage_fields(&dri_ctx->Base, target, texImage, + w, h, 1, 0, internalFormat); + + if (texture_format == __DRI_TEXTURE_FORMAT_RGB) + texImage->TexFormat = MESA_FORMAT_XRGB8888; + else + texImage->TexFormat = MESA_FORMAT_ARGB8888; + + _mesa_set_fetch_functions(texImage, 2); + + sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)texImage->Data, + dPriv->loaderPrivate); + + _mesa_unlock_texture(&dri_ctx->Base, texObj); +} + +static void swrastSetTexBuffer(__DRIcontext *pDRICtx, GLint target, + __DRIdrawable *dPriv) +{ + swrastSetTexBuffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv); +} + +static const __DRItexBufferExtension swrastTexBufferExtension = { + { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION }, + swrastSetTexBuffer, + swrastSetTexBuffer2, +}; + static const __DRIextension *dri_screen_extensions[] = { + &swrastTexBufferExtension.base, NULL }; @@ -486,6 +544,16 @@ viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) swrast_check_and_update_window_size(ctx, read); } +static gl_format swrastChooseTextureFormat(GLcontext * ctx, + GLint internalFormat, + GLenum format, + GLenum type) +{ + if (internalFormat == GL_RGB) + return MESA_FORMAT_XRGB8888; + return _mesa_choose_tex_format(ctx, internalFormat, format, type); +} + static void swrast_init_driver_functions(struct dd_function_table *driver) { @@ -493,6 +561,7 @@ swrast_init_driver_functions(struct dd_function_table *driver) driver->UpdateState = update_state; driver->GetBufferSize = NULL; driver->Viewport = viewport; + driver->ChooseTextureFormat = swrastChooseTextureFormat; }