Mesa (master): st/mesa: Fix texture-from-pixmap.

Chia-I Wu olv at kemper.freedesktop.org
Wed May 5 03:58:24 UTC 2010


Module: Mesa
Branch: master
Commit: 719f7049bb2c7f5ca886055c9cd15b2805bd8e97
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=719f7049bb2c7f5ca886055c9cd15b2805bd8e97

Author: Chia-I Wu <olv at lunarg.com>
Date:   Wed May  5 11:32:33 2010 +0800

st/mesa: Fix texture-from-pixmap.

Remember the size of the level=0 mipmap image.  Do not call
util_format_get_component_bits when st_context_teximage is called to
release a texture image.

---

 src/mesa/state_tracker/st_cb_eglimage.c |    4 +++
 src/mesa/state_tracker/st_manager.c     |   32 +++++++++++++++++++++++++-----
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c
index 0fa1848..00861a6 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -129,6 +129,10 @@ st_bind_surface(GLcontext *ctx, GLenum target,
    /* FIXME create a non-default sampler view from the pipe_surface? */
    pipe_resource_reference(&stImage->pt, ps->texture);
 
+   stObj->width0 = ps->width;
+   stObj->height0 = ps->height;
+   stObj->depth0 = 1;
+
    _mesa_dirty_texobj(ctx, texObj, GL_TRUE);
 }
 
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 44d59d4..ea89553 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -508,6 +508,7 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target
    struct st_texture_object *stObj;
    struct st_texture_image *stImage;
    GLenum internalFormat;
+   GLuint width, height, depth;
 
    switch (target) {
    case ST_TEXTURE_1D:
@@ -527,12 +528,6 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target
       break;
    }
 
-   if (util_format_get_component_bits(internal_format,
-            UTIL_FORMAT_COLORSPACE_RGB, 3) > 0)
-      internalFormat = GL_RGBA;
-   else
-      internalFormat = GL_RGB;
-
    texObj = _mesa_select_tex_object(ctx, texUnit, target);
    _mesa_lock_texture(ctx, texObj);
 
@@ -546,17 +541,42 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target
    texImage = _mesa_get_tex_image(ctx, texObj, target, level);
    stImage = st_texture_image(texImage);
    if (tex) {
+      if (util_format_get_component_bits(internal_format,
+               UTIL_FORMAT_COLORSPACE_RGB, 3) > 0)
+         internalFormat = GL_RGBA;
+      else
+         internalFormat = GL_RGB;
+
       _mesa_init_teximage_fields(ctx, target, texImage,
             tex->width0, tex->height0, 1, 0, internalFormat);
       texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
             GL_RGBA, GL_UNSIGNED_BYTE);
       _mesa_set_fetch_functions(texImage, 2);
+
+      width = tex->width0;
+      height = tex->height0;
+      depth = tex->depth0;
+
+      /* grow the image size until we hit level = 0 */
+      while (level > 0) {
+         if (width != 1)
+            width <<= 1;
+         if (height != 1)
+            height <<= 1;
+         if (depth != 1)
+            depth <<= 1;
+         level--;
+      }
    }
    else {
       _mesa_clear_texture_image(ctx, texImage);
+      width = height = depth = 0;
    }
 
    pipe_resource_reference(&stImage->pt, tex);
+   stObj->width0 = width;
+   stObj->height0 = height;
+   stObj->depth0 = depth;
 
    _mesa_dirty_texobj(ctx, texObj, GL_TRUE);
    _mesa_unlock_texture(ctx, texObj);




More information about the mesa-commit mailing list