/** * Copy the image at level=0 in 'src' to the 'dst' resource at 'dstLevel'. * This is used to copy mipmap images from one texture buffer to another. * This typically happens when our initial guess at the total texture size * is incorrect (see the guess_and_alloc_texture() function). */ void st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource *dst, GLuint dstLevel, struct pipe_resource *src, GLuint srcLevel, GLuint face) { GLuint width = u_minify(dst->width0, dstLevel); GLuint height = u_minify(dst->height0, dstLevel); GLuint depth = u_minify(dst->depth0, dstLevel); struct pipe_box src_box; GLuint i; if (u_minify(src->width0, srcLevel) != width || u_minify(src->height0, srcLevel) != height || u_minify(src->depth0, srcLevel) != depth) { /* The source image size doesn't match the destination image size. * This can happen in some degenerate situations such as rendering to a * cube map face which was set up with mismatched texture sizes. */ return; } src_box.x = 0; src_box.y = 0; src_box.width = width; src_box.height = height; src_box.depth = 1; if (src->target == PIPE_TEXTURE_1D_ARRAY || src->target == PIPE_TEXTURE_2D_ARRAY || src->target == PIPE_TEXTURE_CUBE_ARRAY) { face = 0; depth = src->array_size; } /* Loop over 3D image slices */ /* could (and probably should) use "true" 3d box here - but drivers can't quite handle it yet */ for (i = face; i < face + depth; i++) { src_box.z = i; if (0) { print_center_pixel(pipe, src); } pipe->resource_copy_region(pipe, dst, dstLevel, 0, 0, i,/* destX, Y, Z */ src, srcLevel, &src_box); } }
/** * Copy the image at level=0 in 'src' to the 'dst' resource at 'dstLevel'. * This is used to copy mipmap images from one texture buffer to another. * This typically happens when our initial guess at the total texture size * is incorrect (see the guess_and_alloc_texture() function). */ void st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource *dst, GLuint dstLevel, struct pipe_resource *src, GLuint srcLevel, GLuint face) { GLuint width = u_minify(dst->width0, dstLevel); GLuint height = u_minify(dst->height0, dstLevel); GLuint depth = u_minify(dst->depth0, dstLevel); struct pipe_subresource dstsub, srcsub; GLuint i; assert(u_minify(src->width0, srcLevel) == width); assert(u_minify(src->height0, srcLevel) == height); assert(u_minify(src->depth0, srcLevel) == depth); dstsub.face = face; dstsub.level = dstLevel; srcsub.face = face; srcsub.level = srcLevel; /* Loop over 3D image slices */ for (i = 0; i < depth; i++) { if (0) { print_center_pixel(pipe, src); } pipe->resource_copy_region(pipe, dst, dstsub, 0, 0, i,/* destX, Y, Z */ src, srcsub, 0, 0, i,/* srcX, Y, Z */ width, height); } }