diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/dd.h | 8 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 40 |
2 files changed, 42 insertions, 6 deletions
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 6d564b25274..e2519780ab2 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -248,10 +248,16 @@ struct dd_function_table { /** * Called by glCopyTex[Sub]Image[123]D(). + * + * This function should copy a rectangular region in the rb to a single + * destination slice, specified by @slice. In the case of 1D array + * textures (where one GL call can potentially affect multiple destination + * slices), core mesa takes care of calling this function multiple times, + * once for each scanline to be copied. */ void (*CopyTexSubImage)(struct gl_context *ctx, GLuint dims, struct gl_texture_image *texImage, - GLint xoffset, GLint yoffset, GLint zoffset, + GLint xoffset, GLint yoffset, GLint slice, struct gl_renderbuffer *rb, GLint x, GLint y, GLsizei width, GLsizei height); diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 6f7fbc0d2a1..5226687ff92 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3429,6 +3429,35 @@ get_copy_tex_image_source(struct gl_context *ctx, gl_format texFormat) } } +static void +copytexsubimage_by_slice(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLuint dims, + GLint xoffset, GLint yoffset, GLint zoffset, + struct gl_renderbuffer *rb, + GLint x, GLint y, + GLsizei width, GLsizei height) +{ + if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) { + int slice; + + /* For 1D arrays, we copy each scanline of the source rectangle into the + * next array slice. + */ + assert(zoffset == 0); + + for (slice = 0; slice < height; slice++) { + assert(yoffset + slice < texImage->Height); + ctx->Driver.CopyTexSubImage(ctx, 2, texImage, + xoffset, 0, yoffset + slice, + rb, x, y + slice, width, 1); + } + } else { + ctx->Driver.CopyTexSubImage(ctx, dims, texImage, + xoffset, yoffset, zoffset, + rb, x, y, width, height); + } +} /** @@ -3517,8 +3546,9 @@ copyteximage(struct gl_context *ctx, GLuint dims, struct gl_renderbuffer *srcRb = get_copy_tex_image_source(ctx, texImage->TexFormat); - ctx->Driver.CopyTexSubImage(ctx, dims, texImage, dstX, dstY, dstZ, - srcRb, srcX, srcY, width, height); + copytexsubimage_by_slice(ctx, texImage, dims, + dstX, dstY, dstZ, + srcRb, srcX, srcY, width, height); } check_gen_mipmap(ctx, target, texObj, level); @@ -3610,9 +3640,9 @@ copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, struct gl_renderbuffer *srcRb = get_copy_tex_image_source(ctx, texImage->TexFormat); - ctx->Driver.CopyTexSubImage(ctx, dims, texImage, - xoffset, yoffset, zoffset, - srcRb, x, y, width, height); + copytexsubimage_by_slice(ctx, texImage, dims, + xoffset, yoffset, zoffset, + srcRb, x, y, width, height); check_gen_mipmap(ctx, target, texObj, level); |