aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-09 16:34:28 +0100
committermarha <marha@users.sourceforge.net>2012-01-09 16:34:28 +0100
commita1e97828c89278770cb249039ec92d959440c640 (patch)
treef3d4ed7e3f3d589c606f01b3c9e6de03d638e2d3 /mesalib/src/mesa/main/teximage.c
parent7e9f4ea970e8f7008c212d7d3918a974eb0066da (diff)
downloadvcxsrv-a1e97828c89278770cb249039ec92d959440c640.tar.gz
vcxsrv-a1e97828c89278770cb249039ec92d959440c640.tar.bz2
vcxsrv-a1e97828c89278770cb249039ec92d959440c640.zip
xwininfo libX11 mesa mkfontscale xkeyboard-config git update 9 jan 2011
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()");