aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-09 17:12:32 +0100
committermarha <marha@users.sourceforge.net>2012-01-09 17:12:32 +0100
commit63c3a3a61863ccdc2ff3ab6a9f34d4a6fb72a8c8 (patch)
treec2ec625befefca3759575095264161ffc2267572 /mesalib/src/mesa/main/teximage.c
parent2ae775fec514a032da4e6ec7528c2ef98c3913ee (diff)
parenta1e97828c89278770cb249039ec92d959440c640 (diff)
downloadvcxsrv-63c3a3a61863ccdc2ff3ab6a9f34d4a6fb72a8c8.tar.gz
vcxsrv-63c3a3a61863ccdc2ff3ab6a9f34d4a6fb72a8c8.tar.bz2
vcxsrv-63c3a3a61863ccdc2ff3ab6a9f34d4a6fb72a8c8.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/main/teximage.c')
-rw-r--r--mesalib/src/mesa/main/teximage.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 6dd70b96c..9475e84f5 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -2752,6 +2752,25 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
/**
+ * For glCopyTexSubImage, return the source renderbuffer to copy texel data
+ * from. This depends on whether the texture contains color or depth values.
+ */
+static struct gl_renderbuffer *
+get_copy_tex_image_source(struct gl_context *ctx, gl_format texFormat)
+{
+ if (_mesa_get_format_bits(texFormat, GL_DEPTH_BITS) > 0) {
+ /* reading from depth/stencil buffer */
+ return ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ }
+ else {
+ /* copying from color buffer */
+ return ctx->ReadBuffer->_ColorReadBuffer;
+ }
+}
+
+
+
+/**
* Implement the glCopyTexImage1/2D() functions.
*/
static void
@@ -2828,13 +2847,16 @@ copyteximage(struct gl_context *ctx, GLuint dims,
if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY,
&width, &height)) {
+ struct gl_renderbuffer *srcRb =
+ get_copy_tex_image_source(ctx, texImage->TexFormat);
+
if (dims == 1)
- ctx->Driver.CopyTexSubImage1D(ctx, target, level, dstX,
- srcX, srcY, width);
+ ctx->Driver.CopyTexSubImage1D(ctx, texImage, dstX,
+ srcRb, srcX, srcY, width);
else
- ctx->Driver.CopyTexSubImage2D(ctx, target, level, dstX, dstY,
- srcX, srcY, width, height);
+ ctx->Driver.CopyTexSubImage2D(ctx, texImage, dstX, dstY,
+ srcRb, srcX, srcY, width, height);
}
check_gen_mipmap(ctx, target, texObj, level);
@@ -2930,20 +2952,22 @@ copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y,
&width, &height)) {
+ struct gl_renderbuffer *srcRb =
+ get_copy_tex_image_source(ctx, texImage->TexFormat);
+
switch (dims) {
case 1:
- ctx->Driver.CopyTexSubImage1D(ctx, target, level,
- xoffset, x, y, width);
+ ctx->Driver.CopyTexSubImage1D(ctx, texImage, xoffset,
+ srcRb, x, y, width);
break;
case 2:
- ctx->Driver.CopyTexSubImage2D(ctx, target, level,
- xoffset, yoffset,
- x, y, width, height);
+ ctx->Driver.CopyTexSubImage2D(ctx, texImage, xoffset, yoffset,
+ srcRb, x, y, width, height);
break;
case 3:
- ctx->Driver.CopyTexSubImage3D(ctx, target, level,
+ ctx->Driver.CopyTexSubImage3D(ctx, texImage,
xoffset, yoffset, zoffset,
- x, y, width, height);
+ srcRb, x, y, width, height);
break;
default:
_mesa_problem(ctx, "bad dims in copytexsubimage()");