st/mesa: Fix glEGLImageTargetTexture2DOES.
authorChia-I Wu <olv@lunarg.com>
Wed, 25 Aug 2010 18:15:22 +0000 (02:15 +0800)
committerChia-I Wu <olv@lunarg.com>
Thu, 26 Aug 2010 08:40:01 +0000 (16:40 +0800)
stObj->pt should be set in st_bind_surface, just as in st_TexImage.  On
the other hand, st_TexImage should unreference stObj->pt.  It also needs
to initialize the texture image again as _mesa_clear_texture_object
clears the image.

src/mesa/state_tracker/st_cb_eglimage.c
src/mesa/state_tracker/st_cb_texture.c

index 037e576fabe229366d728195067df780e24bd51c..3145416383baad5dba19547cbeab7e85d7b7e945 100644 (file)
@@ -128,7 +128,8 @@ st_bind_surface(GLcontext *ctx, GLenum target,
    _mesa_set_fetch_functions(texImage, 2);
 
    /* FIXME create a non-default sampler view from the pipe_surface? */
-   pipe_resource_reference(&stImage->pt, ps->texture);
+   pipe_resource_reference(&stObj->pt, ps->texture);
+   pipe_resource_reference(&stImage->pt, stObj->pt);
 
    stObj->width0 = ps->width;
    stObj->height0 = ps->height;
index a41c780d6e698fd13ee4f9fba08f5d98e834d57a..9eb14033eeb57765cab10a19e1eebd6ee8e2b7dd 100644 (file)
@@ -548,6 +548,14 @@ st_TexImage(GLcontext * ctx,
    /* switch to "normal" */
    if (stObj->surface_based) {
       _mesa_clear_texture_object(ctx, texObj);
+      pipe_resource_reference(&stObj->pt, NULL);
+
+      /* oops, need to init this image again */
+      _mesa_init_teximage_fields(ctx, target, texImage,
+            width, height, depth, border, internalFormat);
+      _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
+            internalFormat, format, type);
+
       stObj->surface_based = GL_FALSE;
    }