- /* do copy row by row */
- for (row = 0; row < height; row++) {
- pipe_get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, data);
-
- /* XXX we're ignoring convolution for now */
- if (ctx->_ImageTransferState) {
- _mesa_apply_rgba_transfer_ops(ctx,
- ctx->_ImageTransferState & ~IMAGE_CONVOLUTION_BIT,
- width, (GLfloat (*)[4])data);
+ /*
+ * To avoid a large temp memory allocation, do copy row by row.
+ */
+ if (baseFormat == GL_DEPTH_COMPONENT) {
+ const GLboolean scaleOrBias = (ctx->Pixel.DepthScale != 1.0F ||
+ ctx->Pixel.DepthBias != 0.0F);
+
+ for (row = 0; row < height; row++, srcY++, destY += yStep) {
+ uint data[MAX_WIDTH];
+ pipe_get_tile_z(pipe, src_surf, srcX, srcY, width, 1, data);
+ if (scaleOrBias) {
+ _mesa_scale_and_bias_depth_uint(ctx, width, data);
+ }
+ pipe_put_tile_z(pipe, dest_surf, destX, destY, width, 1, data);
+ }
+ }
+ else {
+ /* RGBA format */
+ for (row = 0; row < height; row++, srcY++, destY += yStep) {
+ float data[4 * MAX_WIDTH];
+ pipe_get_tile_rgba(pipe, src_surf, srcX, srcY, width, 1, data);
+ /* XXX we're ignoring convolution for now */
+ if (ctx->_ImageTransferState) {
+ _mesa_apply_rgba_transfer_ops(ctx,
+ ctx->_ImageTransferState & ~IMAGE_CONVOLUTION_BIT,
+ width, (GLfloat (*)[4]) data);
+ }
+ pipe_put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, data);