swrast: fix glReadPixels from texture attachment
authorBrian Paul <brianp@vmware.com>
Sat, 12 Nov 2011 18:50:32 +0000 (11:50 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 15 Nov 2011 14:49:26 +0000 (07:49 -0700)
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=42635

src/mesa/swrast/s_texrender.c

index 83e7a6a039e3f74e69b93297b5e433596e11ea37..3734ce6d5271781fb475f214a6d77baccb04a50e 100644 (file)
@@ -567,6 +567,19 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
    trb->Base.InternalFormat = trb->TexImage->Base.InternalFormat;
    trb->Base.Format = trb->TexImage->Base.TexFormat;
 
+   /* Set the gl_renderbuffer::Data field so that mapping the buffer
+    * in renderbuffer.c succeeds.
+    */
+   if (att->Texture->Target == GL_TEXTURE_3D ||
+       att->Texture->Target == GL_TEXTURE_2D_ARRAY_EXT) {
+      trb->Base.Data = trb->TexImage->Buffer +
+         trb->TexImage->ImageOffsets[trb->Zoffset] *
+         _mesa_get_format_bytes(trb->TexImage->Base.TexFormat);
+   }
+   else {
+      trb->Base.Data = trb->TexImage->Buffer;
+   }
+
    /* XXX may need more special cases here */
    switch (trb->TexImage->Base.TexFormat) {
    case MESA_FORMAT_Z24_S8: